/* Shared application styles: design tokens, app shell, sidebar, footer.
 *
 * Colours are declared once here as custom properties. `body.light-mode`
 * redefines the tokens rather than restating every rule, so a colour change is
 * one line instead of one per rule per theme. Page-specific CSS goes in
 * `web/static/css/<page>.css`, which the page links from its `page_styles`
 * block and which loads after this file.
 */

:root {
    /* Surfaces and text */
    --bg: #0c0e12;
    --surface: #12151b;
    --border: #252a35;
    --text: #d6d9e0;
    --text-strong: #e4e8ef;
    --muted: #9aa2af;

    /* Navigation */
    --nav-link: #aeb5c1;
    --nav-label: #4b5563;
    --hover-bg: #181c24;
    --active-bg: #181c24;

    /* Form controls */
    --input-bg: #181c24;
    --input-border: #252a35;

    /* Accent: gold on the dark theme, indigo on the light one */
    --accent: #d4a54a;
    /* Constant gold, used where the accent must not follow the theme */
    --gold: #d4a54a;

    --footer-text: #6b7280;

    /* Semantic colours. The pages that needed a "worked" or "failed" colour
       each picked their own; these are the two the system offers. */
    --success: #4ade80;
    --danger: #f87171;

    /* Corners. The shell is square-ish on purpose; a pill is a shape choice,
       not a softer version of the same thing. */
    --radius: 2px;
    --radius-pill: 999px;
}

body.light-mode {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --border: #d7dce6;
    --text: #1f2937;
    --text-strong: #111827;

    --nav-link: #4b5563;
    --nav-label: #9ca3af;
    --hover-bg: #f3f4f6;
    --active-bg: #eef2ff;

    --input-bg: #ffffff;
    --input-border: #cfd5e1;

    --accent: #4338ca;
    --danger: #dc2626;
}

/* ── Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: 'IBM Plex Sans', sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}
h1, h2, h3, h4, h5, h6, th, .sidebar-link, .badge, .status-label {
    font-family: 'IBM Plex Sans Condensed', sans-serif;
    letter-spacing: 0.01em;
}
code, kbd, pre, .mono, .stat-number, .number, .timestamp {
    font-family: 'IBM Plex Mono', monospace;
}

/* ── App Shell ─────────────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
}
.global-sidebar {
    width: 210px;
    min-width: 210px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}
.sidebar-top {
    padding: 14px 14px 12px;
    border-bottom: 1px solid var(--border);
}
.sidebar-brand {
    display: block;
    text-decoration: none;
    line-height: 1.1;
    color: var(--text-strong);
}
.sidebar-brand-wordmark {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.14rem;
    letter-spacing: 0.08em;
}
.sidebar-brand-subtext {
    margin-top: 4px;
    font-family: 'IBM Plex Sans Condensed', sans-serif;
    font-size: 0.68rem;
    letter-spacing: 0.16em;
    color: var(--accent);
}
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--nav-link);
    text-decoration: none;
    padding: 8px 14px 8px 12px;
    border-left: 2px solid transparent;
    font-size: 0.88rem;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sidebar-link:hover { background: var(--hover-bg); color: var(--text-strong); }
.sidebar-link.active { background: var(--active-bg); color: var(--accent); border-left-color: var(--accent); }
.sidebar-section-label {
    font-size: 0.65rem;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--nav-label);
    font-family: 'IBM Plex Mono', monospace;
    padding: 10px 14px 3px;
}
.sidebar-bottom {
    padding: 10px 12px 12px;
}
.sidebar-userline {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.78rem;
    color: var(--muted);
}
.sidebar-user-meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-field-label {
    display: block;
    font-size: 0.7rem;
    color: var(--muted);
    margin-bottom: 4px;
}
.sidebar-select {
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--input-border);
    border-radius: 2px;
    padding: 4px 6px;
    font-size: 0.75rem;
    width: 100%;
    margin-bottom: 8px;
}
.sidebar-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border);
    object-fit: cover;
}

/* `.logout-btn` keeps its explicit light-mode rules: two templates
 * (alliance_access_denied, unauthorized) restyle the class themselves, and
 * folding these into tokens would lower the specificity that currently wins
 * over them. */
