/* ==========================================================================
   LKTV DASHBOARD — CAMADA DE TEMA (v4)
   Carregada DEPOIS de style.css. Apenas refina o visual existente.
   Nada aqui remove funcionalidade: são tokens, tipografia e componentes.
   Paleta original preservada (roxo #8B5CF6 / rosa #EC4899 / slate escuro).
   ========================================================================== */

:root {
  /* ── Marca (inalterada) ── */
  --purple-primary: #8B5CF6;
  --pink-primary: #EC4899;

  /* ── Escala de superfícies (derivada do slate original) ── */
  --surface-0: #0B1220;   /* fundo da página */
  --surface-1: #131C2E;   /* trilho lateral / barra superior */
  --surface-2: #1A2437;   /* cartão */
  --surface-3: #212D42;   /* cartão elevado / hover */
  --surface-4: #2B3950;   /* linhas, bordas fortes */

  /* ── Traços ── */
  --line-soft: rgba(148, 163, 184, 0.10);
  --line: rgba(148, 163, 184, 0.16);
  --line-strong: rgba(148, 163, 184, 0.28);

  /* ── Texto ── */
  --tx-1: #F1F5F9;   /* primário */
  --tx-2: #A9B6CA;   /* secundário */
  --tx-3: #6F7F97;   /* terciário / legendas */

  /* ── Semântica: verde=bom, vermelho=problema, laranja=atenção ── */
  --ok: #22C55E;
  --ok-soft: rgba(34, 197, 94, 0.12);
  --warn: #F59E0B;
  --warn-soft: rgba(245, 158, 11, 0.12);
  --bad: #EF4444;
  --bad-soft: rgba(239, 68, 68, 0.12);
  --info: #38BDF8;
  --info-soft: rgba(56, 189, 248, 0.12);
  --brand-soft: rgba(139, 92, 246, 0.14);
  --pink-soft: rgba(236, 72, 153, 0.14);

  /* ── Raios ── */
  --r-xs: 6px;
  --r-sm: 9px;
  --r-md: 13px;
  --r-lg: 18px;
  --r-full: 999px;

  /* ── Espaçamento ── */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 22px;
  --sp-6: 30px;

  /* ── Sombras (mais suaves que as originais) ── */
  --sh-1: 0 1px 2px rgba(0, 0, 0, .28);
  --sh-2: 0 4px 14px rgba(0, 0, 0, .30);
  --sh-3: 0 14px 40px rgba(0, 0, 0, .42);
  --sh-glow: 0 0 0 1px rgba(139, 92, 246, .34), 0 8px 26px rgba(139, 92, 246, .18);

  /* ── Movimento ── */
  --ease: cubic-bezier(.2, .7, .3, 1);
  --t-fast: .14s var(--ease);
  --t-med: .24s var(--ease);

  /* ── Compatibilidade com a camada antiga ── */
  --dark-bg: var(--surface-1);
  --dark-card: var(--surface-2);
  --dark-lighter: var(--surface-3);
  --text-light: var(--tx-1);
  --text-gray: var(--tx-2);
  --border-color: var(--line);
  --shadow-sm: var(--sh-1);
  --shadow-md: var(--sh-2);
  --shadow-lg: var(--sh-3);
}

/* ==========================================================================
   TIPOGRAFIA — o Inter já era carregado no HTML mas nunca foi usado
   ========================================================================== */
body,
button,
input,
select,
textarea {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'tnum';
}

body {
  background: var(--surface-0);
  color: var(--tx-1);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.006em;
}

h1, h2, h3, h4 {
  letter-spacing: -0.022em;
  font-weight: 650;
  line-height: 1.22;
}

/* Números tabulares: colunas de valores param de "dançar" ao atualizar */
.kpi-value,
.stat-value,
.info-card-value,
.sales-card-mini-value,
.sales-stat-value,
.lk-num,
td.num,
.chat-conv-time {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

/* ==========================================================================
   BARRA DE ROLAGEM
   ========================================================================== */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--surface-4) transparent;
}

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }

