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

:root {
    /* Light Mode */
    --body-background: #f8f8f8;
    --main-text-color: #333;
    --sidebar-border-color: #ccc;
    --sidebar-header-color: #333;
    --sidebar-link-color: #0066cc;
    --sidebar-link-hover-color: #005fa3;
    --sidebar-link-hover-background: #f0f8ff;
    --sidebar-link-selected-color: #004c87;
    --sidebar-link-selected-background: #e6f3ff;
    --collapsible-header-background: #f7f7f7;
    --collapsible-header-hover-background: #eee;
    --table-background: #fff;
    --table-text-color: #333;
    --table-border-color: #ddd;
    --table-header-background: #f2f2f2;
    --table-row-even-background: #fafafa;
        --status-linked-background: #405744; /* New: Dark green for 'Linked' */
        --status-unlinked-background: #5f3e41; /* New: Dark red for 'Unlinked' */
	    --filter-tag-bg: #e9ecef;
    --filter-tag-color: #495057;
	--icon-button-color: #333;
	    --table-row-hover-bg: #0000FF; /* Blue background on hover */
    --table-row-hover-text: #FFFFFF; /* White text on hover */
}

/* Dark Mode - Activated by System Preference or Manual Toggle */
@media (prefers-color-scheme: dark) {
    :root {
        --body-background: #1a1a1a;
        --main-text-color: #e0e0e0;
        --sidebar-border-color: #444;
        --sidebar-header-color: #e0e0e0;
        --sidebar-link-color: #79a1d1;
        --sidebar-link-hover-color: #62707D;
        --sidebar-link-hover-background: #2a2a2a;
        --sidebar-link-selected-color: #79a1d1;
        --sidebar-link-selected-background: #333;
        --collapsible-header-background: #222;
        --collapsible-header-hover-background: #333;
        --table-background: #2a2a2a;
        --table-text-color: #e0e0e0;
        --table-border-color: #444;
        --table-header-background: #333;
        --table-row-even-background: #2a2a2a;
        --status-linked-background: #405744; /* New: Dark green for 'Linked' */
        --status-unlinked-background: #5f3e41; /* New: Dark red for 'Unlinked' */
		--icon-button-color: #fff;
		        --table-row-hover-bg: #008000; /* Green background on hover*/
        --table-row-hover-text: #FFFFFF; /* White text on hover*/
    }
}

body[data-theme='dark'] {
    --body-background: #1a1a1a;
    --main-text-color: #e0e0e0;
    --sidebar-border-color: #444;
    --sidebar-header-color: #e0e0e0;
    --sidebar-link-color: #79a1d1;
    --sidebar-link-hover-color: #62707D;
    --sidebar-link-hover-background: #2a2a2a;
    --sidebar-link-selected-color: #79a1d1;
    --sidebar-link-selected-background: #333;
    --collapsible-header-background: #222;
    --collapsible-header-hover-background: #333;
    --table-background: #2a2a2a;
    --table-text-color: #e0e0e0;
    --table-border-color: #444;
    --table-header-background: #333;
    --table-row-even-background: #2a2a2a;
        --status-linked-background: #405744; /* New: Dark green for 'Linked' */
        --status-unlinked-background: #5f3e41; /* New: Dark red for 'Unlinked' */
		    --table-row-hover-bg: #008000; /* Green background on hover*/
    --table-row-hover-text: #FFFFFF; /* Dark text for light mode */
}

/* =================================
    GENERAL STYLES & LAYOUT
    ================================= */
body {
    height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, 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;
}

.game-content-wrapper {
    min-height: 100vh;
    padding: 0px 20px 40px;
    box-sizing: border-box;
}
.table-wrapper {
    max-height: 70vh; /* MOVED from .table-container */
    overflow-y: auto; /* MOVED from .table-container */
    overflow-x: auto; /* MOVED from .table-container */
    -webkit-overflow-scrolling: touch; /* MOVED from .table-container */
    display: block;
}

.main-content-area {
    flex: 1;
    padding: 0 0 20px 0; /* Changed from 20px to 0 */
    box-sizing: border-box;
}

/* =================================
    PLATFORM TABLE
    ================================= */
