/* =============================================================================
   styles.css – Premium Design System for RTP Basketball Analytics

   Palette: Dark navy (#0b1120) with cyan/turquoise accents
   Effects: Glassmorphism, micro-animations, soft gradients
   ============================================================================= */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* =============================================================================
   CSS Variables (Design Tokens)
   ============================================================================= */
:root {
    /* Primary colors – Navy deep */
    --bg-primary: #0b1120;
    --bg-secondary: #111a2e;
    --bg-tertiary: #162040;
    --bg-card: rgba(17, 26, 46, 0.85);
    --bg-card-hover: rgba(22, 32, 64, 0.9);
    --bg-input: rgba(11, 17, 32, 0.8);

    /* Glassmorphism */
    --glass-bg: rgba(17, 26, 46, 0.6);
    --glass-border: rgba(56, 189, 248, 0.12);
    --glass-blur: 16px;

    /* Accents */
    --accent-primary: #38bdf8;       /* Cyan/Sky */
    --accent-secondary: #818cf8;     /* Light indigo */
    --accent-success: #34d399;       /* Emerald */
    --accent-warning: #fbbf24;       /* Amber */
    --accent-danger: #f87171;        /* Coral red */
    --accent-purple: #a78bfa;        /* Violet */
    --accent-orange: #fb923c;        /* Orange */

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #38bdf8, #818cf8);
    --gradient-success: linear-gradient(135deg, #34d399, #38bdf8);
    --gradient-warm: linear-gradient(135deg, #fbbf24, #f87171);
    --gradient-bg: linear-gradient(180deg, #0b1120 0%, #111a2e 50%, #0c1322 100%);

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-accent: #38bdf8;

    /* Borders and shadows */
    --border-color: rgba(56, 189, 248, 0.08);
    --border-active: rgba(56, 189, 248, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.12);

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Rounded corners */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gradient-bg);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Background with a subtle pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(56, 189, 248, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(129, 140, 248, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* =============================================================================
   Main Layout
   ============================================================================= */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-xl);
    min-height: 100vh;
}

/* =============================================================================
   Header
   ============================================================================= */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-xl);
    margin-bottom: var(--space-xl);
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.app-header__logo {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.app-header__logo-img {
    height: 40px;
    width: auto;
}

.app-header__title {
    font-size: 1.25rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.app-header__subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Header action buttons */
.app-header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.header-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.header-btn--back:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.header-btn--logout:hover {
    border-color: rgba(248, 113, 113, 0.4);
    color: var(--accent-danger);
    background: rgba(248, 113, 113, 0.08);
}

/* =============================================================================
   Tab Navigation
   ============================================================================= */
.tabs-nav {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-xl);
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xs);
}

.tab-btn {
    flex: 1;
    padding: var(--space-md) var(--space-lg);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    position: relative;
    overflow: hidden;
}

.tab-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity var(--transition-base);
    border-radius: inherit;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn:hover::before {
    opacity: 0.06;
}

.tab-btn.active {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    box-shadow: var(--shadow-sm), var(--shadow-glow);
    border: 1px solid var(--border-active);
}

.tab-btn.active::before {
    opacity: 0.1;
}

.tab-btn__icon {
    font-size: 1.1rem;
}

/* Tab content */
.tab-content {
    display: none;
    animation: fadeSlideIn 0.35s ease-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =============================================================================
   Panels / Cards
   ============================================================================= */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
}

.panel:hover {
    border-color: rgba(56, 189, 248, 0.18);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.panel__title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-primary);
}

.panel__title-icon {
    font-size: 1.3rem;
}

/* =============================================================================
   Scraping Form
   ============================================================================= */
.scraping-form {
    display: flex;
    gap: var(--space-md);
    align-items: stretch;
}

.input-group {
    flex: 1;
    position: relative;
}

.input-field {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
    outline: none;
}

.input-field::placeholder {
    color: var(--text-muted);
}

.input-field:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

/* =============================================================================
   Buttons
   ============================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 25px rgba(56, 189, 248, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

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

.btn-danger {
    background: transparent;
    color: var(--accent-danger);
    border: 1px solid rgba(248, 113, 113, 0.3);
    padding: var(--space-sm) var(--space-md);
    font-size: 0.8rem;
}

.btn-danger:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: var(--accent-danger);
}

/* =============================================================================
   Player Table
   ============================================================================= */
.players-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: var(--space-lg);
}

