/* =============================================
   AI Router Management System - Styles
   ============================================= */

:root {
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --surface-50: #f8fafc;
  --surface-100: #f1f5f9;
  --surface-200: #e2e8f0;
  --surface-700: #334155;
  --surface-800: #1e293b;
  --surface-900: #0f172a;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #6366f1;
}

/* ── Base ───────────────────────────────────── */
* { box-sizing: border-box; }

body { font-family: 'Inter', system-ui, -apple-system, sans-serif; font-size: 14px; }

.app-body {
  display: flex;
  min-height: 100vh;
  background: var(--surface-50);
}

/* ── Sidebar ────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  left: 0; top: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.25s ease;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-link {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none;
}

.brand-icon { font-size: 20px; }

.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -0.3px;
}

.sidebar-org-switcher {
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.org-switch-btn {
  background: rgba(255,255,255,0.07) !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  color: #cbd5e1 !important;
  border-radius: 8px !important;
  font-size: 13px;
  padding: 6px 10px !important;
}
.org-switch-btn:hover { background: rgba(255,255,255,0.12) !important; }

.org-avatar {
  width: 28px; height: 28px;
  background: var(--primary);
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.org-avatar.sm { width: 22px; height: 22px; font-size: 9px; border-radius: 4px; }

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  border-radius: 0;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: #e2e8f0;
}

.nav-item.active {
  background: rgba(99,102,241,0.15);
  color: #a5b4fc;
  border-left-color: var(--sidebar-active);
}

.nav-item i { font-size: 15px; width: 18px; text-align: center; }

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 8px 16px;
}

.sidebar-user {
  padding: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.user-btn {
  background: rgba(255,255,255,0.05) !important;
  border: none !important;
  border-radius: 8px !important;
  color: #94a3b8 !important;
  padding: 8px 10px !important;
  text-align: left;
}
.user-btn:hover { background: rgba(255,255,255,0.1) !important; color: #e2e8f0 !important; }

.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.user-avatar-text {
  width: 28px; height: 28px;
  background: var(--primary);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

.user-name { font-size: 12.5px; font-weight: 600; color: #e2e8f0; line-height: 1.2; }
.user-email { font-size: 11px; color: #64748b; line-height: 1.2; }
.org-name { font-size: 13px; }

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

.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--surface-200);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--surface-800);
}

.sidebar-toggle-btn {
  display: none;
  border: none !important;
  background: transparent !important;
  color: var(--surface-700);
  padding: 4px 8px !important;
}

.page-content {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
}

.page-heading {
  font-size: 22px;
  font-weight: 700;
  color: var(--surface-800);
  margin-bottom: 4px;
}

/* ── Cards ──────────────────────────────────── */
.card {
  border: 1px solid var(--surface-200);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-header {
  padding: 12px 16px;
  background: var(--surface-50);
  border-bottom: 1px solid var(--surface-200);
  border-radius: 10px 10px 0 0;
  font-size: 13.5px;
}

/* ── Stat Cards ─────────────────────────────── */
.stat-card {
  background: #fff;
  border: 1px solid var(--surface-200);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.stat-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
  font-size: 18px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--surface-800);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 4px;
}

.stat-sub { font-size: 11px; color: #94a3b8; }

.bg-primary-soft  { background: rgba(99,102,241,0.1); }
.bg-success-soft  { background: rgba(34,197,94,0.1); }
.bg-info-soft     { background: rgba(14,165,233,0.1); }
.bg-warning-soft  { background: rgba(234,179,8,0.1); }
.bg-danger-soft   { background: rgba(239,68,68,0.1); }

.stat-mini { text-align: center; padding: 12px; }
.stat-mini-val { font-size: 18px; font-weight: 700; color: var(--surface-800); }
.stat-mini-label { font-size: 11px; color: #94a3b8; margin-top: 2px; }

/* ── Tables ─────────────────────────────────── */
.table th {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  background: var(--surface-50);
  border-bottom: 1px solid var(--surface-200);
}

.logs-table td, .logs-table th { padding: 6px 12px; }

/* ── Buttons ────────────────────────────────── */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-xs {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 5px;
  line-height: 1.5;
}

/* ── Login page ─────────────────────────────── */
.login-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-wrapper { width: 100%; max-width: 400px; padding: 20px; }

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
}

.login-brand { text-align: center; margin-bottom: 32px; }
.brand-icon-lg { font-size: 48px; display: block; margin-bottom: 12px; }
.login-title { font-size: 24px; font-weight: 700; color: var(--surface-800); margin-bottom: 8px; }
.login-subtitle { color: #64748b; font-size: 14px; line-height: 1.5; }
.login-footer { text-align: center; color: #94a3b8; font-size: 12px; margin-top: 16px; margin-bottom: 0; }

.btn-google {
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-800);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-google:hover { background: var(--surface-900); color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.2); transform: translateY(-1px); }

/* ── Empty state ────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #94a3b8;
}
.empty-icon { font-size: 48px; margin-bottom: 16px; display: block; }
.empty-state h5 { color: var(--surface-700); margin-bottom: 8px; }

/* ── Provider card ──────────────────────────── */
.provider-card { transition: box-shadow 0.2s; }
.provider-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.provider-icon { font-size: 24px; }

/* ── Project card ───────────────────────────── */
.project-card { transition: box-shadow 0.2s; }
.project-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

/* ── API Key reveal ─────────────────────────── */
.alert-key-reveal { background: #064e3b; border: 1px solid #065f46; color: #d1fae5; border-radius: 10px; }
.key-reveal-box {
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex; align-items: center; gap: 8px;
  word-break: break-all;
}
.key-reveal-box code { color: #86efac; font-size: 13px; flex: 1; }

/* ── Code block ─────────────────────────────── */
.code-block {
  background: var(--surface-800);
  color: #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  font-size: 13px;
  line-height: 1.7;
  overflow-x: auto;
  margin: 0;
}
.font-mono { font-family: 'Fira Code', monospace; }

/* ── Responsive ─────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
  }
  .main-content { margin-left: 0; }
  .sidebar-toggle-btn { display: block; }
  .page-content { padding: 16px; }
}

/* ── Scrollbar ──────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-200); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Misc tweaks ────────────────────────────── */
code { color: var(--primary-dark); background: rgba(99,102,241,0.08); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.badge { font-weight: 500; }
.flex-1 { flex: 1; }