/* ==========================================================================
   1. CORE APP LAYOUT & DEFAULTS
   ========================================================================== */
body { 
    background: #f8f9fa; 
    margin: 0; 
    transition: 0.3s; 
    overflow-x: hidden; 
    touch-action: pan-y; 
    position: relative; 
    color: #212529; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    overscroll-behavior-y: none; 
}

#main { 
    margin-left: 280px; 
    padding: 0 !important; 
    transition: margin-left 0.3s ease; 
    background: inherit; 
    position: relative; 
    /* Lower z-index than sidebar */
    z-index: 1; 
}

/* ==========================================================================
   SIDEBAR COMPONENT 
   ========================================================================== */
#sidebar { 
    width: 280px; 
    position: fixed; 
    height: 100dvh; 
    overflow-y: auto; 
    overflow-x: hidden; 
    padding: 0 !important; 
    background: white; 
    border-right: 1px solid #ddd; 
    z-index: 2500 !important; 
    left: 0; 
    top: 0; 
    transition: transform 0.3s ease;    
    display: flex;  
    flex-direction: column; 
    box-sizing: border-box;
}

/* --- SIDEBAR: Scrollbar Edge Fix --- */

/* 2. Apply the padding to a wrapper or all direct children instead */
#sidebar > div, 
#sidebar > .filter-group, 
#sidebar > #searchInput,
#sidebar > .sidebar-tag-container,
#sidebar > #reset-container {
    padding-left: 12px !important;
    padding-right: 12px !important;
}

/* 3. Specifically tighten the vertical gaps between your elements */
#sidebar .mb-3, 
#sidebar .mb-2 {
    margin-bottom: 8px !important;
}

.filter-group {
    margin-bottom: 12px !important;
}

#sidebar-content {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    overflow-x: hidden;
}


.sidebar-header-row {
    display: flex;
    justify-content: flex-start; /* Align items to the left of the sidebar */
    gap: 10px;                   /* Space between gear and arrow */
    width: 100%;
    padding: 0;
    margin-bottom: 15px;
    position: relative;
}

/* Ensure buttons don't float to the right edge of the screen */
.btn-settings, .btn-sidebar-ctrl {
    flex-shrink: 0;
    position: relative;
    left: 0;
}

/* --- RANDOM BUTTON ROW LAYOUT --- */
.sidebar-button-row {
    display: flex;
    gap: 8px;
    padding: 0 10px;
}

.btn-random {
    flex: 1; /* Makes both buttons equal width */
    background: transparent !important;
    font-size: 0.85rem;
    padding: 5px 2px;
    border-radius: 6px;
    transition: all 0.2s;
}

/* 1. LIGHT MODE (Default) */
body:not(.gig-mode):not(.christmas-theme-active) .btn-random {
    border: 1px solid #c53030 !important;
    color: #c53030 !important;
}

/* 2. GIG MODE Border (White) */
body.gig-mode .btn-random {
    border: 1px solid #ffffff !important;
    color: #ffffff !important;
}

/* 3. CHRISTMAS MODE Border (White) */
body.christmas-theme-active .btn-random {
    border: 1px solid #ffffff !important;
    color: #ffffff !important;
}

/* Hover effects */
.btn-random:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    opacity: 0.8;
}

/* --- HIDDEN STATE: Lock to Sidebar --- */

.sidebar-hidden .sidebar-header-row {
    /* Force the entire row to stay at the left edge of the -280px sidebar */
    justify-content: flex-start !important;
}

.sidebar-hidden .btn-settings {
    /* Fade out the gear so it doesn't look awkward while sliding */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

#sidebar-footer {
    flex-shrink: 0 !important; /* Prevents footer from squishing */
    width: 100%;
    background: white;
    border-top: 1px solid #ddd;
    padding: 12px !important;
    position: relative; /* Keeps it in the flex flow but at the bottom */
    z-index: 10;
}



/* --- SIDEBAR ARROW: Alignment with Refresh Button --- */

/* 1. Ensure the header row matches the footer's transition logic */
body.sidebar-hidden .sidebar-header-row {
    /* Match the footer's shift exactly */
    transform: translateX(210px) !important; 
    width: 70px !important; 
    justify-content: center !important;
    padding: 20px 0 0 0 !important;
    margin-left: -20px !important; 
    transition: transform 0.3s ease;
}

