/* ============================================================
   LiteLLM Proxy UI — Tema Dark Futurista (v2)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-deep: #060a14;
  --bg-primary: #0b1120;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-hover: rgba(255, 255, 255, 0.05);
  --border: rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.1);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --blue: #3b82f6;
  --blue-bg: rgba(59, 130, 246, 0.1);
  --purple: #8b5cf6;
  --purple-bg: rgba(139, 92, 246, 0.1);
  --cyan: #06b6d4;
  --cyan-bg: rgba(6, 182, 212, 0.1);
  --green: #10b981;
  --green-bg: rgba(16, 185, 129, 0.1);
  --orange: #f59e0b;
  --orange-bg: rgba(245, 158, 11, 0.1);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.1);
  --pink: #ec4899;
  --gradient-primary: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --gradient-warm: linear-gradient(135deg, #f59e0b, #ef4444);
  --gradient-cool: linear-gradient(135deg, #06b6d4, #3b82f6);
  --gradient-green: linear-gradient(135deg, #10b981, #06b6d4);
  --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.1);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
  --sidebar-width: 260px;
  --navbar-height: 60px;
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* Selection */
::selection { background: var(--blue); color: white; }

/* ===== TELA DE LOGIN ===== */
.login-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg-deep); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.login-bg-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(59,130,246,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59,130,246,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
}
.login-orb { position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.12; animation: orbFloat 25s ease-in-out infinite; }
.login-orb-1 { width: 500px; height: 500px; background: var(--blue); top: -200px; left: -200px; }
.login-orb-2 { width: 400px; height: 400px; background: var(--purple); bottom: -150px; right: -150px; animation-delay: -8s; }
.login-orb-3 { width: 300px; height: 300px; background: var(--cyan); top: 60%; left: 60%; animation-delay: -16s; }
@keyframes orbFloat {
  0%,100%{transform:translate(0,0) scale(1)}
  25%{transform:translate(60px,-60px) scale(1.1)}
  50%{transform:translate(-40px,50px) scale(0.9)}
  75%{transform:translate(50px,40px) scale(1.05)}
}
.login-card { width: 100%; max-width: 420px; animation: fadeInUp 0.6s ease; position: relative; }
.login-logo {
  width: 64px; height: 64px; margin: 0 auto;
  background: var(--gradient-primary); border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.75rem; color: white;
  box-shadow: 0 0 40px rgba(59,130,246,0.25);
  position: relative;
}
.login-logo::after {
  content: ''; position: absolute; inset: -4px;
  border-radius: calc(var(--radius-lg) + 4px);
  background: var(--gradient-primary); opacity: 0.2;
  filter: blur(12px); z-index: -1;
}

/* ===== GLASS ===== */
.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

/* ===== LAYOUT ===== */
.app-layout { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-width); height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  z-index: 1040; display: flex; flex-direction: column;
  transition: transform var(--transition);
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  min-height: var(--navbar-height);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text-primary);
  font-weight: 800; font-size: 1.1rem; letter-spacing: -0.02em;
}
.sidebar-brand i { font-size: 1.35rem; background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.sidebar-user {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--gradient-primary); display: flex;
  align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem; flex-shrink: 0;
}
.sidebar-search { padding: 8px 12px; }
.sidebar-search .input-group { border-radius: var(--radius-sm); overflow: hidden; }
.sidebar-search .input-group-text, .sidebar-search .form-control {
  background: rgba(255,255,255,0.04); border: 1px solid transparent;
  color: var(--text-secondary); font-size: 0.8rem;
}
.sidebar-search .form-control:focus { box-shadow: none; background: rgba(255,255,255,0.06); color: var(--text-primary); }
.sidebar-nav { list-style: none; padding: 4px 8px; margin: 0; flex: 1; overflow-y: auto; }
.nav-section { padding: 16px 8px 4px 12px; }
.nav-section-title {
  font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-muted); font-weight: 600;
}
.nav-item { margin: 1px 0; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  color: var(--text-secondary); text-decoration: none;
  border-radius: var(--radius-sm); transition: all var(--transition);
  font-size: 0.85rem; font-weight: 500;
}
.nav-link i { width: 18px; text-align: center; font-size: 1rem; }
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-link.active { background: var(--blue-bg); color: var(--blue); }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1035; backdrop-filter: blur(4px); }

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

