/* League Switcher Component Styles */

.league-switcher {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-right: 8px;
}

.league-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 8px;
    border: 2px solid #555;
    background: #444;
    color: #4CAF50;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.league-toggle-btn:hover {
    border-color: #4CAF50;
    background: #555;
    transform: scale(1.05);
}

.league-toggle-btn:active {
    transform: scale(0.95);
}

.league-toggle-btn svg {
    width: 24px;
    height: 24px;
    color: inherit;
}

/* Make header a flex container to control element ordering */
header {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
}

/* Position auth-status and theme-toggle on edges */
header #auth-status,
header #theme-toggle-btn {
    position: absolute !important;
}

header #auth-status {
    left: 1rem !important;
}

header #theme-toggle-btn {
    right: 1rem !important;
}

/* Position league switcher to appear before h1 content */
#league-switcher-mount {
    display: flex;
    align-items: center;
    order: 2; /* Place before h1 */
    margin: 0;
    /* Reserve space for the switcher to prevent layout shift during loading */
    min-width: 48px; /* 40px button + 8px margin-right */
    width: 48px;
}

/* Ensure h1 stays centered with switcher as a visual group */
header h1 {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    order: 3; /* Place after league-switcher-mount */
}

/* Nav should appear below on its own row */
header nav {
    order: 4;
    width: 100%;
}

/* Dark mode support */
.dark-mode .league-toggle-btn {
    background: #444;
    border-color: #555;
    color: #4CAF50;
}

.dark-mode .league-toggle-btn:hover {
    background: #555;
    border-color: #4CAF50;
}

/* Mobile optimization */
@media (max-width: 600px) {
    /* Add padding to header to prevent overlap */
    header {
        padding: 1rem 3.5rem !important;
        position: relative !important;
    }

    /* Override: Move theme toggle to far left on mobile */
    header #theme-toggle-btn {
        left: 0.5rem !important;
        right: auto !important;
        top: 1rem !important;
    }

    /* Position hamburger menu on far right - needs to escape nav's flex context */
    header .nav-toggle {
        position: absolute !important;
        right: 0.5rem !important;
        top: 1rem !important;
        z-index: 102 !important;
        display: block !important;
    }

    /* Prevent nav from creating its own row for the toggle button */
    header nav {
        position: static !important;
    }

    /* Center the league switcher and logo together */
    /* Shift left to center the logo icon itself, not the group */
    #league-switcher-mount {
        position: relative !important;
        margin: 0 !important;
        transform: translateX(-21px) !important;
        /* Reserve space for the smaller mobile switcher to prevent layout shift */
        min-width: 42px; /* 36px button + 6px margin-right */
        width: 42px;
    }

    header h1 {
        position: relative !important;
        margin: 0 !important;
        transform: translateX(-21px) !important;
    }

    /* Hide title text on mobile, keep only logo */
    header h1 .header-text {
        display: none !important;
    }

    .league-switcher {
        margin-right: 6px;
    }

    .league-toggle-btn {
        width: 36px;
        height: 36px;
        padding: 6px;
    }

    .league-toggle-btn svg {
        width: 20px;
        height: 20px;
    }
}
