/* =================================
    CSS VARIABLES (Light & Dark Mode)
    ================================= */

:root {
    /* Light Mode */
    --body-background: #f8f8f8;
    --main-text-color: #333;
    --sidebar-border-color: #ccc;
    --sidebar-input-border: #ddd;
    --collapsible-header-bg: #f7f7f7;
    --collapsible-header-hover-bg: #eee;
    --collapsible-border: #ddd;
    --alpha-button-bg: #f0f0f0;
    --alpha-button-border: #ccc;
    --alpha-button-hover-bg: #e2e6ea;
    --alpha-button-selected-bg: #007bff;
    --alpha-button-selected-color: #fff;
    --slider-handle-bg: #007BFF;
    --slider-handle-border: #0056B3;
    --slider-connect-bg: #007BFF;
    --table-container-bg: #f8f8f8;
    --main-heading-border: #ccc;
    --game-count-color: #666;
    --filter-tag-bg: #e9ecef;
    --filter-tag-color: #495057;
    --table-shadow: 0 2px 4px rgba(0,0,0,0.1);
    --table-bg: #fff;
    --table-border: #ddd;
    --table-header-bg: #f2f2f2;
	--table-row-odd-bg: #fdfdfd;
    --table-row-even-bg: #fafafa;
    --table-row-hover-bg: #0000FF; /* Blue background on hover */
    --table-row-hover-text: #FFFFFF; /* White text on hover */
    --table-link-color: #0066cc;
    --sort-indicator-color: #888;
    --sort-indicator-active-color: #007bff;
    --sort-border-active-color: #007bff;
    --responsive-border-bottom: #ccc;
    --view-options-btn-bg: #007bff;
    --view-options-btn-color: #fff;
    --view-options-btn-hover-bg: #0056b3;
    --view-options-btn-border: #007bff;
	
}
/* Style for the new icon buttons */
/* 1. Remove/Replace the .icon-button styles */
.icon-button {
    background-color: var(--alpha-button-bg, #f0f0f0); /* Use your theme variable or a light grey */
    border: 1px solid var(--alpha-button-border, #ccc);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;       /* Smaller font for text labels */
    font-weight: 600;
    color: var(--main-text-color, #444);
    padding: 8px 16px;       /* Horizontal padding for text width */
    transition: all 0.2s ease-in-out;
    text-decoration: none;   /* Ensures the 'Reset' link looks like a button */
    display: inline-flex;
    align-items: center;
}

.icon-button:hover {
    background-color: var(--alpha-button-hover-bg, #e2e6ea);
    color: #007bff;
    border-color: #007bff;
}

/* 2. You can usually REMOVE the divider entirely */
/* With actual buttons, a gap (margin) is cleaner than a vertical line */
.divider {
    display: none; 
}

/* 3. Ensure the container spaces them out */
.main-buttons {
    display: flex;
    gap: 10px; /* This replaces the need for the .divider */
    align-items: center;
}
.search-and-buttons-container {
    display: flex;
    align-items: center; /* This centers the items vertically */
    gap: 15px; /* Adds space between the buttons and search form */
}
.button-group-container {
    display: flex;
    justify-content: flex-start; /* Aligns items to the left */
    align-items: center; /* Vertically centers items */
    gap: 15px; /* Adds space between elements */
    flex-wrap: wrap; /* Allows wrapping on smaller screens */
    width: 100%; /* Ensures it spans the full width to control alignment */
}
#reset-filters-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: #444;
    padding: 5px;
    transition: color 0.2s ease-in-out;
}

#reset-filters-btn:hover {
    color: #007bff;
}
th.sortable {
    position: relative;
    padding-right: 24px; /* Make space for the sort indicator */
}

th.sortable::after {
    content: "⇅";
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7em;
    opacity: 0.3;
    transition: opacity 0.2s;
}

th.sortable:hover::after {
    opacity: 1;
}

/* Active sort indicators - replace the generic sort icon */
th.sort-asc::after {
    content: "↑";
    opacity: 1;
    color: var(--sort-indicator-active-color);
    font-size: 0.9em;
    font-weight: bold;
}

th.sort-desc::after {
    content: "↓";
    opacity: 1;
    color: var(--sort-indicator-active-color);
    font-size: 0.9em;
    font-weight: bold;
}

th.sort-active {
    color: var(--sort-indicator-active-color);
    font-weight: 600;
}

/* Dark Mode - Activated by System Preference or Manual Toggle */
@media (max-width: 480px) {
    .insights-container {
        grid-template-columns: 1fr;
    }

    /* This rule applies to all canvases on even smaller screens */
    .insight-card canvas {
        height: 200px !important;
        max-height: 200px !important;
    }
}prefers-color-scheme: dark) {
    :root {
        --body-background: #1a1a1a;
        --main-text-color: #e0e0e0;
        --sidebar-border-color: #444;
        --sidebar-input-border: #555;
        --collapsible-header-bg: #2a2a2a;
        --collapsible-header-hover-bg: #333;
        --collapsible-border: #444;
        --alpha-button-bg: #333;
        --alpha-button-border: #555;
        --alpha-button-hover-bg: #444;
        --alpha-button-selected-bg: #007bff;
        --alpha-button-selected-color: #fff;
        --slider-handle-bg: #007BFF;
        --slider-handle-border: #0056B3;
        --slider-connect-bg: #007BFF;
        --table-container-bg: #1a1a1a;
        --main-heading-border: #444;
        --game-count-color: #999;
        --filter-tag-bg: #333;
        --filter-tag-color: #ccc;
        --table-shadow: 0 2px 4px rgba(0,0,0,0.2);
        --table-bg: #2a2a2a;
        --table-border: #444;
        --table-header-bg: #333;
		--table-row-odd-bg: #4d4d4d;
		--table-row-even-bg: #3c3c3c;
		--table-row-hover-bg: #5a5a5a;
        --table-link-color: #79a1d1;
        --sort-indicator-color: #999;
        --sort-indicator-active-color: #79a1d1;
        --sort-border-active-color: #79a1d1;
        --responsive-border-bottom: #444;
        --view-options-btn-bg: #333;
        --view-options-btn-color: #e0e0e0;
        --view-options-btn-hover-bg: #444;
        --view-options-btn-border: #555;
    }
}

body[data-theme='dark'] {
    --body-background: #1a1a1a;
    --main-text-color: #e0e0e0;
    --sidebar-border-color: #444;
    --sidebar-input-border: #555;
    --collapsible-header-bg: #2a2a2a;
    --collapsible-header-hover-bg: #333;
    --collapsible-border: #444;
    --alpha-button-bg: #333;
    --alpha-button-border: #555;
    --alpha-button-hover-bg: #444;
    --alpha-button-selected-bg: #007bff;
    --alpha-button-selected-color: #fff;
    --slider-handle-bg: #007BFF;
    --slider-handle-border: #0056B3;
    --slider-connect-bg: #007BFF;
    --table-container-bg: #1a1a1a;
    --main-heading-border: #444;
    --game-count-color: #999;
    --filter-tag-bg: #333;
    --filter-tag-color: #ccc;
    --table-shadow: 0 2px 4px rgba(0,0,0,0.2);
    --table-bg: #2a2a2a;
    --table-border: #444;
    --table-header-bg: #333;
    --table-row-odd-bg: #4d4d4d;
    --table-row-even-bg: #3c3c3c;
        --table-row-hover-bg: #008000; /* Green background on hover*/
        --table-row-hover-text: #FFFFFF; /* Dark text for light mode */
    --sort-indicator-color: #999;
    --sort-indicator-active-color: #79a1d1;
    --sort-border-active-color: #79a1d1;
    --responsive-border-bottom: #444;
    --view-options-btn-bg: #333;
    --view-options-btn-color: #e0e0e0;
    --view-options-btn-hover-bg: #444;
    --view-options-btn-border: #555;
}

/* === General and Body Styling === */
body {
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--body-background);
    color: var(--main-text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}
#game-count-display {
    background-color: #4EA72E;
    color: #FFFFFF;
    padding: 5px 10px;
    border-radius: 4px;
    font-weight: bold;
    white-space: nowrap;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

#sort-display {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85em;
    color: var(--game-count-color);
}

