/* =========================================
   01. CORE PAGE & TYPOGRAPHY
========================================= */
html, body {
    max-width: 100%;
    overflow-x: clip;
}

body { 
    font-family: Arial, sans-serif; 
    margin: 20px auto; 
    padding: 0 10px; 
    background: #f2f2f2; 
    box-sizing: border-box; 
}

h1 { text-align: center; margin-bottom: 5px; }

.fluid-logo {
    max-width: 100%; height: auto; display: block; margin: 0 auto;  
}

html, body, .tab-content, .tab-panel, div[id*="tab-panel"], .dataTables_wrapper, table.dataTable {
    overflow: visible !important;
}

/* =========================================
   02. STICKY UI LAYERS & CAKE FIXES
========================================= */
.tab-bar-container {
    position: sticky; top: 0px; z-index: 1000;
    background: #f2f2f2; padding: 10px 0;
    width: 100% !important; box-sizing: border-box !important;
    box-shadow: 100px 0 0 0 #f2f2f2, -100px 0 0 0 #f2f2f2 !important;
    display: flex; align-items: center; justify-content: center;
}

.tab-bar {
    display: flex; overflow-x: auto; scroll-behavior: smooth;
    -ms-overflow-style: none; scrollbar-width: none; 
    padding: 5px; white-space: nowrap;
}

.tab-bar::-webkit-scrollbar { display: none; }

