/* GameDock design tokens. Dark is the default; [data-theme=light] switches. MudBlazor components get the
   matching palette from MudThemeProvider (see MainLayout); these tokens cover custom elements. */
:root, [data-theme="dark"] {
    --gd-bg: #0d1017;
    --gd-bg-elev: #131722;
    --gd-surface: #171c28;
    --gd-surface-2: #1d2331;
    --gd-border: #262d3d;
    --gd-text: #e6e9f2;
    --gd-muted: #8b93a7;
    --gd-primary: #7c5cff;
    --gd-primary-soft: rgba(124, 92, 255, .14);
    --gd-success: #22c55e;
    --gd-warning: #f59e0b;
    --gd-danger: #ef4444;
    --gd-info: #38bdf8;
    --gd-console-bg: #090b10;
    --gd-console-text: #d6dbe7;
    --gd-shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
    --gd-radius: 14px;
    color-scheme: dark;
}

[data-theme="light"] {
    --gd-bg: #f4f5f9;
    --gd-bg-elev: #ffffff;
    --gd-surface: #ffffff;
    --gd-surface-2: #f0f2f7;
    --gd-border: #e2e5ee;
    --gd-text: #161a24;
    --gd-muted: #5f6779;
    --gd-primary: #6246ea;
    --gd-primary-soft: rgba(98, 70, 234, .10);
    --gd-console-bg: #0f121a;
    --gd-console-text: #d6dbe7;
    --gd-shadow: 0 1px 2px rgba(16,24,40,.06), 0 6px 18px rgba(16,24,40,.06);
    color-scheme: light;
}

html, body {
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--gd-bg);
    color: var(--gd-text);
    margin: 0;
}

a { color: var(--gd-primary); }
code, .gd-mono { font-family: "JetBrains Mono", "Cascadia Code", Consolas, "Liberation Mono", monospace; }

.gd-muted { color: var(--gd-muted); }
.gd-user-menu .mud-button-root { text-transform: none; }
.gd-small { font-size: .82rem; }
.gd-nowrap { white-space: nowrap; }
.gd-grow { flex: 1 1 auto; min-width: 0; }
.gd-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.gd-stack { display: flex; flex-direction: column; gap: 12px; }
.gd-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- layout */
.gd-main { padding: 28px clamp(16px, 3vw, 40px) 48px; max-width: 1480px; margin: 0 auto; }
.gd-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.gd-page-header h1 { font-size: 1.65rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.gd-page-header p { margin: 4px 0 0; color: var(--gd-muted); }

.gd-demo-banner {
    background: repeating-linear-gradient(45deg, #b45309, #b45309 12px, #92400e 12px, #92400e 24px);
    color: #fff; font-weight: 600; text-align: center; padding: 6px 12px; font-size: .85rem; letter-spacing: .02em;
}

.gd-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; }
.gd-brand-mark {
    width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 900;
    background: linear-gradient(135deg, #7c5cff, #22d3ee);
    box-shadow: 0 4px 16px rgba(124, 92, 255, .45);
}
.gd-nav-section {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; color: var(--gd-muted);
    padding: 18px 20px 6px; font-weight: 700;
}

/* ---------- cards */
.gd-card {
    background: var(--gd-surface); border: 1px solid var(--gd-border); border-radius: var(--gd-radius);
    box-shadow: var(--gd-shadow); padding: 20px;
}
.gd-card h2, .gd-card h3 { margin: 0 0 12px; font-size: 1.05rem; font-weight: 650; }
.gd-grid { display: grid; gap: 18px; }
.gd-grid-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.gd-grid-4 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.gd-grid-servers { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.gd-stat { display: flex; flex-direction: column; gap: 6px; }
.gd-stat-label { color: var(--gd-muted); font-size: .85rem; font-weight: 550; display: flex; align-items: center; gap: 8px; }
.gd-stat-value { font-size: 1.65rem; font-weight: 750; letter-spacing: -.02em; }
.gd-stat-sub { color: var(--gd-muted); font-size: .8rem; }

.gd-bar { height: 8px; border-radius: 99px; background: var(--gd-surface-2); overflow: hidden; position: relative; }
.gd-bar > span { display: block; height: 100%; border-radius: 99px; background: var(--gd-primary); transition: width .4s ease; }
.gd-bar.warn > span { background: var(--gd-warning); }
.gd-bar.crit > span { background: var(--gd-danger); }
.gd-bar .gd-bar-preview { position: absolute; top: 0; height: 100%; background: repeating-linear-gradient(45deg, rgba(124,92,255,.55), rgba(124,92,255,.55) 4px, rgba(124,92,255,.25) 4px, rgba(124,92,255,.25) 8px); }

/* ---------- server cards */
.gd-server-card { display: flex; flex-direction: column; gap: 14px; transition: transform .15s ease, border-color .15s ease; }
.gd-server-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--gd-primary) 45%, var(--gd-border)); }
.gd-server-head { display: flex; gap: 12px; align-items: center; }
.gd-game-icon {
    width: 46px; height: 46px; border-radius: 12px; flex: 0 0 auto; display: grid; place-items: center;
    color: #fff; font-weight: 800; font-size: .95rem; background-size: cover; background-position: center;
}
.gd-game-icon.lg { width: 64px; height: 64px; border-radius: 16px; font-size: 1.2rem; }
.gd-server-name { font-weight: 700; font-size: 1.02rem; }
.gd-kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .86rem; }
.gd-kv dt { color: var(--gd-muted); }
.gd-kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.gd-add-card {
    border: 2px dashed var(--gd-border); border-radius: var(--gd-radius); display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 8px; min-height: 220px; color: var(--gd-muted); text-decoration: none; transition: border-color .15s, color .15s;
}
.gd-add-card:hover { border-color: var(--gd-primary); color: var(--gd-text); }
.gd-add-card .plus { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--gd-primary-soft); color: var(--gd-primary); font-size: 1.8rem; }