.players-table thead th {
    padding: var(--space-md) var(--space-lg);
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.players-table tbody tr {
    transition: all var(--transition-fast);
}

.players-table tbody tr:hover {
    background: rgba(56, 189, 248, 0.03);
}

.players-table tbody td {
    padding: var(--space-md) var(--space-lg);
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(56, 189, 248, 0.05);
    vertical-align: middle;
}

.player-name {
    font-weight: 600;
    color: var(--text-primary);
}

.player-team {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.player-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 2px 10px;
    background: rgba(56, 189, 248, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.15);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    color: var(--accent-primary);
    font-weight: 500;
}

/* =============================================================================
   KPI Cards
   ============================================================================= */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kpi-card--cyan::before { background: var(--gradient-primary); }
.kpi-card--green::before { background: var(--gradient-success); }
.kpi-card--purple::before { background: linear-gradient(135deg, #a78bfa, #818cf8); }
.kpi-card--amber::before { background: var(--gradient-warm); }
.kpi-card--red::before { background: linear-gradient(135deg, #f87171, #dc2626); }

.kpi-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-active);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.kpi-card__label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.kpi-card__value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: var(--space-xs);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.kpi-card__detail {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.kpi-card__detail span {
    color: var(--text-accent);
    font-weight: 600;
}

/* =============================================================================
   Filters Section
   ============================================================================= */
.filters-bar {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: var(--space-xl);
    padding: var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    min-width: 180px;
}

.filter-group--wide {
    flex: 1;
    min-width: 250px;
}

.filter-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.filter-select {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.filter-select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

.filter-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* =============================================================================
   Chart
   ============================================================================= */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    margin-top: var(--space-lg);
    box-shadow: var(--shadow-md);
}

.chart-container__title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

#densityChart {
    width: 100%;
    min-height: 400px;
}

/* =============================================================================
   Toast Notifications
   ============================================================================= */
.toast-container {
    position: fixed;
    top: var(--space-xl);
    right: var(--space-xl);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-tertiary);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 320px;
    max-width: 450px;
    animation: toastSlideIn 0.35s ease-out;
    transition: all var(--transition-base);
}

.toast--success { border-left: 3px solid var(--accent-success); }
.toast--error { border-left: 3px solid var(--accent-danger); }
.toast--info { border-left: 3px solid var(--accent-primary); }

.toast__icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.toast__message {
    font-size: 0.85rem;
    color: var(--text-primary);
    flex: 1;
}

.toast__close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: var(--space-xs);
    transition: color var(--transition-fast);
}

.toast__close:hover {
    color: var(--text-primary);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast--exit {
    animation: toastSlideOut 0.3s ease-in forwards;
}

@keyframes toastSlideOut {
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

/* =============================================================================
   Loading / Spinner
   ============================================================================= */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 17, 32, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    gap: var(--space-lg);
    animation: fadeIn 0.2s ease-out;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid rgba(56, 189, 248, 0.15);
    border-top-color: var(--accent-primary);
    animation: spin 0.8s linear infinite;
}

.loading-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* =============================================================================
   Empty State
   ============================================================================= */
.empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-xl);
    color: var(--text-muted);
}

.empty-state__icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.empty-state__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.empty-state__text {
    font-size: 0.85rem;
    line-height: 1.5;
}

/* =============================================================================
   Grouped KPI Section
   ============================================================================= */
.kpi-section {
    margin-bottom: var(--space-lg);
}

.kpi-section__title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-section__title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* =============================================================================
   Responsive
   ============================================================================= */
@media (max-width: 768px) {
    .app-container {
        padding: var(--space-md);
    }

    .app-header {
        flex-direction: column;
        gap: var(--space-sm);
        text-align: center;
        padding: var(--space-md);
    }

    .app-header__actions {
        width: 100%;
        justify-content: center;
    }

    .tabs-nav {
        flex-direction: column;
    }

    .scraping-form {
        flex-direction: column;
    }

    .filters-bar {
        flex-direction: column;
    }

    .filter-group {
        min-width: 100%;
    }

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

    .kpi-card__value {
        font-size: 1.4rem;
    }
}

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

/* ==========================================================================
   Modals
   ========================================================================== */

.modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(11, 17, 32, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal__content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform var(--transition-normal);
}

.modal.active .modal__content {
    transform: translateY(0);
}

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.modal__header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal__close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color var(--transition-fast);
}

