/* =========================================================
   WarRoom — Dark-mode, mobile-first CSS
   ========================================================= */

:root {
    --bg:          #0d0d0f;
    --surface:     #1a1a1f;
    --surface-2:   #24242c;
    --border:      #2e2e3a;
    --accent:      #5b8dee;
    --accent-dim:  #3a5faa;
    --success:     #2ecc71;
    --warning:     #f39c12;
    --danger:      #e74c3c;
    --text:        #e8e8f0;
    --text-muted:  #7a7a99;
    --radius:      6px;
    --radius-lg:   10px;
    --chain-h:     8px;
    --transition:  0.3s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    min-height: 100vh;
}

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

/* ── Site Header ────────────────────────────────────────── */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.5rem 1rem 0;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.4rem;
}

.faction-name {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chain-summary {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.chain-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    text-transform: uppercase;
}

.chain-count {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    min-width: 3ch;
    text-align: right;
}

.chain-timer {
    font-size: 1.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--success);
    min-width: 5ch;
    text-align: right;
    transition: color var(--transition);
}

/* ── Chain Bar ──────────────────────────────────────────── */
#chain-bar-wrap {
    height: var(--chain-h);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
}

.chain-bar {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    transition: width 0.6s ease, background-color var(--transition);
    will-change: width;
}

.chain-bar.green,
.progress-bar.green { background: var(--success); }

.chain-bar.yellow,
.progress-bar.yellow { background: var(--warning); }

.chain-bar.red-flash,
.progress-bar.red-flash {
    background: var(--danger);
    animation: redFlash 0.7s step-start infinite;
}

.chain-timer.red-flash {
    color: var(--danger);
    animation: redFlash 0.7s step-start infinite;
}

@keyframes redFlash {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.25; }
}

/* ── Tab Navigation ─────────────────────────────────────── */
.tab-nav {
    display: flex;
    overflow-x: auto;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.tab-nav::-webkit-scrollbar { display: none; }

.tab-link {
    flex-shrink: 0;
    padding: 0.65rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 2px solid transparent;
    transition: color var(--transition), border-color var(--transition);
    white-space: nowrap;
}

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

.tab-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ── Content Wrapper ────────────────────────────────────── */
.content-wrap {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* ── Tab Sections ───────────────────────────────────────── */
.tab-section { padding: 0.25rem 0; }

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}

/* ── Stat Cards Grid ────────────────────────────────────── */
.chain-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.875rem 1rem;
    text-align: center;
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.stat-value.mono  { font-variant-numeric: tabular-nums; }
.stat-value.accent { color: var(--accent); }
.stat-value.green  { color: var(--success); }
.stat-value.yellow { color: var(--warning); }
.stat-value.red-flash {
    color: var(--danger);
    animation: redFlash 0.7s step-start infinite;
}

/* ── Chain Goal Progress ────────────────────────────────── */
.chain-goal-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.875rem 1rem;
    margin-bottom: 0.75rem;
}

.goal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.goal-header strong { color: var(--text); }

.progress-wrap {
    height: 10px;
    background: var(--surface-2);
    border-radius: 99px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: inherit;
    transition: width 0.6s ease, background-color var(--transition);
    min-width: 2px;
    background: var(--success);
}

/* ── Chain Meta Pills ───────────────────────────────────── */
.chain-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.meta-pill {
    font-size: 0.7rem;
    padding: 0.15rem 0.55rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 99px;
    color: var(--text-muted);
}

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    border-left: 3px solid;
}

