/* ============================================================
   Stamina Digital — dashboard.css
   Design system v0.1
   ============================================================ */

/* ── Layout principal ───────────────────────────────────────── */
.dashboard {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  background: var(--stage);
  border-right: 1px solid var(--stage-line);
  padding: var(--space-lg);
  position: fixed;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

/* Logo */
.logo-sidebar {
  padding: var(--space-sm) var(--space-sm);
  margin-bottom: var(--space-xl);
}
.logo-sidebar img {
  height: 20px;
  width: auto;
}
/* Fallback para quando não há imagem (mantém o h2 funcional) */
.logo-sidebar h2 {
  font-size: 16px;
  font-weight: 500;
  color: var(--mist);
  letter-spacing: -0.01em;
}

/* Info do usuário */
.user-info {
  background: var(--stage);
  border: 1px solid var(--stage-line);
  border-radius: var(--radius-card-sm);
  padding: var(--space-base);
  margin-bottom: var(--space-xl);
}
.user-info h3 {
  font-size: 13px;
  font-weight: 500;
  color: var(--mist);
  margin-bottom: 4px;
}
.user-info p {
  font-size: 12px;
  color: var(--ink-faint);
}

/* Nav lateral */
.menu-link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 10px var(--space-base);
  border-radius: var(--radius-card-sm);
  text-decoration: none;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-faint);
  transition: background 0.12s ease-out, color 0.12s ease-out;
  border-left: 2px solid transparent;
  margin-left: -2px; /* compensa a borda para não deslocar */
}
.menu-link:hover {
  background: var(--stage-2);
  color: var(--mist);
}
.menu-link.active {
  background: var(--stage-2);
  color: var(--mist);
  border-left-color: var(--structure);
}
.menu-link svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* Botão sair — no rodapé da sidebar */
.btn-logout {
  width: 100%;
  padding: 11px;
  background: transparent;
  border: 1.5px solid rgba(217, 68, 68, 0.25);
  border-radius: var(--radius-pill);
  color: var(--error-light);
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease-out, background 0.15s ease-out;
  margin-top: auto;
}
.btn-logout:hover {
  border-color: var(--error);
  background: rgba(217, 68, 68, 0.06);
}

/* ── Conteúdo principal ─────────────────────────────────────── */
.main-content {
  margin-left: 220px;
  flex: 1;
  padding: var(--space-xl);
}

/* ── Header de seção ────────────────────────────────────────── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}
.header h1 {
  font-size: 22px;
  font-weight: 500;
  color: var(--mist);
  letter-spacing: -0.01em;
}

/* ── Botão adicionar — pill, padrão primário ────────────────── */
.btn-adicionar {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 11px 24px;
  background: var(--structure);
  border: none;
  border-radius: var(--radius-pill);
  color: #fff;
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease-out, opacity 0.15s ease-out;
}
.btn-adicionar:hover { background: var(--struct-prof); }
.btn-adicionar:active { opacity: 0.85; }

/* ── Filtros ────────────────────────────────────────────────── */
.filtros {
  background: var(--stage-2);
  border: 1px solid var(--stage-line);
  border-radius: var(--radius-card-sm);
  padding: var(--space-base);
  margin-bottom: var(--space-lg);
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  align-items: center;
}

.filtro-item {
  flex: 1;
  min-width: 180px;
}

/* Inputs e selects de filtro: mesmo padrão do sistema */
.filtro-item input,
.filtro-item select {
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 400;
  width: 100%;
  padding: 10px 14px;
  background: var(--stage);
  border: 1.5px solid var(--stage-line);
  border-radius: var(--radius-input);
  color: var(--mist);
  outline: none;
  transition: border-color 0.15s ease-out;
  -webkit-appearance: none;
}
.filtro-item input::placeholder { color: var(--ink-faint); }
.filtro-item input:focus,
.filtro-item select:focus { border-color: var(--struct-luz); }

/* Todos os selects — mesmo chevron, mesma aparência */
.filtro-item select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239398b0' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.filtro-item select option {
  background-color: var(--stage-2);
  color: var(--mist);
}

/* ── Tabs ───────────────────────────────────────────────────── */
/* Padrão do sistema: borda inferior, sem background de pill */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--stage-line);
  margin-bottom: var(--space-lg);
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}
.tabs::-webkit-scrollbar { display: none; } /* Chrome/Safari */

.tab {
  padding: 10px 20px;
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-faint);
  cursor: pointer;
  transition: color 0.15s ease-out;
  white-space: nowrap;
  background: none;
  border: none;
  user-select: none;
}
.tab:hover { color: var(--mist); }
.tab.active {
  color: var(--struct-luz);
}