.sort-indicator {
    background-color: var(--filter-tag-bg);
    color: var(--sort-indicator-active-color);
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 600;
    white-space: nowrap;
    font-size: 0.9em;
}

/* === Layout: Two-Column Structure === */
.main-content-wrapper {
    display: block;
    min-height: 100vh;
    padding: 120px 20px 40px;
    box-sizing: border-box;
}

.table-container {
    box-sizing: border-box;
    position: relative; /* Added for mobile shadow positioning */
}

/* === Filter Sidebar Components === */
.sidebar-search-form {
    margin-top: 10px;
    margin-bottom: 20px;
}

.sidebar-search-form input {
    width: calc(100% - 20px);
    padding: 8px 10px;
    border: 1px solid var(--sidebar-input-border);
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #ffffff; /* This is the change */
    color: var(--main-text-color);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Collapsible Filters */
.collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--collapsible-border);
    background-color: var(--collapsible-header-bg);
    margin-top: 20px;
    margin-bottom: 10px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.collapsible-header:first-of-type {
    margin-top: 0;
}

.collapsible-header:hover {
    background-color: var(--collapsible-header-hover-bg);
}

.collapsible-header .toggle-icon {
    font-size: 1.2em;
    font-weight: bold;
    line-height: 1;
    transition: transform 0.3s ease-out;
}

