/* ============================================================
   Global Sidebar
   ============================================================ */

:root {
    --sidebar-width: 300px;
    --sidebar-header-height: 3.5rem;
}

.global-sidebar {
    --bs-offcanvas-width: var(--sidebar-width);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, rgba(40, 28, 18, 0.55) 0%, rgba(30, 20, 12, 0.75) 100%),
                url('/img/vintage.jpg') center/cover no-repeat;
    display: flex;
    flex-direction: column;
    z-index: 1045;
    overflow: hidden;
}

.global-sidebar-header {
    flex-shrink: 0;
    height: var(--sidebar-header-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.global-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    /* Fade content at top/bottom edges */
    mask-image: linear-gradient(to bottom, transparent, black 10px, black calc(100% - 15px), transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 10px, black calc(100% - 15px), transparent);
    /* Subtle scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.global-sidebar-body::-webkit-scrollbar {
    width: 5px;
}

.global-sidebar-body::-webkit-scrollbar-track {
    background: transparent;
}

.global-sidebar-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.global-sidebar-footer {
    flex-shrink: 0;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Section labels */
.sidebar-section-label {
    font-size: 0.9 rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 0.75rem;
}

.sidebar-subsection-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.5rem;
}

/* Footer links */
.sidebar-footer-link {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    transition: color 0.15s;
}

.sidebar-footer-link:hover {
    color: rgba(255, 255, 255, 0.85);
}

/* User section */
.sidebar-user-section {
    padding: 0.5rem 0.625rem;
    border-radius: 0.5rem;
    transition: background-color 0.15s;
    cursor: pointer;
}

.sidebar-user-section:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

/* Profile nudge in sidebar */
.sidebar-profile-nudge {
    color: #fde047;
    background: rgba(253, 224, 71, 0.1);
    border: 1px solid rgba(253, 224, 71, 0.25);
    animation: nudge-glow 2s ease-in-out infinite;
}

.sidebar-profile-nudge:hover {
    background: rgba(253, 224, 71, 0.18);
    animation: none;
}

@keyframes nudge-glow {
    0%, 100% {
        box-shadow: 0 0 4px rgba(253, 224, 71, 0.2);
        border-color: rgba(253, 224, 71, 0.25);
    }
    50% {
        box-shadow: 0 0 12px rgba(253, 224, 71, 0.5);
        border-color: rgba(253, 224, 71, 0.6);
    }
}

/* Main content wrapper */
.main-content-wrapper {
    flex-grow: 1;
    min-width: 0;
    overflow: hidden;
}

main {
    min-height: 0;
}

/* Sidebar toggle button (injected into content-header on mobile) */
.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: inherit;
    padding: 0;
    margin-right: 0.25rem;
    font-size: 1.35rem;
    line-height: 1;
    opacity: 0.7;
    cursor: pointer;
}

.sidebar-toggle-btn:hover {
    opacity: 1;
}


/* Fixed-width form container: full width on mobile, capped on desktop */
.fixed-width-form {
    width: 100%;
}

/* ── Desktop (lg+) ── */
@media (min-width: 992px) {
    .main-content-wrapper {
        margin-left: var(--sidebar-width);
    }

    .fixed-width-form {
        width: 800px;
        max-width: 100%;
        margin: 0 auto;
    }
}

/* ══════════════════════════════════════════════════════════════
   Area Nav in Global Sidebar
   ══════════════════════════════════════════════════════════════ */

/* Panel container */
.area-nav-panel {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    padding: 0.75rem;
}

/* Back link */
.global-sidebar-body .area-nav-back {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 0.875rem;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: color 0.15s;
}

.global-sidebar-body .area-nav-back:hover {
    color: #fff;
}

/* Area title */
.global-sidebar-body .area-nav-title {
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Nav links */
.global-sidebar-body .nav-link {
    color: rgba(255, 255, 255, 0.75);
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 0.375rem;
    transition: background-color 0.15s, color 0.15s;
}

.global-sidebar-body .nav-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
}

.global-sidebar-body .nav-link.active {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.15);
    font-weight: 500;
}

/* Section headings */
.global-sidebar-body .sidebar-heading {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

/* Collapsible section toggle */
.sidebar-section-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.25rem 0.75rem;
    margin-top: 1rem;
    margin-bottom: 0.25rem;
    cursor: pointer;
    transition: color 0.15s;
}

.sidebar-section-toggle:hover {
    color: rgba(255, 255, 255, 0.75);
}

.sidebar-section-chevron {
    font-size: 0.65rem;
    transition: transform 0.2s ease;
}

.sidebar-section-toggle.collapsed .sidebar-section-chevron {
    transform: rotate(-90deg);
}

/* Content wrapper for admin/tournament/profile areas */
.area-content-wrapper {
    flex-grow: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--bs-tertiary-bg);
}

[data-bs-theme="light"] .area-content-wrapper {
    background: linear-gradient(180deg, #dbeafe 0%, #e2e8f0 100%);
}

[data-bs-theme="dark"] .area-content-wrapper {
    background: linear-gradient(180deg, #1e3a5f 0%, #172554 100%);
}

[data-bs-theme="light"] .area-content-wrapper .content-header {
    background: #dbeafe;
    border-bottom-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .area-content-wrapper .content-header {
    background: rgba(23, 37, 84, 0.85);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* Content header aligns with sidebar headers.
   main has py-3 (1rem top padding), so subtract that. */
.content-header {
    flex-shrink: 0;
    z-index: 1020;
    height: var(--sidebar-header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0 1rem;
    background: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
}

.content-header > * {
    margin-top: 0;
    margin-bottom: 0;
}

.content-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1.25rem;
}

/* ── Mobile (<md) adjustments ── */
@media (max-width: 767.98px) {
    .content-header {
        height: auto;
        min-height: 3rem;
        flex-wrap: wrap;
        padding: 0.625rem 0.75rem;
    }

    .content-header .home-filters {
        width: 100%;
        flex-wrap: nowrap;
    }

    .content-header .home-filters #tournament-filters {
        flex: 1;
        min-width: 0;
    }

    .content-header .home-filters #tournament-filters .form-select {
        width: 0 !important;
        flex: 1 1 0;
        min-width: 0;
    }
}
