/* ============ Multi-select ============ */
.multi-select { position: relative; }
.multi-select .ms-dropdown { width: max-content; min-width: 100%; }
.multi-select label.ms-option {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.375rem 0.5rem; font-size: 0.8125rem; color: #334155;
  border-radius: 0.25rem; cursor: pointer;
}
.multi-select label.ms-option:hover { background: #f1f5f9; }
.multi-select input[type="checkbox"] { accent-color: #2563eb; }

/* ============ Tabela ============ */
.sortable-table th { user-select: none; white-space: nowrap; }
.sortable-table th[data-sort]::after {
  content: ' ⇅'; opacity: 0.3; font-size: 0.7em;
}
.sortable-table th.sort-asc::after { content: ' ▲'; opacity: 1; color: #2563eb; }
.sortable-table th.sort-desc::after { content: ' ▼'; opacity: 1; color: #2563eb; }
.sortable-table tbody tr.row-best { background: #f0fdf4; }
.sortable-table tbody tr.row-worst { background: #fef2f2; }
.sortable-table tbody tr.row-top-revenue { background: #f5f3ff; }
.sortable-table tbody td { padding: 0.625rem 1rem; }
.sortable-table tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ============ Heatmap ============ */
.heatmap-table {
  border-collapse: separate; border-spacing: 2px;
  font-variant-numeric: tabular-nums;
}
.heatmap-table th {
  font-size: 0.7rem; font-weight: 600; color: #64748b;
  padding: 0.4rem 0.5rem; text-align: center; white-space: nowrap;
  background: #f8fafc; border-radius: 4px;
}
.heatmap-table th.cohort-col {
  text-align: left; min-width: 90px; padding-left: 0.5rem;
}
.heatmap-table th.meta-col { background: transparent; color: #94a3b8; }
.heatmap-table td.cohort-label {
  font-size: 0.75rem; font-weight: 500; color: #1e293b;
  background: #f1f5f9; padding: 0.4rem 0.5rem; border-radius: 4px;
  white-space: nowrap;
}
.heatmap-table td.cohort-meta {
  font-size: 0.7rem; color: #334155; padding: 0.25rem 0.5rem;
  text-align: right; white-space: nowrap; font-weight: 500;
}
.heatmap-table td.cohort-meta.has-warning {
  color: #d97706;
}
.heatmap-cell {
  width: 50px; height: 36px; border-radius: 4px;
  color: white; font-size: 0.75rem; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  cursor: default;
}
.heatmap-cell.incomplete { background: transparent; color: transparent; cursor: default; }
.heatmap-cell.empty { background: transparent; cursor: default; color: transparent; }
.heatmap-table tr.avg-row td.cohort-label {
  background: #1e293b; color: white; font-weight: 600;
}
.heatmap-table tr.avg-row .heatmap-cell {
  outline: 2px solid #1e293b; outline-offset: -2px;
}
/* Colunas-resumo (LTV Médio, Receita Total) — agora no início da tabela */
.heatmap-table th.summary-col {
  background: #f1f5f9; color: #475569;
  border-right: 2px solid #cbd5e1;
  text-align: right; padding: 0.4rem 0.75rem;
  font-variant-numeric: tabular-nums;
}
.heatmap-table th.cohort-col + th.summary-col { border-left: none; }
.heatmap-table th.summary-col:last-of-type { border-right: 2px solid #cbd5e1; }
.heatmap-table td.summary-cell {
  background: transparent;
  color: #64748b;
  font-size: 0.72rem; font-weight: 400;
  text-align: right; padding: 0.4rem 0.75rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.heatmap-table tr td.summary-cell:last-of-type { border-right: 2px solid #cbd5e1; }
.heatmap-table td.summary-cell.summary-cell-best {
  background: rgba(16, 185, 129, 0.15);
  color: #065f46;
  font-weight: 600;
}
html.dark .heatmap-table td.summary-cell.summary-cell-best {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}
html.dark .heatmap-table td.summary-cell.summary-cell-best i {
  color: #34d399;
}
.heatmap-table tr.avg-row td.summary-cell {
  background: #1e293b; color: white; font-weight: 600;
}

/* ============ Diversos ============ */
.tab-btn.active { background: white; box-shadow: 0 1px 2px rgba(0,0,0,0.05); color: #0f172a; }
.produto-btn.active { background: white; box-shadow: 0 1px 2px rgba(0,0,0,0.05); color: #0f172a; }
.export-btn { transition: color 0.15s; cursor: pointer; }
.kpi-card { transition: transform 0.15s, box-shadow 0.15s; }
.kpi-card:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }

/* ============ Help tooltip (?) ============ */
.help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  cursor: help;
  position: relative;
  margin-left: 6px;
  vertical-align: middle;
  flex-shrink: 0;
  user-select: none;
}
.help:hover { background: #cbd5e1; color: #1e293b; }
.help::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f8fafc;
  font-size: 11px;
  font-weight: 400;
  padding: 8px 10px;
  border-radius: 6px;
  white-space: normal;
  width: max-content;
  max-width: 260px;
  text-align: left;
  line-height: 1.45;
  z-index: 100;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s;
}
.help::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1e293b;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s;
}
.help:hover::after, .help:hover::before { opacity: 1; visibility: visible; }
html.dark .help { background: #334155; color: #94a3b8; }
html.dark .help:hover { background: #475569; color: #f1f5f9; }

/* ============ Empty state ============ */
.empty-state {
  text-align: center; padding: 3rem 1rem;
  color: #94a3b8; font-size: 0.875rem;
}

/* ============ Theme toggle icons ============ */
/* Sun mostra no modo escuro (clique → muda pra claro); Lua mostra no claro. */
.theme-icon-sun { display: none; }
.theme-icon-moon { display: block; }
html.dark .theme-icon-sun { display: block; }
html.dark .theme-icon-moon { display: none; }

/* ============ Dark mode ============ */
/* Overrides centralizados — evita reescrever cada classe Tailwind no HTML.
   !important porque o Tailwind CDN injeta as utilities depois do styles.css. */
html.dark body { background-color: #0f172a; color: #e2e8f0; }

html.dark .bg-white { background-color: #1e293b !important; }
html.dark .bg-slate-50 { background-color: #0f172a !important; }
html.dark .bg-slate-100 { background-color: #334155 !important; }

html.dark .border-slate-200 { border-color: #334155 !important; }
html.dark .border-slate-300 { border-color: #475569 !important; }
html.dark .divide-slate-100 > * + * { border-color: #334155 !important; }

html.dark .text-slate-900 { color: #f1f5f9 !important; }
html.dark .text-slate-800 { color: #e2e8f0 !important; }
html.dark .text-slate-700 { color: #cbd5e1 !important; }
html.dark .text-slate-600 { color: #94a3b8 !important; }
html.dark .text-slate-500 { color: #94a3b8 !important; }
html.dark .text-slate-400 { color: #64748b !important; }

/* Tabs ativa vs inativa (legacy - mantido para compatibilidade) */
html.dark .tab-btn.bg-white { background-color: #475569 !important; color: #f1f5f9 !important; }
html.dark .produto-btn.bg-white { background-color: #475569 !important; color: #f1f5f9 !important; }

/* ============ Sidebar nav ============ */
.sidebar-nav {
  width: 220px;
  min-width: 220px;
}

/* Mobile: oculta por padrão, desliza da esquerda */
@media (max-width: 767px) {
  .sidebar-nav {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar-nav.open {
    transform: translateX(0);
  }
}

/* Tab buttons — estilo sidebar */
.tab-btn {
  color: #64748b;
  transition: background 0.12s, color 0.12s;
}
.tab-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.tab-btn.tab-active {
  background: #f1f5f9;
  color: #0f172a;
  font-weight: 500;
}
html.dark .tab-btn              { color: #94a3b8; }
html.dark .tab-btn:hover        { background: #334155; color: #f1f5f9; }
html.dark .tab-btn.tab-active   { background: #334155; color: #f1f5f9; font-weight: 500; }

/* Inputs */
html.dark input, html.dark select {
  background-color: #1e293b !important;
  color: #e2e8f0 !important;
  border-color: #475569 !important;
}
html.dark input[type="month"]::-webkit-calendar-picker-indicator { filter: invert(0.8); }

/* Cards com gradiente (melhor/LTV cohort) */
html.dark .from-emerald-50 { --tw-gradient-from: #064e3b var(--tw-gradient-from-position); }
html.dark .to-emerald-100 { --tw-gradient-to: #065f46 var(--tw-gradient-to-position); }
html.dark .border-emerald-200 { border-color: #047857 !important; }
html.dark .text-emerald-700 { color: #6ee7b7 !important; }
html.dark .from-blue-50 { --tw-gradient-from: #1e3a8a var(--tw-gradient-from-position); }
html.dark .to-blue-100 { --tw-gradient-to: #1e40af var(--tw-gradient-to-position); }
html.dark .border-blue-200 { border-color: #1d4ed8 !important; }
html.dark .text-blue-700 { color: #93c5fd !important; }
html.dark .from-violet-50 { --tw-gradient-from: #2e1065 var(--tw-gradient-from-position); }
html.dark .to-violet-100 { --tw-gradient-to: #3b0764 var(--tw-gradient-to-position); }
html.dark .border-violet-200 { border-color: #6d28d9 !important; }
html.dark .text-violet-700 { color: #c4b5fd !important; }

/* Aviso de período */
html.dark .bg-amber-50 { background-color: #422006 !important; }
html.dark .border-amber-200 { border-color: #78350f !important; }
html.dark .text-amber-800 { color: #fbbf24 !important; }

/* Heatmap */
html.dark .heatmap-table th { background: #1e293b; color: #94a3b8; }
html.dark .heatmap-table th.meta-col { background: transparent; color: #64748b; }
html.dark .heatmap-table td.cohort-label { background: #334155; color: #e2e8f0; }
html.dark .heatmap-table td.cohort-meta { color: #cbd5e1; }
html.dark .heatmap-cell.incomplete { background: transparent; color: transparent; }
html.dark .heatmap-table tr.avg-row td.cohort-label { background: #0f172a; }
html.dark .heatmap-table th.summary-col { background: #1e293b; color: #94a3b8; border-right-color: #475569; }
html.dark .heatmap-table td.summary-cell { background: transparent; color: #64748b; }
html.dark .heatmap-table tr td.summary-cell:last-of-type { border-right-color: #475569; }
html.dark .heatmap-table tr.avg-row td.summary-cell { background: #0f172a; }

/* Tabela ciclo */
html.dark .sortable-table tbody tr.row-best { background: #052e1a; }
html.dark .sortable-table tbody tr.row-worst { background: #2d0a0a; }
html.dark .sortable-table tbody tr.row-top-revenue { background: #1e1b4b; }

/* Multi-select */
html.dark .multi-select label.ms-option { color: #e2e8f0; }
html.dark .multi-select label.ms-option:hover { background: #334155; }

/* Hover utilitários */
html.dark .hover\:bg-slate-100:hover { background-color: #334155 !important; }
html.dark .hover\:text-slate-900:hover { color: #f1f5f9 !important; }

/* Error screen */
html.dark .border-rose-200 { border-color: #be123c !important; }

/* Loading screen background segue body */
html.dark #loading-screen, html.dark #error-screen { background-color: #0f172a !important; }

/* ============================================================
   BLUR MODE — dados sensíveis
   ============================================================ */
body.blur-mode [data-sensitive] {
  filter: blur(7px);
  transition: filter 0.2s ease;
  user-select: none;
}
body.blur-mode [data-sensitive]:hover {
  filter: blur(0);
  cursor: pointer;
}
/* Botão blur ativo */
#blur-toggle.active {
  background-color: #e0e7ff;
  color: #3730a3;
}
html.dark #blur-toggle.active {
  background-color: #1e1b4b;
  color: #a5b4fc;
}

/* Login screen — hidden by default, shown via JS */
#login-screen { display: none; }
#login-screen.flex { display: flex; }

/* Multi-select: separador e "Todos" */
.ms-separator { height: 1px; background: #e2e8f0; margin: 4px 8px; }
html.dark .ms-separator { background: #334155; }
.ms-option-all span { font-weight: 600; }