/* ===== TOPBAR ===== */
.topbar {
  height: var(--navbar-height); display: flex; align-items: center;
  justify-content: space-between; padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(11,17,32,0.85); backdrop-filter: blur(16px);
  position: sticky; top: 0; z-index: 1020;
}
.page-title { font-weight: 700; font-size: 1.15rem; }
.breadcrumb { background: transparent; padding: 0; margin: 0; }
.breadcrumb-item { color: var(--text-muted); font-size: 0.78rem; }
.breadcrumb-item.active { color: var(--blue); }
.breadcrumb-item+.breadcrumb-item::before { color: var(--text-muted); }
.btn-icon { width: 36px; height: 36px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: 10px; }

/* ===== CONTENT ===== */
.content-body { flex: 1; padding: 20px 24px; overflow-y: auto; }
.page-enter { animation: fadeInUp 0.3s ease; }

/* ===== LOADING ===== */
.loading-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80px 20px; }
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ===== FOOTER ===== */
.app-footer {
  padding: 10px 24px; border-top: 1px solid var(--border);
  background: rgba(11,17,32,0.6); backdrop-filter: blur(8px);
}
.status-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 0.72rem; padding: 2px 10px; border-radius: 20px; }
.status-online { color: var(--green); }
.status-online i { font-size: 0.45rem; }
.status-offline { color: var(--text-muted); }

/* ===== CARDS ===== */
.card-dash {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); transition: all var(--transition);
}
.card-dash:hover { border-color: var(--border-light); }
.card-dash-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-dash-header h6 { margin: 0; font-weight: 600; font-size: 0.85rem; }
.card-dash-body { padding: 20px; }
.card-dash-body.p-0 { padding: 0; }

/* ===== STAT CARDS ===== */
.stat {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 18px 20px;
  transition: all var(--transition); position: relative; overflow: hidden;
}
.stat::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 2px; }
.stat.blue::before { background: var(--gradient-primary); }
.stat.green::before { background: var(--gradient-green); }
.stat.orange::before { background: var(--gradient-warm); }
.stat.purple::before { background: linear-gradient(90deg, var(--purple), var(--blue)); }
.stat:hover { border-color: var(--border-light); transform: translateY(-1px); }
.stat-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.stat-label { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.stat-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.stat-change { font-size: 0.72rem; font-weight: 600; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }
.table-dash { margin: 0; width: 100%; border-collapse: collapse; }
.table-dash thead th {
  background: rgba(255,255,255,0.02); border-bottom: 1px solid var(--border);
  color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 600; padding: 10px 16px; text-align: left;
  white-space: nowrap;
}
.table-dash tbody td {
  padding: 10px 16px; vertical-align: middle;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text-secondary); font-size: 0.85rem;
}
.table-dash tbody tr { transition: background var(--transition); }
.table-dash tbody tr:hover { background: var(--bg-hover); }
.table-dash tbody tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge-dash {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 20px; font-weight: 500;
  font-size: 0.7rem; border: 1px solid transparent;
}
.badge-model { background: var(--cyan-bg); color: var(--cyan); border-color: rgba(6,182,212,0.15); }
.badge-key { background: var(--orange-bg); color: var(--orange); border-color: rgba(245,158,11,0.15); }
.badge-user { background: var(--purple-bg); color: var(--purple); border-color: rgba(139,92,246,0.15); }
.badge-success { background: var(--green-bg); color: var(--green); border-color: rgba(16,185,129,0.15); }
.badge-danger { background: var(--red-bg); color: var(--red); border-color: rgba(239,68,68,0.15); }
.badge-warning { background: var(--orange-bg); color: var(--orange); border-color: rgba(245,158,11,0.15); }
.badge-info { background: var(--blue-bg); color: var(--blue); border-color: rgba(59,130,246,0.15); }