.collapsible-header.expanded .toggle-icon {
    transform: rotate(180deg);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    padding: 0 10px;
    margin-bottom: 10px;
}

.collapsible-content.expanded {
    max-height: 500px;
    transition: max-height 0.5s ease-in;
}

.collapsible-content label {
    display: block;
    margin: 5px 0;
    font-size: 14px;
}

.collapsible-content input[type="checkbox"] {
    margin-right: 8px;
}

/* Alphabetical Filter Grid */
.alpha-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 5px;
    padding: 10px 0;
}

.alpha-grid button {
    background-color: var(--alpha-button-bg);
    border: 1px solid var(--alpha-button-border);
    padding: 8px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--main-text-color);
}

.alpha-grid button:hover {
    background-color: var(--alpha-button-hover-bg);
}

.alpha-grid button.selected {
    background-color: var(--alpha-button-selected-bg);
    color: var(--alpha-button-selected-color);
    border-color: var(--alpha-button-selected-bg);
}

/* Styles to center the year slider */
.year-slider-container {
    padding: 27.5px 10px;
    border-bottom: 1px solid var(--sidebar-border-color);
    transition: border-color 0.3s ease;
}

#year-slider .noUi-handle {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: var(--slider-handle-bg);
    border: 2px solid var(--slider-handle-border);
    top: -5px;
    right: -7px;
}

#year-slider .noUi-connect {
    background-color: var(--slider-connect-bg);
}

#year-slider .noUi-handle:before,
#year-slider .noUi-handle:after {
    content: none;
}
#yearFilter {
    margin-top: 15px;
}
#year-slider {
    width: 90%;
}

/* === Main Content Area and Table === */
.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    position: relative;
}

.header-container h1 {
    margin: 0;
    font-size: 2em;
    padding-bottom: 10px;
}

.header-container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    border-bottom: 2px dotted var(--main-heading-border);
}

#game-count-display {
    background-color: #0F9ED5;
    color: #FFFFFF;
    padding: 5px 10px;
    border-radius: 4px;
    font-weight: bold;
    white-space: nowrap;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

