/* ============================================================
   Bowling Tournament Theme — "Lane & Strike" Color Palette
   Overrides Bootstrap 5.3 CSS custom properties
   ============================================================ */

:root,
[data-bs-theme="light"] {
    /* Primary — Lane approach arrows / blue lane lights */
    --bs-primary: #2563eb;
    --bs-primary-rgb: 37, 99, 235;
    --bs-primary-text-emphasis: #0f2d6e;
    --bs-primary-bg-subtle: #dbeafe;
    --bs-primary-border-subtle: #93c5fd;

    /* Secondary — Dark alley interior slate */
    --bs-secondary: #475569;
    --bs-secondary-rgb: 71, 85, 105;
    --bs-secondary-text-emphasis: #1e293b;
    --bs-secondary-bg-subtle: #e2e8f0;
    --bs-secondary-border-subtle: #94a3b8;

    /* Success — Strike "X" on the scorecard */
    --bs-success: #16a34a;
    --bs-success-rgb: 22, 163, 74;
    --bs-success-text-emphasis: #0a5c2a;
    --bs-success-bg-subtle: #dcfce7;
    --bs-success-border-subtle: #86efac;

    /* Info — Oil sheen on a freshly conditioned lane */
    --bs-info: #0891b2;
    --bs-info-rgb: 8, 145, 178;
    --bs-info-text-emphasis: #044e60;
    --bs-info-bg-subtle: #cffafe;
    --bs-info-border-subtle: #67e8f9;

    /* Warning — Trophy gold / tournament banners */
    --bs-warning: #eab308;
    --bs-warning-rgb: 234, 179, 8;
    --bs-warning-text-emphasis: #713f12;
    --bs-warning-bg-subtle: #fef9c3;
    --bs-warning-border-subtle: #fde047;

    /* Danger — Foul line / gutter warning */
    --bs-danger: #dc2626;
    --bs-danger-rgb: 220, 38, 38;
    --bs-danger-text-emphasis: #7f1d1d;
    --bs-danger-bg-subtle: #fee2e2;
    --bs-danger-border-subtle: #fca5a5;

    /* Links */
    --bs-link-color: #2563eb;
    --bs-link-color-rgb: 37, 99, 235;
    --bs-link-hover-color: #1d4ed8;
    --bs-link-hover-color-rgb: 29, 78, 216;

    /* Surface & border tints — blue-tinted to soften harsh whites */
    --bs-body-bg: #f8fafc;
    --bs-body-bg-rgb: 248, 250, 252;
    --bs-tertiary-bg: #f1f5f9;
    --bs-tertiary-bg-rgb: 241, 245, 249;
    --bs-secondary-bg: #e2e8f0;
    --bs-secondary-bg-rgb: 226, 232, 240;
    --bs-border-color: #cbd5e1;
    --bs-border-color-translucent: rgba(148, 163, 184, 0.25);
}

[data-bs-theme="dark"] {
    /* Primary */
    --bs-primary: #2563eb;
    --bs-primary-rgb: 37, 99, 235;
    --bs-primary-text-emphasis: #93c5fd;
    --bs-primary-bg-subtle: #1e3a5f;
    --bs-primary-border-subtle: #1e40af;

    /* Secondary */
    --bs-secondary: #475569;
    --bs-secondary-rgb: 71, 85, 105;
    --bs-secondary-text-emphasis: #cbd5e1;
    --bs-secondary-bg-subtle: #1e293b;
    --bs-secondary-border-subtle: #334155;

    /* Success */
    --bs-success: #16a34a;
    --bs-success-rgb: 22, 163, 74;
    --bs-success-text-emphasis: #86efac;
    --bs-success-bg-subtle: #052e16;
    --bs-success-border-subtle: #14532d;

    /* Info */
    --bs-info: #0891b2;
    --bs-info-rgb: 8, 145, 178;
    --bs-info-text-emphasis: #67e8f9;
    --bs-info-bg-subtle: #083344;
    --bs-info-border-subtle: #155e75;

    /* Warning */
    --bs-warning: #eab308;
    --bs-warning-rgb: 234, 179, 8;
    --bs-warning-text-emphasis: #fde047;
    --bs-warning-bg-subtle: #422006;
    --bs-warning-border-subtle: #713f12;

    /* Danger */
    --bs-danger: #dc2626;
    --bs-danger-rgb: 220, 38, 38;
    --bs-danger-text-emphasis: #fca5a5;
    --bs-danger-bg-subtle: #450a0a;
    --bs-danger-border-subtle: #7f1d1d;

    /* Links */
    --bs-link-color: #60a5fa;
    --bs-link-color-rgb: 96, 165, 250;
    --bs-link-hover-color: #93c5fd;
    --bs-link-hover-color-rgb: 147, 197, 253;

    /* Surface & border — re-assert Bootstrap dark defaults
       (the :root block above overrides them with light values) */
    --bs-body-bg: #212529;
    --bs-body-bg-rgb: 33, 37, 41;
    --bs-tertiary-bg: #2b3035;
    --bs-tertiary-bg-rgb: 43, 48, 53;
    --bs-secondary-bg: #343a40;
    --bs-secondary-bg-rgb: 52, 58, 64;
    --bs-border-color: #495057;
    --bs-border-color-translucent: rgba(255, 255, 255, 0.15);
}