/* status pill */
.gd-status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: .76rem; font-weight: 650; white-space: nowrap; }
.gd-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.gd-status.running { color: var(--gd-success); background: rgba(34,197,94,.12); }
.gd-status.offline, .gd-status.unknown, .gd-status.pending { color: var(--gd-muted); background: var(--gd-surface-2); }
.gd-status.starting, .gd-status.stopping, .gd-status.installing, .gd-status.updating, .gd-status.deleting { color: var(--gd-info); background: rgba(56,189,248,.12); }
.gd-status.starting::before, .gd-status.stopping::before, .gd-status.installing::before, .gd-status.updating::before, .gd-status.deleting::before { animation: gd-pulse 1.2s infinite; }
.gd-status.suspended { color: var(--gd-warning); background: rgba(245,158,11,.13); }
.gd-status.error, .gd-status.unreachable { color: var(--gd-danger); background: rgba(239,68,68,.12); }
@keyframes gd-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* ---------- template catalog */
.gd-catalog { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.gd-game-tile {
    position: relative; border-radius: var(--gd-radius); overflow: hidden; cursor: pointer; border: 2px solid transparent;
    background: var(--gd-surface); box-shadow: var(--gd-shadow); transition: transform .15s, border-color .15s; text-align: left; padding: 0; color: inherit; font: inherit;
}
.gd-game-tile:hover { transform: translateY(-2px); }
.gd-game-tile.selected { border-color: var(--gd-primary); }
.gd-game-tile .cover { height: 108px; background-size: cover; background-position: center; display: grid; place-items: center; font-size: 2rem; font-weight: 900; color: rgba(255,255,255,.92); }
.gd-game-tile .body { padding: 12px 14px 14px; }
.gd-game-tile .title { font-weight: 700; }
.gd-game-tile .meta { color: var(--gd-muted); font-size: .8rem; margin-top: 2px; }

/* ---------- deploy progress */
.gd-steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.gd-steps li { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--gd-muted); }
.gd-steps li.active { color: var(--gd-text); background: var(--gd-primary-soft); font-weight: 600; }
.gd-steps li.done { color: var(--gd-text); }
.gd-steps li.failed { color: var(--gd-danger); background: rgba(239,68,68,.10); font-weight: 600; }
.gd-step-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--gd-border); display: grid; place-items: center; font-size: .72rem; flex: 0 0 auto; }
.gd-steps li.done .gd-step-dot { background: var(--gd-success); border-color: var(--gd-success); color: #fff; }
.gd-steps li.active .gd-step-dot { border-color: var(--gd-primary); border-top-color: transparent; animation: gd-spin .8s linear infinite; }
.gd-steps li.failed .gd-step-dot { background: var(--gd-danger); border-color: var(--gd-danger); color: #fff; }
@keyframes gd-spin { to { transform: rotate(360deg); } }

/* ---------- console */
.gd-console-wrap { display: flex; flex-direction: column; border-radius: var(--gd-radius); overflow: hidden; border: 1px solid var(--gd-border); background: var(--gd-console-bg); }
.gd-console-wrap:fullscreen { border-radius: 0; }
.gd-console-toolbar { display: flex; gap: 8px; align-items: center; padding: 8px 10px; background: #11141c; border-bottom: 1px solid #1e2330; flex-wrap: wrap; color: #c7ccd8; }
.gd-console {
    height: 520px; overflow-y: auto; padding: 12px 14px; margin: 0; color: var(--gd-console-text);
    font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace; font-size: .82rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
}
.gd-console-wrap:fullscreen .gd-console { height: auto; flex: 1; }
.gd-console .sys { color: #7c8aa5; font-style: italic; }
.gd-console .hl { background: rgba(250, 204, 21, .3); }
.gd-console-input { display: flex; gap: 8px; padding: 8px; border-top: 1px solid #1e2330; background: #0c0f15; }
.gd-console-input input {
    flex: 1; background: #141824; color: #e6e9f2; border: 1px solid #262d3d; border-radius: 8px; padding: 9px 12px;
    font-family: "JetBrains Mono", Consolas, monospace; font-size: .85rem; outline: none;
}
.gd-console-input input:focus { border-color: var(--gd-primary); }
.ansi-b { font-weight: 700; } .ansi-i { font-style: italic; } .ansi-u { text-decoration: underline; }

/* ---------- misc */
.gd-empty { text-align: center; padding: 48px 16px; color: var(--gd-muted); }
.gd-empty .icon { font-size: 2.6rem; opacity: .6; }
.gd-empty h3 { color: var(--gd-text); margin: 10px 0 6px; }
.gd-skeleton { border-radius: 10px; background: linear-gradient(90deg, var(--gd-surface-2) 25%, var(--gd-border) 50%, var(--gd-surface-2) 75%); background-size: 200% 100%; animation: gd-shimmer 1.4s infinite; }
@keyframes gd-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.gd-callout { border-radius: 12px; padding: 12px 14px; border: 1px solid var(--gd-border); background: var(--gd-surface-2); font-size: .9rem; }
.gd-callout.warn { border-color: rgba(245,158,11,.45); background: rgba(245,158,11,.08); }
.gd-callout.danger { border-color: rgba(239,68,68,.45); background: rgba(239,68,68,.08); }
.gd-callout.info { border-color: rgba(56,189,248,.4); background: rgba(56,189,248,.07); }
.gd-check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--gd-border); }
.gd-check:last-child { border-bottom: 0; }
.gd-check .ok { color: var(--gd-success); font-weight: 800; }
.gd-check .bad { color: var(--gd-danger); font-weight: 800; }
.gd-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.gd-table th { text-align: left; color: var(--gd-muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--gd-border); white-space: nowrap; }
.gd-table td { padding: 9px 10px; border-bottom: 1px solid var(--gd-border); vertical-align: middle; }
.gd-table tr:last-child td { border-bottom: 0; }
.gd-file-row { cursor: pointer; }
.gd-file-row:hover td { background: var(--gd-surface-2); }
.gd-sparkline { width: 100%; height: 64px; display: block; }
.gd-sparkline path.line { fill: none; stroke: var(--gd-primary); stroke-width: 2; }
.gd-sparkline path.area { fill: var(--gd-primary-soft); stroke: none; }
.gd-center-screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.gd-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--gd-border); border-top-color: var(--gd-primary); animation: gd-spin .8s linear infinite; }
.gd-code-box { font-family: "JetBrains Mono", Consolas, monospace; font-size: .82rem; background: var(--gd-surface-2); border: 1px solid var(--gd-border); border-radius: 10px; padding: 10px 12px; word-break: break-all; }
.gd-editor { height: 560px; border: 1px solid var(--gd-border); border-radius: 10px; overflow: hidden; }
.gd-editor .monaco-editor-container, .gd-editor > div { height: 100%; }

/* ---------- static account pages (no MudBlazor runtime) */
.gd-auth-bg {
    min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
    background: radial-gradient(1200px 600px at 10% -10%, rgba(124,92,255,.22), transparent 60%), radial-gradient(900px 500px at 110% 110%, rgba(34,211,238,.14), transparent 60%), var(--gd-bg);
}
.gd-auth-card { width: 100%; max-width: 420px; background: var(--gd-surface); border: 1px solid var(--gd-border); border-radius: 18px; box-shadow: var(--gd-shadow); padding: 32px 30px; }
.gd-auth-card h1 { font-size: 1.4rem; margin: 18px 0 4px; }
.gd-auth-card p { margin: 0 0 18px; }
.gd-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.gd-field label { font-size: .85rem; font-weight: 600; }
.gd-input {
    background: var(--gd-bg-elev); color: var(--gd-text); border: 1px solid var(--gd-border); border-radius: 10px; padding: 11px 12px; font: inherit; outline: none;
}
.gd-input:focus { border-color: var(--gd-primary); box-shadow: 0 0 0 3px var(--gd-primary-soft); }
.gd-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 10px; padding: 11px 16px; border: 1px solid var(--gd-border);
    background: var(--gd-surface-2); color: var(--gd-text); font: inherit; font-weight: 650; cursor: pointer; text-decoration: none;
}
.gd-btn-primary { background: var(--gd-primary); border-color: var(--gd-primary); color: #fff; }
.gd-btn-primary:hover { filter: brightness(1.08); }
.gd-btn-block { width: 100%; }
.gd-btn-discord { background: #5865f2; border-color: #5865f2; color: #fff; }
.gd-alert { border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: .9rem; }
.gd-alert.error { background: rgba(239,68,68,.12); color: #fca5a5; border: 1px solid rgba(239,68,68,.35); }
[data-theme="light"] .gd-alert.error { color: #b91c1c; }
.gd-alert.ok { background: rgba(34,197,94,.12); color: #86efac; border: 1px solid rgba(34,197,94,.35); }
[data-theme="light"] .gd-alert.ok { color: #15803d; }
.gd-auth-links { display: flex; justify-content: space-between; margin-top: 14px; font-size: .88rem; }
.gd-divider { display: flex; align-items: center; gap: 10px; color: var(--gd-muted); font-size: .8rem; margin: 16px 0; }
.gd-divider::before, .gd-divider::after { content: ""; flex: 1; height: 1px; background: var(--gd-border); }
.gd-checkbox { display: flex; align-items: center; gap: 8px; font-size: .88rem; margin-bottom: 16px; }

/* Blazor error UI */
#blazor-error-ui { display: none; }
.blazor-error-boundary { background: rgba(239,68,68,.12); padding: 1rem; border-radius: 10px; color: var(--gd-danger); }
.blazor-error-boundary::after { content: "Something went wrong while rendering this part of the page."; }

@media (max-width: 640px) {
    .gd-main { padding: 18px 12px 40px; }
    .gd-console { height: 380px; }
}
