/* =================================================================
   assets/admin.css — Car Show Admin
   Single source of truth for all admin page styling.

   Structure:
     1.  CSS Variables  (light + dark mode)
     2.  Base           (body, a, headings)
     3.  Layout         (.card, .top, .toolbar, .grid, .summary-grid)
     4.  Stat tiles     (.stat)
     5.  Alerts         (.message, .good, .warning, .error, .danger, .bad, .danger-note)
     6.  Typography     (.muted, .action, .section-title, .subtitle, .nowrap)
     7.  Forms          (label, input, select, textarea, button, button variants)
     8.  Tables         (table, th, td)
     9.  Status chips   (.status-paid, .leader, .status-unpaid, .tie, etc.)
    10.  Inline helpers (.number, .vehicle-number, .code, .class-card,
                         .vote-grid, .vehicle-list, .summary)
    11.  Navigation     (.admin-nav and children)
    12.  Print
    13.  Responsive     (≤800 px — shared table stacking + nav/layout)
================================================================= */

/* ── 1. CSS Variables ─────────────────────────────────────── */

:root {
    --bg:              #e8eaed;
    --card-bg:         #ffffff;
    --soft-bg:         #f3f4f6;
    --border:          #d1d5db;
    --text:            #111827;
    --text-muted:      #6b7280;
    --link:            #2563eb;

    --green-bg:        #f0fdf4;
    --green-border:    #86efac;
    --green-text:      #15803d;

    --yellow-bg:       #fefce8;
    --yellow-border:   #fde68a;
    --yellow-text:     #854d0e;

    --red-bg:          #fef2f2;
    --red-border:      #fca5a5;
    --red-text:        #991b1b;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:              #0f172a;
        --card-bg:         #1e293b;
        --soft-bg:         #293548;
        --border:          #334155;
        --text:            #f1f5f9;
        --text-muted:      #94a3b8;
        --link:            #60a5fa;

        --green-bg:        #052e16;
        --green-border:    #166534;
        --green-text:      #86efac;

        --yellow-bg:       #1c1400;
        --yellow-border:   #713f12;
        --yellow-text:     #fde68a;

        --red-bg:          #1c0606;
        --red-border:      #7f1d1d;
        --red-text:        #fca5a5;
    }
}

/* ── 2. Base ──────────────────────────────────────────────── */

body {
    font-family: 'Segoe UI', system-ui, Arial, sans-serif;
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 20px 48px;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--link); }

h1 { font-size: 22px; font-weight: 700; margin: 0 0 12px; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }

/* ── 3. Layout ────────────────────────────────────────────── */

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px 20px;
    margin-bottom: 18px;
}

.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 18px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

/* ── 4. Stat tiles ────────────────────────────────────────── */

.stat {
    background: var(--soft-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
}

.stat strong {
    display: block;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
    margin-top: 4px;
}

/* ── 5. Alerts ────────────────────────────────────────────── */

.message,
.good {
    background: var(--green-bg);
    border: 1px solid var(--green-border);
    color: var(--green-text);
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
}

.warning,
.danger-note {
    background: var(--yellow-bg);
    border: 1px solid var(--yellow-border);
    color: var(--yellow-text);
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
}

.error,
.danger,
.bad {
    background: var(--red-bg);
    border: 1px solid var(--red-border);
    color: var(--red-text);
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
}

/* ── 6. Typography ────────────────────────────────────────── */

.muted {
    color: var(--text-muted);
    font-size: 13px;
}

.action {
    font-weight: 700;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.section-title h2 {
    margin: 0;
}

.subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: -8px;
    margin-bottom: 14px;
}

.nowrap {
    white-space: nowrap;
}

/* ── 7. Forms ─────────────────────────────────────────────── */

label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

input,
select,
textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    font-size: 14px;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 5px;
    line-height: 1.4;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--link);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea {
    min-height: 90px;
    resize: vertical;
}

select { cursor: pointer; }