/* ===== KEY DISPLAY ===== */
.key-cell {
  font-family: var(--font-mono); font-size: 0.78rem;
  background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 4px;
  color: var(--cyan); cursor: pointer; transition: all var(--transition);
  display: inline-block; max-width: 160px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.key-cell:hover { background: var(--bg-secondary); color: var(--blue); }

/* ===== CODE ===== */
.code-block {
  background: rgba(0,0,0,0.35); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
  font-family: var(--font-mono); font-size: 0.8rem;
  position: relative; overflow-x: auto;
}
.code-block .copy-btn { position: absolute; top: 6px; right: 6px; padding: 2px 10px; font-size: 0.7rem; opacity: 0; transition: opacity var(--transition); }
.code-block:hover .copy-btn { opacity: 1; }
.code-block pre { margin: 0; color: var(--text-secondary); }
.code-block code { color: var(--text-secondary); }

/* ===== METADATA GRID ===== */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.meta-item {
  padding: 10px 12px; background: rgba(255,255,255,0.02);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.meta-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.meta-value { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); word-break: break-all; }

/* ===== FILTER BAR ===== */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-bar .form-control-sm, .filter-bar .form-select-sm { min-width: 130px; }

/* ===== TIMELINE ===== */
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding: 8px 0 8px 14px; }
.timeline-item::before {
  content: ''; position: absolute; left: -17px; top: 12px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--blue); border: 2px solid var(--bg-primary);
}
.timeline-time { font-size: 0.7rem; color: var(--text-muted); }
.timeline-content { font-size: 0.82rem; color: var(--text-secondary); }

/* ===== TABS ===== */
.tabs-dash { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs-dash .tab {
  padding: 8px 20px; border: none; background: none; color: var(--text-muted);
  font-size: 0.82rem; font-weight: 500; cursor: pointer;
  border-bottom: 2px solid transparent; transition: all var(--transition);
}
.tabs-dash .tab:hover { color: var(--text-primary); }
.tabs-dash .tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ===== QUICK ACTIONS ===== */
.quick-actions { display: flex; gap: 6px; }
.quick-action {
  padding: 6px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-glass);
  color: var(--text-secondary); font-size: 0.78rem;
  display: flex; align-items: center; gap: 6px;
  transition: all var(--transition); cursor: pointer; white-space: nowrap;
}
.quick-action:hover { border-color: var(--border-light); color: var(--text-primary); background: var(--bg-hover); }

/* ===== PROGRESS BAR ===== */
.progress-dash { height: 4px; background: rgba(255,255,255,0.06); border-radius: 2px; overflow: hidden; }
.progress-dash .bar { height: 100%; border-radius: 2px; transition: width 0.6s ease; }

/* ===== MODAL ===== */
.modal-content.glass {
  background: var(--bg-card); border: 1px solid var(--border);
  backdrop-filter: blur(24px); border-radius: var(--radius-lg);
}
.modal-header { border-bottom: 1px solid var(--border); padding: 16px 20px; }
.modal-body { padding: 20px; }
.modal-footer { border-top: 1px solid var(--border); padding: 12px 20px; }
.modal .btn-close { filter: invert(0.8); }

/* ===== TOAST ===== */
.toast-container { z-index: 9999; }
.toast-custom {
  background: var(--bg-card); backdrop-filter: blur(20px);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--text-primary); min-width: 300px;
}

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-state i { font-size: 2.5rem; color: var(--text-muted); opacity: 0.4; margin-bottom: 12px; }
.empty-state h6 { color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { color: var(--text-muted); font-size: 0.85rem; max-width: 360px; margin: 0 auto; }

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
@keyframes slideInRight { from{opacity:0;transform:translateX(16px)} to{opacity:1;transform:translateX(0)} }
.page-enter { animation: fadeInUp 0.3s ease; }

/* ===== RESPONSIVE ===== */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; }
  .content-body { padding: 16px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-control-sm, .filter-bar .form-select-sm { min-width: auto; }
  .meta-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
@media (max-width: 575.98px) {
  .content-body { padding: 12px; }
  .stat { padding: 14px 16px; }
  .stat-value { font-size: 1.25rem; }
  .topbar { padding: 0 12px; }
  .tabs-dash .tab { padding: 8px 12px; font-size: 0.78rem; }
}

/* ===== UTILITIES ===== */
.text-gradient { background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.font-mono { font-family: var(--font-mono); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cursor-pointer { cursor: pointer; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* ===== GLOW BUTTONS ===== */
.btn-glow { position: relative; overflow: hidden; transition: all var(--transition); }
.btn-glow::before {
  content: ''; position: absolute; inset: -2px;
  background: var(--gradient-primary); border-radius: inherit;
  z-index: -1; opacity: 0; filter: blur(12px); transition: opacity var(--transition);
}
.btn-glow:hover::before { opacity: 0.5; }
.btn-glow-green::before { background: var(--gradient-green); }
