/* ============================================
   Shared app shell components

   These are the pieces every page reuses so pages stop reinventing their own
   layout: the page-header card, section labels, the instance selector row, the
   stat rail, data tables, and the responsible-gambling footer.

   Depends on the design tokens declared in styles.css :root.
   Load AFTER styles.css.
   ============================================ */

/* ---------- Logo lockup ---------- */
.logo .logo-wordmark {
    height: 30px;
    width: auto;
    max-width: none;
    object-fit: contain;
    vertical-align: middle;
    margin-right: var(--space-2);
}

.logo .logo-mark {
    display: none;
    height: 32px;
    width: 32px;
    object-fit: contain;
}

.logo .logo-text {
    font-size: var(--fs-xl);
    font-weight: 700;
    letter-spacing: -0.03em;
}

/* ---------- Sidebar section labels ---------- */
body.has-sidebar-shell .nav-section {
    list-style: none;
    padding: var(--space-4) var(--space-3) var(--space-1);
}

body.has-sidebar-shell .nav-section:first-child {
    padding-top: var(--space-2);
}

.nav-section-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--text-faint);
}

body.has-sidebar-shell.sidebar-collapsed .nav-section {
    padding: var(--space-3) 0 var(--space-1);
}

body.has-sidebar-shell.sidebar-collapsed .nav-section-label {
    /* Collapsed rail has no room for the label; keep a divider so grouping reads */
    height: 1px;
    overflow: hidden;
    text-indent: -999px;
    border-top: 1px solid var(--border-subtle);
    margin: 0 var(--space-4);
}

/* ---------- Live dot ---------- */
.nav-live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--live);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.16);
    margin-left: auto;
    flex-shrink: 0;
    animation: shellLivePulse 2s var(--ease) infinite;
}

@keyframes shellLivePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

.nav-link-external {
    margin-left: auto;
    display: inline-flex;
    opacity: 0.4;
    flex-shrink: 0;
}

.nav-link-external svg {
    width: 13px;
    height: 13px;
}

.nav-link:hover .nav-link-external {
    opacity: 0.85;
}

body.has-sidebar-shell.sidebar-collapsed .nav-link-external,
body.has-sidebar-shell.sidebar-collapsed .nav-live-dot {
    display: none;
}

/* Icons inside nav links */
.nav-link-icon svg {
    width: 18px;
    height: 18px;
}

/* ---------- Page header card ---------- */
.page-header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
    padding: var(--space-5) var(--space-6);
    margin-bottom: var(--space-6);
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

.page-header-icon {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--accent-dim);
    border: 1px solid var(--accent-border);
    color: var(--accent);
}

.page-header-icon svg {
    width: 22px;
    height: 22px;
}

.page-header-text {
    min-width: 0;
    flex: 1 1 240px;
}

.page-eyebrow {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: var(--space-1);
}

.page-title {
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
    margin: 0;
}

.page-subtitle {
    margin-top: var(--space-2);
    color: var(--text-muted);
    font-size: var(--fs-base);
}

.page-header-meta {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-left: auto;
}

/* ---------- Meta pills ---------- */
.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 6px var(--space-3);
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    white-space: nowrap;
}

.meta-pill.is-accent {
    color: var(--accent);
    background: var(--accent-dim);
    border-color: var(--accent-border);
}

.meta-pill.is-live {
    color: var(--live);
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.28);
}

.meta-pill.is-live::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--live);
    animation: shellLivePulse 2s var(--ease) infinite;
}

.meta-pill.is-muted {
    color: var(--text-muted);
}

/* ---------- Section label ---------- */
.section-label {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--text-faint);
    margin: var(--space-8) 0 var(--space-3);
}

.section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-subtle);
}

.section-label:first-child {
    margin-top: 0;
}

/* ---------- Panel / card ---------- */
.panel {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-5);
}

.panel:last-child {
    margin-bottom: 0;
}

.panel-title {
    font-size: var(--fs-md);
    font-weight: 650;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

/* ---------- Instance selector row ---------- */
.instance-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-bottom: var(--space-5);
}

.instance-select {
    flex: 1 1 260px;
    min-width: 0;
    padding: 10px var(--space-4);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    cursor: pointer;
    transition: border-color var(--dur) var(--ease);
}