#active-filters-display {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center !important; /* Forces vertical centering to override other rules */
    padding: 10px 0; /* Ensures there is vertical space to center within */
}
#active-filters-display .dynamic-filter-tag {
    background-color: #ffd700;
    color: #000;
    padding: 5px 10px;
    border-radius: 4px;
    font-weight: bold;
    white-space: nowrap;
    font-size: 0.9em;
    transition: all 0.3s ease;
}
.filter-tag {
    background-color: var(--filter-tag-bg);
    color: var(--filter-tag-color);
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.9em;
    transition: background-color 0.3s ease, color 0.3s ease;
}
.table-wrapper {
    position: relative;
    max-height: 70vh;
    overflow-x: auto; /* Enables horizontal scrolling */
    overflow-y: auto; /* Corrected to enable vertical scrolling */
    white-space: nowrap; /* Prevents text from wrapping */
    box-shadow: var(--table-shadow);
    background-color: var(--table-bg);
    -webkit-overflow-scrolling: touch; /* Enhanced mobile scrolling */
}

.clean-table thead th {
    position: sticky;
    top: 0;
    padding: 10px; /* Add this line to match platforms.css */
    background-color: var(--table-container-bg, #f8f8f8); /* Ensures the background matches the table and covers content */
    z-index: 10; /* Keeps the header above the scrolling content */
}
.clean-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    background-color: var(--table-bg);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    color: var(--main-text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.clean-table th, .clean-table td {
    border: 1px solid var(--table-border);
    padding: 8px 10px;
    text-align: left;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: border-color 0.3s ease;
}

.clean-table th {
    background-color: var(--table-header-bg);
    font-weight: bold;
    text-align: center;
    transition: background-color 0.3s ease;
}

/* Apply alternating background colors to table rows */
.clean-table tr.odd-row {
    background-color: var(--table-row-odd-bg);
}
.clean-table tr.even-row {
    background-color: var(--table-row-even-bg);
}

.clean-table tbody tr:hover {
    background-color: var(--table-row-hover-bg);
}

.clean-table tbody tr:hover td {
    color: var(--table-row-hover-text);
}

.clean-table a {
    color: var(--table-link-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.clean-table tr:hover {
    background-color: var(--table-row-hover-bg);
    cursor: pointer;
}

.clean-table .hide-column {
    display: none;
}

/* === Specific column widths based on your CTEtitles.php headers === */
.clean-table th[data-column-id="title"],
.clean-table td[data-column-id="title"] {
    width: 300px;
    max-width: 300px;
}
#gamesTable th[data-column-id="type"],
#gamesTable th[data-column-id="title"],
#gamesTable th[data-column-id="genre"] {
    text-align: left;
}
#gamesTable th[data-column-id="us_year"],
#gamesTable td[data-column-id="us_year"],
#gamesTable th[data-column-id="eu_year"],
#gamesTable td[data-column-id="eu_year"],
#gamesTable th[data-column-id="jp_year"],
#gamesTable td[data-column-id="jp_year"] {
    width: 5%;
    white-space: nowrap;
}

#gamesTable th[data-column-id="type"],
#gamesTable td[data-column-id="type"],
#gamesTable th[data-column-id="genre"],
#gamesTable td[data-column-id="genre"] {
    width: 1%;
    white-space: nowrap;
}
#gamesTable th[data-column-id="is_licensed"],
#gamesTable td[data-column-id="is_licensed"],
#gamesTable th[data-column-id="is_unlicensed"],
#gamesTable td[data-column-id="is_unlicensed"] {
    width: 1%;
    white-space: nowrap;
}

/* Set minimum widths for readability */
.clean-table th[data-column-id="release_year"],
.clean-table td[data-column-id="release_year"] {
    min-width: 50px;
}

.clean-table th[data-column-id="detailed_region"],
.clean-table td[data-column-id="detailed_region"] {
    min-width: 120px;
}

.clean-table th[data-column-id="prod_state"],
.clean-table td[data-column-id="prod_state"] {
    min-width: 150px;
}

.clean-table th[data-column-id="type"],
.clean-table td[data-column-id="type"] {
    min-width: 100px;
}

