/* ================================================================
   Female Fight Manager — Master Stylesheet
   Premium dark-mode glassmorphism UI
   ================================================================ */

:root {
    /* ── Color Palette ── */
    --bg-dark: #08080b;
    --bg-surface: #101014;
    --bg-panel: rgba(16, 16, 22, 0.8);
    --bg-panel-hover: rgba(28, 28, 38, 0.9);
    --bg-panel-solid: #13131a;
    --border-glass: rgba(255, 255, 255, 0.07);
    --border-subtle: rgba(255, 255, 255, 0.04);

    --text-main: #e2e2e8;
    --text-muted: #9a9aaa;
    --text-dim: #8a8a9a;
    --accent: #FF3366;
    --accent-soft: #ff336622;
    --accent-glow: rgba(255, 51, 102, 0.25);
    --gold: #d4af37;
    --gold-soft: rgba(212, 175, 55, 0.15);
    --green: #00e676;
    --red: #ff5252;

    /* Club Colors */
    --club-crimson: #8B0000;
    --club-neon: #6A0DAD;
    --club-iron: #4682B4;
    --club-golden: #FFD700;
    --club-obsidian: #1C1C1C;
    --club-wildfire: #FF6600;
    --club-velvet: #C71585;
    --club-storm: #708090;

    /* Typography */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Spacing */
    --nav-width: 260px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
}

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    overflow: hidden;
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(255, 51, 102, 0.04), transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(106, 13, 173, 0.04), transparent 50%);
    height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Utilities ── */
.font-outfit { font-family: var(--font-heading); }

.text-gradient {
    background: linear-gradient(135deg, #fff 0%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hidden { display: none !important; }

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
}

/* ── Layout ── */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ================================================================
   SIDEBAR NAVIGATION
   ================================================================ */
#main-nav {
    width: var(--nav-width);
    height: 100%;
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    padding: 1.2rem 0.8rem;
    background: var(--bg-surface);
    z-index: 10;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
}

/* ── Branding ── */
.nav-branding {
    padding: 0 0.6rem;
    margin-bottom: 0.4rem;
}

.nav-branding h1 {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.season-badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    background: var(--accent-soft);
    border: 1px solid rgba(255, 51, 102, 0.15);
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.6rem;
    letter-spacing: 0.02em;
}

/* ── Nav Groups ── */
.nav-links {
    list-style: none;
    margin-bottom: auto;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.nav-group {
    margin-bottom: 0.2rem;
}

.nav-group-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.6rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
    border-radius: var(--radius-sm);
    transition: color 0.2s;
}

.nav-group-label:hover {
    color: var(--text-muted);
}

.nav-group-label .chevron {
    font-size: 0.55rem;
    transition: transform 0.25s ease;
    opacity: 0.5;
}

.nav-group.collapsed .chevron {
    transform: rotate(-90deg);
}

.nav-group-items {
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.3s ease, opacity 0.25s ease;
    opacity: 1;
    padding-left: 0.3rem;
}

.nav-group.collapsed .nav-group-items {
    max-height: 0;
    opacity: 0;
}

/* ── Nav Items ── */
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.6rem 0.4rem 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    margin-bottom: 1px;
    position: relative;
}

