/*
 * AI Usage Dashboard — Stylesheet
 * Template by lautandigital.id
 * https://lautandigital.id
 *
 * Version : 1.0.0
 * Date    : 2026-06-26
 */

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* Colors – Light Mode */
  --color-bg:           #f4f5f7;
  --color-surface:      #ffffff;
  --color-surface-2:    #f8f9fb;
  --color-border:       #e5e7eb;
  --color-border-light: #f0f1f3;

  --color-text-primary:   #111827;
  --color-text-secondary: #6b7280;
  --color-text-muted:     #9ca3af;

  --color-purple:         #6366f1;
  --color-purple-light:   #ede9fe;
  --color-purple-dark:    #4f46e5;
  --color-blue:           #3b82f6;
  --color-blue-light:     #dbeafe;
  --color-green:          #10b981;
  --color-green-light:    #d1fae5;
  --color-orange:         #f59e0b;
  --color-orange-light:   #fef3c7;
  --color-red:            #ef4444;
  --color-red-light:      #fee2e2;

  /* Sidebar */
  --sidebar-width:        260px;
  --sidebar-bg:           #1e1b4b;
  --sidebar-text:         #c7d2fe;
  --sidebar-text-active:  #ffffff;
  --sidebar-hover:        rgba(99, 102, 241, 0.15);
  --sidebar-active:       rgba(99, 102, 241, 0.3);
  --sidebar-border:       rgba(255,255,255,0.06);

  /* Layout */
  --topbar-height: 64px;
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     16px;
  --radius-xl:     24px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:  0 10px 30px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.06);

  /* Transitions */
  --transition-fast:   0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow:   0.4s ease;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Dark Mode Tokens */
[data-theme="dark"] {
  --color-bg:           #0f0f18;
  --color-surface:      #1a1a2e;
  --color-surface-2:    #16213e;
  --color-border:       #2d2d4e;
  --color-border-light: #252540;

  --color-text-primary:   #f1f5f9;
  --color-text-secondary: #94a3b8;
  --color-text-muted:     #64748b;

  --color-purple-light:   rgba(99, 102, 241, 0.15);
  --color-blue-light:     rgba(59, 130, 246, 0.15);
  --color-green-light:    rgba(16, 185, 129, 0.15);
  --color-orange-light:   rgba(245, 158, 11, 0.15);
  --color-red-light:      rgba(239, 68, 68, 0.15);

  --sidebar-bg:           #0d0d1a;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg:  0 10px 30px rgba(0,0,0,0.5);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  display: flex;
  min-height: 100vh;
  line-height: 1.6;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
ul { list-style: none; }
img, svg { display: block; }

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

/* Sidebar Header */
.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--sidebar-border);
}

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

.logo-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.logo-text {
  font-size: 1.25rem;
  color: #fff;
  letter-spacing: -0.3px;
}

.logo-text strong { color: var(--color-purple); font-weight: 700; }

.sidebar-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.sidebar-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--sidebar-text);
  border-radius: 2px;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}
.sidebar-toggle:hover { background: var(--sidebar-hover); }

/* Sidebar Nav */
.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }

.sidebar-nav ul { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; }

.nav-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.nav-item a:hover {
  background-color: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active a {
  background-color: var(--sidebar-active);
  color: var(--sidebar-text-active);
  box-shadow: inset 2px 0 0 var(--color-purple);
}

.nav-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 8px 0;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--sidebar-border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}
.user-card:hover { background: var(--sidebar-hover); }

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-purple), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}
.user-name {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-plan {
  display: block;
  font-size: 0.75rem;
  color: var(--color-purple);
  font-weight: 500;
}

.user-menu-btn {
  width: 24px;
  height: 24px;
  color: var(--sidebar-text);
  flex-shrink: 0;
}
.user-menu-btn svg { width: 16px; height: 16px; }

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

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.mobile-menu-btn {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.mobile-menu-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--color-text-secondary);
  border-radius: 2px;
}
.mobile-menu-btn:hover { background: var(--color-surface-2); }

.page-title h1 {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.2;
}
.breadcrumb {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

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

.date-range-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.date-range-picker:hover {
  border-color: var(--color-purple);
  color: var(--color-purple);
}
.date-range-picker svg { width: 15px; height: 15px; }

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
  position: relative;
}
.btn-icon svg { width: 18px; height: 18px; }
.btn-icon:hover {
  border-color: var(--color-purple);
  color: var(--color-purple);
  background: var(--color-purple-light);
}

.notification-btn .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: var(--color-red);
  color: #fff;
  border-radius: 50%;
  font-size: 0.625rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-surface);
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: linear-gradient(135deg, var(--color-purple), #8b5cf6);
  color: #fff;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}
.btn-primary svg { width: 16px; height: 16px; }
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
}
.btn-primary:active { transform: translateY(0); }

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content {
  padding: 28px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hidden { display: none !important; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-purple);
}

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

.stat-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-icon svg { width: 20px; height: 20px; }

