/* Basic Reset & Variables */
:root {
    --color-bg: hsl(220, 20%, 95%); /* Very light blue-grey */
    --color-text: hsl(220, 15%, 30%); /* Darker blue-grey */
    --color-primary: hsl(160, 50%, 60%); /* Soft Teal */
    --color-primary-hover: hsl(160, 50%, 50%);
    --color-secondary: hsl(280, 40%, 70%); /* Muted Lavender */
    --color-secondary-hover: hsl(280, 40%, 60%);
    --color-card-bg: hsl(220, 20%, 98%); /* Slightly off-white for cards */
    --color-border: hsl(220, 10%, 85%); /* Light grey border */
    --color-error: hsl(0, 70%, 60%); /* Soft Red for errors/danger */
    --color-error-hover: hsl(0, 70%, 50%);

    /* Dark Theme Variables */
    --dark-color-bg: hsl(220, 25%, 10%); /* Dark blue-grey */
    --dark-color-text: hsl(220, 20%, 75%); /* Light blue-grey */
    --dark-color-primary: hsl(160, 40%, 50%); /* Teal */
    --dark-color-primary-hover: hsl(160, 40%, 40%);
    --dark-color-secondary: hsl(280, 30%, 60%); /* Lavender */
    --dark-color-secondary-hover: hsl(280, 30%, 50%);
    --dark-color-card-bg: hsl(220, 20%, 15%); /* Darker off-white for cards */
    --dark-color-border: hsl(220, 10%, 30%); /* Dark grey border */
    --color-description-text: hsl(220, 15%, 50%); /* Slightly lighter blue-grey for description */
    --dark-color-description-text: hsl(220, 10%, 85%); /* Light color close to white for dark theme description */

    /* Blue Theme Variables */
    --blue-color-bg: #F0F8FF; /* AliceBlue */
    --blue-color-text: #000080; /* Navy */
    --blue-color-primary: #007BFF; /* Blue */
    --blue-color-primary-hover: #0056b3;
    --blue-color-secondary: #6610f2; /* Indigo */
    --blue-color-secondary-hover: #563d7c;
    --blue-color-card-bg: #FFFFFF; /* White */
    --blue-color-border: #ADD8E6; /* LightBlue */
}

body.blue-theme {
    background-color: var(--blue-color-bg);
    color: var(--blue-color-text);
}