*::-webkit-scrollbar-thumb {
  background: var(--surface-4);
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--line-strong);
  background-clip: content-box;
}

/* ==========================================================================
   FOCO ACESSÍVEL — nada tinha indicação de teclado antes
   ========================================================================== */
:focus-visible {
  outline: 2px solid var(--purple-primary);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

::selection {
  background: var(--brand-soft);
  color: #fff;
}

/* ==========================================================================
   SUPERFÍCIE PADRÃO — .lk-card
   ========================================================================== */
.lk-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}

.lk-card--pad { padding: var(--sp-5); }

.lk-card--hover:hover {
  border-color: var(--line-strong);
  box-shadow: var(--sh-2);
}

.lk-card--click {
  cursor: pointer;
}

.lk-card--click:hover {
  transform: translateY(-2px);
  border-color: rgba(139, 92, 246, .4);
  box-shadow: var(--sh-2);
}

.lk-card--click:active { transform: translateY(0); }

/* Cartões existentes herdam a nova superfície sem perder o comportamento */
.dashboard-section,
.info-card,
.sales-card-mini,
.sales-stat-card,
.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}

.info-card:hover,
.sales-card-mini:hover,
.sales-stat-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--sh-2);
}

.info-card.clickable:hover,
.clickable-stat:hover {
  transform: translateY(-2px);
  border-color: rgba(139, 92, 246, .40);
}

/* ==========================================================================
   CABEÇALHO DE PÁGINA PADRÃO — .lk-page-head
   Mesmo formato em todas as abas: título, descrição, ações.
   ========================================================================== */
.lk-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  padding-bottom: var(--sp-4);
  margin-bottom: var(--sp-5);
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}

.lk-page-head-text { min-width: 0; }

.lk-page-head h2 {
  font-size: 21px;
  font-weight: 650;
  color: var(--tx-1);
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.lk-page-head h2 i {
  color: var(--purple-primary);
  font-size: 17px;
}

.lk-page-head-sub {
  margin-top: 5px;
  font-size: 13px;
  color: var(--tx-3);
  line-height: 1.45;
}

.lk-page-head-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Alinha o page-header legado ao novo padrão */
.page-header {
  padding-bottom: var(--sp-4);
  margin-bottom: var(--sp-5);
  border-bottom: 1px solid var(--line-soft);
}

.page-header h2 {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.022em;
}

/* ==========================================================================
   BOTÕES
   ========================================================================== */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-success,
.lk-btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  border-radius: var(--r-sm);
  padding: 9px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  white-space: nowrap;
  line-height: 1.2;
}

.btn-primary,
.lk-btn--primary {
  background: linear-gradient(135deg, var(--purple-primary), var(--pink-primary));
  color: #fff;
  box-shadow: 0 2px 10px rgba(139, 92, 246, .26);
}

.btn-primary:hover,
.lk-btn--primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(139, 92, 246, .34);
}

.btn-primary:active,
.lk-btn--primary:active { transform: translateY(0); filter: brightness(.96); }

.lk-btn--ghost {
  background: var(--surface-3);
  color: var(--tx-1);
  border-color: var(--line);
}

.lk-btn--ghost:hover {
  background: var(--surface-4);
  border-color: var(--line-strong);
}

.lk-btn--quiet {
  background: transparent;
  color: var(--tx-2);
  border-color: var(--line);
}

.lk-btn--quiet:hover { background: var(--surface-3); color: var(--tx-1); }

.lk-btn--danger {
  background: var(--bad-soft);
  color: #FCA5A5;
  border-color: rgba(239, 68, 68, .32);
}