/* 2. Style the arrow button specifically for the collapsed state */
body.sidebar-hidden #sidebar-arrow-btn {
    margin-left: 0 !important;
    margin-right: 0 !important;
    /* Ensure it is centered in that 70px width */
    display: flex;
    justify-content: center;
    align-items: center;
    /* Flip the arrow to point 'out' */
    transform: rotate(180deg);
}

/* 3. Hide the gear icon completely so it doesn't overlap the arrow */
body.sidebar-hidden .btn-settings {
    display: none !important;
}

/* 4. Critical: Ensure the sidebar allows the header to 'hang' outside */
#sidebar {
    overflow-x: visible !important;
}


/* 2. Hidden state: Sidebar is CLOSED */
/* The arrow should point RIGHT to indicate "Open me" */
body.sidebar-hidden #sidebar-arrow-btn {
    /* 0deg (or 360deg) points the character in its original direction (Right) */
    transform: rotate(0deg) !important; 
}

/* --- Slide & Scrollbar Fix --- */
body.sidebar-hidden #sidebar { 
    transform: translateX(-210px); 
    overflow: hidden !important; 
}

body.sidebar-hidden #main { 
    margin-left: 70px; 
}

/* Header Alignment (Menu Button) */
body.sidebar-hidden .sidebar-header-row {
    transform: translateX(210px); 
    width: 70px; 
    justify-content: center;
    padding: 20px 0 0 0;
    margin-left: -20px; 
}

/* Footer Alignment (Refresh Icon shifted left) */
body.sidebar-hidden #reset-container { 
    transform: translateX(210px);
    width: 70px;
    margin-left: -10px; 
    justify-content: center;
    display: flex;
}

body.sidebar-hidden #refresh-btn { 
    width: 48px; 
    height: 48px; 
    border-radius: 50%; 
    padding: 0; 
    margin: 0 auto; 
    border: 1px solid #bbb; 
    background: white; 
}

/* 3. If the "Offline Mode Off" is inside a specific toggle label */
body.gig-mode .form-check-label {
    color: #f8f9fa !important;
}

/* --- GIG MODE: Settings Modal Subtext Fixes --- */

/* Targets the Offline Mode: Off text */
body.gig-mode #offline-timestamp.text-muted {
    color: #adb5bd !important; /* Lighter grey for readability */
}

/* Targets the "Update to the latest version:" text */
body.gig-mode .modal-content p.text-muted {
    color: #adb5bd !important;
}

/* If you want them pure white instead of light grey, use this: */
body.gig-mode #offline-timestamp,
body.gig-mode .modal-content p.small {
    color: #ffffff !important;
}

.btn-settings { 
    background: none; 
    border: none; 
    font-size: 1.5rem; 
    cursor: pointer; 
    color: #666; 
    padding: 0; 
}

/* --- GIG MODE: Settings Modal Background --- */
body.gig-mode .modal-content {
    background-color: #373536 !important;
    color: #f8f9fa !important;
    border: 1px solid #555;
}

/* Optional: Ensure labels and inputs inside the modal also look correct */
body.gig-mode .modal-content label,
body.gig-mode .modal-content h5 {
    color: #f8f9fa !important;
}

.btn-sidebar-ctrl { 
    background: #f8f9fa; 
    border: 1px solid #ddd; 
    border-radius: 4px; 
    padding: 5px 10px; 
    cursor: pointer;    
    color: #333; 
    font-weight: bold; 
    min-width: 45px; 
    margin-left: auto;
    transition: transform 0.3s ease;
}


#refresh-btn {
    height: 38px !important;      /* Standard compact button height */
    padding: 0 15px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem !important; /* Slightly smaller text for the compact feel */
    letter-spacing: 1px;
    margin: 0 auto;               /* Keep it centered */
}

/* --- 3. Text & Icon Toggling --- */
body.sidebar-hidden #reset-text { 
    display: none; 
}

#reset-text { 
    display: inline; 
}

/* Updated: Icon is now visible in both states */
#reset-icon {
    font-size: 1rem !important;
    margin-right: 8px;
}

body.sidebar-hidden #reset-icon { 
    font-size: 1.3rem; 
}

/* --- 4. Navigation & Tags --- */
.navbar-toggler, #menu-toggle {
    position: relative;
    z-index: 9999 !important; 
    cursor: pointer;
}

