:root {
    --background-color: #f4f4f4;
    --text-color: #333;
    --header-color: #5C4033; /* Dark Brown */
    --filter-bg-color: #fff;
    --table-bg-color: #fff;
    --table-border-color: #ddd;
    --table-header-bg: #5C4033; /* Dark Brown */
    --table-header-hover-bg: #4a3329; /* Slightly darker brown */
    --table-row-even-bg: #f2f2f2;
    --table-row-hover-bg: #ddd;
    --filter-h3-color: #5C4033; /* Dark Brown */
    --link-color: #007bff; /* Default blue for links in light mode */
}

body.dark-mode {
    --background-color: #2c2c2c;
    --text-color: #e0e0e0;
    --header-color: #8B4513; /* Saddle Brown for dark mode header */
    --filter-bg-color: #3c3c3c;
    --table-bg-color: #3c3c3c;
    --table-border-color: #555;
    --table-header-bg: #8B4513; /* Saddle Brown for dark mode table header */
    --table-header-hover-bg: #6b350f; /* Slightly darker saddle brown */
    --table-row-even-bg: #333;
    --table-row-hover-bg: #444;
    --filter-h3-color: white; /* White for dark mode filter h3 */
    --link-color: #8be9fd; /* Light blue/cyan for links in dark mode */
}

body {
    font-family: sans-serif;
    font-size: 1rem; /* Base font size increased for readability */
    line-height: 1.5; /* Improved line spacing */
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
}

a {
    color: var(--link-color);
    text-decoration: underline; /* Always underlined */
}

a:hover {
    text-decoration: underline;
}

h1 {
    color: var(--header-color);
    text-align: center;
    margin: 10px 0;
    font-size: 1.5em; /* Relative to body font size */
}

#themeToggle {
    font-size: 0.9em;
    padding: 5px 10px;
    margin-bottom: 15px; /* Add space below */
    width: 100%; /* Make it full width */
    box-sizing: border-box; /* Ensure padding doesn't break width */
    background-color: var(--table-header-bg);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

#themeToggle:hover {
    background-color: var(--table-header-hover-bg);
}

#toggleFilters {
    font-size: 1em;
    padding: 8px 10px;
    width: 100%;
    box-sizing: border-box;
    background-color: var(--header-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-bottom: 10px; /* Space below the toggle button */
}

#toggleFilters:hover {
    background-color: var(--table-header-hover-bg);
}

#filterContent.collapsed {
    display: none;
}

.filters {
    flex: 0 0 200px; /* Adjusted width for filters */
    background-color: var(--filter-bg-color);
    padding: 10px;
    margin-right: 10px;
    box-shadow: 0 2px 3px rgba(0,0,0,0.1);
    border-radius: 8px;
    transition: flex 0.3s ease-in-out, padding 0.3s ease-in-out; /* Smooth transition */
}

.filters.filters-collapsed {
    flex: 0 0 40px; /* Very narrow when collapsed */
    padding: 5px;
}

#toggleFilters {
    font-size: 1.2em; /* Slightly larger for icon-like text */
    padding: 5px; /* Smaller padding */
    width: 100%;
    box-sizing: border-box;
    background-color: var(--header-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-bottom: 10px;
    white-space: nowrap; /* Prevent text wrapping */
    overflow: hidden; /* Hide overflow if text is too long */
    text-overflow: ellipsis; /* Add ellipsis if text is too long */
}

#toggleFilters:hover {
    background-color: var(--table-header-hover-bg);
}

#filterContent.collapsed {
    display: none;
}

.container {
    display: flex;
    margin: 0 10px; /* Reduced margin */
}

.filters {
    flex: 0 0 200px; /* Adjusted width for filters */
    background-color: var(--filter-bg-color);
    padding: 10px;
    margin-right: 10px;
    box-shadow: 0 2px 3px rgba(0,0,0,0.1);
    border-radius: 8px;
}

.filter-section {
    margin-bottom: 15px;
    padding: 10px;
    border: 1px solid var(--table-border-color);
    border-radius: 5px;
    background-color: var(--filter-bg-color);
}

.filter-section h3 {
    color: var(--filter-h3-color);
    margin-top: 0;
    margin-bottom: 5px;
    border-bottom: 1px solid var(--table-border-color);
    padding-bottom: 3px;
    font-size: 1.1em;
}

.filter-section label {
    display: block;
    margin-bottom: 3px;
    font-size: 0.9em;
}

.filter-section input[type="number"] {
    width: calc(50% - 5px);
    padding: 3px;
    margin-bottom: 5px;
    font-size: 0.9em;
}

#applyFilters {
    background-color: #28a745;
    color: white;
    padding: 5px 10px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 1em;
    width: 100%;
}

#applyFilters:hover {
    background-color: #218838;
}

.table-container {
    flex-grow: 1;
    overflow-x: auto; /* Allows table to scroll horizontally if needed */
}

