/* ============================================
   SALESFORGE DASHBOARD — VOLCANIC GLASS THEME
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* ---- CSS Variables ---- */
:root {
  --bg:        #111111;
  --bg2:       #1A1A1A;
  --bg3:       #222222;
  --card:      #1E1E1E;
  --border:    #2E2E2E;
  --accent:    #FF6B2B;
  --accent2:   #FFB088;
  --accent-glow: rgba(255, 107, 43, 0.18);
  --text:      #F0EDE8;
  --text-muted:#888888;
  --text-dim:  #555555;
  --positive:  #4ADE80;
  --negative:  #F87171;
  --sidebar-w: 220px;
  --ticker-h:  36px;
  --radius:    14px;
  --radius-sm: 8px;
  --font:      'Outfit', sans-serif;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: var(--font); }
canvas { display: block; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ============================================
   TICKER BAR
   ============================================ */
.ticker-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--ticker-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  z-index: 100;
  display: flex;
  align-items: center;
}
.ticker-track {
  display: flex;
  gap: 0;
  white-space: nowrap;
  animation: ticker 28s linear infinite;
  will-change: transform;
}
.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 28px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
}
.ticker-item .ticker-name { color: var(--text); font-weight: 600; }
.ticker-item .up   { color: var(--positive); }
.ticker-item .down { color: var(--negative); }
@keyframes ticker {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ============================================
   LAYOUT
   ============================================ */
.sidebar {
  position: fixed;
  top: var(--ticker-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--ticker-h));
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 28px 0 20px;
  z-index: 50;
}

.main {
  margin-left: var(--sidebar-w);
  margin-top: var(--ticker-h);
  padding: 28px 28px 40px;
  min-height: calc(100vh - var(--ticker-h));
}

/* ============================================
   SIDEBAR
   ============================================ */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.logo-icon {
  font-size: 1.5rem;
  color: var(--accent);
  line-height: 1;
  filter: drop-shadow(0 0 8px var(--accent));
}
.logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s ease;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(255,107,43,0.2);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 22px 0;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #c94a10);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 0.8rem; font-weight: 600; color: var(--text); }
.user-role { font-size: 0.7rem; color: var(--text-muted); }

/* ============================================
   TOPBAR
   ============================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}
.page-title {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
}
.page-subtitle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 400;
}
.page-subtitle::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--positive);
  box-shadow: 0 0 6px var(--positive);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.8); }
}

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

.period-selector {
  display: flex;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.period-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  transition: all 0.2s;
}
.period-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(255,107,43,0.4);
}
.period-btn:hover:not(.active) { color: var(--text); background: var(--bg3); }

.export-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.2s;
}
.export-btn svg { width: 14px; height: 14px; }
.export-btn:hover { border-color: var(--accent); color: var(--accent); }

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

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 22px 16px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
  opacity: 0;
  transform: translateY(20px);
}
.kpi-card.visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s ease, transform 0.5s ease, border-color 0.2s;
}
.kpi-card:hover { border-color: rgba(255,107,43,0.3); transform: translateY(-2px); }
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}
.kpi-primary::before {
  background: linear-gradient(90deg, var(--accent), #ff9a6b);
}
.kpi-primary {
  border-color: rgba(255,107,43,0.25);
  background: linear-gradient(135deg, #1E1E1E 0%, #221810 100%);
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1;
  margin-bottom: 10px;
}
.kpi-primary .kpi-value { color: var(--accent); }

.kpi-delta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 14px;
}
.kpi-delta svg { width: 12px; height: 12px; }
.kpi-delta.positive { color: var(--positive); }
.kpi-delta.negative { color: var(--negative); }

.kpi-sparkline { height: 40px; }
.kpi-sparkline canvas { width: 100% !important; height: 40px !important; }

/* ============================================
   CHART CARDS
   ============================================ */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  margin-bottom: 20px;
}
.bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: border-color 0.2s;
}
.chart-card:hover { border-color: rgba(255,107,43,0.2); }

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}
.chart-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.chart-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.chart-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.legend-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.chart-wrap { position: relative; height: 220px; }
.chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* Donut */
.donut-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 180px;
}
.donut-center {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}
.donut-total {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
}
.donut-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.donut-legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
}
.donut-legend-left {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}
.donut-legend-dot {
  width: 8px; height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.donut-legend-pct {
  font-weight: 600;
  color: var(--text);
}

/* ============================================
   PRODUCT LIST
   ============================================ */
.product-list { display: flex; flex-direction: column; gap: 12px; }
.product-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.product-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.product-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}
.product-rev {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent2);
}
.product-bar-bg {
  height: 5px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}
.product-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  width: 0;
  transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   LEADERBOARD
   ============================================ */
.leaderboard { display: flex; flex-direction: column; gap: 10px; }
.leader-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}
.leader-item:hover { border-color: rgba(255,107,43,0.25); }
.leader-rank {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-dim);
  width: 18px;
  text-align: center;
}
.leader-rank.gold   { color: #FFD700; }
.leader-rank.silver { color: #C0C0C0; }
.leader-rank.bronze { color: #CD7F32; }
.leader-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.leader-info { flex: 1; }
.leader-name { font-size: 0.8rem; font-weight: 600; color: var(--text); }
.leader-deals { font-size: 0.68rem; color: var(--text-muted); }
.leader-rev {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent2);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .bottom-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .bottom-row { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
}