/* --- Global Styles --- */
:root {
    --primary-color: #333;
    --secondary-color: #f4f4f4;
    --accent-color: #d4af37;
    --white: #ffffff;
    --border-color: #ddd;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    background-color: var(--secondary-color);
    color: var(--primary-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
main, .page-content {
    flex-grow: 1;
}
.container { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 0 1.5rem; 
}
img { 
    max-width: 100%; 
    display: block; 
}

/* --- Header & Navigation --- */
header {
    background-color: var(--white);
    box-shadow: var(--shadow);
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}
header .container {
    display: grid;
    /* Mobile: Logo Left, Cart Right */
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 1rem;
}
.logo-name { 
    text-decoration: none; 
    color: inherit;
    grid-column: 1 / 2;
}
.logo-name h1 { 
    font-size: 1.5rem; 
    font-weight: 700;
    margin: 0;
}
.logo-graphic {
    display: none; /* Hidden on mobile */
    text-align: center;
}
.cart-icon { 
    font-size: 1.1rem; 
    font-weight: 600;
    grid-column: 2 / 3;
    text-align: right;
    text-decoration: none;
    color: #333;
}

/* --- Page Layout & Sidebar --- */

/* Mobile: Hide sidebar */
.sidebar {
    display: none;
}
/* Mobile: Single column layout */
.grid-page .page-content {
    display: block;
    padding: 1.5rem 0;
}

/* Mobile: Style the new filter dropdown */
.mobile-filter {
    margin: 0 1.5rem 1.5rem 1.5rem;
}
.mobile-filter label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.mobile-filter select {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--white);
    font-family: inherit;
}


/* --- Product Grid (index.html) --- */
.product-grid {
    display: grid;
    /* Mobile: 1-column grid */
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 0 1.5rem;
}

a.product-card-link {
    text-decoration: none;
    color: var(--primary-color);
}
.product-card {
    background-color: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}
.product-card-link:hover .product-card {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
}
.product-image {
    width: 100%;
    object-fit: cover;
    aspect-ratio: 4 / 5;
}
.product-info { 
    padding: 1.5rem; 
    flex-grow: 1; 
}
.product-info h3 { 
    font-size: 1.2rem; 
    font-weight: 600; 
    margin-bottom: 0.5rem; 
}
.product-price { 
    font-size: 1.1rem; 
    font-weight: 700; 
    color: var(--accent-color); 
}

/* --- Footer --- */
footer {
    text-align: center;
    padding: 2rem 0;
    background-color: var(--white);
    margin-top: 2rem;
    border-top: 1px solid var(--border-color);
}

/* --- Product Detail Page (product.html) --- */
.product-detail-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    background-color: var(--white);
    padding: 1.5rem;
    border-radius: 12px;
    margin: 1.5rem 0;
}
.product-gallery .main-image {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 1rem;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}
.thumbnail-list {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}
.thumbnail-item {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.3s ease;
}
.thumbnail-item:hover, .thumbnail-item.active {
    opacity: 1;
}
.thumbnail-item.active {
    border-color: var(--primary-color);
}
.product-details-info h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.product-details-info .product-price {
    font-size: 1.5rem;
    color: var(--accent-color);
    margin-bottom: 1.5rem;
}
.product-details-info .product-description {
    font-size: 1rem;
    margin-bottom: 2rem;
}
.product-options {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.option-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.product-options select,
.product-options .quantity-input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--white);
    font-family: inherit;
}
.product-options .quantity-input {
    width: 100px;
}
.add-to-cart-btn {
    display: block;
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    color: var(--white);
    background-color: var(--primary-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}
.add-to-cart-btn:hover { background-color: #555; }
.add-to-cart-btn:disabled { background-color: #ccc; cursor: not-allowed; }


/* --- (DESKTOP) Overrides --- */
@media (min-width: 768px) {
    /* --- Header --- */
    header .container {
        /* Desktop: Name | Logo | Cart */
        grid-template-columns: 1fr auto 1fr;
    }
    .logo-name h1 {
        font-size: 1.8rem;
    }
    .logo-graphic {
        display: block; /* Show logo placeholder */
        grid-column: 2 / 3;
    }
    .cart-icon {
        grid-column: 3 / 4;
    }

    /* --- Page Layout --- */
    .sidebar {
        display: block;
        background-color: var(--white);
        padding: 1.5rem;
        border-radius: 12px;
        box-shadow: var(--shadow);
        align-self: start;
        position: sticky;
        top: 110px; /* Header height + padding */
    }
    .sidebar nav {
        flex-direction: column;
        gap: 0.5rem;
    }
    .filter-btn {
        width: 100%;
        text-align: left;
        padding: 0.8rem 1rem;
        font-size: 1rem;
        border-radius: 8px;
        border: 1px solid transparent;
        background-color: var(--white); /* Match clean look */
    }
    .filter-btn:hover {
        background-color: var(--secondary-color);
        border-color: transparent;
    }
    .filter-btn.active {
        background-color: var(--primary-color);
        color: var(--white);
        border-color: var(--primary-color);
    }
    
    /* Hide mobile filter on desktop */
    .mobile-filter {
        display: none;
    }

    /* Enable 2-column grid layout */
    .grid-page .page-content {
        display: grid;
        grid-template-columns: 240px 1fr;
        gap: 2rem;
        padding: 3rem 0;
    }

    /* --- Grid --- */
    .product-grid {
        /* Desktop: 2-column grid */
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
        padding: 0; /* Reset mobile padding */
    }

    /* --- Product Detail --- */
    .product-detail-layout {
        grid-template-columns: 1fr 1fr;
        gap: 3rem;
        padding: 3rem;
        margin: 3rem 0;
    }
    .product-details-info h1 {
        font-size: 2.5rem;
    }
    .product-details-info .product-price {
        font-size: 1.8rem;
    }
    .product-details-info .product-description {
        font-size: 1.1rem;
    }
}

/* --- (NEW) Cart Page Styles --- */
.cart-page-container h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    text-align: center;
}

.cart-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

.cart-items-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.cart-item {
    background-color: var(--white);
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: 100px 1fr 120px;
    gap: 1rem;
    padding: 1rem;
    align-items: center;
}

.cart-item-image {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
}

.item-info .item-name {
    font-size: 1.2rem;
    font-weight: 600;
}
.item-info .item-details {
    font-size: 0.9rem;
    color: #555;
    margin: 0.25rem 0;
}
.item-info .item-price {
    font-size: 1.1rem;
    font-weight: 700;
}

.item-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.item-actions .item-quantity {
    width: 70px;
    padding: 0.5rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-align: center;
}

.item-actions .remove-item-btn {
    font-size: 0.8rem;
    color: #900;
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
}

.cart-summary {
    background-color: var(--white);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    align-self: start;
    position: sticky;
    top: 110px;
}
.cart-summary h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}
.summary-line {
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
    margin-bottom: 1rem;
}
.summary-line.total-line {
    font-size: 1.2rem;
    font-weight: 700;
    margin-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}
.cart-summary .add-to-cart-btn {
    width: 100%;
    margin-top: 1rem;
}

/* Responsive Cart */
@media (max-width: 767px) {
    .cart-item {
        grid-template-columns: 80px 1fr; /* Stack actions */
        grid-template-rows: auto auto;
    }
    .cart-item-image {
        grid-row: 1 / 3;
    }
    .item-info {
        grid-column: 2 / 3;
    }
    .item-actions {
        grid-column: 1 / 3;
        grid-row: 3 / 4;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid var(--border-color);
    }
}

@media (min-width: 768px) {
    .cart-layout {
        /* Desktop: 2-column layout */
        grid-template-columns: 2fr 1fr;
        align-items: start;
    }
}

/* --- (NEW) Modal Styles --- */
.modal-overlay {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
}

.modal-overlay.show-modal {
    display: flex; /* Show the modal */
}

.modal-content {
    background-color: var(--white);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 450px;
    text-align: center;
}

.modal-content h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #c00; /* Red for error */
    margin-bottom: 1rem;
}

.modal-content p {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.modal-content .add-to-cart-btn {
    width: 100%;
}