#loading {
    text-align: center;
    font-style: italic;
    margin-bottom: 10px;
    font-size: 1em;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 auto;
    background-color: var(--table-bg-color);
    box-shadow: 0 2px 3px rgba(0,0,0,0.1);
    border-radius: 8px;
}
th, td {
    border: 1px solid var(--table-border-color);
    padding: 5px;
    text-align: left;
    font-family: sans-serif; /* Apply sans-serif to table cells */
    font-size: 0.9em;
}

th {
    background-color: var(--table-header-bg);
    color: white;
    cursor: pointer;
    white-space: nowrap; /* Prevent header text from wrapping */
    font-size: 1em;
}

th:hover {
    background-color: var(--table-header-hover-bg);
}

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

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

#last-updated {
    margin-top: 15px;
    font-size: 0.8em;
    color: var(--text-color);
}

/* Make specific columns narrower */
/* Price/GB and Price */
th:nth-child(2), td:nth-child(2),
th:nth-child(3), td:nth-child(3) {
    width: 80px;
}

/* Form Factor and RAM Technology */
th:nth-child(8), td:nth-child(8),
th:nth-child(9), td:nth-child(9) {
    width: 100px;
}

/* Form Factor and RAM Technology */
th:nth-child(8), td:nth-child(8),
th:nth-child(9), td:nth-child(9) {
    width: 100px;
}

/* Form Factor and RAM Technology */
th:nth-child(8), td:nth-child(8),
th:nth-child(9), td:nth-child(9) {
    width: 100px;
}

/* --- Product Page Specific Styles --- */
.product-page.container {
    display: block; /* Override flex for single-column layout */
    max-width: 800px; /* Narrower container for single column */
    margin: 0 auto; /* Center the container */
    padding: 20px;
}

.product-page h1 {
    text-align: center; /* Center the main title */
    border-bottom: 2px solid var(--header-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.product-page .product-details {
    /* This is no longer a flex container */
}

.product-page .product-image {
    margin: 0 auto 20px auto; /* Center the image block */
    max-width: 400px; /* Control max image width */
}

.product-page .product-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--table-border-color);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    display: block; /* Remove extra space below image */
}

.product-page .product-info {
    /* No flex properties needed */
}

.product-page .product-specs h2,
.product-page .product-purchase h2 {
    font-size: 1.4em;
    color: var(--header-color);
    border-bottom: 1px solid var(--table-border-color);
    padding-bottom: 8px;
    margin-bottom: 15px;
}

.product-page .product-specs table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px; /* Space between specs and purchase box */
}

.product-page .product-specs td {
    padding: 10px 5px;
    border-bottom: 1px solid var(--table-border-color);
}

.product-page .product-specs tr:nth-child(even) {
    background-color: var(--table-row-even-bg);
}

.product-page .product-specs tr td:first-child {
    font-weight: bold;
    color: var(--text-color);
    width: 180px; /* Give labels a bit more space */
}

.product-page .product-purchase {
    padding: 20px;
    background-color: var(--filter-bg-color);
    border: 1px solid var(--table-border-color);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.product-page .price {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--header-color);
    margin: 0 0 5px 0;
    text-align: center;
}

.product-page .price-per-gb {
    font-size: 1.1em;
    margin: 0 0 20px 0;
    text-align: center;
}

.product-page .purchase-button {
    display: block;
    width: 100%;
    box-sizing: border-box; /* Ensures padding is included in the width */
    background-color: #28a745;
    color: white;
    padding: 15px 20px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.2em;
    text-align: center;
    transition: background-color 0.2s ease-in-out;
}

.product-page .purchase-button:hover {
    background-color: #218838;
}

.product-page .disclaimer {
    font-size: 0.8em;
    margin-top: 15px;
    color: var(--text-color);
    text-align: center;
}

.product-page .back-link {
    margin-bottom: 20px;
    font-size: 1.1em;
}

/* --- Main Navigation Bar --- */
.main-nav {
    background-color: var(--header-color);
    width: 100%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 1rem; /* Add space below the nav bar */
}

.main-nav .container {
    display: flex;
    justify-content: flex-start;
    padding: 0;
    margin: 0 auto;
    max-width: 1200px; /* Adjust as needed */
}

.main-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
}

.main-nav li a {
    display: block;
    color: white;
    text-decoration: none;
    padding: 0.8rem 1.2rem;
    font-size: 1rem;
    font-weight: bold;
    transition: background-color 0.2s ease-in-out;
}

.main-nav li a:hover {
    background-color: var(--table-header-hover-bg);
    text-decoration: none;
}

/* --- Featured Content Section --- */
.featured-container {
    display: block; /* Override flex for this container */
    margin-top: 2rem;
    padding: 1rem 0;
    border-top: 1px solid var(--table-border-color);
}

#featured-content h2 {
    text-align: center;
    color: var(--header-color);
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
}

.featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.featured-card {
    background-color: var(--filter-bg-color);
    border: 1px solid var(--table-border-color);
    border-radius: 8px;
    padding: 1.5rem;
    text-decoration: none;
    color: var(--text-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.featured-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    text-decoration: none;
}

.featured-card h3 {
    margin-top: 0;
    color: var(--header-color);
    font-size: 1.3rem;
}

.featured-card p {
    font-size: 0.95rem;
    line-height: 1.6;
}