/* ============================================================
   Button overrides — Bootstrap 5.3 buttons use scoped
   --bs-btn-* variables that don't inherit from :root
   ============================================================ */

/* Primary button */
.btn-primary {
    --bs-btn-bg: #2563eb;
    --bs-btn-border-color: #2563eb;
    --bs-btn-hover-bg: #1d4ed8;
    --bs-btn-hover-border-color: #1e40af;
    --bs-btn-active-bg: #1e40af;
    --bs-btn-active-border-color: #1e3a8a;
    --bs-btn-disabled-bg: #2563eb;
    --bs-btn-disabled-border-color: #2563eb;
}

/* Secondary button */
.btn-secondary {
    --bs-btn-bg: #475569;
    --bs-btn-border-color: #475569;
    --bs-btn-hover-bg: #334155;
    --bs-btn-hover-border-color: #1e293b;
    --bs-btn-active-bg: #1e293b;
    --bs-btn-active-border-color: #0f172a;
    --bs-btn-disabled-bg: #475569;
    --bs-btn-disabled-border-color: #475569;
}

/* Success button */
.btn-success {
    --bs-btn-bg: #16a34a;
    --bs-btn-border-color: #16a34a;
    --bs-btn-hover-bg: #15803d;
    --bs-btn-hover-border-color: #166534;
    --bs-btn-active-bg: #166534;
    --bs-btn-active-border-color: #14532d;
    --bs-btn-disabled-bg: #16a34a;
    --bs-btn-disabled-border-color: #16a34a;
}

/* Info button */
.btn-info {
    --bs-btn-bg: #0891b2;
    --bs-btn-border-color: #0891b2;
    --bs-btn-hover-bg: #0e7490;
    --bs-btn-hover-border-color: #155e75;
    --bs-btn-active-bg: #155e75;
    --bs-btn-active-border-color: #164e63;
    --bs-btn-disabled-bg: #0891b2;
    --bs-btn-disabled-border-color: #0891b2;
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-color: #fff;
}

/* Warning button */
.btn-warning {
    --bs-btn-bg: #eab308;
    --bs-btn-border-color: #eab308;
    --bs-btn-hover-bg: #ca8a04;
    --bs-btn-hover-border-color: #a16207;
    --bs-btn-active-bg: #a16207;
    --bs-btn-active-border-color: #854d0e;
    --bs-btn-disabled-bg: #eab308;
    --bs-btn-disabled-border-color: #eab308;
}

/* Danger button */
.btn-danger {
    --bs-btn-bg: #dc2626;
    --bs-btn-border-color: #dc2626;
    --bs-btn-hover-bg: #b91c1c;
    --bs-btn-hover-border-color: #991b1b;
    --bs-btn-active-bg: #991b1b;
    --bs-btn-active-border-color: #7f1d1d;
    --bs-btn-disabled-bg: #dc2626;
    --bs-btn-disabled-border-color: #dc2626;
}

/* Darken floating label placeholders (Bootstrap default is 0.65) */
.form-floating > label {
    color: rgba(var(--bs-body-color-rgb), 0.45);
}

/* ============================================================
   Original app styles
   ============================================================ */

.validation-summary-errors ul {
    margin-bottom: 0;
}

/* Validation error styles */
.input-validation-error {
    border: 5px var(--bs-danger-border-subtle) solid;
}