body:not(.gig-mode) .tag-badge { 
display: inline-block;
    padding: 4px 12px;
    margin-right: 5px;
    margin-bottom: 5px;
    border-radius: 50px;       /* Creates the pill shape */
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    cursor: pointer; 
}

body.gig-mode .tag-badge {
    display: inline-block; 
    padding: 4px 8px; 
    background: #2b2a2b !important; 
    color: #adb5bd !important;
    border: 1px solid #444 !important; 
    margin: 2px; 
    border-radius: 6px; 
    font-size: 0.75rem; 
    cursor: pointer;
}



/* ==========================================================================
   3. UI CONTROLS (Search, Inputs, Dropdowns)
   ========================================================================== */
.form-control, .form-select { border-radius: 6px; }
.sidebar-label { display: block; font-weight: bold; font-size: 0.75rem; text-transform: uppercase; color: #666; margin-bottom: 5px; margin-top: 10px; }


/* Difficulty related styles */

body:not(.gig-mode) .diff-icon-white {
    display: none !important;
}
body:not(.gig-mode) .diff-icon-black {
    display: block !important;
}

body.gig-mode .diff-icon-white {
    display: block !important;
}
body.gig-mode .diff-icon-black {
    display: none !important;
}

body.gig-mode .diff-selected {
    background-color: #373536 !important;
    color: #f8f9fa !important;
    border-color: #555 !important;
}

/* --- GIG MODE: Search Input Text and Placeholder --- */

/* 1. The typed text color */
body.gig-mode #searchInput.form-control {
    background-color: #2b2a2b !important;
    color: #ffffff !important;
    border: 1px solid #555 !important;
}

/* 2. The placeholder text color (Search Title, Artist...) */
body.gig-mode #searchInput.form-control::placeholder {
    color: #adb5bd !important;
    opacity: 1; /* Ensures the color is fully applied */
}

/* 3. Handle focus state to prevent white-flashing on click */
body.gig-mode #searchInput.form-control:focus {
    background-color: #2b2a2b !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 0.25rem rgba(255, 255, 255, 0.1);
}

/* --- GIG MODE: Search Bar Background --- */
body.gig-mode #searchInput.form-control {
    background-color: #373536 !important;
    color: #ffffff !important;
    border: 1px solid #555 !important;
}

/* Ensure the background stays dark when the user clicks into it */
body.gig-mode #searchInput.form-control:focus {
    background-color: #373536 !important;
    color: #ffffff !important;
    border-color: #777 !important;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(255, 255, 255, 0.1);
}

body.gig-mode .diff-options {
    background-color: #373536 !important;
    border-color: #555 !important;
}

body.gig-mode .diff-option {
    color: #f8f9fa !important;
    border-bottom: 1px solid #555 !important;
}

body.gig-mode .diff-option:hover {
    background-color: #4a4849 !important;
}

.diff-dropdown { 
	position: relative; width: 100%; 
	margin-bottom: 10px; 
}

.diff-selected { 
	background-color: #fff; 
	border: 1px solid #dee2e6; 
	border-radius: 0.375rem; padding: .375rem .75rem; 
	cursor: pointer; 
	display: flex; 
	align-items: center; 
	min-height: 38px; 
	font-size: 0.9rem; 
}

.diff-options { 
	display: none; 
	position: absolute; 
	top: 100%; 
	left: 0; 
	width: 100%; 
	background: white; 
	border: 1px solid #dee2e6; 
	border-radius: 0.375rem; 
	z-index: 5000; 
	box-shadow: 0 4px 12px rgba(0,0,0,0.1); 
	margin-top: 2px; 
}

.diff-option { 
	padding: 10px; 
	cursor: pointer; 
	border-bottom: 1px solid #eee; 
	display: flex; 
	align-items: center; 
}


/* Tag Cloud Buttons */

/* The state when a tag is selected */
.tag-badge.active {
    background-color: #0d6efd !important; /* Standard Bootstrap Blue */
    color: white !important;
    border-color: #0a58ca !important;
}

/* --- GIG MODE: Selected Tag Styling --- */

/* 1. Sidebar Tag Buttons (Selected) */
body.gig-mode .sidebar-tag-btn.active {
    background-color: #f8f9fa !important; /* Off-white background */
    color: #373536 !important;            /* Dark text */
    border-color: #f8f9fa !important;
    font-weight: bold;
}

