/* dashboard.css — TotalScopeOS performance dashboard styles */

/* ── LAYOUT ─────────────────────────────────────────────────────────────── */

.dashboard-body {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* ── NAV ─────────────────────────────────────────────────────────────────── */

.dash-nav {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.dash-nav-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
}

.dash-logo-mark {
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 5px;
  display: inline-block;
  flex-shrink: 0;
}

.dash-badge {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.2rem 0.6rem;
  border-radius: 2rem;
}

/* ── MAIN ─────────────────────────────────────────────────────────────────── */

.dash-main {
  flex: 1;
  padding: 2rem 2.5rem 3rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.dash-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.dash-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.2;
}

.dash-subtitle {
  font-size: 0.875rem;
  color: var(--fg-muted);
  margin-top: 0.25rem;
}

/* ── KPI GRID ────────────────────────────────────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.kpi-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: border-color 0.2s ease;
}

.kpi-tile:hover {
  border-color: var(--accent);
}

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon--revenue { background: rgba(0,229,160,0.12); color: var(--accent); }
.kpi-icon--orders  { background: rgba(100,180,255,0.12); color: #64b4ff; }
.kpi-icon--aov     { background: rgba(255,200,100,0.12); color: #ffc864; }
.kpi-icon--top     { background: rgba(200,100,255,0.12); color: #c864ff; }

.kpi-content {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.kpi-label {
  font-size: 0.72rem;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  white-space: nowrap;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.2;
  white-space: nowrap;
}

.kpi-value--sm {
  font-size: 1rem;
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ── CARDS ───────────────────────────────────────────────────────────────── */

.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border);
}

.dash-card-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
}

.dash-card-sub {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

/* ── CHART ───────────────────────────────────────────────────────────────── */

.chart-card {}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--fg-muted);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot--revenue { background: var(--accent); }

.chart-wrap {
  padding: 1.5rem 1.75rem;
  height: 260px;
  position: relative;
}

/* ── PRODUCTS TABLE ──────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
}

.products-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.products-table th {
  padding: 0.75rem 1.25rem;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.products-table td {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid rgba(42,42,58,0.5);
  color: var(--fg);
  vertical-align: middle;
}

.product-row:last-child td {
  border-bottom: none;
}

.product-row:hover td {
  background: rgba(0,229,160,0.03);
}

.col-rank { width: 48px; }
.col-num  { text-align: right; white-space: nowrap; }
.col-bar  { width: 120px; }
.col-product { max-width: 280px; }

.rank-badge {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--fg-muted);
  display: inline-block;
  min-width: 28px;
}

.rank-1, .rank-2, .rank-3 { color: var(--accent); }

.product-info {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.product-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.product-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.product-name {
  font-weight: 500;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
  display: block;
}

.product-type {
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.col-revenue {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--accent);
}

.margin-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-display);
}

.margin-badge.positive    { background: rgba(0,229,160,0.12); color: var(--accent); }
.margin-badge.warning-soft{ background: rgba(255,200,100,0.12); color: #ffc864; }
.margin-badge.warning     { background: rgba(255,107,74,0.12); color: var(--warning); }

.margin-na {
  color: var(--fg-muted);
  font-size: 0.875rem;
}

.revenue-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.revenue-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 3px;
  transition: width 0.6s ease;
}

/* ── FOOTER ──────────────────────────────────────────────────────────────── */

.dash-footer {
  padding: 1.25rem 2.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.dash-footer-brand {
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg);
}

.dash-footer-note {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

/* ── RESPONSIVE ──────────────────────────────────────────────────────────── */

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

@media (max-width: 600px) {
  .dash-main {
    padding: 1.25rem 1rem 2rem;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .chart-wrap {
    height: 200px;
    padding: 1rem;
  }
  .dash-footer {
    flex-direction: column;
    text-align: center;
    gap: 0.25rem;
  }
  .col-bar { display: none; }
}
