﻿@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0d0f14;
    --surface: #13151c;
    --surface-2: #1a1d27;
    --border: rgba(255, 255, 255, 0.07);
    --border-hover: rgba(255, 255, 255, 0.13);
    --text: #dde1ec;
    --text-muted: #5a6380;
    --text-dim: #3a4060;
    --accent: #5b82f0;
    --accent-dim: rgba(91, 130, 240, 0.15);
    --danger: #e05454;
    --danger-dim: rgba(224, 84, 84, 0.12);
    --success: #4caf7d;
    --warn: #e09a3a;
    --radius: 6px;
    --radius-lg: 10px;
}

html, body {
    height: 100%;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--surface-2);
    border-radius: 99px;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
}

.topbar-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.topbar-nav {
    display: flex;
    gap: 10px;
    flex: 1;
    overflow-x: auto;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    padding: 5px 11px;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s, background 0.15s;
    border: 1px solid transparent;
}

    .nav-link:hover {
        color: var(--text);
        background: var(--surface-2);
    }

    .nav-link.active {
        color: var(--text);
        background: var(--surface-2);
        border-color: var(--border);
    }

.topbar-end {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn {
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 13px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

    .btn:hover {
        color: var(--text);
        border-color: var(--border-hover);
    }

    .btn:active {
        opacity: 0.8;
    }

.btn-accent {
    background: var(--accent-dim);
    border-color: rgba(91, 130, 240, 0.3);
    color: var(--accent);
}

    .btn-accent:hover {
        background: rgba(91, 130, 240, 0.22);
        border-color: rgba(91, 130, 240, 0.5);
        color: #7ca0f5;
    }

.btn-danger {
    background: var(--danger-dim);
    border-color: rgba(224, 84, 84, 0.25);
    color: var(--danger);
}

    .btn-danger:hover {
        background: rgba(224, 84, 84, 0.2);
        border-color: rgba(224, 84, 84, 0.45);
        color: #f07070;
    }

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
    font-size: 12px;
}

    .btn-ghost:hover {
        color: var(--text);
        border-color: var(--border-hover);
        background: var(--surface-2);
    }

.btn-xs {
    padding: 3px 9px;
    font-size: 11px;
}

.btn-full {
    width: 100%;
    justify-content: center;
    padding: 9px 13px;
    font-size: 13px;
}

.controlbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.main {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
}

.components-row {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

@media (max-width: 720px) {
    .components-row {
        grid-template-columns: 1fr;
    }

    .topbar-title {
        display: none;
    }
}

@media (max-width: 480px) {
    .main {
        padding: 10px;
        gap: 10px;
    }
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.console-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
}

.console-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    min-height: 300px;
}

    .console-card .tab-panel.active {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
    }

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    font-weight: 500;
    padding: 9px 14px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

    .tab-btn:hover {
        color: var(--text);
    }

    .tab-btn.active {
        color: var(--accent);
        border-bottom-color: var(--accent);
    }

.tab-panel {
    display: none;
}

    .tab-panel.active {
        display: block;
    }

.players-scroll {
    max-height: 300px;
    overflow-y: auto;
    padding: 6px;
}

.player-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius);
    transition: background 0.12s;
}

    .player-row:hover {
        background: var(--surface-2);
    }

.player-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
}

.player-name {
    flex: 1;
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    color: var(--text);
}

.player-actions {
    display: flex;
    gap: 4px;
}

.empty-msg {
    padding: 28px 16px;
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
    font-family: 'DM Mono', monospace;
}

.chart-wrap {
    padding: 14px;
    position: relative;
    height: 280px; /* fixed — chart fills via maintainAspectRatio:false */
}

/* ════════════════════════════════════
   MODAL
════════════════════════════════════ */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

    .modal-backdrop.open {
        display: flex;
    }

.modal {
    background: var(--surface);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    width: calc(100% - 32px);
    max-width: 340px;
}

.modal-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 7px;
}

.modal-body {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.55;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 7px;
}

/* ════════════════════════════════════
   CONSOLE PANELS
════════════════════════════════════ */
.console {
    font-family: 'DM Mono', monospace;
    font-size: 11.5px;
    line-height: 1.6;
    color: #b0bbd4;
    padding: 10px;
    flex: 1;
    min-height: 120px;
    overflow-y: auto;
    background: #0a0c10;
}

