:root {
    /* Modern Palette - Green & Woody Brown */
    --color-bg: #fdfbf7;
    /* Creamy off-white background */
    --color-text-main: #3e3221;
    /* Dark brown for text */
    --color-text-muted: #6b5842;
    /* Lighter brown for secondary text */

    --color-primary: #7da340;
    /* Fresh Apple Green */
    --color-primary-hover: #668534;
    --color-primary-light: #eef5e6;
    /* Light tint of primary green */
    --color-text-on-primary: #ffffff;

    --color-secondary: #c68e56;
    /* Warm Wood Brown */
    --color-secondary-hover: #a87643;

    --color-card-bg: #ffffff;
    --color-border: #e6e2da;

    /* Shadows & Radius */
    --shadow-sm: 0 2px 4px rgba(62, 50, 33, 0.05);
    --shadow-md: 0 6px 12px rgba(62, 50, 33, 0.08);
    --shadow-lg: 0 12px 24px rgba(62, 50, 33, 0.12);

    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;

    /* Transitions */
    --transition-fast: 0.2s ease;
}

/* Global Box Sizing */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    background-color: var(--color-bg);
    background-image: url('ApplePictures/bcgovphoto.jpg');
    background-attachment: fixed;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: var(--color-text-main);
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

/* --- Navigation --- */
/* Navbar styles are now handled by navbar.css */