/* ── Tabela ─────────────────────────────────────────────────── */
.tabela-container {
  background: var(--stage-2);
  border: 1px solid var(--stage-line);
  border-radius: var(--radius-card-sm);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-align: left;
  padding: 0 var(--space-base) var(--space-md);
  border-bottom: 2px solid var(--stage-line);
  padding-top: var(--space-base);
}

tbody td {
  padding: 14px var(--space-base);
  border-bottom: 1px solid var(--stage-line);
  color: var(--mist);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { animation: slideDown 0.2s ease; }
tbody tr:hover { background: var(--stage); }

.cliente-nome-cel {
  font-weight: 500;
  color: var(--mist);
}
.cliente-detalhes {
  font-size: 12px;
  color: var(--ink-faint);
  margin-top: 3px;
}

/* ── Badges de serviço ──────────────────────────────────────── */
.servicos-cel {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}
.servico-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: var(--structure-soft);
  border: 1px solid rgba(109, 75, 255, 0.15);
  border-radius: var(--radius-pill);
  font-size: 11px;
  color: var(--struct-luz);
  font-weight: 400;
}
.servico-badge.inativo {
  background: rgba(217, 68, 68, 0.08);
  border-color: rgba(217, 68, 68, 0.2);
  color: var(--error-light);
  opacity: 0.7;
}
.servico-badge.mais {
  background: transparent;
  border-color: var(--stage-line);
  color: var(--ink-faint);
}

/* ── Paginação ──────────────────────────────────────────────── */
#paginacao {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  padding: var(--space-base);
}
#paginacao button {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-card-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Manrope', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-faint);
  border: 1px solid var(--stage-line);
  background: var(--stage-2);
  cursor: pointer;
  transition: background 0.15s ease-out, color 0.15s ease-out, border-color 0.15s ease-out;
  padding: 0 12px;
  width: auto;
  min-width: 32px;
}
#paginacao button:hover { border-color: var(--struct-luz); color: var(--mist); }
#paginacao button:disabled { opacity: 0.3; pointer-events: none; }
#infoPagina {
  font-size: 13px;
  color: var(--ink-faint);
}

/* -- Estatisticas - filtros em blocos narrativos --------------------- */
.stats-filtros {
  background: var(--stage-2);
  border: 1px solid var(--stage-line);
  border-radius: var(--radius-card-sm);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
  display: flex;
  align-items: flex-start;
  gap: 0;
}
.stats-filtro-bloco {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  flex: 1;
  padding: 0 var(--space-xl);
}
.stats-filtro-bloco:first-child { padding-left: 0; }
.stats-filtro-bloco:last-child  { padding-right: 0; }
.stats-filtro-bloco-titulo {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--stage-line);
}
.stats-filtro-sep {
  width: 1px;
  background: var(--stage-line);
  align-self: stretch;
  flex-shrink: 0;
}
.stats-filtro-linha {
  display: flex;
  gap: var(--space-sm);
}
.stats-filtro-linha .stats-filtro-grupo { flex: 1; }
.stats-filtro-grupo {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stats-filtro-grupo label {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
@media (max-width: 768px) {
  .stats-filtros { flex-direction: column; }
  .stats-filtro-bloco { padding: var(--space-md) 0; }
  .stats-filtro-bloco:first-child { padding-top: 0; }
  .stats-filtro-bloco:last-child  { padding-bottom: 0; }
  .stats-filtro-sep { width: 100%; height: 1px; }
}

/* -- Estatisticas - cards de metricas -------------------------------- */
.stat-card {
  background: var(--stage-2);
  border: 1px solid var(--stage-line);
  border-radius: var(--radius-card-sm);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
  animation: slideUp 0.3s ease;
  transition: border-color 0.2s ease-out, transform 0.2s ease-out;
}
.stat-card:hover {
  border-color: rgba(109, 75, 255, 0.35);
  transform: translateY(-2px);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
}
.stat-card.card-ativos::before   { background: var(--success); }
.stat-card.card-teste::before    { background: #8265ff; }
.stat-card.card-pausados::before { background: var(--warning); }
.stat-card.card-inativos::before { background: var(--error); }
.stat-card.card-total::before    { background: var(--structure); }
.stat-card.card-churn::before    { background: var(--error-light); }

.stat-card-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
  margin-bottom: var(--space-md);
}
.stat-card-valor {
  font-size: 52px;
  font-weight: 300;
  color: var(--mist);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-md);
}
/* Variacao como texto colorido simples - sem badge/pill */
.stat-card-trend {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}
.stat-card-trend.positivo { color: var(--signal); }
.stat-card-trend.negativo { color: var(--error-light); }
.stat-card-trend.neutro   { color: var(--ink-faint); }

/* -- Churn badges ---------------------------------------------------- */
.churn-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
}
.churn-badge.alto   { background: rgba(217, 68, 68, 0.1);  color: var(--error-light); }
.churn-badge.medio  { background: rgba(255, 194, 75, 0.1);  color: var(--warning); }
.churn-badge.baixo  { background: rgba(42, 171, 98, 0.1);  color: var(--success); }
.churn-badge.zero   { background: transparent; color: var(--ink-faint); border: 1px solid var(--stage-line); }