.instance-select:hover {
    border-color: var(--border-strong);
}

.icon-btn {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.icon-btn:hover {
    color: var(--accent);
    border-color: var(--accent-border);
    background: var(--accent-dim);
}

.icon-btn svg {
    width: 16px;
    height: 16px;
}

/* ---------- Two-column body with stat rail ---------- */
.shell-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: var(--space-5);
    align-items: start;
}

.shell-rail {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    position: sticky;
    top: var(--space-5);
}

@media (max-width: 1000px) {
    .shell-split {
        grid-template-columns: minmax(0, 1fr);
    }

    .shell-rail {
        position: static;
    }
}

/* ---------- Stat rail ---------- */
.stat-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.stat-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-subtle);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-key {
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

.stat-value {
    font-family: var(--font-mono);
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.stat-value.is-accent { color: var(--accent); }
.stat-value.is-success { color: var(--success); }
.stat-value.is-danger { color: var(--danger); }

/* Horizontal stat strip */
.stat-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.stat-card {
    padding: var(--space-4);
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.stat-card-key {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: var(--space-2);
}

.stat-card-value {
    font-family: var(--font-mono);
    font-size: var(--fs-xl);
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.stat-card-value.is-accent { color: var(--accent); }

/* ---------- Data table ---------- */
.data-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    background: var(--surface-1);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-base);
}

.data-table th {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--text-faint);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.data-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr {
    transition: background var(--dur) var(--ease);
}

.data-table tbody tr:hover {
    background: var(--surface-1);
}

.data-table .num {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.data-table .rank {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-faint);
    width: 1%;
    white-space: nowrap;
}

.data-table .rank.is-1 { color: var(--accent); }
.data-table .rank.is-2 { color: #cfd3d8; }
.data-table .rank.is-3 { color: #c08457; }

.data-table .primary {
    color: var(--text-primary);
    font-weight: 550;
}

.data-table .sub {
    display: block;
    font-size: var(--fs-sm);
    color: var(--text-faint);
    margin-top: 2px;
}

/* ---------- Empty state ---------- */
.empty-state {
    padding: var(--space-12) var(--space-6);
    text-align: center;
    color: var(--text-muted);
}

.empty-state-icon {
    display: inline-flex;
    width: 46px;
    height: 46px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    color: var(--text-faint);
    margin-bottom: var(--space-4);
}

.empty-state-icon svg {
    width: 22px;
    height: 22px;
}

.empty-state-title {
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: var(--space-2);
}

.empty-state-text {
    font-size: var(--fs-base);
    max-width: 42ch;
    margin: 0 auto;
}

/* ---------- Buttons ---------- */
.btn-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 12px var(--space-5);
    border-radius: var(--radius);
    border: 1px solid var(--accent-border);
    background: var(--accent);
    color: var(--accent-contrast);
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.btn-cta:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-cta svg {
    width: 16px;
    height: 16px;
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 12px var(--space-5);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.btn-ghost:hover {
    border-color: var(--border-strong);
    background: var(--surface-3);
}

.btn-ghost svg {
    width: 16px;
    height: 16px;
}

/* ---------- Responsible gambling footer ---------- */
.site-footer {
    margin-top: var(--space-16);
    padding: var(--space-6) 0 var(--space-8);
    border-top: 1px solid var(--border-subtle);
}

.site-footer-inner {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-5);
    align-items: flex-start;
    justify-content: space-between;
}

.site-footer-copy {
    flex: 1 1 420px;
    max-width: 72ch;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.site-footer-note {
    font-size: var(--fs-sm);
    line-height: var(--lh);
    color: var(--text-faint);
    margin: 0;
}

.site-footer-note a {
    color: var(--text-muted);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.site-footer-note a:hover { color: var(--accent); }

.site-footer-note strong {
    display: block;
    color: var(--text-muted);
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    margin-bottom: var(--space-2);
}

.site-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    font-size: var(--fs-sm);
}

.site-footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--dur) var(--ease);
}

.site-footer-links a:hover {
    color: var(--accent);
}

/* ---------- Utilities ---------- */
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-accent { color: var(--accent); }
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