.modal__close:hover {
    color: var(--text-primary);
}

.modal__body {
    padding: var(--space-lg);
}

.users-controls {
    margin-bottom: var(--space-md);
    display: flex;
    justify-content: flex-end;
}

.user-form-container {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px dashed var(--border-color);
}

.user-form-container h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.user-form-container.hidden {
    display: none;
}

/* =============================================================================
   Comparison Table
   ============================================================================= */

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: var(--space-sm) var(--space-md);
    font-size: 0.82rem;
}

.btn-secondary:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
    background: rgba(56, 189, 248, 0.06);
}

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

/* --- Multiselect --- */
.multiselect {
    position: relative;
}

.multiselect__toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.multiselect__toggle:hover,
.multiselect.open .multiselect__toggle {
    border-color: var(--accent-primary);
}

.multiselect__toggle span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.multiselect__arrow {
    color: var(--text-muted);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.multiselect__panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 40;
    max-height: 280px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-sm);
}

.multiselect__panel.hidden {
    display: none;
}

.multiselect__option {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: background var(--transition-fast);
}

.multiselect__option:hover {
    background: rgba(56, 189, 248, 0.06);
    color: var(--text-primary);
}

.multiselect__option input[type="checkbox"] {
    accent-color: var(--accent-primary);
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.multiselect__panel-actions {
    display: flex;
    justify-content: space-between;
    padding: var(--space-xs) var(--space-sm) var(--space-sm);
    margin-bottom: var(--space-xs);
    border-bottom: 1px solid var(--glass-border);
}

.multiselect__panel-actions button {
    background: none;
    border: none;
    color: var(--accent-primary);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 4px;
}

.multiselect__panel-actions button:hover {
    text-decoration: underline;
}

/* --- Segmented control (aggregation mode / color) --- */
.segmented {
    display: inline-flex;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 3px;
    gap: 2px;
}

.segmented__btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    padding: var(--space-xs) var(--space-sm);
    border-radius: calc(var(--radius-sm) - 2px);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.segmented__btn:hover {
    color: var(--text-primary);
}

.segmented__btn.active {
    background: var(--gradient-primary);
    color: white;
}

.comparativa-actions__buttons {
    display: flex;
    gap: var(--space-sm);
}

/* --- Table --- */
.comparativa-table-scroll {
    overflow-x: auto;
    margin-top: var(--space-md);
}

.comparativa-table-scroll.hidden {
    display: none;
}

.comparativa-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.82rem;
}

.comparativa-table thead th {
    padding: var(--space-sm) var(--space-md);
    text-align: right;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 2;
}

.comparativa-table thead th:first-child,
.comparativa-table tbody td:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--bg-secondary);
    min-width: 220px;
}

.comparativa-table tbody td:first-child {
    /* Opaque on purpose: --bg-card has alpha (rgba .85) and horizontal
       scrolling let the content of the columns beneath this fixed column
       show through. --bg-secondary is a solid color. */
    background: var(--bg-secondary);
}

.comparativa-table tbody td {
    padding: var(--space-sm) var(--space-md);
    text-align: right;
    border-bottom: 1px solid rgba(56, 189, 248, 0.05);
    white-space: nowrap;
    color: var(--text-primary);
    transition: background-color var(--transition-fast);
}