/* 2. Song Card Tags (Selected) */
body.gig-mode .tag-badge.active,
body.gig-mode .song-tag-badge.active {
    background-color: #f8f9fa !important; /* Off-white background */
    color: #373536 !important;            /* Dark text */
    border: 1px solid #f8f9fa !important;
    font-weight: bold;
}

/* 3. Hover state for selected tags in Gig Mode */
body.gig-mode .sidebar-tag-btn.active:hover,
body.gig-mode .tag-badge.active:hover {
    background-color: #ffffff !important;
    filter: brightness(0.9);
}

/* Hide the pull-to-refresh indicator when sidebar is collapsed */
body.sidebar-hidden #ptr-indicator {
    display: none !important;
}

#ptr-indicator {
    margin: 0 !important;
    padding: 10px 0; /* Vertical padding only when visible */
    height: 40px;
    line-height: 20px;
    text-align: center;
    width: 100%;
    /* If your JS doesn't hide it, force it to start off-screen or collapsed */
    display: none; 
}

/* If your JS adds an 'active' class to show it */
#ptr-indicator.active {
    display: block !important;
}

/* ==========================================================================
   4. BUTTONS & ACTIONS
   ========================================================================== */


/* Reset Button */
#reset-container {
    width: 100%;
    margin-top: 10px;
    display: flex;
    justify-content: center;
    /* This ensures the container doesn't block clicks to things behind it 
       while letting the button itself remain clickable */
    pointer-events: none; 
}

#refresh-btn {
    /* Critical: Re-enable pointer events for the button specifically */
    pointer-events: auto;
    
    display: flex; 
    align-items: center; 
    justify-content: center;
    width: 100%; 
    padding: 12px; /* Increased for better mobile tap target */
    border-radius: 6px; 
    border: 1px solid #ddd;
    background: #f8f9fa; 
    font-weight: 600; 
    cursor: pointer; 
    transition: all 0.2s ease;
    /* Ensure it sits on top of any scrolling content */
    position: relative;
    z-index: 2005; 
}

/* IMPORTANT: This prevents the Emoji or Text from "stealing" the click 
   from the actual button logic */
#refresh-btn span {
    pointer-events: none;
}

#refresh-btn:hover {
    background: #e9ecef;
}

#refresh-btn:active {
    background: #dee2e6;
    transform: scale(0.98); /* Visual feedback that it was pressed */
}

body.sidebar-hidden #refresh-btn { 
    width: 50px; 
    height: 50px; 
    border-radius: 50%; 
    padding: 0; 
    margin: 0 auto; 
    display: flex;
    justify-content: center;
    align-items: center;
}
#reset-icon { font-size: 1.2rem; }
body:not(.sidebar-hidden) #reset-icon { margin-right: 8px; }

/* Card Actions */
.card-actions { display: flex; align-items: center; gap: 12px; }
.heart-btn { cursor: pointer; font-size: 1.2rem; user-select: none; }
.pdf-link { text-decoration: none; font-weight: 800; font-size: 0.75rem; padding: 2px 6px; border-radius: 4px; }

body:not(.gig-mode) .pdf-link { 
    color: #dc3545 !important; 
    border: 1.5px solid #dc3545 !important;
    text-decoration: none; 
    font-weight: 800; 
    font-size: 0.75rem; 
    padding: 2px 6px; 
    border-radius: 4px; 
}

/* ==========================================================================
   SETLIST COMPONENT (Production Styling)
   ========================================================================== */

/* The individual item container */
.setlist-item { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    border-bottom: 1px solid #eee; 
    padding: 8px 0; /* Increased padding for better vertical rhythm */
    transition: background 0.2s ease;
}

/* Light mode hover effect */
body:not(.gig-mode) .setlist-item:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* --- NEW SETLIST BUTTON: SIDEBAR ONLY --- */

/* 1. GIG MODE: White text ONLY for the button in the sidebar */
body.gig-mode #sidebar .btn-outline-danger {
    color: #ffffff !important;
    border-color: #ffffff !important;
}

/* 2. CHRISTMAS MODE: White text ONLY for the button in the sidebar */
body.christmas-theme-active #sidebar .btn-outline-danger {
    color: #ffffff !important;
    border-color: #ffffff !important;
}

