@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #f5f3ef;
    --bg-page: #f5f3ef;
    --bg-card: #ffffff;
    --bg-sidebar: #1a1814;
    --text: #1a1814;
    --text-muted: #8a8580;
    --text-subtle: #b5b0a8;
    --border: #e6e2da;
    --sidebar-text: rgba(255,255,255,.55);
    --sidebar-active-bg: rgba(217,150,10,.15);
    --sidebar-active-text: #f5c542;
    --accent: #d9960a;
    --accent-hover: #c08509;
    --accent-light: #fdf4e0;
    --accent-glow: rgba(217,150,10,.25);
    --danger: #e05555;
    --danger-light: #fde8e8;
    --success: #4dab6f;
    --success-light: #e6f4ea;
    --blue: #3a8fd9;
    --blue-light: #e8f2fb;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.05);
    --shadow-card: 0 2px 12px rgba(0,0,0,.06), 0 0 0 1px rgba(0,0,0,.02);
    --shadow-card-hover: 0 8px 30px rgba(217,150,10,.12), 0 0 0 1px rgba(217,150,10,.08);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 7px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.dark-mode {
    --bg: #121110;
    --bg-page: #121110;
    --bg-card: #1e1d1a;
    --bg-sidebar: #0e0d0b;
    --text: #ece8de;
    --text-muted: #8a8580;
    --text-subtle: #5a5550;
    --border: #2e2c27;
    --sidebar-text: rgba(255,255,255,.5);
    --sidebar-active-bg: rgba(217,150,10,.15);
    --sidebar-active-text: #f5c542;
    --accent: #e8a817;
    --accent-hover: #d9960a;
    --accent-light: #2a2510;
    --accent-glow: rgba(232,168,23,.2);
    --danger: #e06c6c;
    --danger-light: #2d1f1f;
    --success: #5ab87a;
    --success-light: #1a2d1f;
    --blue: #529cca;
    --blue-light: #1a2a33;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
    --shadow-card: 0 2px 12px rgba(0,0,0,.3), 0 0 0 1px rgba(255,255,255,.03);
    --shadow-card-hover: 0 8px 30px rgba(217,150,10,.12), 0 0 0 1px rgba(217,150,10,.06);
}

* { font-family: var(--font); }

body {
    background: var(--bg-page);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
    line-height: 1.6;
    transition: background .3s, color .3s;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-card);
    color: var(--text);
    transition: box-shadow .3s, transform .3s, border-color .3s;
}
.card:hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-2px);
    border-color: rgba(217,150,10,.12);
}