.nav-item .nav-icon {
    font-size: 0.9rem;
    width: 1.2rem;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-item:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
    color: #fff;
    background: var(--accent-soft);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

/* Special item tints */
.nav-item[data-route="underground"] { color: #e05555; }
.nav-item[data-route="underground"]:hover { color: #ff5252; background: rgba(255, 82, 82, 0.06); }
.nav-item[data-route="underground"].active { color: #ff5252; background: rgba(255, 82, 82, 0.12); }
.nav-item[data-route="underground"].active::before { background: #ff5252; }

.nav-item[data-route="sponsors"] { color: #b8962e; }
.nav-item[data-route="sponsors"]:hover { color: var(--gold); background: var(--gold-soft); }
.nav-item[data-route="sponsors"].active { color: var(--gold); background: var(--gold-soft); }
.nav-item[data-route="sponsors"].active::before { background: var(--gold); }

/* ── Resources ── */
.nav-resources {
    background: rgba(0, 0, 0, 0.25);
    border-radius: var(--radius-md);
    padding: 0.7rem 0.8rem;
    margin: 0.5rem 0;
    border: 1px solid var(--border-glass);
}

.resource-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.15rem 0;
    font-size: 0.78rem;
}

.resource-item + .resource-item {
    margin-top: 0.2rem;
}

.res-label {
    color: var(--text-dim);
    font-weight: 500;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.res-value {
    font-weight: 700;
    color: #fff;
    font-family: var(--font-heading);
    font-size: 0.85rem;
}

.resource-item.highlight .res-value {
    color: var(--accent);
    text-shadow: 0 0 8px var(--accent-glow);
}

/* ── Advance Week Button ── */
.btn-advance {
    padding: 0.7rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), #e62e5c);
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 12px var(--accent-glow);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    width: 100%;
}

.btn-advance:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(255, 51, 102, 0.4);
    filter: brightness(1.1);
}

.btn-advance:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px var(--accent-glow);
}

/* ── Nav Divider ── */
.nav-divider {
    height: 1px;
    background: var(--border-glass);
    margin: 0.4rem 0.6rem;
}

/* ================================================================
   MAIN CONTENT AREA
   ================================================================ */
#main-view {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding: 1.8rem 2.2rem;
    background: var(--bg-dark);
}

/* ── Glassmorphism Panel ── */
.glass-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

.glass-panel.hoverable {
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.glass-panel.hoverable:hover {
    transform: translateY(-2px);
    background: var(--bg-panel-hover);
    border-color: rgba(255, 255, 255, 0.1);
}

/* ── Buttons ── */
.btn-primary {
    padding: 0.7rem 1.4rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.88rem;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), #e62e5c);
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 18px rgba(255, 51, 102, 0.45);
    filter: brightness(1.08);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
    color: #fff;
}

/* ── Screens ── */
.view-screen {
    display: none;
}

.view-screen.active {
    display: block;
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Section Headers ── */
.section-header {
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.7rem;
    letter-spacing: -0.02em;
}

.section-header p {
    font-size: 0.88rem;
    margin-top: 0.2rem;
}

/* ── Loader ── */
.loader { text-align: center; }

.spinner {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border-glass);
    border-top: 2px solid var(--accent);
    border-radius: 50%;
    margin: 1.5rem auto 0;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ── Tables (used in roster, league, etc.) ── */
table {
    border-collapse: collapse;
    width: 100%;
}

table th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    font-weight: 600;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border-glass);
    text-align: left;
}

table td {
    padding: 0.5rem 0.8rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.85rem;
}

table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* ── Stat Bar utility ── */
.stat-bar-track {
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* ── Responsive: tablet ── */
@media (max-width: 1200px) {
    #main-nav { width: 220px; }
    :root { --nav-width: 220px; }
    #main-view { padding: 1.5rem; }
}

/* ── Tooltip System ── */
[data-tooltip] {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted var(--text-muted);
}
[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(8, 8, 12, 0.96);
    color: var(--text-main);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.78rem;
    line-height: 1.4;
    white-space: normal;
    width: max-content;
    max-width: 260px;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(255, 51, 102, 0.2);
    animation: tooltipFade 0.15s ease-out;
}
[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--accent);
    z-index: 9999;
    pointer-events: none;
}
@keyframes tooltipFade {
    from { opacity: 0; transform: translateX(-50%) translateY(4px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Responsive: mobile / small tablet ── */
@media (max-width: 900px) {
    .app-container { flex-direction: column; }
    #main-nav {
        width: 100%;
        height: auto;
        max-height: 40vh;
        overflow-y: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-glass);
        padding: 0.5rem;
    }
    #main-nav .nav-header { padding: 0.5rem; }
    #main-nav .nav-group-label { font-size: 0.7rem; padding: 0.3rem 0.5rem; }
    #main-nav .nav-item { padding: 0.5rem 0.8rem; font-size: 0.85rem; }
    #main-view { padding: 1rem; }

    /* Force single-column grids on mobile */
    .dashboard-grid,
    [style*="grid-template-columns: 1fr 1fr"],
    [style*="grid-template-columns: 2fr 1fr"],
    [style*="grid-template-columns: repeat(4"] {
        display: flex !important;
        flex-direction: column !important;
    }

    /* Tables: horizontal scroll wrapper */
    table { display: block; overflow-x: auto; white-space: nowrap; }
    table th, table td { padding: 0.5rem 0.6rem; font-size: 0.8rem; }

    /* Section headers */
    .section-header h2 { font-size: 1.3rem; }

    /* Panels */
    .glass-panel { padding: 0.8rem; }

    /* Buttons */
    .btn-primary, .btn-secondary { min-height: 44px; font-size: 0.9rem; }

    /* Tabs: horizontal scroll */
    .tabs, [style*="display: flex; gap: 15px; border-bottom"] {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
        padding-bottom: 8px;
    }
    .tabs button, [style*="border-bottom"] button {
        flex-shrink: 0;
        font-size: 0.8rem !important;
        padding: 8px 14px !important;
    }

    /* Modal */
    .modal-overlay .modal-content,
    [style*="max-width: 780px"],
    [style*="max-width: 700px"] {
        max-width: 95vw !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
        margin: 1rem !important;
    }

    /* Stat bars */
    .stat-bar { height: 4px; }

    /* Fight log */
    #match-log, [id*="match-log"] {
        font-size: 0.82rem;
        max-height: 50vh;
    }
}

/* ── Responsive: phone ── */
@media (max-width: 480px) {
    body { font-size: 14px; }
    #main-view { padding: 0.6rem; }
    #main-nav { max-height: 35vh; }

    h1 { font-size: 1.4rem !important; }
    h2 { font-size: 1.2rem !important; }
    h3 { font-size: 1rem !important; }

    /* Start screen */
    #start-screen { padding: 1rem; }
    #start-screen h1 { font-size: 1.5rem !important; }

    /* Advance week button */
    #btn-advance-week {
        font-size: 0.85rem;
        padding: 0.6rem 1rem;
    }

    /* Resource bar */
    .resource-bar, #resource-bar {
        flex-wrap: wrap;
        gap: 0.3rem;
        font-size: 0.75rem;
    }

    /* Fighter cards */
    .glass-panel.hoverable { padding: 0.6rem; }

    /* Tooltip: position below on mobile (above can clip) */
    [data-tooltip]:hover::after {
        bottom: auto;
        top: calc(100% + 8px);
        max-width: 200px;
        font-size: 0.72rem;
    }
    [data-tooltip]:hover::before {
        bottom: auto;
        top: calc(100% + 2px);
        border-top-color: transparent;
        border-bottom-color: var(--accent);
    }
}