/* 3. HOVER STATES: Scoped to sidebar to prevent impacting modal */
body.gig-mode #sidebar .btn-outline-danger:hover {
    background-color: #ffffff !important;
    color: #373536 !important;
}

body.christmas-theme-active #sidebar .btn-outline-danger:hover {
    background-color: #ffffff !important;
    color: #c53030 !important;
}

/* Ensure the text typed into the search box is white in Christmas Mode */
body.christmas-theme-active #sidebar #searchInput {
    color: #ffffff !important;
}

/* Ensure the blinking cursor (caret) is also white */
body.christmas-theme-active #sidebar #searchInput {
    caret-color: #ffffff !important;
}

/* Ensure the placeholder text is visible but slightly transparent */
body.christmas-theme-active #sidebar #searchInput::placeholder {
    color: rgba(255, 255, 255, 0.7) !important;
}

/* The reorder button group */
.setlist-reorder-btns { 
    display: flex; 
    gap: 6px; 
    margin-right: 12px; 
}

/* Styled reorder buttons */
.reorder-btn { 
    font-size: 0.8rem; 
    border: 1px solid #ddd; 
    background: #f8f9fa; 
    border-radius: 4px; /* Slightly smoother corners */
    cursor: pointer; 
    width: 26px; /* Slightly larger tap target */
    height: 26px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    color: #555; 
    transition: all 0.2s ease;
}

.reorder-btn:hover {
    background: #e9ecef;
    border-color: #ccc;
    color: #000;
}