.lk-btn--danger:hover { background: var(--bad); color: #fff; border-color: var(--bad); }

.lk-btn--sm { padding: 6px 11px; font-size: 12.5px; }
.lk-btn--icon { padding: 8px; width: 34px; height: 34px; }

button:disabled,
.lk-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none !important;
  filter: none !important;
}

/* ==========================================================================
   SUB-ABAS PADRÃO — .lk-tabs
   (o estilo de Vendas, agora disponível em qualquer aba)
   ========================================================================== */
.lk-tabs {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 4px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-5);
  overflow-x: auto;
  scrollbar-width: none;
}

.lk-tabs::-webkit-scrollbar { display: none; }

.lk-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 0;
  background: transparent;
  color: var(--tx-2);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}

.lk-tab i { font-size: 12.5px; opacity: .85; }

.lk-tab:hover { color: var(--tx-1); background: var(--surface-2); }

.lk-tab.active {
  background: linear-gradient(135deg, var(--purple-primary), var(--pink-primary));
  color: #fff;
  box-shadow: 0 2px 10px rgba(139, 92, 246, .28);
}

.lk-tab.active i { opacity: 1; }

.lk-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 19px;
  padding: 0 6px;
  border-radius: var(--r-full);
  background: var(--surface-4);
  color: var(--tx-2);
  font-size: 11px;
  font-weight: 700;
}

.lk-tab.active .lk-tab-count { background: rgba(255, 255, 255, .22); color: #fff; }
.lk-tab-count.is-alert { background: var(--bad); color: #fff; }

/* Sub-abas de Vendas herdam o novo padrão */
.sales-subtabs {
  padding: 4px;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  gap: var(--sp-1);
}

.sales-subtab {
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 13.5px;
  transition: background var(--t-fast), color var(--t-fast);
}

/* ==========================================================================
   ETIQUETAS SEMÂNTICAS — .lk-pill
   verde = bom · vermelho = problema · laranja = atenção
   ========================================================================== */
.lk-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid transparent;
}

.lk-pill i { font-size: 9.5px; }

.lk-pill--ok { background: var(--ok-soft); color: #6EE7A8; border-color: rgba(34, 197, 94, .26); }
.lk-pill--warn { background: var(--warn-soft); color: #FCD34D; border-color: rgba(245, 158, 11, .26); }
.lk-pill--bad { background: var(--bad-soft); color: #FCA5A5; border-color: rgba(239, 68, 68, .26); }
.lk-pill--info { background: var(--info-soft); color: #7DD3FC; border-color: rgba(56, 189, 248, .26); }
.lk-pill--brand { background: var(--brand-soft); color: #C4B5FD; border-color: rgba(139, 92, 246, .26); }
.lk-pill--mute { background: var(--surface-3); color: var(--tx-2); border-color: var(--line); }

/* Ponto pulsante de status */
.lk-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--tx-3);
}

.lk-dot--ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.lk-dot--bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); animation: lk-pulse 1.6s infinite; }
.lk-dot--warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }

@keyframes lk-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

/* Variação percentual (↑ verde / ↓ vermelho) */
.lk-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.lk-delta--up { color: #6EE7A8; }
.lk-delta--down { color: #FCA5A5; }
.lk-delta--flat { color: var(--tx-3); }

/* ==========================================================================
   TABELAS — cabeçalho fixo, linhas alternadas, ordenação
   ========================================================================== */
.lk-table-wrap {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: auto;
  max-height: 68vh;
  box-shadow: var(--sh-1);
}

.lk-table,
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}

.lk-table thead th,
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface-1);
  color: var(--tx-3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .075em;
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.lk-table tbody td,
.data-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--tx-1);
  vertical-align: middle;
}

.lk-table tbody tr:nth-child(even),
.data-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, .014);
}

.lk-table tbody tr:hover,
.data-table tbody tr:hover {
  background: var(--surface-3);
}

.lk-table tbody tr:last-child td,
.data-table tbody tr:last-child td { border-bottom: 0; }