/* Stat gradient cards */
.stat-card {
    border: none !important;
    border-radius: var(--radius) !important;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.stat-card h6 { font-size: .78rem; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; opacity: .9; }
.stat-card h2 { font-weight: 800; font-size: 1.85rem; letter-spacing: -.5px; }
.stat-card-gold { background: linear-gradient(135deg, #d9960a 0%, #e8a817 50%, #f0b830 100%) !important; }
.stat-card-blue { background: linear-gradient(135deg, #2e7ab8 0%, #3a8fd9 50%, #52a5e8 100%) !important; }
.stat-card-rose { background: linear-gradient(135deg, #c94040 0%, #e05555 50%, #f06e6e 100%) !important; }
.stat-card::after {
    content: '';
    position: absolute;
    top: -35%;
    right: -15%;
    width: 140px;
    height: 140px;
    background: rgba(255,255,255,.1);
    border-radius: 50%;
}
.stat-card::before {
    content: '';
    position: absolute;
    bottom: -25%;
    left: -10%;
    width: 80px;
    height: 80px;
    background: rgba(255,255,255,.06);
    border-radius: 50%;
}

/* Hero card */
.hero-card {
    border: none !important;
    border-radius: var(--radius) !important;
    background: linear-gradient(135deg, #1a1814 0%, #2a2518 50%, #3a2e10 100%) !important;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.dark-mode .hero-card {
    background: linear-gradient(135deg, #0e0d0b 0%, #1a1814 50%, #2a2518 100%) !important;
}
.hero-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -5%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(217,150,10,.2) 0%, transparent 70%);
    border-radius: 50%;
    animation: heroGlow 6s ease-in-out infinite alternate;
}
.hero-card::after {
    content: '';
    position: absolute;
    bottom: -40%;
    left: 8%;
    width: 280px;
    height: 280px;
    background: radial-gradient(circle, rgba(232,168,23,.1) 0%, transparent 70%);
    border-radius: 50%;
    animation: heroGlow 8s ease-in-out infinite alternate-reverse;
}
@keyframes heroGlow {
    0%   { transform: translate(0, 0) scale(1); }
    100% { transform: translate(25px, -15px) scale(1.15); }
}
.hero-card .btn-hero-primary {
    background: linear-gradient(135deg, #e8a817 0%, #d9960a 100%);
    color: #1a1814;
    border: none;
    font-weight: 700;
    border-radius: var(--radius-sm);
    padding: .65rem 1.8rem;
    box-shadow: 0 2px 12px rgba(217,150,10,.35);
    transition: transform .2s, box-shadow .2s;
}
.hero-card .btn-hero-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(217,150,10,.45);
    color: #1a1814;
}
.hero-card .btn-hero-outline {
    border: 2px solid rgba(255,255,255,.25);
    color: #fff;
    background: transparent;
    border-radius: var(--radius-sm);
    padding: .65rem 1.8rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
}
.hero-card .btn-hero-outline:hover {
    background: rgba(255,255,255,.1);
    border-color: rgba(255,255,255,.4);
    color: #fff;
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 1030;
    transition: transform .3s;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 1.1rem 1rem .85rem;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -.3px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand-icon {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, #e8a817 0%, #d9960a 100%);
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    color: #1a1814;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(217,150,10,.3);
}
.sidebar-nav {
    flex: 1;
    padding: .6rem .5rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: .5rem .75rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .88rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: background .15s, color .15s;
}
.sidebar-link:hover {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}
.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 600;
}
.sidebar-link svg { flex-shrink: 0; opacity: .6; }
.sidebar-link.active svg, .sidebar-link:hover svg { opacity: 1; }
.sidebar-footer {
    padding: .5rem .5rem .75rem;
    border-top: 1px solid rgba(255,255,255,.06);
}
.theme-toggle {
    width: 100%;
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
}

/* Main content with sidebar */
.main-with-sidebar {
    margin-left: 240px;
    padding: 2rem 2.5rem;
    max-width: 100%;
}

/* ---- Navbar (logged-out) ---- */
.navbar-dark.bg-dark {
    background-color: var(--bg-sidebar) !important;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.navbar-brand { font-weight: 700; color: #fff !important; }
.navbar-dark .navbar-nav .nav-link { color: var(--sidebar-text); }
.navbar-dark .navbar-nav .nav-link:hover { color: #f5c542; }

/* ---- Buttons ---- */
.btn-primary {
    background: linear-gradient(135deg, #e8a817 0%, #d9960a 100%);
    border: none;
    color: #1a1814;
    border-radius: var(--radius-sm);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(217,150,10,.25);
    transition: transform .15s, box-shadow .15s;
}
.btn-primary:hover {
    background: linear-gradient(135deg, #d9960a 0%, #c08509 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(217,150,10,.35);
    color: #1a1814;
}
.btn-outline-primary {
    border-radius: var(--radius-sm);
    border-color: var(--accent);
    color: var(--accent);
}
.btn-outline-primary:hover {
    background: var(--accent-light);
}
.btn-outline-danger { border-radius: var(--radius-sm); }

/* ---- Tables ---- */
.table { color: var(--text); }
.dark-mode .table { --bs-table-bg: transparent; --bs-table-hover-bg: rgba(255,255,255,.03); color: var(--text); }
.dark-mode .table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-bg: rgba(255,255,255,.015); }

/* ---- Forms ---- */
.dark-mode .form-control, .dark-mode .form-select { background: var(--bg-card); border-color: var(--border); color: var(--text); }
.dark-mode .form-control:focus { background: var(--bg-card); color: var(--text); }

/* ---- Badges ---- */
.badge.bg-success { background: linear-gradient(135deg, #4dab6f 0%, #5ab87a 100%) !important; }
.badge.bg-warning { background: linear-gradient(135deg, #d9960a 0%, #e8a817 100%) !important; color: #1a1814 !important; font-weight: 600; }
.dark-mode .badge { opacity: .9; }

/* ---- Model tags ---- */
.model-tag {
    background: var(--accent-light);
    padding: 2px 10px;
    border-radius: var(--radius-xs);
    font-size: .83em;
    margin-right: 4px;
    color: var(--accent);
    font-weight: 600;
}

/* ---- Text overrides ---- */
.dark-mode .text-muted { color: var(--text-muted) !important; }
.dark-mode .text-secondary { color: var(--text-muted) !important; }
.dark-mode .text-dark { color: var(--text) !important; }
.dark-mode .bg-light { background-color: var(--bg-card) !important; }

/* ---- Code ---- */
code { color: #b85c2a; font-size: .9em; }
.dark-mode code { color: #e8a060; }
.api-key-display { user-select: all; font-size: .83em; }

/* ---- Links ---- */
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* ---- Footer ---- */
footer { color: var(--text-subtle) !important; }

/* ---- Mobile sidebar ---- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.5);
    z-index: 1029;
}
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-open .sidebar-overlay { display: block; }
    .main-with-sidebar { margin-left: 0; padding: 1.5rem; }
}