.logout-btn {
    background: #181c24;
    color: #d6d9e0;
    padding: 6px 10px;
    border: 1px solid #252a35;
    border-radius: 2px;
    text-decoration: none;
    font-size: 12px;
    cursor: pointer;
    display: inline-block;
    width: 100%;
    text-align: center;
}
.logout-btn:hover { border-color: #d4a54a; color: #d4a54a; }
body.light-mode .logout-btn { background: #fff; color: #374151; border-color: #cfd5e1; }
body.light-mode .logout-btn:hover { border-color: #4338ca; color: #4338ca; }

.main-shell {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.main-content {
    flex: 1;
    min-width: 0;
}

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    color: var(--footer-text);
    font-size: 0.78rem;
    text-align: center;
    padding: 16px 12px;
    line-height: 1.8;
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--gold); }

/* ── Shared icon helper ─────────────────────────────────────── */
.icon { display:inline-flex; width:1em; height:1em; vertical-align:-0.15em; margin-right:0.35em; }
.icon svg { width:100%; height:100%; stroke:currentColor; fill:none; stroke-width:1.75; stroke-linecap:round; stroke-linejoin:round; }

@media (max-width: 960px) {
    .app-shell { flex-direction: column; }
    .global-sidebar {
        width: 100%;
        min-width: 0;
        height: auto;
        position: static;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
    .sidebar-nav {
        max-height: 260px;
    }
}


/* Shared components.
 *
 * Each rule below was written out identically in three or more templates,
 * which is what made changing a button mean editing seven files and finding
 * six of them. A rule earns its place here once it is the same on every page
 * that uses it; a page wanting a different one still overrides it from its own
 * sheet, loaded after this file.
 *
 * Colours are `var(--token)` wherever the dark and light values are exactly
 * the pair a token already holds, which is what lets the light rule disappear
 * instead of restating the same colour. Where no token spans both themes the
 * literal stays, with its `body.light-mode` rule below: a token invented to fit
 * one component would change every other rule that reads it.
 *
 * `tests/test_shared_styles.py` fails when one of these is duplicated again.
 */

.back-link:hover {
    color: var(--accent);
}

.badge-official {
    background: rgba(127, 177, 138, .12);
    color: #7fb18a;
    border-color: rgba(127, 177, 138, .3);
}

.badge-unofficial {
    background: var(--hover-bg);
    color: var(--footer-text);
}

.btn-primary {
    background: #d4a54a;
    color: #0c0e12;
    border-color: #d4a54a;
}

.btn-outline {
    background: transparent;
    color: #9aa2af;
    border-color: var(--input-border);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}

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

.form-label {
    display: block;
    font-size: .8rem;
    color: #9aa2af;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.recipient-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
    margin-right: 8px;
    border: 1px solid var(--border);
}

.tab-bar {
    display: flex;
    gap: 0;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    max-width: 1280px;
    margin: 0 auto 24px;
}

.tab-link:hover {
    color: var(--accent);
}

.back-link {
    display: inline-block;
    margin: 16px 24px 0;
    color: #9aa2af;
    font-size: .88rem;
    text-decoration: none;
}

.btn-primary:hover {
    background: #c49a3f;
}

.empty-state {
    padding: 64px 24px;
    text-align: center;
    color: var(--footer-text);
}

.empty-state h2 {
    margin: 0 0 8px;
    font-size: 1.4rem;
    color: #9aa2af;
}

.page-body {
    padding: 10px;
}

.stat-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin: 8px 0 24px;
}

.tab-link {
    padding: 10px 20px;
    margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    color: #9aa2af;
    font-size: .88rem;
    font-weight: 600;
    text-decoration: none;
    transition: color .15s, border-color .15s;
}

/* Light theme, for the colours no token spans. */

body.light-mode .back-link {
    color: #6b7280;
}

body.light-mode .btn-outline {
    color: #4b5563;
}

body.light-mode .empty-state h2 {
    color: #374151;
}

body.light-mode .form-label {
    color: #6b7280;
}

body.light-mode .tab-link {
    color: #6b7280;
}

body.light-mode .stat-chip {
    background: var(--surface);
    border-color: var(--border);
}
