/* ============================================
   MINHA QUITANDINHA — PREMIUM DARK THEME
   ============================================ */

/* ============================================
   TOKENS
   ============================================ */
:root {
  /* Backgrounds — layered depth */
  --bg-base:        #090b0f;
  --bg-surface:     #0f1117;
  --bg-card:        #141820;
  --bg-card-hover:  #191e28;
  --bg-elevated:    #1c2130;
  --bg-input:       #0c0e14;

  /* Borders */
  --border:         #1e2333;
  --border-mid:     #252c3d;
  --border-light:   #2d3550;

  /* Text */
  --text-primary:   #eef0f6;
  --text-secondary: #7d8aa8;
  --text-muted:     #444e67;
  --text-faint:     #2d3550;

  /* Accent */
  --accent:         #4f7cff;
  --accent-dim:     rgba(79,124,255,0.12);
  --accent-glow:    rgba(79,124,255,0.08);
  --accent-hover:   #6b92ff;
  --accent-border:  rgba(79,124,255,0.3);

  /* Semantic */
  --green:          #1fd47a;
  --green-dim:      rgba(31,212,122,0.1);
  --green-border:   rgba(31,212,122,0.2);
  --red:            #f05a6a;
  --red-dim:        rgba(240,90,106,0.1);
  --red-border:     rgba(240,90,106,0.2);
  --yellow:         #f0be3c;
  --yellow-dim:     rgba(240,190,60,0.1);
  --yellow-border:  rgba(240,190,60,0.2);

  /* Store colors */
  --color-albatroz: #4f7cff;
  --color-point:    #1fd47a;
  --color-tagus:    #f0be3c;

  /* Layout */
  --sidebar-width:  248px;
  --topbar-height:  60px;

  /* Radius */
  --radius-xs:  4px;
  --radius-sm:  7px;
  --radius-md:  11px;
  --radius-lg:  16px;

  /* Shadows */
  --shadow-xs:   0 1px 2px rgba(0,0,0,0.5);
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
  --shadow-card: 0 0 0 1px var(--border), 0 2px 4px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.2);
  --shadow-glow: 0 0 0 1px var(--accent-border), 0 4px 20px rgba(79,124,255,0.15);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 140ms cubic-bezier(0.4,0,0.2,1);
  --transition-slow: 300ms cubic-bezier(0.4,0,0.2,1);
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: var(--font); border: none; background: none; }
canvas { display: block; }

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes barGrow {
  from { width: 0 !important; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 22px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--accent) 0%, #7b5fff 100%);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; letter-spacing: 0.3px;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(79,124,255,0.4);
}

.brand-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.1px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 450;
  transition: all var(--transition);
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 2px; height: 60%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  width: 15px; height: 15px;
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  padding: 2px 6px;
  border-radius: 20px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.user-info:hover { background: rgba(255,255,255,0.04); }

.user-avatar {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent) 0%, #7b5fff 100%);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-details { display: flex; flex-direction: column; gap: 1px; }
.user-name  { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.user-role  { font-size: 10px; color: var(--text-muted); }

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================
   TOPBAR
   ============================================ */
.topbar {
  height: var(--topbar-height);
  background: rgba(15,17,23,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: baseline; gap: 12px; }

.page-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.page-date {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

.period-selector {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.period-btn {
  padding: 4px 11px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
  letter-spacing: -0.1px;
}
.period-btn:hover { color: var(--text-secondary); }
.period-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

.topbar-divider { width: 1px; height: 18px; background: var(--border); }

.refresh-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all var(--transition);
  border: 1px solid transparent;
}
.refresh-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--border-mid);
  color: var(--text-secondary);
}
.refresh-btn.spinning svg { animation: spin 0.5s linear; }
.refresh-btn svg { width: 14px; height: 14px; }

/* ============================================
   PAGES
   ============================================ */
.page {
  display: none;
  padding: 24px 28px 40px;
  flex: 1;
}
.page.active { display: block; }

.placeholder-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  gap: 8px;
  color: var(--text-muted);
}
.placeholder-page h2 { font-size: 18px; font-weight: 600; color: var(--text-secondary); }

