/* LLM Gateway Admin UI — enterprise design system */

:root {
    --bg:          #0f1117;
    --surface:     #1a1d27;
    --surface-2:   #22263a;
    --border:      #2e3348;
    --text:        #e2e8f0;
    --text-muted:  #64748b;
    --accent:      #3b82f6;
    --success:     #22c55e;
    --warning:     #f59e0b;
    --danger:      #ef4444;
    --sidebar-w:   240px;
    --topbar-h:    48px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ── Layout ────────────────────────────────────────────────────────────────── */

.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */

.sidebar {
    grid-row: 1 / -1;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-logo {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.02em;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-logo span {
    color: var(--accent);
}

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

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

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    transition: color 0.1s, background 0.1s;
    white-space: nowrap;
}

.sidebar-nav a:hover {
    color: var(--text);
    background: var(--surface-2);
}

.sidebar-nav a.active {
    color: var(--accent);
    background: var(--surface-2);
    font-weight: 500;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}

.sidebar-footer .user-email {
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 8px;
}

.sidebar-footer a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 12px;
}

.sidebar-footer a:hover {
    color: var(--danger);
}

/* ── Topbar ────────────────────────────────────────────────────────────────── */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: var(--topbar-h);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.topbar-left .page-title {
    color: var(--text);
    font-weight: 500;
}

.topbar-sep {
    color: var(--border);
    font-size: 16px;
}

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

/* ── Content area ──────────────────────────────────────────────────────────── */

.content {
    overflow-y: auto;
    padding: 24px;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.1s, border-color 0.1s;
    white-space: nowrap;
}

.btn:hover {
    background: var(--surface-2);
    border-color: var(--text-muted);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
}

.btn-danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.btn-success {
    background: transparent;
    border-color: var(--success);
    color: var(--success);
}

.btn-success:hover {
    background: rgba(34, 197, 94, 0.1);
}

.btn-sm {
    padding: 3px 10px;
    font-size: 12px;
}

/* ── Status badges ─────────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 2px;
    font-size: 11px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-neutral {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-muted);
    border: 1px solid rgba(100, 116, 139, 0.3);
}

/* ── Tables ────────────────────────────────────────────────────────────────── */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

thead th {
    background: var(--surface-2);
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    height: 40px;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:nth-child(odd) {
    background: var(--surface);
}

tbody tr:nth-child(even) {
    background: var(--bg);
}

tbody tr:hover {
    background: var(--surface-2);
}

tbody td {
    padding: 0 16px;
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
}

tbody td.muted {
    color: var(--text-muted);
}

tbody td.mono {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    font-size: 12px;
}

/* ── Dashboard stat tiles ──────────────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 20px;
}

.stat-tile .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-tile .value {
    font-size: 28px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    line-height: 1;
}

/* ── Forms ─────────────────────────────────────────────────────────────────── */

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.1s;
}

.form-input:focus {
    border-color: var(--accent);
}

.form-select {
    width: 100%;
    padding: 8px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

.form-select:focus {
    border-color: var(--accent);
}

/* ── Section header ────────────────────────────────────────────────────────── */

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

.section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

/* ── Login page ────────────────────────────────────────────────────────────── */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 40px;
    width: 380px;
}

.login-card h1 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
}

.login-card .subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 32px;
}

.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 11px 16px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.1s, border-color 0.1s;
    margin-bottom: 12px;
}

.login-btn:hover {
    background: var(--surface);
    border-color: var(--accent);
}

.login-btn:last-child {
    margin-bottom: 0;
}

.login-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 4px;
    padding: 10px 14px;
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 20px;
}

/* ── Inline form (invite) ──────────────────────────────────────────────────── */

.inline-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.inline-form .form-group {
    flex: 1;
    margin-bottom: 0;
}

/* ── Invite link result ────────────────────────────────────────────────────── */

.invite-result {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 12px 16px;
    margin-top: 12px;
}

.invite-result .invite-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.invite-result .invite-url {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    font-size: 12px;
    color: var(--accent);
    word-break: break-all;
}

/* ── Pagination ────────────────────────────────────────────────────────────── */

.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ── HTMX indicator ────────────────────────────────────────────────────────── */

.htmx-indicator {
    opacity: 0;
    transition: opacity 0.1s;
}

.htmx-request .htmx-indicator {
    opacity: 1;
}

/* ── Misc ──────────────────────────────────────────────────────────────────── */

.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent); }

.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

.empty-state {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}