.tab-scroll-btn {
    border: none; font-size: 20px; cursor: pointer; color: #000;
    padding: 0 15px; position: absolute; z-index: 1001; height: 100%;
    display: flex; align-items: center; justify-content: center;
    transition: color 0.2s, opacity 0.2s;
}
.tab-scroll-btn.left { left: -10px; background: linear-gradient(to left, transparent, #f2f2f2 60%); }
.tab-scroll-btn.right { right: -10px; background: linear-gradient(to right, transparent, #f2f2f2 60%); }
.tab-scroll-btn:hover { color: #f3a638; }

.legend-panel { 
    position: sticky; top: 57px; z-index: 990; 
    background: #f2f2f2; width: 100% !important; box-sizing: border-box !important; 
    padding: 10px 0; margin: 0; 
    box-shadow: 100px 0 0 0 #f2f2f2, -100px 0 0 0 #f2f2f2 !important; 
}

div.dataTables_filter { 
    position: sticky; top: 107px; z-index: 980; 
    background: #f2f2f2 !important; 
    padding: 10px 15px !important; margin: 0 !important; 
    display: flex !important; justify-content: flex-end !important; 
	align-items: center !important; flex-wrap: wrap !important;
    width: 100% !important; box-sizing: border-box !important; 
    box-shadow: 100px 0 0 0 #f2f2f2, -100px 0 0 0 #f2f2f2, 0 2px 0 0 #f2f2f2 !important; 
}

table.dataTable thead th, table.dataTable thead td { 
    position: sticky !important; top: 170px; z-index: 970 !important; 
    background-color: #ffffff !important; background-clip: padding-box !important;
    text-align: center; box-shadow: 0 -4px 0 0 #f2f2f2, 0 2px 2px -1px rgba(0, 0, 0, 0.2); 
    outline: 1px solid #b0b0b0 !important; outline-offset: -1px !important;
    padding: 8px 10px !important; 
}

/* =========================================
   03. TABLE CORE STYLES
========================================= */
table.dataTable { 
    background: white; border-collapse: separate !important; border-spacing: 0; 
    width: 100% !important; max-width: 100% !important;
}
table.dataTable tbody td {
    white-space: normal !important; word-break: break-word; border-bottom: 1px solid #000 !important;
}
.thumb { max-width: 101px; max-height: 88px; display: block; margin: 0 auto; }
td, th { vertical-align: middle; }
td.center-col { text-align: center; }
td.bold-col { font-weight: bold; }

table.dataTable tbody td:first-child { 
    cursor: pointer; position: relative; border-left: 1px solid #b0b0b0 !important;
    width: 1% !important; white-space: nowrap !important;
}
table.dataTable tbody td:has(img.thumb) { width: 1% !important; white-space: nowrap !important; }
table.dataTable tbody td:last-child { border-right: 1px solid #b0b0b0 !important; }
table.dataTable tbody td:first-child:hover,
table.dataTable tbody td:nth-child(2):hover { box-shadow: inset 0 0 0 9999px rgba(255, 255, 255, 0.3); cursor: pointer; }

/* =========================================
   04. CUSTOM HEADER LAYOUT & SORTING
========================================= */
.header-content { display: flex; align-items: center; justify-content: center; gap: 5px; }
.no-sort { text-align: center; }
.sort-target { cursor: pointer; user-select: none; text-align: center; }
.sort-target:hover { text-decoration: underline; }

table.dataTable thead th { cursor: default; padding-right: 15px !important; }
table.dataTable thead th.sorting:after, table.dataTable thead th.sorting_asc:after, table.dataTable thead th.sorting_desc:after,
table.dataTable thead th.sorting:before, table.dataTable thead th.sorting_asc:before, table.dataTable thead th.sorting_desc:before { display: none !important; }

table.dataTable thead th .sort-target::after { content: "\00a0\21C5"; opacity: 0.3; font-size: 14px; }
table.dataTable thead th.sorting_asc .sort-target::after { content: "\00a0\2191"; opacity: 1; color: #3498db; }
table.dataTable thead th.sorting_desc .sort-target::after { content: "\00a0\2193"; opacity: 1; color: #3498db; }
table.dataTable > tbody > tr.child span.dtr-title .header-funnel { display: none !important; }
table.dataTable > tbody > tr.child span.dtr-title .header-content { display: inline-flex !important; justify-content: flex-start !important; }

/* =========================================
   05. CENTRALIZED FILTERS MENU & CONTROLS
========================================= */
.dt-search-controls {
    display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px;
}

.filter-toggle-btn, .sort-toggle-btn {
    padding: 6px 12px; border: 1px solid #7c3a99;
    border-radius: 4px; background: white; cursor: pointer; font-size: 14px; font-weight: bold; color: #7c3a99;
    transition: all 0.2s;
}
.filter-toggle-btn:hover, .filter-toggle-btn.active, .sort-toggle-btn:hover, .sort-toggle-btn.active { background: #7c3a99; color: white; }

.desktop-filter-menu {
    width: 100%; margin-top: 10px; padding-top: 10px; border-top: 1px solid #ddd; display: none; 
    background: #fff; border-radius: 6px; padding: 15px; box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
    max-height: 60vh; overflow-y: auto; overflow-x: hidden; box-sizing: border-box;
}
.filter-menu-inner { display: flex; flex-wrap: wrap; gap: 20px; }
.filter-group {
    flex: 1; min-width: 180px; max-width: 250px;
    background: #f9f9f9; padding: 10px; border-radius: 6px; border: 1px solid #eee;
}
.filter-group h4 { margin: 0 0 8px 0; font-size: 14px; color: #333; display: flex; justify-content: space-between; align-items: center; }
.clear-group-btn { font-size: 11px; padding: 2px 6px; cursor: pointer; border-radius: 3px; border: 1px solid #ccc; background: #fff; color: #333; }
.clear-group-btn:hover { background: #e74c3c; color: white; border-color: #e74c3c; }

.checkbox-container { max-height: 150px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.checkbox-container label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; margin: 0; }
.checkbox-container label:hover { background: #eee; border-radius: 3px; }

/* =========================================
   06. UI ELEMENTS & BUTTONS
========================================= */
.tab-button { 
    padding: 10px 18px; margin-right: 8px; border-radius: 20px; cursor: pointer; font-size: 14px; flex-shrink: 0;
    background-color: transparent !important; color: #000 !important;                
    border: 1px solid #7c3a99 !important; border-bottom: 3px solid #7c3a99 !important;
    transition: all 0.2s ease !important;
}
.tab-button:active { background-color: rgba(124, 58, 153, 0.15) !important; }
.tab-button.active {
    background-color: transparent !important; color: #000 !important; font-weight: bold;                        
    border: 1px solid #f3a638 !important; border-bottom: 3px solid #f3a638 !important; 
    box-shadow: inset 0 0 5px rgba(243, 166, 56, 0.1), 0 0 8px rgba(243, 166, 56, 0.2) !important; 
}

.reset-sort-btn { padding: 6px 12px; border: 1px solid #bbb; border-radius: 4px; background: white; cursor: pointer; font-size: 13px; font-weight: bold; }
.reset-sort-btn:hover { background: #eee; }

.theme-toggle-btn { padding: 6px 12px; border: 1px solid #ccc; border-radius: 4px; background: white; cursor: pointer; font-size: 13px; font-weight: bold; }
.theme-toggle-btn:hover { background: #eee; }

#back-to-top { 
    position: fixed; bottom: 30px; right: 30px; z-index: 9999; background-color: #7f8ec9; color: white; border: none; 
    border-radius: 50%; width: 50px; height: 50px; font-size: 24px; font-weight: bold; cursor: pointer; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.3); display: flex; justify-content: center; align-items: center; 
    opacity: 0; visibility: hidden; transition: opacity 0.4s ease, visibility 0.4s ease, background-color 0.2s ease;
}
#back-to-top.show { opacity: 1; visibility: visible; }
#back-to-top:hover { background-color: #5a6ab0; }

.db-update-time { margin-right: auto; font-size: 14px; font-weight: bold; color: #000; }

/* =========================================
   07. LEGEND & WARNING BANNERS
========================================= */
.legend-panel-inner { 
    display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; 
    width: fit-content; max-width: 95%; margin: 0 auto; background: white; 
    border: 1px solid #ddd; border-radius: 6px; padding: 8px 14px; box-shadow: 0 2px 6px rgba(0,0,0,0.15); font-size: 12px; 
}
.legend-entry { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.legend-swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.2); flex-shrink: 0; }
.legend-label { color: #000000 !important; font-weight: bold !important; }

.warning-container { 
    display: flex; flex-direction: column; align-items: center; justify-content: center; 
    background-color: #ffffff; border: 2px solid #e74c3c; border-radius: 12px; padding: 15px 20px; margin: 0 auto 20px auto; max-width: 600px; text-align: center; 
}
.warning-img { width: 45px; height: auto; margin-bottom: 10px; }
.warning-text { margin: 0; color: #e74c3c; font-size: 18px; font-weight: 600; }

/* =========================================
   08. OVERLAYS & TOAST
========================================= */
#loading-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; height: 100dvh; 
    background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(3px); z-index: 99999; 
    display: flex; flex-direction: column; justify-content: center; align-items: center; color: white;
}
.dreamlight-logo { width: 100px; height: auto; margin-bottom: 20px; animation: pulse 1.5s infinite ease-in-out; }
@keyframes pulse { 0% { transform: scale(0.95); opacity: 0.7; } 50% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(0.95); opacity: 0.7; } }
.loading-text { font-size: 24px; font-weight: bold; text-align: center; }
.loading-subtext { font-size: 16px; color: #ddd; margin-top: 10px; text-align: center; }

#copy-toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: #333; color: #fff; padding: 10px 20px; border-radius: 5px;
    opacity: 0; transition: opacity 0.3s ease-in-out; pointer-events: none; z-index: 9999; font-weight: bold;
}
#copy-toast.show { opacity: 1; }

/* =========================================
   09. FOOTER
========================================= */
.site-footer { text-align: center; padding: 30px 20px; margin-top: 50px; font-size: 13px; color: #666; border-top: 1px solid #ddd; background: #f7f7f7; }
.site-footer p { margin: 5px 0; line-height: 1.5; }
.footer-link { color: #e67e22; font-weight: bold; text-decoration: underline; text-decoration-thickness: 2px; transition: color 0.2s ease; }
.footer-link:visited { color: #e67e22; }
.footer-link:hover { color: #ff9f43; text-decoration: none; }

/* =========================================
   10. LIGHTBOX OVERLAY
========================================= */
.lightbox {
    visibility: hidden; opacity: 0; position: fixed; z-index: 999999;
    left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.85); backdrop-filter: blur(4px);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.lightbox.show { visibility: visible; opacity: 1; }
.lightbox-content { max-width: 90%; max-height: 80vh; border-radius: 8px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5); animation: zoomIn 0.3s ease; }
#lightbox-caption { margin-top: 15px; color: #f1f1f1; font-size: 20px; font-weight: bold; text-align: center; max-width: 80%; }
.lightbox-close { position: absolute; top: 30px; right: 40px; color: #fff; font-size: 45px; font-weight: bold; cursor: pointer; transition: color 0.2s ease; }
.lightbox-close:hover { color: #f3a638; }
@keyframes zoomIn { from { transform: scale(0.9); } to { transform: scale(1); } }
td[data-label="Image"] img.thumb { cursor: zoom-in; transition: transform 0.2s ease; }
td[data-label="Image"] img.thumb:hover { transform: scale(1.1); }

/* =========================================
   11. RESPONSIVE ACCORDION STYLING
========================================= */
table.dataTable > tbody > tr.child ul.dtr-details { display: flex; flex-direction: column; width: 100%; }
table.dataTable > tbody > tr.child ul.dtr-details > li { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #efefef; padding: 8px 0; }
table.dataTable > tbody > tr.child span.dtr-title { font-weight: bold; min-width: 120px; text-align: left !important; }
table.dataTable > tbody > tr.child span.dtr-data { text-align: right; word-break: break-word; flex: 1; padding-left: 20px; }
table.dataTable > tbody > tr.child span.dtr-data .thumb { margin-left: auto !important; margin-right: 0 !important; }

table.dataTable > tbody > tr.child .sort-target::after { display: none !important; }
table.dataTable > tbody > tr.child .sort-target { pointer-events: none; text-decoration: none; }

/* 1. Hide the default DataTables icon so we don't get two arrows */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control::before {
    display: none !important;
}

/* 2. Make space for the button in the cell */
table.dataTable.dtr-inline.collapsed > tbody > tr > td:first-child {
    padding-left: 35px !important;
    position: relative;
}

/* 3. Hide button on large screens when accordion is disabled */
table.dataTable > tbody > tr > td:first-child .row-toggler {
    display: none; 
}

/* 4. Style our custom button EXACTLY like the mobile version */
table.dataTable.dtr-inline.collapsed > tbody > tr > td:first-child .row-toggler {
    display: inline-flex !important;
    justify-content: center;
    align-items: center;
    width: 22px !important;
    height: 22px !important;
    color: #7c3a99 !important;
    background-color: #f2f2f2 !important;
    font-size: 10px !important;
    font-weight: bold !important;
    border: 1px solid #b0b0b0 !important;
    border-radius: 4px !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1) !important;
    cursor: pointer !important;
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

/* 5. Closed state arrow (▶) */
table.dataTable.dtr-inline.collapsed > tbody > tr > td:first-child .row-toggler::before {
    content: "▶" !important;
}

/* 6. Open state arrow (▼) */
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td:first-child .row-toggler::before {
    content: "▼" !important;
}

/* 7. Dark Mode Overrides (Matching Mobile) */
body.dark-mode table.dataTable.dtr-inline.collapsed > tbody > tr > td:first-child .row-toggler {
    background-color: #1e1e1e !important;
    color: #f3a638 !important;
    border: 1px solid #777 !important;
}

/* =========================================
   12. DARK MODE OVERRIDES
========================================= */
body.dark-mode { background: #1a1a1a; color: #e0e0e0; }
body.dark-mode h1 { color: #fff; }
body.dark-mode h2 { color: #e0e0e0; }
body.dark-mode .site-footer { background: #1a1a1a; color: #888; border-top: 1px solid #333; }
body.dark-mode .footer-link, body.dark-mode .footer-link:visited { color: #f1c40f; }
body.dark-mode .footer-link:hover { color: #fceea7; }
body.dark-mode .warning-container { border-color: #c0392b; background-color: #2c1e1e; }
body.dark-mode .warning-text { color: #ff6b6b; }
body.dark-mode .db-update-time { color: #e0e0e0; }
body.dark-mode .tab-button { color: #7c3a99 !important; }
body.dark-mode .tab-button.active { color: #f3a638 !important; }
body.dark-mode div.dataTables_filter { background-color: #1a1a1a !important; box-shadow: 100px 0 0 0 #1a1a1a, -100px 0 0 0 #1a1a1a, 0 2px 0 0 #222222 !important; }

body.dark-mode .tab-bar-container { background: #1a1a1a !important; box-shadow: 100px 0 0 0 #1a1a1a, -100px 0 0 0 #1a1a1a !important; }
body.dark-mode .tab-scroll-btn.left { background: linear-gradient(to left, transparent, #1a1a1a 60%); color: #f3a638; }
body.dark-mode .tab-scroll-btn.right { background: linear-gradient(to right, transparent, #1a1a1a 60%); color: #f3a638; }
body.dark-mode .tab-scroll-btn:hover { color: #ffffff; }

body.dark-mode .filter-toggle-btn, body.dark-mode .sort-toggle-btn { background: #333; color: #f3a638; border-color: #555; }
body.dark-mode .filter-toggle-btn:hover, body.dark-mode .filter-toggle-btn.active, body.dark-mode .sort-toggle-btn:hover, body.dark-mode .sort-toggle-btn.active { background: #f3a638; color: #1a1a1a; }

body.dark-mode .desktop-filter-menu { background: #222; border-color: #444; }
body.dark-mode .filter-group { background: #2c2c2c; border-color: #444; }
body.dark-mode .filter-group h4 { color: #eee; }
body.dark-mode .clear-group-btn { background: #444; color: #eee; border-color: #666; }
body.dark-mode .checkbox-container label:hover { background: #444; }

body.dark-mode .reset-sort-btn { background: #333; color: #fff; border-color: #555; }
body.dark-mode .reset-sort-btn:hover { background: #444; }
body.dark-mode .theme-toggle-btn { background: #333; color: #fff; border-color: #555; }
body.dark-mode .theme-toggle-btn:hover { background: #444; }

body.dark-mode .legend-panel { background: #1a1a1a !important; width: 100% !important; box-sizing: border-box !important; box-shadow: 100px 0 0 0 #1a1a1a, -100px 0 0 0 #1a1a1a !important; }
body.dark-mode .legend-panel-inner { background: #1e1e1e !important; border: 1px solid #777 !important; box-shadow: 0 2px 6px rgba(0,0,0,0.5), 100px 0 0 0 #1a1a1a, -100px 0 0 0 #1a1a1a !important; margin: 0 auto !important; }
body.dark-mode .legend-swatch { border: 1px solid rgba(255,255,255,0.2) !important; }
body.dark-mode .legend-label { color: #e0e0e0 !important; font-weight: bold !important; }

body.dark-mode table.dataTable { background: #2d2d2d; border-color: #444; }
body.dark-mode table.dataTable thead { background-color: #222222 !important; }
body.dark-mode table.dataTable thead th, body.dark-mode table.dataTable thead td { background-color: #222 !important; color: #fff !important; outline: 1px solid #777777 !important; outline-offset: -1px !important; }
body.dark-mode table.dataTable tbody td { color: #000000 !important; border-bottom: 1px solid #000000 !important; }
body.dark-mode table.dataTable tbody td:first-child { border-left: 1px solid #777777 !important; }
body.dark-mode table.dataTable tbody td:last-child { border-right: 1px solid #777777 !important; }

body.dark-mode table.dataTable > tbody > tr.child td.child { background-color: #2a2a2a !important; border-bottom: 1px solid #000 !important; }
body.dark-mode table.dataTable > tbody > tr.child ul.dtr-details > li { border-bottom: 1px solid #444; }
body.dark-mode table.dataTable > tbody > tr.child span.dtr-title { color: #f3a638 !important; }
body.dark-mode table.dataTable > tbody > tr.child span.dtr-data { color: #e0e0e0 !important; }

/* =========================================
   13. RESPONSIVE DESKTOP CONTROLS
========================================= */

/* Triggers instantly when JS detects accordion mode */
.dataTables_wrapper.accordion-layout-active .dataTables_filter {
    display: flex;
    flex-direction: column;
    align-items: center;
    float: none !important;
    text-align: center;
    gap: 12px;
    margin-bottom: 15px;
}

/* Line 1: Last Updated (Centered) */
.dataTables_wrapper.accordion-layout-active .db-update-time {
    position: static !important;
    text-align: center !important;
    width: 100%;
    margin-bottom: 5px;
}

/* Container for Search and Buttons */
.dataTables_wrapper.accordion-layout-active .dt-search-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

/* Line 2: Search Bar (Forces it to take up the whole line) */
.dataTables_wrapper.accordion-layout-active .dt-search-controls label {
    width: 100%; 
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 8px;
}