.platform-table {
    width: 100%;
    border-collapse: collapse;
	border-spacing: 0; /* Add this line */
    background-color: var(--table-background);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: var(--table-text-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.platform-table th,
.platform-table td {
    border: 1px solid var(--table-border-color);
    padding: 8px 10px;
    text-align: left;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background-color 0.3s ease, color 0.3s ease;
}
/* Add this new rule */
.platform-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--table-header-background);
}
.platform-table th {
    /* Your existing styles are preserved */
    border: 1px solid var(--table-border-color);
    padding: 8px 10px;
    text-align: left;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.platform-table tr:nth-child(even) {
    background-color: var(--table-row-even-background);
}

.platform-table tr:hover {
    background-color: var(--table-row-hover-background);
}

.platform-table th.generation,
.platform-table td.generation {
    width: 80px;
    max-width: 80px;
    text-align: left;
}

.platform-table th.family,
.platform-table td.family {
    width: 120px;
    max-width: 120px;
    text-align: left;
}

.platform-table th.device-type,
.platform-table td.device-type {
    width: 150px;
    max-width: 150px;
    text-align: left;
}

.platform-table th.platform-name,
.platform-table td.platform-name {
    text-align: left;
}

.platform-table th.first-game,
.platform-table td.first-game,
.platform-table th.last-game,
.platform-table td.last-game {
    width: 75px;
    max-width: 75px;
    text-align: center;
}

.platform-table th.games,
.platform-table td.games {
    width: 45px;
    max-width: 45px;
    text-align: center;
}

.platform-table th.Status,
.platform-table td.Status {
    width: 45px;
    min-width: 45px;
    max-width: 45px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Specific column widths and alignment */
.platform-table th.platform-id,
.platform-table td.platform-id {
    display: none;
}
/* === Layout: Two-Column Structure === */
.main-content-wrapper {
    display: flex;
    min-height: 100vh;
    padding: 120px 20px 40px; /* This padding correctly positions the content below the fixed header */
    box-sizing: border-box;
}

/* === Slide-out Menu === */
.slideout-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99;
    display: none;
    cursor: pointer;
}

.slideout-menu {
    position: fixed;
    top: 0;
    left: -350px; /* Hidden off-screen by default */
    width: 300px;
    max-width: 90%;
    height: 100%;
    background-color: var(--body-background);
    color: var(--main-text-color);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
    transition: left 0.3s ease-in-out;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.slideout-menu.active {
    left: 0;
}

.slideout-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--sidebar-border-color);
}

.slideout-menu-header h2 {
    margin: 0;
    font-size: 1.5em;
}

.slideout-menu .close-btn {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: var(--main-text-color);
    line-height: 1;
    padding: 0;
}

.slideout-menu-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
}
/* Re-use this for your slideout menu */
.filter-sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    background-color: transparent;
    padding-right: 0;
}
/* This is for the content within the sidebar */
.sidebar-scroll-area {
    width: 100%;
}
/* === Main Heading & Count === */
.main-heading-container {
    border-bottom: 2px solid var(--main-heading-border);
    padding-bottom: 10px;
    margin-bottom: 20px;
}
.main-heading-container h1 {
    margin: 0;
    font-size: 2em;
}

.datfile-count {
    background-color: #0F9ED5;
    color: #FFFFFF;
    padding: 5px 10px;
    border-radius: 4px;
    font-weight: bold;
    white-space: nowrap;
    font-size: 14px;
}
/* === Main Search and Filter Sections === */
.filter-and-buttons-container {
    display: flex;
    align-items: center;
    gap: 10px; /* Use this to control the spacing between elements */
    margin-bottom: 20px;
}
.datfile-count {
    font-size: 14px;
    font-weight: bold;
    color: white;
    white-space: nowrap;
    margin-left: 10px;
}
.divider {
    width: 1px;
    height: 30px;
    background-color: #ccc;
    margin: 0 5px;
}
/* === Responsive Design === */
@media (max-width: 768px) {
    .game-content-wrapper {
        flex-direction: column;
    }

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

    .main-content-area {
        padding-left: 0;
    }
}
/* New CSS for sort indicators, from company_details.css */
th.sortable {
    position: relative;
    padding-right: 25px; /* Add space for the icon */
}

th.sortable::after {
    content: "⇅";
    position: absolute;
    right: 10px;
    font-size: 0.7em;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.3;
    transition: opacity 0.2s, transform 0.2s;
    line-height: 1; /* Ensures vertical alignment */
}

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

/* Style for active sorted column */
th.sortable[data-sort-direction="asc"]::after {
    opacity: 1;
    transform: translateY(-50%) rotate(180deg);
}

th.sortable[data-sort-direction="desc"]::after {
    opacity: 1;
    transform: translateY(-50%) rotate(0deg);
}
.intro-text {
    padding-bottom: 20px;
    width: 33.33%;
    max-width: 800px; /* Optional: Adjust for large screens */
    margin: 0; /* Ensures there is no auto margin for centering */
}
.dotted-line {
    border-bottom: 2px dotted #ccc;
    margin-top: 5px;
    margin-bottom: 20px;
}
/* You can keep these parts as they are not related to the sort icon */
.disallowed-row {
    cursor: not-allowed !important;
    opacity: 0.6;
}

.main-heading-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--main-heading-border);
    padding-bottom: 10px;
    margin-bottom: 20px;
    margin-top: 80px; /* This is the key change to push the section down */
}

/* Container for the filter and sort tags */
#active-filters-display {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

/* Styles for individual filter and sort tags */
.filter-tag,
.sort-tag {
    display: inline-block;
    padding: 5px 10px;
    margin-right: 10px;
    margin-bottom: 0;
    background-color: #FFEB3B;
    color: #000000;
    font-size: 14px;
    white-space: nowrap;
    border-radius: 4px;
    font-weight: bold;
}

/* Style for the "No filters applied" message */
.no-filter {
    color: black;
}
.icon-button {
    background-color: transparent;
    border: none;
}
.icon-button {
    background-color: var(--button-background);
    color: var(--button-text-color);
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 5px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    transition: background-color 0.3s ease-in-out;
}
.filter-buttons-container {
    display: flex;
}
.platform-table tbody tr:hover {
    background-color: var(--table-row-hover-bg);
    color: var(--table-row-hover-text);
    cursor: pointer;
}