/* AI Gateway — custom theme */
:root {
    --ag-sidebar-bg: #0f172a;
    --ag-sidebar-width: 240px;
    --ag-sidebar-text: #94a3b8;
    --ag-sidebar-hover-bg: rgba(255,255,255,0.05);
    --ag-sidebar-active-bg: rgba(99,102,241,0.15);
    --ag-sidebar-active-text: #a5b4fc;
    --ag-sidebar-active-border: #6366f1;
    --ag-content-bg: #f1f5f9;
    --ag-card-bg: #ffffff;
    --ag-accent: #6366f1;
    --ag-accent-dark: #4f46e5;
    --ag-topbar-bg: #ffffff;
    --ag-topbar-height: 60px;
    --ag-text: #1e293b;
    --ag-muted: #64748b;
    --ag-border: #e2e8f0;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, sans-serif; background: var(--ag-content-bg); color: var(--ag-text); }

/* ── Layout ── */
.ag-wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.ag-sidebar {
    width: var(--ag-sidebar-width);
    background: var(--ag-sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .25s ease;
}
.ag-sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}
.ag-brand-icon {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.ag-brand-icon svg { width: 18px; height: 18px; fill: white; }
.ag-brand-name { color: #f8fafc; font-size: 15px; font-weight: 700; letter-spacing: -0.3px; }
.ag-brand-version { color: #64748b; font-size: 10px; font-weight: 500; margin-top: 1px; }

.ag-nav { list-style: none; padding: 12px 10px; margin: 0; flex: 1; }
.ag-nav-item a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    border-radius: 7px;
    color: var(--ag-sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: background .15s, color .15s;
    border-left: 3px solid transparent;
}
.ag-nav-item a:hover { background: var(--ag-sidebar-hover-bg); color: #e2e8f0; }
.ag-nav-item.active a {
    background: var(--ag-sidebar-active-bg);
    color: var(--ag-sidebar-active-text);
    border-left-color: var(--ag-sidebar-active-border);
}
.ag-nav-item a i { font-size: 15px; flex-shrink: 0; }
.ag-nav-section {
    font-size: 10px; font-weight: 700; letter-spacing: 1px;
    color: #475569; text-transform: uppercase;
    padding: 16px 12px 6px;
}

.ag-sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,0.07);
    color: #475569;
    font-size: 11px;
    display: flex; align-items: center; gap: 6px;
}
.ag-sidebar-footer .status-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: #22c55e; flex-shrink: 0;
}

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

/* ── Topbar ── */
.ag-topbar {
    height: var(--ag-topbar-height);
    background: var(--ag-topbar-bg);
    border-bottom: 1px solid var(--ag-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    position: sticky; top: 0; z-index: 50;
}
.ag-topbar-title { font-size: 15px; font-weight: 600; color: var(--ag-text); flex: 1; }
.ag-topbar-right { display: flex; align-items: center; gap: 10px; }
.ag-user-chip {
    display: flex; align-items: center; gap: 8px;
    background: #f1f5f9; border-radius: 20px;
    padding: 5px 12px 5px 8px;
    font-size: 13px; font-weight: 500;
}
.ag-user-avatar {
    width: 24px; height: 24px; border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white; font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

/* ── Content ── */
.ag-content { padding: 28px 28px; flex: 1; }

/* ── Cards ── */
.ag-card {
    background: var(--ag-card-bg);
    border: 1px solid var(--ag-border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.ag-card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--ag-border);
}
.ag-card-title { font-size: 14px; font-weight: 600; color: var(--ag-text); margin: 0; }
.ag-card-subtitle { font-size: 12px; color: var(--ag-muted); margin-top: 2px; }

/* ── Stat Cards ── */
.ag-stat-card {
    background: var(--ag-card-bg);
    border: 1px solid var(--ag-border);
    border-radius: 12px;
    padding: 20px 22px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    position: relative;
    overflow: hidden;
}
.ag-stat-icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; margin-bottom: 14px;
}
.ag-stat-value { font-size: 26px; font-weight: 700; color: var(--ag-text); line-height: 1; }
.ag-stat-label { font-size: 12px; color: var(--ag-muted); margin-top: 4px; font-weight: 500; }
.ag-stat-change { font-size: 11px; margin-top: 8px; font-weight: 500; }
.ag-stat-change.up { color: #10b981; }
.ag-stat-change.neutral { color: var(--ag-muted); }

/* ── Tables ── */
.ag-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ag-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ag-muted);
    border-bottom: 1px solid var(--ag-border);
    white-space: nowrap;
}
.ag-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.ag-table tbody tr:last-child td { border-bottom: none; }
.ag-table tbody tr:hover td { background: #f8fafc; }

/* ── Badges ── */
.ag-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 20px;
    font-size: 11px; font-weight: 600;
}
.ag-badge-green { background: #dcfce7; color: #15803d; }
.ag-badge-red { background: #fee2e2; color: #b91c1c; }
.ag-badge-yellow { background: #fef9c3; color: #a16207; }
.ag-badge-gray { background: #f1f5f9; color: #64748b; }
.ag-badge-indigo { background: #e0e7ff; color: #4338ca; }
.ag-badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ── Key display ── */
.ag-key-display {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    background: #f8fafc;
    border: 1px solid var(--ag-border);
    border-radius: 6px;
    padding: 4px 10px;
    color: #475569;
    display: inline-flex; align-items: center; gap: 8px;
}
.ag-copy-btn {
    border: none; background: none;
    color: #94a3b8; cursor: pointer;
    padding: 0; line-height: 1;
    transition: color .15s;
}
.ag-copy-btn:hover { color: var(--ag-accent); }

/* ── Provider Cards ── */
.ag-provider-card {
    background: var(--ag-card-bg);
    border: 1px solid var(--ag-border);
    border-radius: 12px;
    padding: 20px;
    transition: border-color .2s, box-shadow .2s;
}
.ag-provider-card:hover { border-color: #c7d2fe; box-shadow: 0 4px 12px rgba(99,102,241,0.08); }
.ag-provider-logo {
    width: 44px; height: 44px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; margin-bottom: 12px;
    background: #f8fafc; border: 1px solid var(--ag-border);
}
.ag-provider-name { font-size: 14px; font-weight: 700; color: var(--ag-text); }
.ag-provider-desc { font-size: 12px; color: var(--ag-muted); margin-top: 2px; }
.ag-provider-status { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }

/* ── Toggle switch ── */
.ag-toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.ag-toggle input { opacity: 0; width: 0; height: 0; }
.ag-toggle-slider {
    position: absolute; inset: 0;
    background: #cbd5e1; border-radius: 10px;
    cursor: pointer; transition: background .2s;
}
.ag-toggle-slider::before {
    content: '';
    position: absolute;
    left: 2px; top: 2px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: white;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.ag-toggle input:checked + .ag-toggle-slider { background: var(--ag-accent); }
.ag-toggle input:checked + .ag-toggle-slider::before { transform: translateX(16px); }

/* ── Buttons ── */
.btn-ag-primary {
    background: var(--ag-accent); color: white;
    border: none; border-radius: 8px;
    padding: 8px 16px; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: background .15s;
    display: inline-flex; align-items: center; gap: 6px;
}
.btn-ag-primary:hover { background: var(--ag-accent-dark); }
.btn-ag-outline {
    background: transparent; color: var(--ag-text);
    border: 1px solid var(--ag-border); border-radius: 8px;
    padding: 7px 14px; font-size: 13px; font-weight: 500;
    cursor: pointer; transition: border-color .15s, background .15s;
    display: inline-flex; align-items: center; gap: 6px;
}
.btn-ag-outline:hover { border-color: #a5b4fc; background: #f5f3ff; }
.btn-ag-danger {
    background: #fee2e2; color: #b91c1c;
    border: none; border-radius: 8px;
    padding: 7px 14px; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: background .15s;
}
.btn-ag-danger:hover { background: #fecaca; }

/* ── Forms ── */
.ag-form-group { margin-bottom: 16px; }
.ag-label { font-size: 12px; font-weight: 600; color: var(--ag-muted); margin-bottom: 6px; display: block; text-transform: uppercase; letter-spacing: 0.4px; }
.ag-input {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--ag-border); border-radius: 8px;
    font-size: 13.5px; color: var(--ag-text);
    background: white; outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.ag-input:focus { border-color: var(--ag-accent); box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
.ag-input::placeholder { color: #cbd5e1; }

/* ── Modal ── */
.ag-modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.6);
    z-index: 200; align-items: center; justify-content: center;
    backdrop-filter: blur(2px);
}
.ag-modal-overlay.show { display: flex; }
.ag-modal {
    background: white; border-radius: 14px;
    padding: 28px; width: 100%; max-width: 480px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.2);
    animation: ag-modal-in .2s ease;
}
.ag-modal-lg { max-width: 640px; }
@keyframes ag-modal-in {
    from { transform: translateY(-12px) scale(.98); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
.ag-modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.ag-modal-title { font-size: 16px; font-weight: 700; }
.ag-modal-close { border: none; background: none; font-size: 20px; color: var(--ag-muted); cursor: pointer; padding: 0; line-height: 1; }
.ag-modal-close:hover { color: var(--ag-text); }
.ag-modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--ag-border); }

/* ── Toast ── */
.ag-toast {
    position: fixed; bottom: 24px; right: 24px;
    background: #1e293b; color: white;
    padding: 12px 16px; border-radius: 10px;
    font-size: 13px; font-weight: 500;
    display: flex; align-items: center; gap: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    z-index: 999; opacity: 0; transform: translateY(8px);
    transition: opacity .25s, transform .25s;
    pointer-events: none;
}
.ag-toast.show { opacity: 1; transform: translateY(0); }

/* ── Sidebar toggle (mobile) ── */
.ag-sidebar-toggle { display: none; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .ag-sidebar { transform: translateX(-100%); }
    .ag-sidebar.open { transform: translateX(0); }
    .ag-main { margin-left: 0; }
    .ag-content { padding: 16px; }
    .ag-sidebar-toggle {
        display: flex; align-items: center; justify-content: center;
        width: 36px; height: 36px; border-radius: 8px;
        border: 1px solid var(--ag-border);
        background: transparent; cursor: pointer;
        font-size: 18px; color: var(--ag-text);
    }
}

/* ── Misc ── */
.text-muted-sm { font-size: 12px; color: var(--ag-muted); }
.monospace { font-family: 'Courier New', monospace; font-size: 12px; }
.ag-divider { border: none; border-top: 1px solid var(--ag-border); margin: 20px 0; }
.ag-section-title { font-size: 16px; font-weight: 700; color: var(--ag-text); margin: 0 0 4px; }
.ag-section-sub { font-size: 13px; color: var(--ag-muted); margin: 0 0 20px; }