/* Cropper circular overlay for avatar cropping */
.cropper-circular .cropper-view-box {
    border-radius: 50% !important;
    outline: none !important;
    overflow: hidden !important;
    box-shadow: 0 0 0 2px rgba(51, 153, 255, 0.75) !important;
}

.cropper-circular .cropper-face {
    border-radius: 50% !important;
    background-color: transparent !important;
}

/* Dark overlay outside the circle */
.cropper-circular .cropper-crop-box::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

/* Hide default modal overlay since we use circular one */
.cropper-circular .cropper-modal {
    background-color: transparent !important;
}

/* Keep resize handles visible */
.cropper-circular .cropper-point {
    z-index: 1;
}

.cropper-circular .cropper-line {
    z-index: 1;
}

#themeToggle {
    border: none;
    background: transparent;
    transition: transform 0.2s ease;
}

#themeToggle:hover {
    transform: scale(1.1);
}

#themeToggle:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* ...existing code... */

.prose {
    max-width: none;
}

.prose h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.prose h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.prose h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.prose p {
    margin-bottom: 1rem;
}

.prose ul, .prose ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.prose li {
    margin-bottom: 0.5rem;
}

.prose a {
    color: var(--bs-link-color);
    text-decoration: underline;
}

.prose code {
    background-color: var(--bs-secondary-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
}

.prose pre {
    background-color: var(--bs-secondary-bg);
    padding: 1rem;
    border-radius: 0.375rem;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.prose pre code {
    background-color: transparent;
    padding: 0;
}

/* Sortable list styles */
.sortable-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sortable-list-item {
    background-color: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
    transition: background-color 0.15s ease;
}

.sortable-list-item:hover {
    background-color: var(--bs-tertiary-bg);
}

.clickable-row {
    cursor: pointer;
}

.clickable-row:hover {
    color: inherit;
}

.card-lift {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-lift:hover {
    transform: translateY(-4px) scale(1.0125);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.kpi-filter {
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.kpi-filter.active {
    opacity: 1;
}

.kpi-filter:hover {
    opacity: 0.85;
}

.kpi-filter.active:hover {
    opacity: 1;
}

.sortable-list-item.draggable-mirror {
    list-style: none;
    background-color: var(--bs-body-bg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 0.375rem;
    border: 1px solid var(--bs-border-color);
    z-index: 1000;
}

.sortable-list-item.draggable-source--is-dragging {
    opacity: 0.4;
}

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

:root {
    --sidebar-width: 280px;
    --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.75rem;
    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;
}


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

/* ══════════════════════════════════════════════════════════════
   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;
}

/* 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;
    /* 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);
}

/* Remove mask when a Bootstrap modal is open so the modal's z-index
   escapes the stacking context created by mask-image */
body.modal-open .content-body {
    mask-image: none;
    -webkit-mask-image: none;
}

/* ── 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;
    }
}

/* ============================================================
   FullCalendar — Bootstrap 5 plugin overrides
   The plugin handles most theming via Bootstrap classes.
   These overrides fix dark mode (plugin hardcodes --bs-gray-*)
   and add today highlight + event colors.
   ============================================================ */

.fc {
    --fc-today-bg-color: var(--bs-primary-bg-subtle);
}

/* Dark mode: plugin injects --bs-gray-400 borders / --bs-gray-200 shading */
[data-bs-theme="dark"] .fc-theme-bootstrap5 td,
[data-bs-theme="dark"] .fc-theme-bootstrap5 th,
[data-bs-theme="dark"] .fc-theme-bootstrap5 .fc-list,
[data-bs-theme="dark"] .fc-theme-bootstrap5 .fc-scrollgrid {
    border-color: var(--bs-border-color);
}

[data-bs-theme="dark"] .fc-theme-bootstrap5-shaded {
    background-color: var(--bs-tertiary-bg);
}

/* Button sizing to match Bootstrap sm buttons */
.fc .fc-button {
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
}

/* Weekend day columns */
.fc .fc-day-sat,
.fc .fc-day-sun {
    background-color: var(--bs-secondary-bg);
}

/* Holiday labels */
.fc .fc-event.fc-holiday {
    background: none;
    border: none;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    font-style: italic;
    opacity: 0.8;
}

/* Clickable events */
.fc .fc-event {
    cursor: pointer;
}

/* Readonly form controls should look disabled */
input.form-control:read-only {
    background-color: var(--bs-secondary-bg);
}
