/* ============================================
   LIMES — Dashboard de Carrinho Abandonado
   Design System & Estilos Globais
   Paleta: mel/dourado sobre dark mode
   ============================================ */

/* ---------- VARIÁVEIS DE DESIGN ---------- */
:root {
  /* Cores primárias (mel/dourado) */
  --gold-500: #E8B830;
  --gold-600: #D4A017;
  --gold-700: #C8961E;
  --gold-400: #F0C850;
  --gold-300: #F5D978;

  /* Superfícies (dark mode) */
  --bg-body: #0E0B07;
  --bg-surface: #1A1410;
  --bg-surface-raised: #241C14;
  --bg-surface-hover: #2E241A;

  /* Bordas */
  --border-subtle: rgba(200, 150, 30, 0.1);
  --border-default: rgba(200, 150, 30, 0.18);
  --border-strong: rgba(200, 150, 30, 0.3);

  /* Texto */
  --text-primary: #F5F0E8;
  --text-secondary: #A89A82;
  --text-muted: #6B5F4F;
  --text-inverse: #1A1410;

  /* Semânticas */
  --color-success: #34D399;
  --color-warning: #FBBF24;
  --color-danger: #F87171;
  --color-info: #60A5FA;

  /* Produto: MHA (amber) */
  --mha-accent: #E8B830;
  --mha-bg: rgba(232, 184, 48, 0.08);

  /* Produto: NHP (roxo/dourado) */
  --nhp-accent: #A78BFA;
  --nhp-bg: rgba(167, 139, 250, 0.08);

  /* Tipografia */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Espaçamento */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Bordas arredondadas */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  /* Sombras */
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.4);

  /* Transições */
  --transition-fast: 150ms ease;
  --transition-default: 250ms ease;
}

/* ---------- RESET & BASE ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

/* ---------- HEADER ---------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.header__logo {
  display: flex;
  align-items: center;
  justify-content: center;
}

.header__title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold-500);
  letter-spacing: -0.02em;
}

.header__subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.header__controls {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* Seletor de período */
.select-period {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.85rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: border-color var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23A89A82' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.select-period:hover {
  border-color: var(--gold-600);
}

.select-period:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 2px rgba(232, 184, 48, 0.15);
}

.select-period option {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
}

/* Botão de atualizar */
.btn-refresh {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--bg-surface-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.85rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-refresh:hover {
  background: var(--bg-surface-hover);
  color: var(--gold-500);
  border-color: var(--gold-600);
}

.btn-refresh.loading svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Indicador de última atualização */
.last-update {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---------- MAIN ---------- */
.main {
  padding: var(--space-xl);
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

/* ---------- KPI CARDS ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-md);
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  transition: all var(--transition-default);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold-700), var(--gold-500), var(--gold-700));
  opacity: 0;
  transition: opacity var(--transition-default);
}

.kpi-card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-hover);
}

.kpi-card:hover::before {
  opacity: 1;
}

.kpi-card__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-card__icon--abandonos {
  background: rgba(248, 113, 113, 0.1);
  color: var(--color-danger);
}
.kpi-card__icon--emails {
  background: rgba(96, 165, 250, 0.1);
  color: var(--color-info);
}
.kpi-card__icon--taxa {
  background: rgba(52, 211, 153, 0.1);
  color: var(--color-success);
}
.kpi-card__icon--revenue {
  background: rgba(232, 184, 48, 0.1);
  color: var(--gold-500);
}
.kpi-card__icon--ticket {
  background: rgba(167, 139, 250, 0.1);
  color: var(--nhp-accent);
}

.kpi-card__label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.kpi-card__value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kpi-card__delta {
  font-size: 0.75rem;
  font-weight: 500;
}

.kpi-card__delta--up {
  color: var(--color-success);
}

.kpi-card__delta--down {
  color: var(--color-danger);
}

.kpi-card__delta--neutral {
  color: var(--text-muted);
}

/* ---------- LAYOUT DUAS COLUNAS ---------- */
.two-col {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: var(--space-xl);
}

/* ---------- PAINÉIS ---------- */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.panel--wide {
  width: 100%;
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
}

.panel__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.panel__badge {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-surface-raised);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
}

/* ---------- TABELA DE DADOS ---------- */
.table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.data-table th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-surface-raised);
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}

.data-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

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

.data-table tfoot td {
  font-weight: 700;
  color: var(--gold-500);
  border-top: 2px solid var(--border-default);
  background: var(--bg-surface-raised);
}

/* Badge do nome do email na tabela */
.email-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.email-badge__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.email-badge__dot--1 { background: var(--gold-500); }
.email-badge__dot--2 { background: var(--gold-400); }
.email-badge__dot--3 { background: var(--gold-300); }
.email-badge__dot--4 { background: var(--color-warning); }
.email-badge__dot--5 { background: var(--color-danger); }

/* ---------- PRODUCT CARDS ---------- */
.product-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-lg);
}

.product-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition-default);
}

.product-card:hover {
  border-color: var(--border-default);
}

.product-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-md);
}

.product-card__header--mha {
  background: var(--mha-bg);
}

.product-card__header--nhp {
  background: var(--nhp-bg);
}

.product-card__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.product-card__dot--mha {
  background: var(--mha-accent);
}

.product-card__dot--nhp {
  background: var(--nhp-accent);
}

.product-card__header h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.product-card__id {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.product-card__metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border-subtle);
}

.product-card__metric {
  background: var(--bg-surface);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.product-card__metric--highlight {
  grid-column: 1 / -1;
  background: var(--bg-surface-raised);
}

.product-card__metric-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.product-card__metric-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.product-card__metric--highlight .product-card__metric-value {
  color: var(--gold-500);
}

/* ---------- GRÁFICOS ---------- */
.charts-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: var(--space-xl);
}

.chart-container {
  padding: var(--space-lg);
  height: 320px;
  position: relative;
}

.chart-legend {
  display: flex;
  gap: var(--space-md);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ---------- ESTADOS DE CARREGAMENTO ---------- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-surface-raised) 25%,
    var(--bg-surface-hover) 50%,
    var(--bg-surface-raised) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Estado de erro */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-2xl);
  text-align: center;
}

.error-state__icon {
  color: var(--color-danger);
}

.error-state__message {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ---------- FOOTER ---------- */
.footer {
  text-align: center;
  padding: var(--space-lg) var(--space-xl);
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.75rem;
}

.footer__note {
  margin-top: var(--space-xs);
  font-size: 0.65rem;
}

/* ---------- RESPONSIVO ---------- */
@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: var(--space-md);
    align-items: flex-start;
  }

  .header__controls {
    flex-wrap: wrap;
    width: 100%;
  }

  .main {
    padding: var(--space-md);
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .charts-section {
    grid-template-columns: 1fr;
  }

  .product-card__metrics {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- SCROLLBAR PERSONALIZADA ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gold-700);
}

/* ---------- TOOLTIP (para chart.js) ---------- */
.chartjs-tooltip {
  background: var(--bg-surface-raised) !important;
  border: 1px solid var(--border-default) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text-primary) !important;
  font-family: var(--font-sans) !important;
  font-size: 0.8rem !important;
  box-shadow: var(--shadow-hover) !important;
}