/* Alinhamento central nas colunas numericas da tabela de churn */
.th-center { text-align: center !important; }
#statsChurnSection tbody td:not(:first-child) { text-align: center; }
#statsChurnSection tbody td:not(:first-child) .churn-badge { margin: 0 auto; }

/* -- Menu hamburguer (mobile) --------------------------------------- */
.menu-toggle {
  display: none;
  position: fixed;
  top: var(--space-base);
  left: var(--space-base);
  z-index: 1001;
  background: var(--stage-2);
  border: 1px solid var(--stage-line);
  border-radius: var(--radius-card-sm);
  padding: 10px;
  cursor: pointer;
  color: var(--mist);
  transition: background 0.15s ease-out;
}
.menu-toggle:hover { background: var(--stage); }
.menu-toggle svg { width: 22px; height: 22px; display: block; }

/* -- Responsivo ----------------------------------------------------- */
@media (max-width: 768px) {
  .menu-toggle { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease-out;
    z-index: 1002;
  }
  .sidebar.show { transform: translateX(0); }

  .main-content {
    margin-left: 0;
    padding: 72px var(--space-base) var(--space-base);
  }

  .header { flex-direction: column; gap: var(--space-base); align-items: stretch; }
  .btn-adicionar { width: 100%; justify-content: center; }

  .filtros { flex-direction: column; }
  .filtro-item { min-width: 100%; }

  .stats-filtros { flex-direction: column; }
  .stats-filtro-bloco { padding: var(--space-md) 0; }
  .stats-filtro-bloco:first-child { padding-top: 0; }
  .stats-filtro-bloco:last-child  { padding-bottom: 0; }
  .stats-filtro-sep { width: 100%; height: 1px; }

  .tabs { overflow-x: auto; padding-bottom: var(--space-sm); }
  .tabela-container { overflow-x: auto; }
  table { min-width: 560px; }

  th:nth-child(2), td:nth-child(2) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  tbody tr, .stat-card { animation: none; }
}

/* -- Modal de Cliente - Serviços (reparado) -------------------------- */
.servico-input-group {
  background: var(--stage);
  padding: 16px;
  border: 1.5px solid var(--stage-line);
  border-radius: var(--radius-card-sm);
  margin-bottom: 12px;
}
.servico-header-input {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.servico-header-input label {
  font-size: 13px;
  font-weight: 500;
  color: var(--mist);
}
.servico-nome-select, .servico-detalhes {
  font-family: 'Manrope', sans-serif;
  font-size: 13px;
  color: var(--mist);
  background: var(--stage-2);
  border: 1.5px solid var(--stage-line);
  border-radius: var(--radius-input);
  padding: 9px 12px;
  outline: none;
  width: 100%;
  margin-bottom: 8px;
  -webkit-appearance: none;
}
.servico-nome-select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239398b0' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.servico-nome-select:focus, .servico-detalhes:focus {
  border-color: var(--struct-luz);
}
.servico-detalhes {
  min-height: 60px;
  resize: vertical;
  margin-bottom: 0;
}

/* -- Botões do Serviço ---------------------------------------------- */
.servico-input-group .select-custom-wrapper {
  margin-bottom: 12px;
}
.btn-adicionar-servico {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: var(--mist);
  border: 1px dashed var(--stage-line);
  padding: 8px 12px;
  border-radius: var(--radius-input);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  width: auto;
  justify-content: flex-start;
  margin-top: 8px;
  margin-bottom: 24px;
}
.btn-adicionar-servico:hover {
  color: var(--struct-luz);
  border-color: rgba(130, 101, 255, 0.4);
  background: rgba(130, 101, 255, 0.05);
}
.btn-remover-servico {
  background: transparent;
  border: none;
  color: var(--error-light);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.15s ease;
  line-height: 1;
}
.btn-remover-servico:hover {
  background: rgba(255, 84, 112, 0.1);
}
.stats-filtro-grupo input[type="date"] {
    background: var(--stage-2);
    border: 1.5px solid var(--stage-line);
    border-radius: 8px; /* var(--radius-input) fallback */
    color: var(--mist);
    padding: 9px 14px;
    height: auto;
    font-size: 13px;
    font-weight: 400;
    font-family: 'Manrope', sans-serif;
    outline: none;
    transition: border-color 0.15s ease-out;
    width: 100%;
    box-sizing: border-box;
}
.stats-filtro-grupo input[type="date"]:focus {
    border-color: var(--struct-luz);
}
.stats-filtro-grupo input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.5;
    cursor: pointer;
}

.stat-card.sentiment-card::before { background: var(--card-color) !important; }