/* ============================================
   KPI CARDS
   ============================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  animation: fadeUp 0.4s ease both;
  cursor: default;
}
.kpi-card:nth-child(1) { animation-delay: 0ms; }
.kpi-card:nth-child(2) { animation-delay: 60ms; }
.kpi-card:nth-child(3) { animation-delay: 120ms; }

.kpi-card:hover {
  border-color: var(--border-mid);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}

/* Accent top line */
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--kpi-accent, var(--border-mid));
  opacity: 0;
  transition: opacity var(--transition);
}
.kpi-card:hover::before { opacity: 1; }

.kpi-card.kpi-revenue  { --kpi-accent: var(--accent); }
.kpi-card.kpi-sales    { --kpi-accent: var(--green); }
.kpi-card.kpi-ticket   { --kpi-accent: var(--yellow); }

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

.kpi-icon {
  width: 28px; height: 28px;
  border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.kpi-icon svg { width: 14px; height: 14px; }
.kpi-revenue .kpi-icon { background: var(--accent-dim);  color: var(--accent); }
.kpi-sales   .kpi-icon { background: var(--green-dim);   color: var(--green); }
.kpi-ticket  .kpi-icon { background: var(--yellow-dim);  color: var(--yellow); }

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 12px;
  font-variant-numeric: tabular-nums;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
}
.kpi-delta svg { width: 11px; height: 11px; }
.kpi-delta.positive { background: var(--green-dim);  color: var(--green);  border: 1px solid var(--green-border); }
.kpi-delta.negative { background: var(--red-dim);    color: var(--red);    border: 1px solid var(--red-border); }
.kpi-delta.neutral  { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border-mid); }

/* ============================================
   DASHBOARD GRID
   ============================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: auto auto auto;
  gap: 14px;
}

.card-insights { grid-column: 1 / -1; }

/* ============================================
   CARDS — base
   ============================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
  animation: fadeUp 0.4s ease both;
}
.card:nth-child(1) { animation-delay: 80ms; }
.card:nth-child(2) { animation-delay: 140ms; }
.card:nth-child(3) { animation-delay: 200ms; }
.card:nth-child(4) { animation-delay: 260ms; }

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.1px;
}

.card-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

/* ============================================
   RANKING DE LOJAS
   ============================================ */
.card-ranking { grid-row: 1 / 3; }

.ranking-list { display: flex; flex-direction: column; gap: 10px; }

.ranking-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  border: 1px solid var(--border);
  transition: border-color var(--transition), background var(--transition);
}
.ranking-item:hover { background: var(--bg-elevated); border-color: var(--border-mid); }

.ranking-pos {
  width: 26px;
  text-align: center;
  font-size: 16px;
  flex-shrink: 0;
}

.ranking-info { flex: 1; min-width: 0; }

.ranking-name {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ranking-bar-wrap {
  height: 4px;
  background: var(--bg-surface);
  border-radius: 2px;
  overflow: hidden;
}
.ranking-bar {
  height: 100%;
  border-radius: 2px;
  animation: barGrow 0.7s ease both;
}

.ranking-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ============================================
   GRÁFICO
   ============================================ */
.card-chart { min-height: 280px; }

.chart-container {
  position: relative;
  height: 240px;
}

/* ============================================
   TICKET MÉDIO
   ============================================ */
.ticket-list { display: flex; flex-direction: column; gap: 14px; }

.ticket-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.ticket-item:hover { background: var(--bg-elevated); }

.ticket-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  width: 96px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticket-bar-wrap {
  flex: 1;
  height: 5px;
  background: var(--bg-base);
  border-radius: 3px;
  overflow: hidden;
}
.ticket-bar {
  height: 100%;
  border-radius: 3px;
  animation: barGrow 0.7s ease both;
}

.ticket-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  width: 72px;
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* ============================================
   INSIGHTS
   ============================================ */
.insights-list { display: flex; flex-direction: column; gap: 8px; }

.insight-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  transition: filter var(--transition), transform var(--transition);
}
.insight-item:hover { transform: translateX(2px); }