button {
    padding: 8px 16px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    background: var(--soft-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 5px;
    cursor: pointer;
    line-height: 1.4;
    margin-top: 10px;
}

button:hover { background: var(--border); }

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.danger-button {
    background: #dc2626;
    color: #ffffff;
    border-color: #b91c1c;
}

.danger-button:hover { background: #b91c1c; }

.hard-danger-button {
    background: #7f1d1d;
    color: #ffffff;
    border-color: #450a0a;
    font-weight: 700;
}

.hard-danger-button:hover { background: #6b1818; }

/* ── 8. Tables ────────────────────────────────────────────── */

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    color: var(--text);
    font-size: 14px;
}

th,
td {
    border: 1px solid var(--border);
    padding: 7px 10px;
    vertical-align: top;
    text-align: left;
}

th {
    background: var(--soft-bg);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

/* ── 9. Status chips ──────────────────────────────────────── */

.status-paid,
.leader,
.ok,
.status-active {
    color: var(--green-text);
    font-weight: 600;
}

.status-unpaid,
.tie,
.needs,
.status-inactive {
    color: var(--yellow-text);
    font-weight: 600;
}

/* ── 10. Inline helpers ───────────────────────────────────── */

.number,
.vehicle-number,
.code {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Vehicle info summary boxes (vehicle_edit, vehicle_change_class, vehicle_remove) */
.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.summary > div {
    background: var(--soft-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
}

.summary > div strong {
    display: block;
    margin-top: 4px;
    font-weight: 700;
}

/* Divider between ballot sections (paper_entry) */
.class-card {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    margin-top: 14px;
}

/* Quick-entry vote grid (paper_quick_entry) */
.vote-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 12px;
}

/* Vehicle reference list (paper_quick_entry) */
.vehicle-list {
    columns: 2;
    column-gap: 24px;
    font-size: 14px;
}

.vehicle-list div {
    break-inside: avoid;
    margin-bottom: 4px;
}

/* ── 11. Navigation ───────────────────────────────────────── */

.admin-status-strip {
    max-width: 1100px;
    margin: 0 auto 14px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card-bg);
    text-align: center;
}

.admin-status-title {
    font-size: 17px;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 8px;
}

.admin-status-phase {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 10px;
}

.admin-status-items {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 2px;
}

.admin-status-items span {
    display: inline-block;
    padding: 5px 11px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--soft-bg);
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
}

/* Main event phase */
.admin-status-strip.live .admin-status-phase {
    color: #052e16 !important;
    background: #bbf7d0 !important;
    border: 1px solid #22c55e !important;
}

.admin-status-strip.locked .admin-status-phase {
    color: #431407 !important;
    background: #fed7aa !important;
    border: 1px solid #f97316 !important;
}

.admin-status-strip.published .admin-status-phase {
    color: #042f2e !important;
    background: #99f6e4 !important;
    border: 1px solid #14b8a6 !important;
}

.admin-status-strip.neutral .admin-status-phase {
    color: #111827 !important;
    background: #e5e7eb !important;
    border: 1px solid #9ca3af !important;
}

/* Smaller status badges */
.admin-status-items span.open {
    color: #052e16 !important;
    background: #dcfce7 !important;
    border-color: #22c55e !important;
}

.admin-status-items span.closed {
    color: #7f1d1d !important;
    background: #fee2e2 !important;
    border-color: #ef4444 !important;
}

.admin-status-items span.neutral {
    color: #111827 !important;
    background: #e5e7eb !important;
    border-color: #9ca3af !important;
}



.admin-nav {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 10px;
    margin-bottom: 18px;
}

.admin-nav-section {
    display: grid;
    grid-template-columns: 88px 1fr;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid var(--border);
}

.admin-nav-section:last-child { border-bottom: none; }

.admin-nav-heading {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.admin-nav-links { line-height: 1.6; }

.admin-nav-links a {
    display: inline-block;
    margin: 2px 3px 2px 0;
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--link);
    font-size: 13px;
    text-decoration: none;
}

.admin-nav-links a:hover {
    background: var(--soft-bg);
    text-decoration: none;
}

.admin-nav-links a.active {
    background: var(--soft-bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 600;
}

/* ── 12. Print ────────────────────────────────────────────── */

.page-break { break-after: page; }

@media print {
    .admin-nav,
    .top,
    .toolbar,
    .screen-nav {
        display: none !important;
    }

    body,
    .card,
    .stat,
    table,
    th,
    td {
        background: #ffffff !important;
        color: #000000 !important;
        border-color: #cccccc !important;
    }

    a { color: #000000 !important; }
}

/* ── 13. Responsive (≤800 px) ─────────────────────────────── */

@media (max-width: 800px) {
    body { padding: 12px 12px 32px; }
    .card { padding: 14px; }

    .top { display: block; }
    .top > * + * { margin-top: 10px; }

    .section-title { display: block; }

    .admin-nav-section {
        grid-template-columns: 72px 1fr;
        align-items: start;
        gap: 6px;
    }

    .admin-nav-heading { padding-top: 4px; }

    .admin-nav-links a {
        padding: 4px 7px;
        border: 1px solid var(--border);
        font-size: 12px;
    }

    .vehicle-list { columns: 1; }
	
	
	.admin-status-strip {
		padding: 11px 12px;
	}

	.admin-status-title {
		font-size: 16px;
	}

	.admin-status-phase {
		font-size: 13px;
	}

	.admin-status-items {
		justify-content: center;
}

    /* Generic table → stacked cards.
       Pages with named table classes override this with their own
       @media rules to restore tabular or grid-card layout. */
    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    thead { display: none; }

    tr {
        border: 1px solid var(--border);
        margin-bottom: 12px;
        background: var(--card-bg);
    }

    td {
        border: none;
        border-bottom: 1px solid var(--soft-bg);
        padding: 6px 8px;
    }

    td::before {
        content: attr(data-label);
        display: block;
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-muted);
        margin-bottom: 2px;
    }
}