/* --- Layout Components --- */

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.horizontal-row {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

/* --- Carousel Section --- */

.carousel-container {
    background-color: var(--color-card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    padding: 2rem;
    /* Restored padding for contained look */
    gap: 2rem;
    /* Gap between header box and description box */
}

.featured-header-box {
    width: 100%;
    padding: 1.5rem;
    background-color: var(--color-primary-light);
    border: 1px solid var(--color-primary);
    /* Full border */
    border-radius: var(--radius-md);
    /* Rounded corners */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.featured-content-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.textbox {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 1.5rem;
    color: var(--color-text-main);
    background: none;
    border: none;
    min-width: auto;
    margin-top: 1rem;
}

.desc-item {
    text-align: center;
    max-width: 600px;
    color: var(--color-text-muted);
    background: none;
    /* Removed background as container has it */
    padding: 0;
    /* Removed padding */
    border: none;
    /* Removed border */
    margin-top: 0.5rem;
}

.featured-info-box {
    border: 2px solid var(--color-primary);
    background-color: rgba(125, 163, 64, 0.05);
    /* Light green tint */
    border-radius: var(--radius-md);
    padding: 0;
    /* Remove padding so title touches edges */
    overflow: hidden;
    /* Clip title to corners */
    text-align: center;
    max-width: 800px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.featured-info-box .horizontal-row {
    padding: 1.5rem;
    /* Restore padding for description */
}

#main-apple-title {
    background-color: var(--color-primary);
    color: white;
    /* Text on primary */
    padding: 1rem 2rem;
    border-radius: 0;
    /* Let parent clip it */
    width: 100%;
    /* Stretch full width */
    margin-bottom: 0;
    box-shadow: none;
    /* Remove shadow to look like unified header */
}

.carousel-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
    max-width: 900px;
}

.carousel-track {
    position: relative;
    width: 100%;
    max-width: 900px;
    height: 300px;
    /* Fixed height to contain absolute items */
    margin: 1rem 0;
    perspective: 1000px;
}

.carousel-item {
    position: absolute;
    top: 50%;
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    transition: all 0.5s ease-in-out;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    border: 2px solid white;
}

/* Position 0: Far Left */
.pos-0 {
    left: 5%;
    transform: translateY(-50%) translateX(-50%) scale(0.6);
    z-index: 1;
    filter: brightness(0.5);
    opacity: 1;
}

/* Position 1: Mid Left */
.pos-1 {
    left: 15%;
    transform: translateY(-50%) translateX(-50%) scale(1.0);
    z-index: 2;
    filter: brightness(0.7);
    opacity: 1;
}

/* Position 2: Near Left */
.pos-2 {
    left: 30%;
    transform: translateY(-50%) translateX(-50%) scale(1.4);
    z-index: 3;
    filter: brightness(0.9);
    opacity: 1;
}

/* Position 3: Center (Featured) */
.pos-3 {
    left: 50%;
    width: 200px;
    /* Base size for center */
    height: 200px;
    /* Base size for center */
    transform: translateY(-50%) translateX(-50%) scale(1.2);
    z-index: 10;
    filter: brightness(1);
    opacity: 1;
    border: 4px solid white;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    cursor: default;
}

/* Position 4: Near Right */
.pos-4 {
    left: 70%;
    transform: translateY(-50%) translateX(-50%) scale(1.4);
    z-index: 3;
    filter: brightness(0.9);
    opacity: 1;
}

/* Position 5: Mid Right */
.pos-5 {
    left: 85%;
    transform: translateY(-50%) translateX(-50%) scale(1.0);
    z-index: 2;
    filter: brightness(0.7);
    opacity: 1;
}

/* Position 6: Far Right */
.pos-6 {
    left: 95%;
    transform: translateY(-50%) translateX(-50%) scale(0.6);
    z-index: 1;
    filter: brightness(0.5);
    opacity: 1;
}

.is-wrapping {
    opacity: 0 !important;
    z-index: -1 !important;
    transition: opacity 0.2s ease, left 0s 0.2s, transform 0s 0.2s !important;
}

/* Hover Effects */
.carousel-item:hover {
    filter: brightness(1) !important;
    z-index: 20 !important;
}

/* Far Left/Right Hover */
.pos-0:hover,
.pos-6:hover {
    transform: translateY(-50%) translateX(-50%) scale(0.7);
}

/* Mid Left/Right Hover */
.pos-1:hover,
.pos-5:hover {
    transform: translateY(-50%) translateX(-50%) scale(1.1);
}

/* Near Left/Right Hover */
.pos-2:hover,
.pos-4:hover {
    transform: translateY(-50%) translateX(-50%) scale(1.5);
}

/* Center Hover (No change or slight pop if desired, but usually static) */
.pos-3:hover {
    /* Center item usually doesn't need hover effect as it's already featured */
    transform: translateY(-50%) translateX(-50%) scale(1.2);
}

.title-box {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text-main);
    background: none;
    border: none;
    min-width: auto;
    margin-top: 0;
    /* Removed margin-top as it's handled by container padding */
    text-align: center;
    width: 100%;
}

.selection-button {
    background-color: var(--color-card-bg);
    /* White background */
    color: var(--color-primary);
    border: 2px solid var(--color-border);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    /* Prevent shrinking */
    z-index: 100;
    /* Ensure buttons are above carousel items if they overlap */
}

.selection-button:hover {
    background-color: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.selection-button:active {
    transform: scale(0.95);
}

/* --- Table Section --- */

#full-apple-table {
    background-color: var(--color-card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    border: 1px solid var(--color-border);
    width: 100%;
}

.table-scroll-wrapper {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling on iOS */
    border-radius: var(--radius-lg);

    /* Hide scrollbar for Chrome, Safari and Opera */
    &::-webkit-scrollbar {
        display: none;
    }

    /* Hide scrollbar for IE, Edge and Firefox */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.table-scroll-wrapper.is-draggable {
    cursor: grab;
}

.table-scroll-wrapper.is-draggable:active {
    cursor: grabbing;
}

.table-content-container {
    min-width: 100%;
    width: fit-content;
}

.table-header-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--color-primary);
    border-bottom: none;
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    padding: 1.5rem;
    background-color: var(--color-primary-light);
}

.search-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.search-bar input {
    width: 100%;
    max-width: 400px;
    padding: 0.8rem 1.2rem;
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: var(--transition-fast);
    outline: none;
}

.search-bar input:focus {
    border-color: var(--color-primary-hover);
    box-shadow: 0 0 0 3px rgba(125, 163, 64, 0.2);
}

.search-helper-text {
    color: var(--color-text-muted);
    font-style: italic;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0;
    /* Flush with header box */
}

th {
    text-align: left;
    padding: 1rem;
    background-color: var(--color-primary);
    color: var(--color-text-on-primary);
    font-weight: 600;
    border: 1px solid var(--color-primary-hover);
    cursor: pointer;
    transition: var(--transition-fast);
    user-select: none;
}

th:hover:not(.non-button) {
    background-color: var(--color-primary-hover);
    color: white;
}

/* Sort Indicators */
th:not(.non-button) {
    /* Restore default table cell behavior */
    padding-right: 0.5rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header-arrows {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-left: 10px;
}

.arrow-up,
.arrow-down {
    font-size: 0.6em;
    color: rgba(255, 255, 255, 0.5);
    /* Semi-transparent white */
    transition: transform 0.2s ease, color 0.2s ease;
}

/* Active States */
th.sort-asc .arrow-up {
    color: white;
    transform: scale(1.5);
}

th.sort-desc .arrow-down {
    color: white;
    transform: scale(1.5);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-muted);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: rgba(125, 163, 64, 0.05);
}

/* Specific column widths/styles */
#header-picture {
    width: 100px;
}