.clean-table th[data-column-id="genre"],
.clean-table td[data-column-id="genre"] {
    min-width: 150px;
}

.clean-table th[data-column-id="format_specific"],
.clean-table td[data-column-id="format_specific"] {
    min-width: 100px;
    white-space: nowrap;
}

.clean-table th[data-column-id="title"],
.clean-table td[data-column-id="title"] {
    width: auto;
}

.hide-column {
    display: none;
}

/* Set minimum widths for readability */
.clean-table th[data-column-id="release_year"],
.clean-table td[data-column-id="release_year"] {
    min-width: 50px;
}

.clean-table th[data-column-id="detailed_region"],
.clean-table td[data-column-id="detailed_region"] {
    min-width: 120px;
}

.clean-table th[data-column-id="prod_state"],
.clean-table td[data-column-id="prod_state"] {
    min-width: 150px;
}

.clean-table th[data-column-id="type"],
.clean-table td[data-column-id="type"] {
    min-width: 100px;
}

.clean-table th[data-column-id="genre"],
.clean-table td[data-column-id="genre"] {
    min-width: 150px;
}

.clean-table th[data-column-id="format_specific"],
.clean-table td[data-column-id="format_specific"] {
    min-width: 100px;
    white-space: nowrap;
}

.clean-table th[data-column-id="title"],
.clean-table td[data-column-id="title"] {
    width: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content-wrapper {
        flex-direction: column;
        padding: 20px;
    }

    .filter-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 2px dotted var(--responsive-border-bottom);
        margin-bottom: 20px;
        position: static;
        height: auto;
    }

    .table-container {
        padding-left: 0;
    }
}
/* =================================
    Slide-Out Menu Overlay
    ================================= */

.slideout-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black */
    z-index: 999; /* Below the menu (1000) */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    cursor: pointer; /* Indicates it can be clicked to close */
}

.slideout-menu-overlay.open {
    opacity: 1;
    visibility: visible;
}
/* =================================
    Slide-Out Menu
    ================================= */

.slideout-menu {
    position: fixed;
    top: 80px;
    left: 0;
    height: calc(100vh - 120px);
    width: 800px;
    max-width: 90%;
    background-color: var(--body-background);
    border-right: 1px solid var(--sidebar-border-color);
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.5s ease-in-out;
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
    transform: translateX(-100%);
}

.slideout-menu.open {
    transform: translateX(0);
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 20px;
    background: none;
    border: none;
    font-size: 30px;
    cursor: pointer;
    color: var(--main-text-color);
}
#slideout-trigger-btn,
.main-btn {
    padding: 10px 20px;
    font-size: 16px;
    border: 1px solid var(--view-options-btn-border);
    border-radius: 5px;
    background-color: var(--view-options-btn-bg);
    color: var(--view-options-btn-color);
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

#slideout-trigger-btn:hover,
.main-btn:hover {
    background-color: var(--view-options-btn-hover-bg);
}
/* Updated CSS for the header search form and buttons */
.button-group-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-right: 20px;
}

.main-search-form {
    width: 500px; /* Adjust this value to your desired width */
    margin-right: 20px;
}

.main-search-form input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--sidebar-input-border);
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--main-text-color);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.main-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

#slideout-trigger-btn,
    padding: 10px 20px;
    font-size: 16px;
    border: 1px solid var(--view-options-btn-border);
    border-radius: 5px;
    background-color: var(--view-options-btn-bg);
    color: var(--view-options-btn-color);
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

#slideout-trigger-btn:hover,
    background-color: var(--view-options-btn-hover-bg);
}

/* =================================
    Tabs Styling
    ================================= */
.tabs-container {
    padding-top: 40px;
}

.tab-headers {
    display: flex;
    justify-content: space-around;
    border-bottom: 1px solid var(--sidebar-border-color);
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 15px 0;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 18px;
    transition: border-bottom 0.3s;
    color: var(--main-text-color);
    text-align: center;
}
.tab-btn:hover {
    background-color: var(--collapsible-header-hover-bg);
}