/* Coluna clicável para ordenar */
.lk-th-sort {
  cursor: pointer;
  user-select: none;
  transition: color var(--t-fast);
}

.lk-th-sort:hover { color: var(--tx-1); }

.lk-th-sort::after {
  content: '\f0dc';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 9px;
  margin-left: 6px;
  opacity: .3;
}

.lk-th-sort[data-dir="asc"]::after { content: '\f0de'; opacity: 1; color: var(--purple-primary); }
.lk-th-sort[data-dir="desc"]::after { content: '\f0dd'; opacity: 1; color: var(--purple-primary); }

/* Ações sempre no mesmo canto */
.lk-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

/* ==========================================================================
   ESTADO VAZIO — explica o que fazer em vez de deixar a tela em branco
   ========================================================================== */
.lk-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 56px 26px;
  gap: 6px;
}

.lk-empty-icon {
  width: 58px;
  height: 58px;
  border-radius: var(--r-lg);
  display: grid;
  place-items: center;
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--tx-3);
  font-size: 22px;
  margin-bottom: 8px;
}

.lk-empty h4 {
  font-size: 15px;
  font-weight: 650;
  color: var(--tx-1);
}

.lk-empty p {
  font-size: 13px;
  color: var(--tx-3);
  max-width: 380px;
  line-height: 1.55;
}

.lk-empty .lk-btn,
.lk-empty .btn-primary { margin-top: 12px; }

/* Estado vazio legado */
.empty-state i { color: var(--tx-3); }

/* ==========================================================================
   CARREGAMENTO — esqueleto no formato da tela (em vez de "Carregando...")
   ========================================================================== */
.lk-skel {
  position: relative;
  overflow: hidden;
  background: var(--surface-3);
  border-radius: var(--r-sm);
}

.lk-skel::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .055), transparent);
  animation: lk-shimmer 1.35s infinite;
}

@keyframes lk-shimmer {
  100% { transform: translateX(100%); }
}

.lk-skel--text { height: 11px; margin: 7px 0; }
.lk-skel--title { height: 19px; width: 42%; margin: 9px 0; }
.lk-skel--card { height: 96px; }
.lk-skel--chart { height: 210px; }
.lk-skel--row { height: 44px; margin-bottom: 7px; }

@media (prefers-reduced-motion: reduce) {
  .lk-skel::after { animation: none; }
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ==========================================================================
   FORMULÁRIOS
   ========================================================================== */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="search"],
select,
textarea,
.form-group input,
.form-group select,
.form-group textarea {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--tx-1);
  font-size: 13.5px;
  padding: 9px 12px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}

input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) { border-color: var(--line-strong); }

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--purple-primary);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, .16);
}

input::placeholder,
textarea::placeholder { color: var(--tx-3); }

label,
.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--tx-2);
  letter-spacing: -0.005em;
}

/* ==========================================================================
   MODAIS
   ========================================================================== */
.modal-overlay,
.modal {
  backdrop-filter: blur(7px);
  background: rgba(6, 10, 20, .68);
}

.modal-content,
.modal-pro {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
}

/* ==========================================================================
   NOTIFICAÇÕES (toast) — showNotification() em app.js
   ========================================================================== */
.notification {
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-3);
  box-shadow: var(--sh-3);
  font-size: 13.5px;
  font-weight: 550;
}

/* ==========================================================================
   UTILITÁRIOS
   ========================================================================== */
.lk-row { display: flex; align-items: center; gap: var(--sp-3); }
.lk-col { display: flex; flex-direction: column; gap: var(--sp-2); }
.lk-grow { flex: 1; min-width: 0; }
.lk-muted { color: var(--tx-3); }
.lk-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lk-hide { display: none !important; }

.lk-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .075em;
  color: var(--tx-3);
}

.lk-sr {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Separador de seção */
.lk-sep {
  height: 1px;
  background: var(--line-soft);
  border: 0;
  margin: var(--sp-5) 0;
}
