:root {
    --dkr-blue: #3b5998;
    --dkr-yellow: #f4e87d;
    --dkr-bg: #b2e2f2;
    --sidebar-width: 120px;
}

body {
    margin: 0;
    font-family: var(--body-font), sans-serif;
    /* This will be updated by JS to a pastel version of the world color */
    background-color: var(--dkr-bg); 
    transition: background-color 0.5s ease-in-out;
    /* Remove the image-rendering and background properties from here */
}

h1, h2, 
.site-title h1, 
.world-name, 
.nav-btn,
.tab {
    font-family: var(--title-font), cursive;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Header with Checkered Pattern */
.main-header {
    background-color: var(--dkr-blue);
    background-image: repeating-conic-gradient(#2a447a 0% 25%, transparent 0% 50%) 50% / 40px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 40px;
    color: white;
    border-bottom: 4px solid #1a2a4d;
}

.top-nav a {
    color: white;
    text-decoration: none;
    margin-left: 20px;
    font-weight: bold;
    opacity: 0.8;
}

.top-nav a.active { opacity: 1; border-bottom: 2px solid white; }

/* Wrapper Layout */
.timesheet-wrapper {
    display: flex;
    gap: 0; /* Remove any gap between sidebars and main display */
}

/* Sidebar Nav Buttons */
.side-nav {
    display: flex;
    width: 150px; 
    height: calc(100vh - 80px);
    overflow: visible; /* Changed from hidden to allow the "pop" out effect */
    position: relative;
}

.nav-tab {
    flex: 1;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.2s, flex 0.3s;
    outline: none;
    padding: 0;
    position: relative; /* Needed for z-index */

    /* This creates a 2px black outline around the letters */
    -webkit-text-stroke: 1.0px rgba(0, 0, 0, 0.61); 
    /* This shadow adds a bit of depth behind the outline */
    text-shadow: 2px 2px 0px rgba(0,0,0,0.4);
}

/* The Vertical Text Magic */
.nav-tab span {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-family: var(--title-font);
    font-size: 1.4rem; /* Slightly larger text for the wider tabs */
    color: white;
    text-transform: uppercase;
    white-space: nowrap;
    user-select: none;
    z-index: 3;
}

/* Flip text on the left sidebar so it reads from top-to-bottom or bottom-to-top as preferred */
.side-nav.left .nav-tab span {
    transform: rotate(180deg);
}

/* Subtle separator line between the two buttons */

.side-nav.left .track-tab {
    border-right: 1px solid rgba(0,0,0,0.1);
    border-top-left-radius: 75px;
    border-bottom-left-radius: 75px;
    /* Add a small gap between the tab and the main content */
    margin-left: -10px;
}

.side-nav.right .track-tab {
    border-right: 1px solid rgba(0,0,0,0.1);
    border-top-right-radius: 75px;
    border-bottom-right-radius: 75px;
    /* Add a small gap between the tab and the main content to emphasize the curve */
    margin-right: -10px; /* Pulls it over the world tab slightly */
}

.world-tab {
    width: 110px; /* Make it slightly wider so it "tucks" under */
    z-index: 1;
}

.track-tab {
    width: 100px;
    z-index: 2; /* Sits on top */
    box-shadow: 0 0 15px rgba(0,0,0,0.1); /* Adds a subtle shadow to "lift" it off the world tab */
}



/* Hover effects */
.nav-tab:hover {
    filter: brightness(1.1);
    flex: 1.2; /* Subtle "pop" effect like a folder tab */
}

/* Visual separation */
.track-tab {
    border-left: 2px solid rgba(255,255,255,0.3);
    border-right: 2px solid rgba(255,255,255,0.3);
}

.world-tab {
    opacity: 0.9; /* Make the world tab slightly different if desired */
}

.world-name {
    font-size: 0.8rem;
    font-weight: bold;
    color: #555;
    margin: 10px 0;
    writing-mode: vertical-rl;
    text-transform: uppercase;
}

#track-title {
    font-family: var(--title-font);
    font-size: 3rem; /* Slightly larger since it's stacked */
    line-height: 0.9; /* Pulls the words closer together vertically */
    color: var(--dkr-blue);
    margin: 10px 0;
    text-transform: uppercase;
    text-align: left; /* Or center, depending on your layout preference */
    
    /* Optional: adds a "thick" look to the Caprasimo font */
    text-shadow: 3px 3px 0px white; 
}

/* Side Nav Button Text */
.nav-btn span {
    font-family: var(--title-font);
    font-size: 0.85rem;
    display: block;
}

/* Main Display */
.track-display {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px); /* Matches sidebar height */
    box-sizing: border-box;
}

.track-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.silhouette { height: 150px; width: auto; }

.render-container {
    width: 650px; /* Slightly larger than the image */
    height: 270px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 15px;
    box-shadow: 5px 5px 15px rgba(0,0,0,0.2);
    
    /* This is where the 64x64 texture will now live */
    background-repeat: repeat;
    image-rendering: pixelated;
    overflow: hidden; 
    transition: background-image 0.5s ease-in-out;
}

.render-img { 
    max-height: 250px;
    max-width: 630px;
}

/* Vehicle Tabs */
.tabs-container {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.tab {
    padding: 10px;
    border: 3px solid transparent;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    border-radius: 12px; /* Rounded look for icons */
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: translateY(-2px);
}

.tab.active {
    background: var(--dkr-yellow);
    border-color: var(--dkr-blue);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.vehicle-icon {
    width: 50px; /* Adjust size based on your images */
    height: auto;
    display: block;
    /* Optional: filter to make inactive icons slightly greyscale */
    filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.2));
}