.tab-btn.active {
    border-bottom: 3px solid #007bff;
    font-weight: bold;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* =================================
    Insights Container and Charts
    ================================= */
.insights-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

.insight-card {
    background-color: var(--table-bg);
    border: 1px solid var(--table-border);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--table-shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.insight-header {
    margin: 0 0 15px 0;
    font-size: 1.2em;
    color: var(--main-text-color);
    text-align: center;
    font-weight: 600;
}
/* CSS to ensure only the active tab is displayed */
.tab-pane {
    display: none;
}
.tab-pane.active {
    display: block;
}

/* New styles for scrollable chart container */
.chart-container-scroll {
    position: relative;
    height: 400px; /* Default height for smaller charts */
    overflow-y: auto; /* Enable vertical scrolling */
}
#total-titles-chart {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100px;
}

.insight-value {
    font-size: 3em;
    font-weight: bold;
    color: var(--sort-indicator-active-color);
    text-align: center;
    margin: 0;
}

/* This rule applies to all canvases, we need to adjust it */
.insight-card canvas {
    width: 100% !important;
}

/* This rule applies to all canvases except the genre and format specific charts */
#titles-by-year-chart,
#titles-by-region-chart,
#titles-by-type-chart {
    max-height: 300px !important;
    height: 300px !important;
}

@media (max-width: 768px) {
    .insights-container {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 15px 0;
    }

    .insight-card {
        padding: 15px;
    }

    /* This rule applies to all canvases on smaller screens, again excluding the dynamic charts */
    .insight-card canvas {
        height: 250px !important;
        max-height: 250px !important;
    }

    /* We need to specifically exclude the genre and format specific charts here */
    #titles-by-year-chart,
    #titles-by-region-chart,
    #titles-by-type-chart {
        max-height: 250px !important;
        height: 250px !important;
    }
}

/*
 * Final scroll shadow fix for all devices.
 * This code replaces all previous desktop and mobile shadow rules.
 */

.table-scroll-container {
    position: relative;
    box-shadow: var(--table-shadow);
    background-color: var(--table-bg);
    border-radius: 8px;
    border: 1px solid var(--table-border);
    margin-top: 20px;
}

.table-wrapper {
    position: relative;
    max-height: 70vh;
    overflow-x: auto;
    overflow-y: auto;
    white-space: nowrap;
    box-shadow: var(--table-shadow);
    background-color: var(--table-bg);
    -webkit-overflow-scrolling: touch;
}

.mobile-scroll-shadow {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(0, 0, 0, 0.2));
    pointer-events: none;
    z-index: 100; /* Increased z-index */
    transition: opacity 0.3s ease;
    display: block;
    opacity: 1;
}

/* Adjust shadow when scrollbar is present */
.table-wrapper.has-scrollbar + .mobile-scroll-shadow {
    right: 0; /* Keep at 0 for mobile since scrollbars are usually hidden */
}

/* Update for dark mode */
body[data-theme='dark'] .mobile-scroll-shadow {
    background: linear-gradient(to right, rgba(42, 42, 42, 0), rgba(0, 0, 0, 0.4));
}

.mobile-scroll-shadow.hidden {
    opacity: 0;
    pointer-events: none;
}
/* 1. Enable wrapping for the container of the filter items */
/* Update your existing filter container rule to include the format filter */
#addonFilter, 
#yearFilter .year-checkboxes, 
#detailedRegionFilter, 
#contentTypeFilter, 
#genreFilter, 
#licenseFilter, 
#productionStateFilter, 
#gameExclusivityFilter, 
#gameAvailabilityFilter,
#mediaSubtypeFilter { /* Added this ID */
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 10px 15px !important;
    padding: 10px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* 2. Ensure individual labels behave like inline-flex items */
.tab-pane label {
    display: inline-flex !important;
    align-items: center !important;
    flex: 0 1 auto !important; /* Don't force them to grow, but allow them to shrink */
    white-space: nowrap !important; /* Keep the checkbox and text together */
    font-size: 14px !important;
    cursor: pointer;
}