body.blue-theme header {
    background-color: var(--blue-color-card-bg);
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

body.blue-theme .intro-section {
    background-color: var(--blue-color-card-bg);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

body.blue-theme .product-card {
    background-color: var(--blue-color-card-bg);
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
}

body.blue-theme .product-info h3,
body.blue-theme .cart-item-info h4 {
    color: var(--blue-color-text);
}

body.blue-theme .modal-content {
    background-color: var(--blue-color-card-bg);
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
}

body.blue-theme .form-group input[type="text"],
body.blue-theme .form-group input[type="email"],
body.blue-theme .form-group textarea {
    background-color: var(--blue-color-bg);
    border-color: var(--blue-color-border);
    color: var(--blue-color-text);
}

body.blue-theme .form-group input:focus,
body.blue-theme .form-group textarea:focus {
    box-shadow: 0 0 0 2px hsla(160, 40%, 50%, 0.3);
}

body.blue-theme #cart-items {
    border-color: var(--blue-color-border);
}

body.blue-theme .cart-item {
    border-bottom-color: var(--blue-color-border);
}

body.dark-theme {
    background-color: var(--dark-color-bg);
    color: var(--dark-color-text);
}

body.dark-theme header {
    background-color: var(--dark-color-card-bg);
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

body.dark-theme .intro-section {
    background-color: var(--dark-color-card-bg);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

body.dark-theme .product-card {
    background-color: var(--dark-color-card-bg);
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
}

body.dark-theme .product-info h3,
body.dark-theme .cart-item-info h4 {
    color: var(--dark-color-text);
}

body.dark-theme .modal-content {
    background-color: var(--dark-color-card-bg);
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
}

body.dark-theme .form-group input[type="text"],
body.dark-theme .form-group input[type="email"],
body.dark-theme .form-group textarea {
    background-color: var(--dark-color-bg);
    border-color: var(--dark-color-border);
    color: var(--dark-color-text);
}

body.dark-theme .form-group input:focus,
body.dark-theme .form-group textarea:focus {
    box-shadow: 0 0 0 2px hsla(160, 40%, 50%, 0.3);
}

body.dark-theme #cart-items {
    border-color: var(--dark-color-border);
}

body.dark-theme .cart-item {
    border-bottom-color: var(--dark-color-border);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    padding-bottom: 50px; /* General padding at the bottom */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background-color: #fff;
    padding: 20px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    margin-bottom: 30px;
    position: sticky; /* Make the header sticky */
    top: 0; /* Stick it to the top of the viewport */
    z-index: 100; /* Ensure it stays on top of other content */
}

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

.theme-toggle-container {
    position: fixed;
    bottom: 10px;
    right: 20px;
}

.theme-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5em;
    color: var(--color-text);
    transition: color 0.3s ease;
    padding: 5px;
}

.theme-toggle-btn:hover {
    color: var(--color-primary);
}

header h1 {
    color: var(--color-primary);
    font-size: 2em;
    font-weight: 600;
}

.cart-icon {
    position: relative;
    cursor: pointer;
    font-size: 1.8em;
    color: var(--color-text);
    transition: color 0.2s ease;
}

.cart-icon:hover {
    color: var(--color-primary);
}

.cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: var(--color-error);
    color: white;
    border-radius: 50%;
    padding: 2px 7px;
    font-size: 0.6em;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
    line-height: 1.5;
    display: none; /* Hidden by default, shown by JS if items > 0 */
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn.primary {
    background-color: var(--color-primary);
    color: white;
}

.btn.primary:hover {
    background-color: var(--color-primary-hover);
    transform: translateY(-1px);
}

.btn.secondary {
    background-color: var(--color-secondary);
    color: white;
}

.btn.secondary:hover {
    background-color: var(--color-secondary-hover);
    transform: translateY(-1px);
}

.btn.danger {
    background-color: var(--color-error);
    color: white;
}

.btn.danger:hover {
    background-color: var(--color-error-hover);
    transform: translateY(-1px);
}

.btn {
    text-decoration: none;
}

.btn:disabled {
    background-color: var(--color-border);
    cursor: not-allowed;
    transform: none;
}

/* Intro Section */
.intro-section {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 20px;
    background-color: var(--color-card-bg);
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.intro-section h2 {
    font-size: 2.2em;
    color: var(--color-primary);
    margin-bottom: 15px;
    font-weight: 700;
}

.intro-section p {
    font-size: 1.1em;
    color: var(--color-text);
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.8;
}

.tagline {
    font-size: 1.5em;
    color: var(--color-secondary);
    text-align: center;
    margin-top: 20px;
    font-style: italic;
}


/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
}

.product-card {
    background-color: var(--color-card-bg);
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    overflow: hidden;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product-card.in-cart {
    border: 2px solid var(--color-primary);
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

.product-card canvas,
.product-card img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    display: block;
    border-bottom: 1px solid var(--color-border);
}

.product-info {
    padding: 20px;
}

.product-info h3 {
    font-size: 1.4em;
    margin-bottom: 10px;
    color: var(--color-text);
}

.product-info .product-description {
    font-size: 0.9em;
    color: var(--color-description-text);
    font-style: italic;
    margin-bottom: 10px;
    min-height: 4em;
}

body.dark-theme .product-info .product-description {
    color: var(--dark-color-description-text);
    max-height: 4em;
    overflow: hidden;
    padding: 5px;
}

.product-info .product-price {
    font-size: 1.1em;
    color: var(--color-primary);
    font-weight: 600;
    margin-bottom: 15px;
}

/* Modals */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
    backdrop-filter: blur(3px); /* Frosted glass effect */
    /* Removed 'display: flex;' from here. It will be added by JS when modal opens. */
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fefefe;
    margin: auto; /* For older browsers, flex handles centering */
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    position: relative;
    width: 90%;
    max-width: 600px;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: var(--color-text);
    text-decoration: none;
}

.modal-content h2 {
    color: var(--color-primary);
    margin-bottom: 20px;
    text-align: center;
}

/* Cart Items List */
#cart-items {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    padding: 15px 0;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed var(--color-border);
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-info {
    flex-grow: 1;
}

.cart-item-info h4 {
    font-size: 1.1em;
    color: var(--color-text);
}

.cart-item-info p {
    font-size: 0.9em;
    color: #777;
}

.cart-item-actions {
    margin-left: 20px;
}

.cart-item-actions .btn {
    padding: 5px 10px;
    font-size: 0.9em;
}

.cart-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

.cart-actions .btn {
    flex: 1;
    margin: 0 5px;
}

.cart-actions .btn:first-child {
    margin-left: 0;
}

.cart-actions .btn:last-child {
    margin-right: 0;
}

.cart-summary {
    text-align: right;
    margin-top: 20px;
}

.cart-summary p {
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 15px;
}

.cart-summary #cart-total {
    color: var(--color-primary);
}

/* Order Form */
#order-form .btn {
    width: 100%;
    margin-top: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--color-text);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--color-border);
    border-radius: 5px;
    font-size: 1em;
    font-family: inherit;
    color: var(--color-text);
    background-color: var(--color-bg);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px hsla(160, 50%, 60%, 0.3); /* Using HSLA for shadow */
}

textarea {
    resize: vertical;
}

#order-form .btn {
    width: 100%;
    margin-top: 20px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .product-grid {
        grid-template-columns: 1fr;
    }

    /* Ensure header stays at the top and cart is visible */
    header {
        position: fixed; /* Changed to fixed */
        top: 0;
        left: 0; /* Add left: 0 to ensure full width */
        width: 100%; /* Add width: 100% to ensure full width */
        z-index: 100; /* Ensure it's above other content */
        background-color: #fff; /* Ensure background is solid */
        padding: 10px 0; /* Reduce padding for smaller screens */
    }

    header .container {
        flex-direction: row; /* Keep items in a row */
        justify-content: space-between; /* Keep space between logo and cart */
        align-items: center; /* Vertically align items */
        padding: 0 10px; /* Reduce container padding */
        position: relative;
    }

    header h1 {
        font-size: 1.5em; /* Smaller heading */
        margin: 0; /* Remove default margin */
    }

    .cart-icon {
        font-size: 1.5em; /* Smaller cart icon */
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }

    .intro-section h2 {
        font-size: 1.8em;
    }

    .intro-section p {
        font-size: 1em;
    }

    body {
        padding-top: 60px; /* Add padding to the body to account for the fixed header height */
    }
}

header {
    position: sticky; /* Make the header sticky */
    top: 0; /* Stick it to the top of the viewport */
    z-index: 100; /* Ensure it stays on top of other content */
}
