/**
 * Dynasty Roster Planner — Global Stylesheet
 *
 * Purpose:
 *   Provides the single shared stylesheet for the private roster-planning app.
 *
 * Usage:
 *   Link from each page using: <link rel="stylesheet" href="styles.css">
 *
 * Dependencies:
 *   None.
 *
 * Key Blocks:
 *   - SECTION: Variables and Reset
 *   - SECTION: Application Shell
 *   - SECTION: Navigation
 *   - SECTION: Page Layout
 *   - SECTION: Components
 *   - SECTION: Tables
 *   - SECTION: Responsive
 */

/* SECTION: Variables and Reset */
:root {
    --page-bg: #ffffff;
    --surface: #ffffff;
    --surface-muted: #f6f7f9;
    --surface-soft: #fafbfc;
    --border: #d9dee5;
    --border-strong: #c5ccd5;
    --text: #1e2732;
    --text-muted: #66717f;
    --text-faint: #8993a0;
    --primary: #2056a8;
    --primary-hover: #174787;
    --success: #237a45;
    --warning: #9a6810;
    --danger: #a63a3a;
    --shadow: 0 1px 2px rgba(26, 39, 54, 0.06);
    --radius: 6px;
    --content-width: 1540px;
}

* {
    box-sizing: border-box;
}

html {
    background: var(--page-bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--page-bg);
}

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

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

button,
input,
select,
textarea {
    font: inherit;
}

/* SECTION: Application Shell */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page {
    width: min(100%, var(--content-width));
    margin: 0 auto;
    padding: 18px 24px 28px;
    flex: 1;
}

.footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 24px;
    border-top: 1px solid var(--border);
    color: var(--text-faint);
    font-size: 11px;
}

/* SECTION: Navigation */
.topbar {
    min-height: 48px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 24px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 9px;
    white-space: nowrap;
}

.brand {
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.brand:hover {
    color: var(--text);
    text-decoration: none;
}

.environment-badge {
    padding: 2px 6px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    color: var(--text-muted);
    background: var(--surface-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.primary-nav {
    display: flex;
    align-items: stretch;
    min-width: 0;
    height: 48px;
    overflow-x: auto;
}

.primary-nav a {
    display: flex;
    align-items: center;
    padding: 0 11px;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
}

.primary-nav a:hover {
    color: var(--text);
    background: var(--surface-soft);
}

.primary-nav a.is-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 12px;
}

.user-menu span {
    color: var(--text);
    font-weight: 600;
}

/* SECTION: Page Layout */
.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 14px;
}

.eyebrow {
    margin: 0 0 3px;
    color: var(--primary);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 5px;
    font-size: 22px;
    line-height: 1.15;
}

h2 {
    margin-bottom: 3px;
    font-size: 14px;
}

.subtle,
.panel-header p {
    margin-bottom: 0;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.4;
}

.heading-actions {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.field-inline {
    display: grid;
    gap: 4px;
}

.field-inline span,
.label {
    color: var(--text-faint);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

select {
    height: 30px;
    min-width: 130px;
    padding: 0 28px 0 9px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    color: var(--text);
    background: var(--surface);
}

.status-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
    align-items: center;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.status-strip > div {
    display: grid;
    gap: 3px;
    padding: 10px 13px;
    border-right: 1px solid var(--border);
}

.status-strip > div:last-child {
    border-right: 0;
}

.status-strip strong {
    font-size: 12px;
}

.status-action {
    display: block !important;
    text-align: right;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 0.75fr);
    gap: 12px;
    margin-bottom: 12px;
}

/* SECTION: Components */
.metric-card,
.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.metric-card {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
}

.metric-label {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
}

.metric-value {
    font-size: 22px;
    line-height: 1;
}

.metric-detail {
    color: var(--text-faint);
    font-size: 10px;
}

.panel {
    min-width: 0;
    margin-bottom: 12px;
}

.dashboard-grid .panel {
    margin-bottom: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    padding: 11px 13px;
    border-bottom: 1px solid var(--border);
}

.panel-header > a {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 600;
}

.button {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    justify-content: center;
    padding: 0 11px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
}

.button:hover {
    text-decoration: none;
}

.button-primary {
    color: #ffffff;
    border-color: var(--primary);
    background: var(--primary);
}

.button-primary:hover {
    color: #ffffff;
    border-color: var(--primary-hover);
    background: var(--primary-hover);
}

.button-secondary {
    color: var(--text);
    border-color: var(--border-strong);
    background: var(--surface);
}

.button-secondary:hover {
    color: var(--text);
    background: var(--surface-muted);
}

.checklist {
    display: grid;
}

.checklist-item {
    display: grid;
    grid-template-columns: 24px 1fr;
    gap: 9px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}

.checklist-item:last-child {
    border-bottom: 0;
}

.checklist-item:hover {
    background: var(--surface-soft);
    text-decoration: none;
}

.check-icon {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    color: var(--primary);
    background: var(--surface);
    font-size: 10px;
    font-weight: 700;
}

.checklist-item strong,
.checklist-item small {
    display: block;
}

.checklist-item strong {
    margin-bottom: 2px;
    font-size: 11px;
}

.checklist-item small {
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1.35;
}

.empty-state {
    display: grid;
    justify-items: center;
    gap: 7px;
    padding: 24px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state strong {
    color: var(--text);
    font-size: 13px;
}

.status-neutral {
    display: inline-flex;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    background: var(--surface-muted);
    font-size: 10px;
}

/* SECTION: Tables */
.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

th,
td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

th {
    color: var(--text-muted);
    background: var(--surface-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover {
    background: var(--surface-soft);
}

.number {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* SECTION: Responsive */
@media (max-width: 1100px) {
    .topbar {
        grid-template-columns: 1fr auto;
    }

    .primary-nav {
        grid-column: 1 / -1;
        order: 3;
        width: 100%;
        height: 38px;
        border-top: 1px solid var(--border);
    }

    .primary-nav a {
        height: 38px;
    }

    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .page {
        padding: 14px 12px 22px;
    }

    .topbar {
        padding: 0 12px;
        gap: 12px;
    }

    .environment-badge,
    .user-menu span {
        display: none;
    }

    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .heading-actions {
        justify-content: flex-start;
    }

    .status-strip {
        grid-template-columns: 1fr;
    }

    .status-strip > div {
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .status-strip > div:last-child {
        border-bottom: 0;
    }

    .status-action {
        text-align: left;
    }

    .metric-grid {
        grid-template-columns: 1fr 1fr;
    }

    .footer {
        padding: 10px 12px;
    }
}

@media (max-width: 480px) {
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .heading-actions,
    .heading-actions .button,
    .field-inline,
    select {
        width: 100%;
    }

    .footer {
        flex-direction: column;
        gap: 3px;
    }
}
