/**
 * SimBC premium sports app shell — sidebar, topbar, shared tokens.
 */

:root {
    --bg-main: #070B12;
    --bg-sidebar: #0A101A;
    --bg-card: #101722;
    --bg-card-hover: #141D2B;
    --bg-elevated: #151E2E;
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(255, 106, 0, 0.35);
    --accent: #FF6A00;
    --accent-soft: rgba(255, 106, 0, 0.12);
    --accent-glow: rgba(255, 106, 0, 0.25);
    --text-primary: #E8EDF5;
    --text-secondary: #8B9BB4;
    --text-muted: #5C6B82;
    --success: #22C55E;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 20px;
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.35);
    --shadow-soft: 0 2px 12px rgba(0, 0, 0, 0.25);
    --sidebar-width: 248px;
}

.page-app {
    --bg: var(--bg-main);
    --bg-2: var(--bg-sidebar);
    --panel: var(--bg-card);
    --border: var(--border-subtle);
    --text: var(--text-primary);
    --muted: var(--text-secondary);
    --orange: var(--accent);
    --gold: #FFB347;
    --purple: #64748B;
    --purple-glow: #94A3B8;
}

.page-app body,
body.page-app {
    background: var(--bg-main);
    color: var(--text-primary);
}

.page-app a {
    color: var(--accent);
}

.page-app a:hover {
    color: #FF8533;
}

/* Country flags (inline) */
.country-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.country-flag {
    width: 20px;
    height: 14px;
    border-radius: 3px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.country-name {
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Layout */
.page-app .app-layout {
    display: block;
    min-height: 100vh;
}

.page-app .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    height: 100vh;
    z-index: 40;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    padding: 1.25rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    overflow-y: auto;
}

.page-app .app-main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-main);
}

.page-app .main-content {
    padding: 1rem 1.25rem 1.5rem;
}

/* Brand */
.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 0.35rem 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar__logo-mark {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent) 0%, #CC5500 100%);
    box-shadow: 0 0 16px var(--accent-glow);
    flex-shrink: 0;
}

.sidebar__brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.sidebar__logo {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

.sidebar__brand small {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
    font-weight: 600;
}

/* Nav */
.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.62rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
    border: 1px solid transparent;
}

.sidebar__link:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.sidebar__link.is-active {
    background: var(--accent-soft);
    color: var(--text-primary);
    border-color: var(--border-accent);
    box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar__link--admin {
    color: var(--accent);
    margin-top: 0.35rem;
}

.sidebar__link--muted {
    color: var(--text-muted) !important;
    font-size: 0.85rem;
}

.sidebar__link--indent {
    padding-left: 2.35rem;
}

.sidebar__link--indent .sidebar__icon {
    width: 16px;
    height: 16px;
    opacity: 0.85;
}

.sidebar__icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.85;
}

.sidebar__icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.sidebar__link.is-active .sidebar__icon {
    color: var(--accent);
    opacity: 1;
}

.sidebar__section-label {
    display: block;
    margin: 0.85rem 0 0.35rem 0.75rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}

/* Footer / user */
.sidebar__footer {
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-subtle);
}

.sidebar__user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.35rem;
}

.sidebar__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-accent);
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 800;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.sidebar__user-meta {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.sidebar__user-meta strong {
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar__user-meta a {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar__user-meta a:hover {
    color: var(--accent);
}

/* Topbar */
.page-app .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.5rem;
    background: rgba(7, 11, 18, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
}

.topbar__left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.topbar__toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
}

.topbar__toggle svg {
    width: 20px;
    height: 20px;
}

.topbar__season-block {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.topbar__season-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 600;
}

.topbar__season {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
}

.topbar__date-block {
    padding-left: 0.85rem;
    border-left: 1px solid var(--border-subtle);
}

.topbar__current-date {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.btn-advance {
    padding: 0.45rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn-advance:hover:not(:disabled):not(.is-loading) {
    border-color: var(--border-accent);
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.btn-advance:disabled,
.btn-advance.is-loading {
    opacity: 0.6;
    cursor: wait;
}

.btn-advance-primary {
    background: var(--accent);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 10px var(--accent-glow);
}

.btn-advance-primary:hover:not(:disabled):not(.is-loading) {
    background: #FF8533;
    color: #fff;
    border-color: transparent;
}

.topbar__stats {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.topbar__stat {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.45rem 0.85rem;
    min-width: 88px;
    box-shadow: var(--shadow-soft);
}

.topbar__stat span {
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.topbar__stat strong {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar__stat--ovr strong {
    font-size: 1.15rem;
    color: var(--accent);
}

.topbar__stat--money strong {
    color: var(--gold);
}

/* Backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 35;
    backdrop-filter: blur(2px);
}

.sidebar-backdrop.is-visible {
    display: block;
}

/* Buttons — aliases used across app pages */
.page-app .btn-primary,
.page-app .btn--primary {
    background: var(--accent);
    color: #fff;
    border: 1px solid transparent;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.page-app .btn-primary:hover,
.page-app .btn--primary:hover {
    background: #FF8533;
    color: #fff;
    transform: translateY(-1px);
}

.page-app .btn-ghost,
.page-app .btn--secondary {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.page-app .btn-ghost:hover,
.page-app .btn--secondary:hover {
    border-color: var(--border-accent);
    color: var(--text-primary);
}

/* Mobile */
@media (max-width: 960px) {
    .page-app .app-layout {
        grid-template-columns: 1fr;
    }

    .page-app .sidebar {
        display: flex !important;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }

    .page-app .sidebar.is-open {
        transform: translateX(0);
    }

    .page-app .app-main {
        margin-left: 0;
    }

    .topbar__toggle {
        display: inline-flex;
    }

    .page-app .topbar {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 0.65rem;
        padding: 0.75rem 1rem;
    }

    .topbar__left {
        flex: 1 1 100%;
        flex-wrap: wrap;
        gap: 0.55rem;
    }

    .topbar-actions {
        flex: 1 1 auto;
        min-width: 0;
    }

    .btn-advance {
        flex: 1 1 auto;
        min-width: 0;
        text-align: center;
    }

    .topbar__stats {
        flex: 1 1 100%;
        gap: 0.4rem;
        justify-content: stretch;
    }

    .topbar__stat {
        min-width: 72px;
        padding: 0.4rem 0.6rem;
        flex: 1 1 auto;
    }

    .topbar__stat span {
        font-size: 0.6rem;
    }

    .topbar__stat strong {
        font-size: 0.85rem;
    }
}

@media (max-width: 560px) {
    .page-app .main-content {
        padding: 1rem;
    }

    .topbar__stats {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    .topbar__stat--ovr {
        grid-column: span 1;
    }
}