.alert-danger  { background: rgba(231,76,60,0.1);  border-color: var(--danger);  color: #f5a5a0; }
.alert-info    { background: rgba(91,141,238,0.1); border-color: var(--accent);  color: #a8bfee; }
.alert-success { background: rgba(46,204,113,0.1); border-color: var(--success); color: #a0e8bb; }
.alert-warning { background: rgba(243,156,18,0.1); border-color: var(--warning); color: #f5d08a; }

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

thead th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.55rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

td {
    padding: 0.55rem 0.75rem;
    color: var(--text);
    vertical-align: middle;
}

.input-with-btn {
    display: flex;
    gap: 0.5rem;
}

.input-with-btn input {
    flex: 1;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.player-brief {
    background: var(--surface-2);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    border-left: 3px solid var(--accent);
}

.flex-gap {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ── Status Badges ──────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.badge-okay      { background: rgba(46,204,113,0.15);  color: var(--success); }
.badge-hospital  { background: rgba(231,76,60,0.15);   color: var(--danger);  }
.badge-traveling { background: rgba(91,141,238,0.15);  color: var(--accent);  }
.badge-offline   { background: rgba(122,122,153,0.15); color: var(--text-muted); }

/* ── Forms & Inputs ─────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    transition: border-color var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}

select option { background: var(--surface-2); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.55rem 1.1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), opacity var(--transition);
    white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary  { background: var(--accent);     color: #fff; }
.btn-primary:hover { background: var(--accent-dim); }
.btn-danger   { background: var(--danger);     color: #fff; }
.btn-success  { background: var(--success);    color: #000; }
.btn-ghost    { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm       { padding: 0.3rem 0.7rem; font-size: 0.78rem; }

/* ── Site Footer ─────────────────────────────────────────── */
.site-footer {
    text-align: center;
    padding: 1.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* ── Utilities ───────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mono { font-variant-numeric: tabular-nums; }

/* ── Assignment row states ───────────────────────────────── */
tr.row-hospital {
    background: rgba(46, 204, 113, 0.07);
}

tr.row-hospital:hover {
    background: rgba(46, 204, 113, 0.13);
}

tr.row-offline {
    opacity: 0.55;
}

tr.row-offline:hover {
    opacity: 0.75;
}

/* ── Mobile-only overrides (< 480px) ─────────────────────── */
@media (max-width: 479px) {
    .chain-stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .content-wrap {
        padding: 0.75rem;
    }

    .section-title {
        font-size: 1rem;
    }

    .tab-link {
        padding: 0.55rem 0.7rem;
        font-size: 0.72rem;
    }

    .btn {
        padding: 0.5rem 0.85rem;
        font-size: 0.82rem;
    }

    .faction-name {
        font-size: 0.85rem;
    }

    .chain-count,
    .chain-timer {
        font-size: 0.95rem;
    }

    table {
        font-size: 0.78rem;
    }

    thead th {
        font-size: 0.65rem;
        padding: 0.45rem 0.5rem;
    }

    td {
        padding: 0.45rem 0.5rem;
    }

    .form-row-inline {
        flex-direction: column;
    }

    .form-row-inline > * {
        width: 100%;
    }

    .assign-select {
        min-width: 100px;
    }

    .assign-notes {
        min-width: 80px;
    }

    .goal-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }

    .chain-meta {
        gap: 0.3rem;
    }

    .meta-pill {
        font-size: 0.65rem;
    }

    .header-top {
        gap: 0.5rem;
    }

    .chain-summary {
        gap: 0.25rem;
    }
}

/* ── Tablet & Desktop breakpoint ─────────────────────────── */
@media (min-width: 768px) {
    .content-wrap { padding: 1.5rem 2rem; }

    .chain-stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .tab-link {
        padding: 0.75rem 1.25rem;
        font-size: 0.85rem;
    }
}

/* ── Dashboard Shell ─────────────────────────────────────── */
.dashboard-shell {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    max-width: 1400px;
    margin: 0 auto;
}

.sidebar {
    width: 230px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: sticky;
    top: 88px;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sidebar::-webkit-scrollbar { display: none; }

.main-area {
    flex: 1;
    min-width: 0;
}

.dashboard-shell .content-wrap {
    max-width: none;
    margin: 0;
    padding: 0;
}

/* ── Widget Base ─────────────────────────────────────────── */
.widget {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.widget-header {
    padding: 0.45rem 0.75rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.widget-body {
    padding: 0.75rem;
}

.widget-empty {
    font-size: 0.8rem;
    margin: 0;
}

/* ── Branding Widget ─────────────────────────────────────── */
.widget-branding-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.4rem;
    padding: 1rem 0.75rem;
}

.faction-logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border-radius: var(--radius);
}

.faction-logo-placeholder {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    background: var(--surface-2);
    border: 2px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.05em;
}

.faction-brand-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.faction-brand-sub {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* ── Leadership Corner Widget ────────────────────────────── */
.directive-body {
    font-size: 0.82rem;
    color: var(--text);
    line-height: 1.55;
    margin-bottom: 0.5rem;
}

.directive-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.directive-date {
    display: block;
    font-size: 0.7rem;
    font-style: normal;
    margin-top: 0.1rem;
}

/* ── Mug Watch Widget ────────────────────────────────────── */
.mugwatch-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.mugwatch-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}

.mugwatch-name {
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.mugwatch-view-all {
    width: 100%;
    text-align: center;
}

.badge-warning {
    background: rgba(243,156,18,0.15);
    color: var(--warning);
}

/* ── Sidebar — mobile (collapses to horizontal scroll row) ── */
@media (max-width: 767px) {
    .dashboard-shell {
        flex-direction: column;
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .sidebar {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: visible;
        position: static;
        max-height: none;
        gap: 0.5rem;
        padding-bottom: 0.25rem;
    }

    .sidebar .widget {
        min-width: 190px;
        flex-shrink: 0;
    }
}