.stat-icon--purple { background: var(--color-purple-light); color: var(--color-purple); }
.stat-icon--blue   { background: var(--color-blue-light);   color: var(--color-blue);   }
.stat-icon--green  { background: var(--color-green-light);  color: var(--color-green);  }
.stat-icon--orange { background: var(--color-orange-light); color: var(--color-orange); }

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--color-text-primary);
  margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
}

.stat-change {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8125rem;
  font-weight: 500;
}
.stat-change svg { width: 14px; height: 14px; }
.stat-change.positive { color: var(--color-green); }
.stat-change.negative { color: var(--color-red); }

/* ============================================================
   CHARTS
   ============================================================ */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}

.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

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

.chart-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text-primary);
}
.chart-subtitle {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.chart-body { position: relative; }
.chart-card--large .chart-body { height: 240px; }
.chart-card:not(.chart-card--large) .chart-body { height: 200px; }

.chart-legend {
  display: flex;
  gap: 12px;
}
.legend-item {
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-item::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.legend-item--input::before  { background: var(--color-purple); }
.legend-item--output::before { background: var(--color-blue); }

.donut-legend {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.donut-legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8125rem;
}
.donut-legend-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text-secondary);
}
.donut-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.donut-legend-value {
  font-weight: 600;
  color: var(--color-text-primary);
}

/* ============================================================
   BOTTOM ROW CARDS
   ============================================================ */
.bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr 320px;
  gap: 20px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
}
.card-link {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-purple);
  transition: color var(--transition-fast);
}
.card-link:hover { color: var(--color-purple-dark); }

/* Activity List */
.activity-list { display: flex; flex-direction: column; gap: 1px; }

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border-light);
  transition: background var(--transition-fast);
}
.activity-item:last-child { border-bottom: none; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.activity-dot--success { background: var(--color-green); }
.activity-dot--warning { background: var(--color-orange); }
.activity-dot--error   { background: var(--color-red); }
.activity-dot--info    { background: var(--color-blue); }

.activity-body { flex: 1; min-width: 0; }
.activity-text {
  font-size: 0.8125rem;
  color: var(--color-text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-meta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.activity-tokens {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

/* Endpoint List */
.endpoint-list { display: flex; flex-direction: column; gap: 12px; }

.endpoint-item { }
.endpoint-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.endpoint-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-primary);
  font-family: 'Courier New', monospace;
}
.endpoint-count {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.mini-bar {
  height: 6px;
  background: var(--color-border);
  border-radius: 99px;
  overflow: hidden;
}
.mini-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--color-purple), #8b5cf6);
  transition: width 1s ease;
}

/* Budget Gauge */
.badge-info {
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--color-blue-light);
  color: var(--color-blue);
  padding: 3px 10px;
  border-radius: 99px;
}

.budget-gauge {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}

.gauge-chart {
  position: relative;
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}

.gauge-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.gauge-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-text-primary);
}
.gauge-label {
  display: block;
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.budget-details { flex: 1; }
.budget-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.8125rem;
}
.budget-row span { color: var(--color-text-secondary); }
.budget-row strong { font-weight: 700; }

.text-warning { color: var(--color-orange) !important; }
.text-success { color: var(--color-green) !important; }

.budget-progress { margin-top: 4px; }
.progress-bar {
  height: 8px;
  background: var(--color-border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--color-green), var(--color-orange));
  transition: width 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================================
   PLACEHOLDER PAGES
   ============================================================ */
.page-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.placeholder-block {
  text-align: center;
  max-width: 360px;
}
.placeholder-block svg {
  width: 64px;
  height: 64px;
  color: var(--color-text-muted);
  margin: 0 auto 20px;
  opacity: 0.4;
}
.placeholder-block h2 {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.placeholder-block p {
  font-size: 0.9375rem;
  color: var(--color-text-secondary);
}

/* ============================================================
   FOOTER
   ============================================================ */
.dashboard-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}
.dashboard-footer a {
  color: var(--color-purple);
  font-weight: 600;
  transition: color var(--transition-fast);
}
.dashboard-footer a:hover { color: var(--color-purple-dark); }

/* ============================================================
   SIDEBAR OVERLAY (mobile)
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
  opacity: 0;
  transition: opacity var(--transition-normal);
}
.sidebar-overlay.active {
  opacity: 1;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes countUp {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.stat-card { animation: fadeInUp 0.4s ease both; }
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.10s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.20s; }

.chart-card { animation: fadeInUp 0.4s ease 0.2s both; }
.card       { animation: fadeInUp 0.4s ease 0.3s both; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1280px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .bottom-row { grid-template-columns: 1fr 1fr; }
}

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

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

  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-overlay { display: block; pointer-events: none; }
  .sidebar-overlay.active { pointer-events: all; }

  .main-content { margin-left: 0; }

  .mobile-menu-btn { display: flex; }

  .topbar { padding: 0 16px; }

  .date-range-picker { display: none; }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 14px; }

  .page-content { padding: 20px 16px; gap: 16px; }

  .stat-value { font-size: 1.625rem; }

  .charts-row { gap: 16px; }
  .chart-card--large .chart-body { height: 200px; }

  .dashboard-footer { flex-direction: column; gap: 4px; text-align: center; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.875rem; }
  .topbar-right { gap: 8px; }
  .btn-primary span { display: none; }
}