.tab.active .vehicle-icon {
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.4)) saturate(1.2);
}

/* Table */
.stats-table-wrapper {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(5px);
    border-radius: 0 10px 10px 10px;
    
    /* CHANGE: Remove top padding so header hits the very top */
    padding: 0 20px 20px 20px; 
    
    height: 450px; 
    overflow-y: auto;
    position: relative;
}

/* Optional: Style the scrollbar to match DKR colors */
.stats-table-wrapper::-webkit-scrollbar {
    width: 8px;
}

.stats-table-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

.stats-table-wrapper::-webkit-scrollbar-thumb {
    background: var(--dkr-blue);
    border-radius: 10px;
}

.track-info h2 {
    /* Add a small background or text-shadow if the title is over the BG */
    padding: 5px 15px;
    display: inline-block;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed; /* Forces the browser to respect our widths */
}

/* Ensure the table header stays visible while scrolling */
table thead th {
    position: sticky;
    top: 0; /* Now it's truly flush with the top of the wrapper */
    background-color: #ffffff; 
    z-index: 10;
    
    /* ADD: Extra padding here to make up for the lost wrapper padding */
    padding: 20px 5px 12px 5px; 
    
    border-bottom: 3px solid #eee;
    text-transform: uppercase;
    color: var(--dkr-blue);
    font-size: 0.8rem;
}

/* Define Column Widths */
th:nth-child(1), .cat-cell { width: 30%; }
th:nth-child(2) { width: 15%; } /* Personal Record */
th:nth-child(3) { width: 15%; } /* Date */
th:nth-child(4) { width: 10%; } /* Rank */
th:nth-child(5) { width: 15%; } /* World Record */
th:nth-child(6), .media-cell { width: 15%; }

th, td {
    padding: 12px 8px;
    text-align: left;
    vertical-align: top; /* Keeps text aligned to top even when history is open */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Allow the Category cell to wrap for the history list */
.cat-cell {
    white-space: normal;
}

.time-value {
    font-weight: bold;
    font-size: 1rem;
}

th:nth-child(2), th:nth-child(3), th:nth-child(4) {
    text-align: center;
}

/* Style the History inside the Cat Cell */
.history-dropdown {
    margin-top: 5px;
    font-size: 0.8rem;
}

.history-dropdown ul {
    list-style: none;
    padding: 5px 0 0 10px;
    margin: 0;
    border-left: 2px solid var(--dkr-blue);
}

.cat-name {
    font-weight: 700;
}

.media-cell {
    display: flex;
    flex-direction: row;
    justify-content: center; /* Centers them horizontally */
    align-items: center;     /* Centers them vertically */
    gap: 12px;               /* Defines the exact space between them */
    min-width: 80px;         /* Prevents the column from getting too thin */
    white-space: nowrap;     /* Forces them to stay on one line */
}

.media-cell a {
    text-decoration: none;
    display: inline-flex;    /* Helps with vertical alignment of the emoji */
    font-size: 1.3rem;       /* Makes them a bit more clickable */
    line-height: 1;
}

.media-cell a:hover {
    transform: scale(1.2); /* Makes them "pop" when you go to click a video */
}

.history-dropdown summary {
    cursor: pointer;
    color: var(--dkr-blue);
    font-weight: bold;
    outline: none;
}

.history-dropdown li {
    padding: 2px 0;
    border-bottom: 1px dashed #eee;
}

.history-dropdown li:last-child {
    border-bottom: none;
}

.swipe-arrow {
    display: none;
}

details { font-size: 0.8rem; color: #888; margin-top: 5px; }

@media (max-width: 768px) {
    .side-nav {
        display: none;
    }

    .timesheet-wrapper {
        flex-direction: column;
    }

    .track-display {
        height: auto;
        padding: 15px;
    }

    .render-container {
        display: none;
    }

    .track-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .silhouette {
        height: 100px;
    }

    .track-title-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 10px;
        background: rgba(255,255,255,0.6);
        border-radius: 10px;
    }

    .swipe-arrow {
        font-size: 1.5rem;
        opacity: 0.5;
        user-select: none;
        display: block;
    }

    #track-title {
        flex: 1;
        text-align: center;
        font-size: 1.5rem;
    }

    .stats-table-wrapper {
        overflow-x: auto;
    }

    table {
        min-width: 700px;
    }

    th:nth-child(3), td:nth-child(3), /* DATE */
    th:nth-child(5), td:nth-child(5)  /* WORLD RECORD */
    {
        display: none;
    }

    .tabs-container {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 5px;
    }

    .tab {
        flex: 0 0 auto;
    }

    header {
        padding: 10px 15px;
    }

    .site-title h1 {
        font-size: 1.2rem;
    }

    .site-title img {
        height: 30px;
    }

    .mobile-nav-buttons {
        display: flex;
        justify-content: space-between;
        margin: 10px 0;
    }

    .mobile-nav-buttons button {
        padding: 10px 15px;
        border: none;
        background: var(--dkr-blue);
        color: white;
        border-radius: 8px;
    }

    th, td {
        padding: 6px 4px;
        font-size: 0.75rem;
    }

    .time-value {
        font-size: 0.85rem;
    }

    table thead th {
        padding: 10px 4px;
        font-size: 0.7rem;
    }

    th:nth-child(1), .cat-cell { width: 10%; }
    th:nth-child(2) { width: 10%; }
    th:nth-child(4) { width: 5%; }
    th:nth-child(6), .media-cell { width: 5%; }

    .media-cell {
        gap: 6px;
    }

    .media-cell a {
        font-size: 1rem;
    }
}