/*
 * Admin console styling.
 *
 * Lifted out of the inline <style> block that dashboard.html carried so the console's pages share
 * one stylesheet instead of each growing its own copy. The palette and card treatment are
 * unchanged from that dashboard on purpose — this is the same service, wearing the same skin.
 *
 * No webfont is loaded: the container has no egress, so a remote font would cost a DNS timeout on
 * every page load and render in the fallback anyway.
 */

:root {
    --primary: #6366f1;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-dark: #0f172a;
    --card-bg: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.1);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --text-faint: #64748b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(16, 185, 129, 0.1) 0%, transparent 50%);
    background-attachment: fixed;
}

a {
    color: #a5b4fc;
}

/* ── Console shell ───────────────────────────────────────────────────── */

.shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    border-right: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.6);
    padding: 2rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.brand {
    font-weight: 600;
    font-size: 1.15rem;
    background: linear-gradient(to right, #818cf8, #34d399);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-sub {
    font-size: 0.75rem;
    color: var(--text-faint);
    margin-top: 0.25rem;
    -webkit-text-fill-color: initial;
}

.nav {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav a {
    display: block;
    padding: 0.625rem 0.875rem;
    border-radius: 0.625rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.nav a.active {
    background: rgba(99, 102, 241, 0.15);
    color: #c7d2fe;
}

.sidebar-foot {
    margin-top: auto;
    font-size: 0.75rem;
    color: #475569;
}

.content {
    padding: 2rem;
    max-width: 1100px;
}

header.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
}

h1 {
    font-weight: 600;
    font-size: 1.5rem;
}

h2 {
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 1rem;
}

/* ── Status badge ────────────────────────────────────────────────────── */

.status-badge {
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-badge.healthy {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.unhealthy {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ── Cards ───────────────────────────────────────────────────────────── */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2rem;
    font-weight: 600;
    color: #fff;
}

.stat-sub {
    font-size: 0.875rem;
    color: var(--text-faint);
    margin-top: 0.5rem;
}

.demo-card {
    margin-bottom: 1.5rem;
}

.demo-card form {
    margin-top: 1.5rem;
    display: grid;
    gap: 1rem;
}

.demo-card input[type="file"] {
    width: 100%;
    padding: 1rem;
    color: var(--text);
    border: 1px dashed rgba(165, 180, 252, 0.55);
    border-radius: 0.75rem;
    background: rgba(99, 102, 241, 0.08);
}

.demo-result {
    min-height: 1.5rem;
    margin-top: 1rem;
    color: var(--text-muted);
}

.demo-result.success { color: var(--success); }
.demo-result.error { color: var(--danger); }
.demo-result.pending { color: #c7d2fe; }

.demo-note p {
    color: var(--text-muted);
    line-height: 1.6;
}

/* ── Config list ─────────────────────────────────────────────────────── */

.config-list {
    list-style: none;
}

.config-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.config-item:last-child {
    border-bottom: none;
}

.config-key {
    color: var(--text-muted);
}

.config-val.ok {
    color: var(--success);
}

.config-val.missing {
    color: var(--danger);
}

/* ── Buttons and forms ───────────────────────────────────────────────── */

.btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    text-decoration: none;
    display: inline-block;
    font-size: 0.875rem;
}

.btn:hover {
    opacity: 0.9;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: #fff;
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
}

.btn-danger {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    padding: 0.375rem 0.875rem;
}

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

.btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.8rem;
}

label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text);
    font-size: 0.9rem;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.6);
}

.field {
    margin-bottom: 1rem;
}

.inline-form {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.inline-form .field {
    margin-bottom: 0;
    flex: 1;
    min-width: 180px;
}

fieldset {
    border: none;
}

.scope-choice {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.scope-choice label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
}

/* ── Flash messages ──────────────────────────────────────────────────── */

.flash {
    padding: 0.875rem 1.25rem;
    border-radius: 0.75rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.flash.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fca5a5;
}

.flash.success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: #6ee7b7;
}

.flash.warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.25);
    color: #fcd34d;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 0.875rem 0.5rem;
    border-bottom: 1px solid var(--border);
    color: #cbd5e1;
}

tr.revoked td {
    color: var(--text-faint);
    text-decoration: line-through;
}

code, .mono {
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
    font-size: 0.85em;
}

.pill {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(99, 102, 241, 0.15);
    color: #c7d2fe;
}

.empty {
    color: var(--text-faint);
    font-size: 0.875rem;
    padding: 1.5rem 0;
    text-align: center;
}

/* ── Show-once token ─────────────────────────────────────────────────── */

.token-reveal {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.token-reveal .value {
    display: block;
    background: rgba(2, 6, 23, 0.8);
    border: 1px solid var(--border);
    border-radius: 0.625rem;
    padding: 0.875rem 1rem;
    margin: 1rem 0 0.75rem;
    word-break: break-all;
    color: #6ee7b7;
    user-select: all;
}

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

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    padding: 2rem;
}

.login-card h1 {
    font-size: 1.25rem;
    margin-bottom: 0.35rem;
}

.login-card .sub {
    font-size: 0.8rem;
    color: var(--text-faint);
    margin-bottom: 1.75rem;
}

.footer {
    margin-top: 3rem;
    color: #475569;
    font-size: 0.8rem;
}

@media (max-width: 760px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
}

/* ── Status badges ──────────────────────────────────────────────────────
   Every badge carries its own word, so state is never conveyed by colour
   alone — it stays readable to anyone who cannot distinguish the hues. */
.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-faint);
    white-space: nowrap;
}

.badge-ok {
    color: var(--success);
    border-color: color-mix(in srgb, var(--success) 40%, transparent);
    background: color-mix(in srgb, var(--success) 12%, transparent);
}

.badge-warn {
    color: var(--warning);
    border-color: color-mix(in srgb, var(--warning) 40%, transparent);
    background: color-mix(in srgb, var(--warning) 12%, transparent);
}

.badge-bad {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 40%, transparent);
    background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.flash-warning {
    color: var(--warning);
    border-color: color-mix(in srgb, var(--warning) 40%, transparent);
    background: color-mix(in srgb, var(--warning) 10%, transparent);
}