.insight-badge {
  width: 26px; height: 26px;
  border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.insight-body { flex: 1; min-width: 0; }
.insight-body p { font-size: 12.5px; line-height: 1.55; color: var(--text-secondary); }
.insight-body p strong { color: var(--text-primary); font-weight: 600; }
.insight-meta {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.insight-positive {
  background: var(--green-dim);
  border: 1px solid var(--green-border);
}
.insight-positive .insight-badge { background: rgba(31,212,122,0.15); color: var(--green); }

.insight-warning {
  background: var(--yellow-dim);
  border: 1px solid var(--yellow-border);
}
.insight-warning .insight-badge { background: rgba(240,190,60,0.15); color: var(--yellow); }

.insight-neutral {
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
}
.insight-neutral .insight-badge { background: var(--bg-card); color: var(--text-muted); }

/* insight-icon e insight-text (usados no overview e vendas) */
.insight-icon {
  width: 26px; height: 26px;
  border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}
.insight-positive .insight-icon { background: rgba(31,212,122,0.15); color: var(--green); }
.insight-warning  .insight-icon { background: rgba(240,190,60,0.15);  color: var(--yellow); }
.insight-neutral  .insight-icon { background: var(--bg-card);          color: var(--text-muted); }

.insight-text {
  flex: 1;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}
.insight-text strong { color: var(--text-primary); font-weight: 600; }

/* ============================================
   MENU BUTTON (mobile)
   ============================================ */
.menu-btn {
  display: none;
  width: 34px; height: 34px;
  align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition);
  border: 1px solid transparent;
  flex-shrink: 0;
}
.menu-btn:hover { background: var(--bg-elevated); border-color: var(--border-mid); }
.menu-btn svg { width: 16px; height: 16px; }

/* ============================================
   SIDEBAR OVERLAY (mobile)
   ============================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}
.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ============================================
   RESPONSIVIDADE
   ============================================ */
@media (max-width: 1280px) {
  .dashboard-grid { grid-template-columns: 280px 1fr; }
}

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .card-ranking { grid-row: auto; }
}

/* ============================================
   BOTTOM NAVIGATION (mobile)
   ============================================ */
.bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 58px;
    background: rgba(15,17,23,0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    z-index: 90;
    align-items: stretch;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-muted);
    font-size: 9.5px;
    font-weight: 500;
    transition: color var(--transition);
    min-height: 44px;
    padding: 6px 4px;
    background: none;
    border: none;
    font-family: var(--font);
    cursor: pointer;
    text-decoration: none;
  }

  .bottom-nav-item.active { color: var(--accent); }
  .bottom-nav-item:active { opacity: 0.7; }
  .bottom-nav-item.bottom-nav-disabled { opacity: 0.3; pointer-events: none; }

  .bottom-nav-item svg {
    width: 20px; height: 20px;
    flex-shrink: 0;
  }

  .bottom-nav-item span { line-height: 1; }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 248px; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
    z-index: 100;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; }

  .menu-btn { display: flex; }
  .main-content { margin-left: 0; }

  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

  .topbar { padding: 0 14px; gap: 8px; }
  .topbar-left { gap: 8px; }
  .topbar-right {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
    max-width: calc(100vw - 160px);
  }
  .topbar-right::-webkit-scrollbar { display: none; }

  .page-date { display: none; }
  .page { padding: 14px 14px 80px; }

  .chart-container { height: 210px; }

  .period-selector {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: none;
    flex-shrink: 0;
  }
  .period-selector::-webkit-scrollbar { display: none; }
  .period-btn { white-space: nowrap; padding: 4px 9px; font-size: 11px; }

  .topbar-divider { display: none; }

  .dashboard-grid { grid-template-columns: 1fr; gap: 12px; }
  .card-ranking { grid-row: auto; }

  .kpi-value { font-size: 22px; }
  .kpi-card { padding: 16px 16px; }

  .ticket-name { width: 80px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; gap: 8px; }
  .kpi-card { padding: 14px 16px; }
  .kpi-value { font-size: 26px; }
  .chart-container { height: 190px; }
}