/* 3. Specifically fix the year checkboxes container if it's nested */
.year-checkboxes {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
}

/* 4. Ensure the slideout menu itself handles the overflow correctly */
#slideout-menu {
    overflow-x: hidden !important; /* Prevent horizontal scroll on the menu itself */
}

.tab-content {
    overflow-x: hidden !important;
}
.hide-column {
    display: none !important;
}
/* Loading Overlay */
.loader-overlay {
    position: absolute; /* Relative to .table-container */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--body-background);
    z-index: 9999; /* Ensure it's above the sticky table headers */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
    transition: opacity 0.3s ease;
}

/* The Animated Spinner */
.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--sidebar-border-color);
    border-top: 5px solid var(--alpha-button-selected-bg);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader-text {
    font-weight: bold;
    color: var(--main-text-color);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Helper class for JS */
.loader-hidden {
    opacity: 0;
    pointer-events: none;
    display: none !important;
}
/* =================================
   PAGINATION CONTROLS
   ================================= */
.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--table-border);
    background: var(--table-header-bg);
    border-radius: 0 0 6px 6px;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 30px;
}

.pagination-per-page {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85em;
    color: var(--game-count-color);
}

.pagination-per-page select {
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid var(--table-border);
    background: var(--table-bg);
    color: var(--main-text-color);
    font-size: 0.95em;
    cursor: pointer;
}

.pagination-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85em;
}

.pagination-btn {
    display: inline-block;
    padding: 6px 16px;
    border: 1px solid #007bff;
    border-radius: 4px;
    background: #007bff;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.9em;
}

.pagination-btn:hover {
    background: #0056b3;
    border-color: #0056b3;
    color: #fff;
}

.pagination-btn[disabled],
button.pagination-btn:disabled {
    background: var(--table-header-bg);
    border-color: var(--table-border);
    color: #aaa;
    cursor: not-allowed;
    pointer-events: none;
}

#pageIndicator {
    font-weight: 500;
    color: var(--main-text-color);
    min-width: 100px;
    text-align: center;
}

/* =================================
   FILTER SEARCH BOXES & CONTAINERS
   ================================= */

/* Search input boxes for developer/publisher filters */
.sidebar-filter-search {
    width: 100%;
    padding: 8px;
    margin-bottom: 8px;
    border: 1px solid var(--sidebar-input-border, #ddd);
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 0.9em;
    background: var(--table-bg, #fff);
    color: var(--main-text-color, #333);
    transition: border-color 0.2s ease;
}

.sidebar-filter-search:focus {
    outline: none;
    border-color: #007bff;
}

.sidebar-filter-search::placeholder {
    color: #999;
    font-style: italic;
}

/* Scrollable container for developer/publisher filters */
.filter-scroll-container {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid var(--sidebar-border-color, #ccc);
    border-radius: 4px;
    padding: 8px;
    background: var(--table-bg, #fff);
}

/* Individual filter items */
.filter-item {
    display: flex;
    align-items: center;
    padding: 6px 4px;
    margin-bottom: 4px;
    transition: background-color 0.2s ease;
}

.filter-item:hover {
    background-color: var(--collapsible-header-hover-bg, #eee);
    border-radius: 3px;
}

.filter-item input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.filter-item span {
    font-size: 0.9em;
    color: var(--main-text-color, #333);
    cursor: pointer;
    flex: 1;
}

/* Scrollbar styling for filter containers */
.filter-scroll-container::-webkit-scrollbar {
    width: 8px;
}

.filter-scroll-container::-webkit-scrollbar-track {
    background: var(--collapsible-header-bg, #f7f7f7);
    border-radius: 4px;
}

.filter-scroll-container::-webkit-scrollbar-thumb {
    background: var(--sidebar-border-color, #ccc);
    border-radius: 4px;
}

.filter-scroll-container::-webkit-scrollbar-thumb:hover {
    background: #999;
}