td img {
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    width: 60px;
    height: 60px;
    object-fit: cover;
}

/* --- Footer --- */

.footer {
    background-color: var(--color-text-main);
    color: white;
    padding: 3rem 1rem;
    margin-top: 4rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.footer-row-box {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-items: center;
}

.footer a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
}

.footer a:hover {
    text-decoration: underline;
    color: var(--color-primary-hover);
}

/* --- Modal --- */

#modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* Prevent body scroll */
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s;
    align-items: center;
    justify-content: center;
}

#modal[aria-hidden="false"] {
    display: flex;
}

#modal-screen {
    position: absolute;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

#modal-container {
    background-color: var(--color-card-bg);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: fit-content;
    max-width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    animation: slideUp 0.3s;
    z-index: 1001;
    overflow-y: auto;
}

#modal-close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--color-text-muted);
    line-height: 1;
    transition: var(--transition-fast);
}

#modal-close-btn:hover {
    color: var(--color-primary);
    transform: scale(1.1);
}

#modal-title {
    font-size: 1.5rem;
    color: var(--color-text-main);
    margin-bottom: 1rem;
    margin-top: 1rem;
    text-align: center;
}

#modal-image {
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    object-fit: contain;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* --- Graph Section --- */

#graph-section {
    width: 100%;
}

.graph-box {
    background-color: var(--color-card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    border: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.graph-content {
    width: 100%;
    max-width: 800px;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.bar-chart {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    width: 100%;
    height: 300px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--color-border);
    gap: 10px;
}

.test-bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    height: 100%;
    justify-content: flex-end;
}

.test-bar-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-end;
    /* Align bars to bottom */
    justify-content: center;
    position: relative;
    padding: 0 5px;
}

.test-bar {
    width: 100%;
    background-color: var(--color-primary);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: height 1s ease-out, background-color 0.2s;
    position: relative;
    cursor: pointer;
    min-height: 2px;
    /* Ensure 0 values have a tiny line or just hidden */
}

.test-bar:hover {
    background-color: var(--color-primary-hover);
}

.test-bar-label {
    margin-top: 10px;
    font-weight: 600;
    color: var(--color-text-muted);
}

.graph-x-axis-label {
    margin-top: 1rem;
    font-weight: 700;
    color: var(--color-text-main);
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

/* Tooltip */
.test-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--color-text-main);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s;
    pointer-events: none;
    margin-bottom: 8px;
    z-index: 10;
}

.test-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--color-text-main) transparent transparent transparent;
}

.test-bar:hover .test-tooltip {
    opacity: 1;
    visibility: visible;
}

/* --- Mobile Responsiveness --- */

@media screen and (max-width: 768px) {
    .search-bar {
        flex-direction: column;
    }

    .bar-chart {
        gap: 2px;
        /* Tighter bars */
    }

    .test-bar-label {
        font-size: 0.8rem;
        /* Smaller numbers */
    }
}

@media screen and (max-width: 480px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .bar-chart {
        height: 200px;
    }
}