/* ── Sutalis Dark Theme ─────────────────────────────────────────────────────
   Edit these variables to retheme the entire app.
   ─────────────────────────────────────────────────────────────────────────── */
:root {
    --bg-primary:    #0c0c18;
    --bg-surface:    #12121f;
    --bg-elevated:   #1a1a2e;
    --bg-hover:      #22223a;
    --border:        #2a2a45;
    --border-subtle: #1e1e32;

    --text-primary:   #e2ddf0;
    --text-secondary: #8b82a8;
    --text-muted:     #4a4566;

    --accent:       #7456b8;
    --accent-light: #9070d8;
    --accent-dim:   #2a1e50;
    --accent-glow:  rgba(116, 86, 184, 0.18);

    --gold:    #c8a84a;
    --runic:   #9070d8;
    --success: #4a9e6a;
    --danger:  #9e4a4a;
    --warn:    #b8862a;

    --radius-sm: 4px;
    --radius:    8px;
    --radius-lg: 12px;

    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

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

html, body {
    height: 100%;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-light); text-decoration: none; }
a:hover { color: var(--text-primary); }

/* ── App Shell ─────────────────────────────────────────────────────────────── */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── Top Bar ───────────────────────────────────────────────────────────────── */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 52px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 10;
}

.top-bar-brand {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--accent-light);
}

.top-bar-player {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
}

.player-name {
    font-weight: 600;
    color: var(--text-primary);
}

.player-stat {
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-mono);
    letter-spacing: 0.5px;
}
.player-stat.gold   { background: rgba(200,168,74,0.12);  color: var(--gold);    border: 1px solid rgba(200,168,74,0.25); }
.player-stat.runic  { background: rgba(144,112,216,0.12); color: var(--runic);   border: 1px solid rgba(144,112,216,0.25); }
.player-stat.hp     { background: rgba(74,158,106,0.12);  color: var(--success); border: 1px solid rgba(74,158,106,0.25); }

/* ── Body ──────────────────────────────────────────────────────────────────── */
.body-wrap {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
    width: 200px;
    flex-shrink: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 12px 0;
}

.nav-section {
    padding: 14px 16px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.nav-item {
    display: block;
    padding: 7px 16px;
    font-size: 14px;
    color: var(--text-secondary);
    border-left: 2px solid transparent;
    transition: all 0.15s ease;
}
.nav-item.nav-sub { padding-left: 24px; font-size: 13px; }
.nav-item:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-item.active {
    color: var(--accent-light);
    border-left-color: var(--accent);
    background: var(--accent-dim);
}

/* ── Main Content ──────────────────────────────────────────────────────────── */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
}
.card-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* ── Page heading ──────────────────────────────────────────────────────────── */
.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}
.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: var(--font);
    letter-spacing: 0.3px;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-light); }

.btn-surface {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-surface:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--accent); }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover:not(:disabled) { filter: brightness(1.2); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { color: var(--text-primary); border-color: var(--accent); }

.btn-full  { width: 100%; }
.btn-small { padding: 5px 12px; font-size: 12px; }

/* ── Form controls ─────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-input {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.15s ease;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-muted); }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    border-left: 3px solid;
}
.alert-error   { background: rgba(158,74,74,0.12);   border-color: var(--danger);  color: #e08888; }
.alert-success { background: rgba(74,158,106,0.12);  border-color: var(--success); color: #80d0a0; }
.alert-warn    { background: rgba(184,134,42,0.12);  border-color: var(--warn);    color: #d4a860; }
.alert-info    { background: rgba(116,86,184,0.12);  border-color: var(--accent);  color: #b090f8; }

/* ── Auth page ─────────────────────────────────────────────────────────────── */
.auth-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    padding: 24px;
}
.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 0 1px var(--border-subtle);
}
.auth-title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 3px;
    text-transform: uppercase;
    text-align: center;
    color: var(--accent-light);
    margin-bottom: 6px;
}
.auth-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 28px;
}
.auth-footer {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 20px;
}
.auth-footer a { color: var(--accent-light); }
.auth-footer a:hover { color: var(--text-primary); }
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ── Home grid ─────────────────────────────────────────────────────────────── */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    margin-top: 8px;
}
.menu-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    display: block;
}
.menu-card:hover {
    border-color: var(--accent);
    background: var(--bg-elevated);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
    color: var(--text-primary);
}
.menu-card-icon { font-size: 24px; margin-bottom: 10px; }
.menu-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.menu-card-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ── Stat bar ──────────────────────────────────────────────────────────────── */
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-subtle);
}
.stat-row:last-child { border-bottom: none; }
.stat-label { font-size: 13px; color: var(--text-secondary); }
.stat-value { font-size: 14px; font-weight: 600; color: var(--text-primary); font-family: var(--font-mono); }

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Persistent Chat Widget ────────────────────────────────────────────────── */
.chat-toggle {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.chat-toggle:hover { border-color: var(--accent); background: var(--bg-hover); }

.chat-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--accent);
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
}

.chat-panel {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 100;
    width: 340px;
    height: 440px;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 0 1px var(--border-subtle);
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    height: 40px;
    flex-shrink: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}

.chat-tabs { display: flex; gap: 2px; }
.chat-tab {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font);
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.12s ease;
}
.chat-tab:hover { color: var(--text-primary); }
.chat-tab.active { color: var(--accent-light); background: var(--accent-dim); }

.chat-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font);
}
.chat-close:hover { color: var(--text-primary); border-color: var(--border); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-empty {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    margin-top: 40px;
}

.chat-msg { line-height: 1.4; }
.chat-msg-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 6px;
}
.chat-msg-time {
    font-size: 10px;
    color: var(--text-muted);
}
.chat-msg-body {
    font-size: 13px;
    color: var(--text-primary);
    word-break: break-word;
}

.chat-input-row {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-elevated);
}

.chat-input {
    flex: 1;
    padding: 7px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
}
.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--text-muted); }

.chat-send {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font);
    transition: background 0.12s ease;
}
.chat-send:hover:not(:disabled) { background: var(--accent-light); }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Mobile / Responsive ───────────────────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 40;
}

.hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    font-family: var(--font);
    flex-shrink: 0;
}
.hamburger:hover { border-color: var(--accent); background: var(--bg-hover); }

@media (max-width: 680px) {
    .hamburger { display: flex; }

    .top-bar { padding: 0 12px; gap: 8px; }
    .top-bar-brand { font-size: 15px; letter-spacing: 2px; }
    .top-bar-player { gap: 6px; }
    .player-stat { display: none; }

    .sidebar {
        position: fixed;
        top: 52px;
        left: 0;
        bottom: 0;
        width: 220px;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }

    .content { padding: 16px 14px; }

    .chat-panel {
        width: 100vw;
        right: 0;
        left: 0;
        bottom: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        height: 60vh;
    }
    .chat-toggle { right: 12px; bottom: 12px; padding: 8px 14px; font-size: 12px; }
}