/* The Song Title inside the setlist */
.setlist-song-title {
    flex-grow: 1;
    font-weight: 500;
    font-size: 0.95rem;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Remove button (The "X") */
.btn-remove-setlist {
    background: none;
    border: none;
    color: #dc3545;
    font-weight: bold;
    cursor: pointer;
    padding: 0 10px;
    font-size: 1.1rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.btn-remove-setlist:hover {
    opacity: 1;
}

/* --- Gig Mode Overrides for Setlist --- */
body.gig-mode .setlist-item {
    border-color: #444 !important;
}

body.gig-mode .reorder-btn {
    background: #2b2a2b !important;
    border-color: #555 !important;
    color: #f8f9fa !important;
}

body.gig-mode .reorder-btn:hover {
    background: #444 !important;
}

/* ==========================================================================
   5. SONG VIEW COMPONENTS (Lyrics & Chords)
   ========================================================================== */
.song-header { 
    cursor: pointer; 
    position: relative;
    /* Higher z-index than the lyrics-content */
    z-index: 10 !important; 
    /* Solid background to hide lyrics passing under */
    background-color: #ffffff !important;
    border-bottom: 1px solid #eee; padding: 10px; 
    border-radius: 8px; 
    margin-bottom: 0px; 
}

.song-title-main-text { font-weight: 600 !important; font-size: 1.25rem; }

.chord-bar { 
    background: #ffffff !important; border-bottom: 1px solid #eee !important; 
    display: flex; flex-wrap: wrap; gap: 12px; padding: 12px; align-items: center; 
    position: relative; z-index: 10; color: #212529 !important; 
}

/* --- SONG CARD: Flush & Square Edges --- */
.song-card {
    background: #ffffff !important; 
    color: #212529;
    border: 0px solid #dee2e6;
    /* Remove rounded edges */
    border-radius: 0 !important; 
    padding: 0px;
    /* Remove the gap between cards */
    margin-bottom: 0 !important; 
    /* Prevent double borders where cards meet */
    border-top: none; 
    
    transition: background-color 0.2s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

/* Add the top border back only for the very first card */
.song-card:first-child {
    border-top: 1px solid #dee2e6;
}

/* Gig Mode Override */
body.gig-mode .song-card {
    background-color: #373536 !important;
    color: #f8f9fa !important;
    border-color: #555 !important;
}
/* Ensure sub-text inside cards looks correct */
.song-card .text-muted {
    font-size: 0.85rem;
}

body.gig-mode .song-card .text-muted {
    color: #adb5bd !important;
}

/* --- SONG HEADER: Reduced Padding --- */
.song-card .song-header.p-3 {
    /* Half of the standard p-3 padding (16px -> 8px) */
    padding: 8px !important; 
}

/* Optional: Tighten the margin below the title row to match the new compact look */
.song-header .mb-1 {
    margin-bottom: 4px !important;
}

/* Optional: Tighten the margin above the tag container */
.song-header .mt-2 {
    margin-top: 4px !important;
}

/* --- CHORD STYLING: Semi-Bold --- */


/* 1. Base style for chords (Light Mode) */
.chord-tooltip {
    font-weight: 500 !important; /* Semi-bold weight */
    color: #373536;             /* Professional red for Light Mode */
    cursor: pointer;
    display: inline-block;
}

/* 2. Gig Mode Override */
body.gig-mode .chord-tooltip {
    /* Uses the same off-white as your tags/text */
    color: #f8f9fa !important;   
    font-weight: 500 !important;
}

/* 3. Inherit weight for any nested elements */
.chord-tooltip span, 
.chord-tooltip b {
    font-weight: 500 !important;
}


.chord-item { text-align: center; width: 60px; display: flex; flex-direction: column; align-items: center; }
.chord-item small { font-weight: bold; font-size: 0.75rem; color: #212529 !important; }
.chord-item img { width: 50px; height: auto; border-radius: 3px; }

.lyrics-box { 
    background: white !important; 
    display: none; overflow: visible !important; 
    isolation: isolate;
}


.lyrics-content {
    color: #212529;
    will-change: transform;
    transform: translate3d(0, 0, 0); 
    transform-style: preserve-3d;
    backface-visibility: hidden;
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: subpixel-antialiased;
    white-space: pre-wrap;
    font-size: 1.15rem;
    line-height: 1.6;
    padding: 20px;
}


/* --- GIG MODE: Artist Name Color --- */
body.gig-mode .song-artist {
    color: #f8f9fa !important;
}

/* ==========================================================================
   6. TAGS & BADGES
   ========================================================================== */

/* Light Mode Tags */
body:not(.gig-mode) .tag-badge.active {
    background-color: #373536 !important;
    color: #ffffff !important;
    border: 1px solid #373536 !important;
    font-weight: bold;
}

/* Consolidated Light Mode Tags (Sidebar & Song Cards) */
body:not(.gig-mode) .tag-badge, 
body:not(.gig-mode) .song-tag-badge,
body:not(.gig-mode) .badge.rounded-pill {
    background-color: #ffffff !important;
    color: #373536 !important;
    border: 1px solid #373536 !important;
    display: inline-block;
    padding: 4px 8px;
    margin: 2px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

/* Active State for Light Mode */
body:not(.gig-mode) .tag-badge.active, 
body:not(.gig-mode) .song-tag-badge.active,
body:not(.gig-mode) .badge.rounded-pill.active {
    background-color: #373536 !important;
    color: #ffffff !important;
}

/* --- SONG CARD TAGS: Forced Pill Shape (Light Mode) --- */
.badge.rounded-pill {
    padding: 5px 12px !important;
    font-weight: 500 !important;
    font-size: 0.7rem !important;
    border: 1px solid #dee2e6 !important; /* Adds definition */
    background-color: #f1f3f5 !important; /* Light grey pill color */
    color: #373536 !important;            /* Dark text */
    margin-bottom: 4px;
    display: inline-block;
}

/* --- ACTIVE STATE: When a tag is selected --- */
.badge.rounded-pill.active {
    background-color: #373536 !important; /* Dark background */
    color: #ffffff !important;            /* White text */
    border-color: #373536 !important;
}

/* --- GIG MODE OVERRIDE --- */
body.gig-mode .badge.rounded-pill {
    background-color: #2b2a2b !important;
    color: #f8f9fa !important;
    border: 1px solid #555 !important;
}

body.gig-mode .badge.rounded-pill.active {
    background-color: #f8f9fa !important;
    color: #373536 !important;
}

/* ==========================================================================
   7. GIG MODE (Dark Theme Overrides)
   ========================================================================== */
body.gig-mode, body.gig-mode #main, body.gig-mode #sidebar, 
body.gig-mode #sidebar-content, body.gig-mode #sidebar-footer, 
body.gig-mode .lyrics-box, 
body.gig-mode .lyrics-content {
    background-color: #373536 !important;
    color: #f8f9fa !important;
    border-color: #555 !important;
}

body.gig-mode .form-control, body.gig-mode .form-select, 
body.gig-mode #searchInput, body.gig-mode .diff-selected,
body.gig-mode .diff-options {
    background-color: #373536 !important;
    color: #f8f9fa !important;
    border-color: #555 !important;
}

body.gig-mode .song-header { border: 1px solid #ffffff !important; position: relative; z-index: 10; }
body.gig-mode .pdf-link { color: #ffffff !important; border: 1.5px solid #ffffff !important; }
body.gig-mode .pdf-link img { filter: brightness(0) invert(1); }

/* Gig Mode Tags */
body.gig-mode .tag-badge { background-color: #373536; color: #ffffff; border: 1px solid #555; }
body.gig-mode .tag-badge.active { background-color: #ffffff; color: #373536; font-weight: bold; }
body.gig-mode .song-tag-badge, 
body.gig-mode .song-card .badge { background-color: #4a4849 !important; color: #f8f9fa !important; }

/* 2. Gig Mode Card (Black/Dark Background) */
body.gig-mode .song-card,
body.gig-mode .song-header,
body.gig-mode .lyrics-box,
body.gig-mode .lyrics-content {
    background-color: #373536 !important;
    color: #f8f9fa !important;
    border-color: #555 !important;
}

body.gig-mode .song-header {
    border: 1px solid #ffffff !important;
    margin: 5px 0; /* Add a small gap in Gig Mode for the border visibility */
}

/* Specific text color fixes for Gig Mode */
body.gig-mode .text-muted, 
body.gig-mode .song-artist {
    color: #adb5bd !important;
}

body.gig-mode .song-title-main-text {
    color: #ffffff !important;
}

/* ==========================================================================
   8. SPECIAL FEATURES (Modals, Timers, Christmas)
   ========================================================================== */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.7); z-index: 3000; justify-content: center; align-items: center; }
.modal-overlay.active { display: flex !important; }
.modal-content { background: #fff; padding: 25px; border-radius: 15px; width: 90%; max-width: 400px; }

/* Update Banner - Hidden by default */
#update-banner { 
    position: fixed; 
    bottom: 30px; 
    left: 50%; 
    transform: translateX(-50%); 
    z-index: 100000; 
    display: none; /* Add this line */
}

/* Class to show it when needed */
#update-banner.show {
    display: block !important;
}

#update-banner:hover {
    background: #218838;
}

.btn-update-moselele { 
    background: white !important; 
    color: black !important; 
    border: 2px solid black !important; 
    font-weight: 900; 
    border-radius: 8px; 
    padding: 12px 20px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.3); 
}

/* --- SCROLL CONTROLS: Floating Logic --- */


/* Ensure the floating bar can contain the absolute timer */
.scroll-ctrl.floating {
    position: fixed !important;
    bottom: 30px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 4000 !important;
    min-width: 120px;
    min-height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #ffffff !important; 
    border: 2px solid #373536 !important; 
    box-shadow: 0 8px 30px rgba(0,0,0,0.3) !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* --- Timer Box Styling (Inside the Floating Bar) --- */
.scroll-ctrl.floating .countdown-overlay,
.countdown-overlay {
    background-color: #373536 !important;
    color: #ffffff !important;
    width: 60px !important;
    height: 45px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    border: 2px solid #ffffff !important;
    font-size: 1.8rem !important;
    font-weight: 900 !important;
    z-index: 5000 !important;
}



/* The pulse animation for the white text */
.countdown-number-animation {
    display: inline-block;
    animation: countPop 1s ease-in-out infinite;
}

@keyframes countPop {
    0% { transform: scale(0.8); opacity: 0.7; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 0.7; }
}

/* Ensure the floating bar itself doesn't look empty */
.scroll-ctrl.floating {
    min-width: 100px;
    min-height: 55px;
    background: #ffffff !important;
    border: 2px solid #0d6efd !important;
}

/* Gig Mode Adjustment for the Bar */
body.gig-mode .scroll-ctrl.floating {
    background: #ffffff !important;
    border-color: #f8f9fa !important;
}
.scroll-ctrl { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    background: #f1f3f5; 
    padding: 10px 15px; 
    border-radius: 20px; 
    border: 1px solid #dee2e6; 
    gap: 4px;
    /* Smooth transition for when it vanishes */
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* 1. This hides the box AND the outline when the timer is running */
.countdown-active .scroll-ctrl {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none;
}

/* 2. Ensure that if JS sets display: none, the border doesn't linger */
.scroll-ctrl[style*="display: none"] {
    display: none !important;
}

/* --- SCROLL CONTROLS: Ghost Box Fix --- */

/* If the inner controls div is hidden by JS, hide the entire container */
.scroll-ctrl:has(div[style*="visibility: hidden"]) {
    opacity: 0 !important;
    visibility: hidden !important;
    border: none !important;
    background: transparent !important;
    pointer-events: none;
}

/* Ensure the box stays hidden if display: none is used */
.scroll-ctrl[style*="display: none"] {
    display: none !important;
}

/* 3. Floating state (The box reappears at the bottom once scrolling starts) */
.scroll-ctrl.floating { 
    position: fixed !important; 
    bottom: 30px !important; 
    left: 50% !important; 
    transform: translateX(-50%) !important; 
    z-index: 4000 !important; 
    background: #ffffff !important; 
    border: 2px solid #373536 !important; 
    box-shadow: 0 8px 30px rgba(0,0,0,0.2) !important;
    /* Force visibility back on when it's floating */
    opacity: 1 !important;
    visibility: visible !important;
}

/* ==========================================================================
   CHRISTMAS THEME (Snowselele Mode) - SCOPED TO SIDEBAR & MAIN
   ========================================================================== */

/* 1. Global Layout */
body.christmas-theme-active {
    background-color: #fff5f5 !important;
}

/* 2. Sidebar Container - Scoped strictly to Sidebar */
body.christmas-theme-active #sidebar,
body.christmas-theme-active #sidebar-content,
body.christmas-theme-active #sidebar-footer {
    background-color: #c53030 !important;
    background: #c53030 !important; 
    color: #ffffff !important;
    border-right: 1px solid #a02020 !important;
}

/* 3. Text & Labels - Scoped to Sidebar */
body.christmas-theme-active #sidebar .sidebar-label,
body.christmas-theme-active #sidebar .sidebar-header-row h6,
body.christmas-theme-active #sidebar .btn-settings,
body.christmas-theme-active #sidebar #more-tags-btn,
body.christmas-theme-active #sidebar .text-muted,
body.christmas-theme-active #sidebar h6 {
    color: #ffffff !important;
}

/* 4. Sidebar Inputs & Dropdowns */
body.christmas-theme-active #sidebar .form-control,
body.christmas-theme-active #sidebar .form-select,
body.christmas-theme-active #sidebar #searchInput,
body.christmas-theme-active #sidebar #bookSelect,
body.christmas-theme-active #sidebar #sortSelect,
body.christmas-theme-active #sidebar .diff-selected {
    background-color: #a02020 !important; 
    color: #ffffff !important;
    border: 1px solid #851a1a !important;
}

/* 5. Custom Difficulty Dropdown - Scoped to Sidebar */
body.christmas-theme-active #sidebar #diffOptions {
    background-color: #c53030 !important;
    border: 1px solid #ffffff !important;
}

body.christmas-theme-active #sidebar .diff-option {
    background-color: #c53030 !important;
    color: #ffffff !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
}

/* 6. Sidebar Tag Badges */
body.christmas-theme-active #sidebar .tag-badge {
    background-color: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
}

/* 7. Icon Swapping - Scoped to Sidebar Red Background */
body.christmas-theme-active #sidebar .diff-icon-white {
    display: inline-block !important;
}

body.christmas-theme-active #sidebar .diff-icon-black {
    display: none !important;
}

/* 8. Reset/Refresh Button in Sidebar Footer */
/* Inside your Christmas Theme section in style.css */
body.christmas-theme-active #sidebar #refresh-btn {
    background-color: rgba(255, 255, 255, 0.9) !important;
    color: #c53030 !important;
    font-weight: bold;
    border: none !important;
    height: 38px !important; /* Ensure height matches compact style */
}

/* 9. Christmas Top Banner (Only in Main Content) */
.christmas-banner-mode {
    background: #c53030; 
    color: white; 
    text-align: center; 
    padding: 15px; 
    border-radius: 0; 
    margin-bottom: 0px; 
    font-weight: bold; 
    border-bottom: 2px solid #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    font-size: 1.2rem;
}