.console-line {
    white-space: pre-wrap;
    word-break: break-all;
    padding: 1px 4px;
    border-radius: 3px;
}

    .console-line:hover {
        background: rgba(255,255,255,0.03);
    }

#cmd-output .console-line {
    color: #8ab4f8;
}

.console-empty {
    color: var(--text-dim);
    padding: 4px;
}

/* ── Command input bar ── */
.cmd-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 8px 12px;
    position: sticky;
    bottom: 16px;
}

.cmd-prompt {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    color: var(--accent);
    flex-shrink: 0;
    user-select: none;
}

.cmd-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    color: var(--text);
    caret-color: var(--accent);
}

    .cmd-input::placeholder {
        color: var(--text-dim);
    }

/* ── Result modal error body ── */
.modal-body-error {
    color: var(--danger);
    font-family: 'DM Mono', monospace;
    font-size: 11.5px;
    background: var(--danger-dim);
    border: 1px solid rgba(224,84,84,0.2);
    border-radius: var(--radius);
    padding: 8px 10px;
    margin-bottom: 20px;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ════════════════════════════════════
   AUTH PAGE
════════════════════════════════════ */
.auth-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 360px;
    overflow: hidden;
}

    /* reuse .tabs / .tab-btn for the login ↔ register switcher */
    .auth-card .tabs {
        /* override tab underline colour to be subtler on the auth card */
    }

.auth-form-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Form field ── */
.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

    .field label {
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        color: var(--text-muted);
    }

    .field input {
        font-family: 'DM Sans', sans-serif;
        font-size: 13px;
        padding: 8px 10px;
        background: var(--surface-2);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        color: var(--text);
        outline: none;
        transition: border-color 0.15s;
        width: 100%;
    }

        .field input:focus {
            border-color: var(--accent);
        }

        .field input::placeholder {
            color: var(--text-dim);
        }

/* ── Status message ── */
.auth-status {
    font-family: 'DM Mono', monospace;
    font-size: 11.5px;
    padding: 8px 10px;
    border-radius: var(--radius);
    display: none; /* shown by JS */
    white-space: pre-wrap;
    word-break: break-all;
}

    .auth-status.ok {
        display: block;
        color: var(--success);
        background: rgba(76, 175, 125, 0.1);
        border: 1px solid rgba(76, 175, 125, 0.2);
    }

    .auth-status.err {
        display: block;
        color: var(--danger);
        background: var(--danger-dim);
        border: 1px solid rgba(224, 84, 84, 0.2);
    }

.server-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    padding: 5px 11px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    margin-right: 6px;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}

    .server-status-badge::before {
        content: '';
        width: 6px;
        height: 6px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .server-status-badge.running {
        color: var(--success);
        background: rgba(76, 175, 125, 0.1);
        border-color: rgba(76, 175, 125, 0.25);
    }

        .server-status-badge.running::before {
            background: var(--success);
            box-shadow: 0 0 5px var(--success);
        }

    .server-status-badge.stopped {
        color: var(--danger);
        background: var(--danger-dim);
        border-color: rgba(224, 84, 84, 0.25);
    }

        .server-status-badge.stopped::before {
            background: var(--danger);
        }

    .server-status-badge.unknown {
        color: var(--text-muted);
        background: transparent;
        border-color: var(--border);
    }

        .server-status-badge.unknown::before {
            background: var(--text-dim);
        }

/* ── Backup list ── */
.backup-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 6px;
}

.backup-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: var(--radius);
    transition: background 0.12s;
}

    .backup-row:hover {
        background: var(--surface-2);
    }

/* Left column: filename + meta line */
.backup-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0; /* lets long names truncate */
}

.backup-name {
    font-family: 'DM Mono', monospace;
    font-size: 11.5px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.backup-meta {
    font-family: 'DM Mono', monospace;
    font-size: 10.5px;
    color: var(--text-muted);
}

.backup-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* Footer: total size left, create button right */
.backup-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    gap: 8px;
}

.backup-total {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: var(--text-muted);
}