.comparativa-row--player {
    font-weight: 600;
}

.comparativa-row--player:hover td {
    background-color: rgba(56, 189, 248, 0.03);
}

.comparativa-row--comp td {
    color: var(--text-secondary);
    font-weight: 400;
}

.comparativa-row--comp.disabled td {
    opacity: 0.35;
}

.comparativa-row--comp.hidden {
    display: none;
}

/* Season sub-rows: same styles as competition */
.comparativa-row--season td {
    color: var(--text-secondary);
    font-weight: 400;
}

.comparativa-row--season.disabled td {
    opacity: 0.35;
}

.comparativa-row--season.hidden {
    display: none;
}

/* Hide the inactive filter multiselect */
.cmp-filter-hidden {
    display: none !important;
}

.comparativa-player-cell {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.comparativa-expand-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.7rem;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

.comparativa-expand-btn.expanded {
    transform: rotate(90deg);
}

/* --- Editable name --- */
.comparativa-name-input {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: inherit;
    font-weight: 600;
    padding: 3px 6px;
    min-width: 0;
    flex: 1;
}

.comparativa-name-input:hover:not([readonly]) {
    border-color: var(--glass-border);
}

.comparativa-name-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-input);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

.comparativa-name-input[readonly] {
    cursor: default;
}

/* --- Sortable headers --- */
.comparativa-sortable {
    cursor: pointer;
    user-select: none;
    transition: color var(--transition-fast);
}

.comparativa-sortable:hover {
    color: var(--accent-primary);
}

.comparativa-sort-arrow {
    color: var(--accent-primary);
    font-size: 0.65rem;
}

/* Season context and legend: only shown when exporting to PDF (print) */
.comparativa-print-context,
.comparativa-legend {
    display: none;
}

.comparativa-comp-cell {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding-left: 26px;
}

.comparativa-comp-cell input[type="checkbox"] {
    accent-color: var(--accent-primary);
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.comparativa-remove-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px 4px;
    margin-left: auto;
}

.comparativa-remove-btn:hover {
    color: var(--accent-danger);
}

.comparativa-sd {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.comparativa-dash {
    color: var(--text-muted);
}

/* Comment cell */
.comparativa-comment-cell {
    text-align: left;
    min-width: 260px;
    white-space: normal;
}

.comparativa-comment-scope {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-bottom: var(--space-xs);
}

.comparativa-comment-scope select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.72rem;
    padding: 2px 6px;
}

.comparativa-comment-textarea {
    width: 100%;
    min-height: 46px;
    resize: vertical;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.8rem;
    padding: var(--space-xs) var(--space-sm);
}

.comparativa-comment-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.comparativa-comment-save {
    margin-top: var(--space-xs);
    background: none;
    border: 1px solid var(--border-color);
    color: var(--accent-primary);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.comparativa-comment-save:hover {
    background: rgba(56, 189, 248, 0.08);
}

.comparativa-comment-save.saved {
    color: var(--accent-success);
    border-color: var(--accent-success);
}

/* --- Print / Export PDF --- */
@media print {
    body.print-comparativa-only .login-screen,
    body.print-comparativa-only .welcome-screen,
    body.print-comparativa-only .module-selector,
    body.print-comparativa-only .toast-container,
    body.print-comparativa-only .loading-overlay,
    body.print-comparativa-only .app-header,
    body.print-comparativa-only .tabs-nav,
    body.print-comparativa-only #comparativaFiltersBar,
    body.print-comparativa-only #tab-gestion,
    body.print-comparativa-only #tab-analytics,
    body.print-comparativa-only #comparativaEmptyState {
        display: none !important;
    }

    body.print-comparativa-only {
        background: #ffffff !important;
    }

    body.print-comparativa-only #mainApp {
        display: block !important;
        background: #ffffff !important;
    }

    body.print-comparativa-only #tab-comparativa {
        display: block !important;
    }

    body.print-comparativa-only #comparativaPanel {
        background: #ffffff !important;
        border: none !important;
        box-shadow: none !important;
    }

    body.print-comparativa-only .comparativa-table-scroll {
        display: block !important;
        overflow: visible !important;
    }

    body.print-comparativa-only .comparativa-table th,
    body.print-comparativa-only .comparativa-table td,
    body.print-comparativa-only .comparativa-table th:first-child,
    body.print-comparativa-only .comparativa-table td:first-child {
        color: #0f172a !important;
        background: #ffffff !important;
        border-color: #cbd5e1 !important;
        position: static !important;
    }

    body.print-comparativa-only .comparativa-table .player-name,
    body.print-comparativa-only .comparativa-table .comparativa-player-cell span,
    body.print-comparativa-only .comparativa-table .comparativa-comp-cell span,
    body.print-comparativa-only .comparativa-table .comparativa-sd,
    body.print-comparativa-only .comparativa-table .comparativa-dash,
    body.print-comparativa-only .comparativa-name-input,
    body.print-comparativa-only .comparativa-comment-textarea {
        color: #0f172a !important;
    }

    body.print-comparativa-only .comparativa-name-input {
        background: transparent !important;
        border: none !important;
    }

    body.print-comparativa-only .comparativa-comment-textarea {
        background: #ffffff !important;
        border: 1px solid #cbd5e1 !important;
    }

    body.print-comparativa-only .comparativa-comment-scope select {
        display: none !important;
    }

    body.print-comparativa-only .comparativa-expand-btn,
    body.print-comparativa-only .comparativa-comp-cell input[type="checkbox"],
    body.print-comparativa-only .comparativa-remove-btn,
    body.print-comparativa-only .comparativa-comment-save,
    body.print-comparativa-only .comparativa-sort-arrow {
        display: none !important;
    }

    /* Filtered-season context and variable legend */
    body.print-comparativa-only .comparativa-print-context {
        display: block !important;
        color: #475569 !important;
        font-size: 0.85rem;
        font-weight: 600;
        margin-bottom: var(--space-md);
    }

    body.print-comparativa-only .comparativa-legend {
        display: block !important;
        margin-top: var(--space-lg);
        padding-top: var(--space-md);
        border-top: 1px solid #cbd5e1;
    }

    body.print-comparativa-only .comparativa-legend__title {
        color: #0f172a !important;
        font-size: 0.95rem;
        margin-bottom: var(--space-sm);
    }

    body.print-comparativa-only .comparativa-legend__list {
        color: #334155 !important;
        font-size: 0.72rem;
        line-height: 1.6;
        list-style: disc;
        padding-left: 1.2em;
        columns: 2;
        column-gap: var(--space-xl);
    }

    body.print-comparativa-only .comparativa-legend__list b {
        color: #0f172a !important;
    }
}

/* =============================================================================
   Conflicts Modal (Proballers import)
   ============================================================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 16, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.modal-overlay.hidden {
    display: none;
}

/* "conflicts-modal" prefix is intentional: a generic ".modal" component
   already exists in this file (line ~875) with its own class meaning
   (full-screen overlay with .modal__content); using ".modal" here
   would collide with those rules and break the positioning. */
.conflicts-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-xl);
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.conflicts-modal__title {
    font-size: 1.1rem;
    margin-bottom: var(--space-sm);
}

.conflicts-modal__text {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: var(--space-lg);
}

.conflicts-modal__list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    min-height: 0;
}

.conflicts-modal__row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    font-size: 0.82rem;
}

.conflicts-modal__date {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 90px;
}

.conflicts-modal__details {
    flex: 1;
    color: var(--text-secondary);
    line-height: 1.5;
}

.conflicts-modal__details b {
    color: var(--text-primary);
    font-weight: 600;
}

.conflicts-modal__toggle {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.78rem;
    color: var(--accent-primary);
    white-space: nowrap;
    cursor: pointer;
}

.conflicts-modal__toggle input {
    accent-color: var(--accent-primary);
    width: 15px;
    height: 15px;
}

.conflicts-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
}
