/* CSS Variables - Summer Palette & Spacing */
:root {
    /* Rose Gold & Cream Palette based on Logo */
    --color-gold: #C48B71; /* Rose Gold */
    --color-rose-gold: #C48B71;
    --color-gold-light: #EBD3C6;
    --color-peach: #FAF4EF;
    --color-peach-light: #FFFFFF;
    
    /* Neutrals */
    --color-bg: #FAF4EF; /* Cream background from logo */
    --color-surface: #FFFFFF;
    --color-text-dark: #3A3331; /* Charcoal Brown */
    --color-text: #3A3331;
    --color-text-light: #8B7D78;
    --color-border: #E8DCCC;
    --color-beige: #FAF4EF;
    /* Spacing */
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 32px;
    --spacing-xl: 64px;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
}

/* Dark Mode Palette */
[data-theme="dark"] {
    --color-bg: #1A1514;
    --color-surface: #262120;
    --color-peach: #262120;
    --color-peach-light: #3A3331;
    --color-text-dark: #F5EFEB;
    --color-text: #F5EFEB;
    --color-text-light: #D5C9C4;
    --color-border: #4A4341;
    --color-beige: #221D1C;
    --color-gold: #D4A895; /* Lighter rose gold for dark mode contrast */
    --color-rose-gold: #D4A895;
}

/* Base Styles - Optimized for performance */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Tajawal', system-ui, -apple-system, sans-serif;
    background: var(--color-bg);
    min-height: 100vh;
    color: var(--color-text-dark);
    line-height: 1.6;
    padding-top: 80px; /* Offset for fixed navbar */
    overflow-x: hidden; /* Prevent horizontal scroll */
    transition: background-color 0.3s, color 0.3s;
}

html {
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding-left: clamp(16px, 4vw, 32px);
    padding-right: clamp(16px, 4vw, 32px);
}

a {
    color: var(--color-gold);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--color-text-dark);
}

/* Navbar */
.navbar {
    background-color: var(--color-beige);
    padding: 1rem 0;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: transform 0.3s ease-in-out;
}

.navbar.nav-hidden {
    transform: translateY(-100%);
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-md);
}

.logo h1 {
    font-family: 'Cinzel', serif;
    font-size: 1.8rem;
    color: var(--color-rose-gold);
    margin: 0;
}

.main-nav ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2rem;
    margin: 0;
    padding: 0;
}

.main-nav a {
    text-decoration: none;
    color: var(--color-text);
    font-weight: 700;
    font-size: 1.1rem;
    transition: color 0.3s;
}

.main-nav a:hover {
    color: var(--color-rose-gold);
}

.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.switcher select {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--color-rose-gold);
    border-radius: 20px;
    background: var(--color-surface);
    color: var(--color-text-dark);
    font-family: 'Tajawal', sans-serif;
    cursor: pointer;
    outline: none;
}

.theme-toggle {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-dark);
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    width: 42px;
    height: 42px;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
}

.theme-toggle:hover {
    background: var(--color-gold-light);
    transform: scale(1.1);
}

/* Hero Section */
.hero {
    background: var(--color-beige);
    padding: 4rem 0;
    text-align: center;
    border-bottom: 1px solid var(--color-border);
}

.hero-overlay {
    display: none;
}

.hero-content {
    position: relative;
    z-index: 1;
    background: transparent;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
}

.hero-logo {
    max-width: 450px;
    width: 100%;
    height: auto;
    object-fit: contain;
    mix-blend-mode: multiply;
}

/* Products Section */
.products-section {
    padding-top: var(--spacing-xl);
    padding-bottom: var(--spacing-xl);
}

.section-title {
    text-align: center;
    font-family: 'Amiri', 'Cinzel', serif;
    font-size: 2.2rem;
    color: var(--color-gold);
    margin-bottom: var(--spacing-lg);
    position: relative;
    display: block;
    width: 100%;
    left: auto;
    transform: none;
}

.section-title::after {
    content: "✧";
    display: block;
    font-size: 1.2rem;
    color: var(--color-gold-light);
    margin-top: -5px;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--spacing-lg);
    align-items: stretch;
}

/* Product Card */
.product-card {
    background-color: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(196, 139, 113, 0.05);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(196, 139, 113, 0.15); /* Thin rose gold border */
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(196, 139, 113, 0.25); /* Rose Gold shadow on hover */
    border-color: var(--color-gold);
}

.product-image-wrap {
    background: var(--color-peach-light);
    height: clamp(240px, 24vw, 280px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--color-border);
    overflow: hidden;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transform: scale(1.1);
}

.product-info {
    padding: var(--spacing-md);
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--spacing-sm);
    min-height: 0;
}

.product-title {
    font-size: 1.2rem;
    margin-bottom: var(--spacing-sm);
    color: var(--color-text-dark);
    word-wrap: break-word;
    line-height: 1.4;
}

.product-desc {
    font-size: 0.9rem;
    color: var(--color-text-light);
    margin-bottom: var(--spacing-sm);
    word-wrap: break-word;
    overflow-wrap: anywhere;
    flex: 1;
}

.product-ingredients {
    font-size: 0.85rem;
    background-color: var(--color-peach-light);
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-md);
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--color-border);
    padding-top: var(--spacing-md);
}

.product-price {
    font-weight: bold;
    font-size: 1.2rem;
    color: var(--color-gold);
}

.empty-msg {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--color-text-light);
    padding: var(--spacing-lg);
}

.view-btn,
.btn-primary,
.remove-item {
    background: var(--color-gold);
    color: #FFFFFF;
    border: 1px solid var(--color-gold);
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.view-btn {
    width: 100%;
    padding: 0.85rem 1rem;
    font-size: 1rem;
    margin-top: auto;
}

.view-btn:hover,
.btn-primary:hover,
.remove-item:hover {
    background: var(--color-text-dark);
    border-color: var(--color-text-dark);
    color: var(--color-surface);
    transform: translateY(-1px);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(3px);
    overflow: hidden;
    padding: clamp(10px, 3vh, 32px) clamp(10px, 3vw, 24px);
}

.modal-content {
    background-color: var(--color-surface);
    margin: 0 auto;
    padding: clamp(1rem, 2.5vw, 2rem);
    border-radius: 15px;
    width: min(100%, 800px);
    max-width: 800px;
    max-height: min(90dvh, 760px);
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: slideUp 0.4s ease;
    color: var(--color-text-dark);
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close-modal {
    position: absolute;
    right: 1.5rem;
    top: 1rem;
    font-size: 2rem;
    cursor: pointer;
    color: var(--color-text-light);
}

.close-modal:hover,
.close-cart:hover {
    color: var(--color-gold);
}

.modal-body {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 2rem;
    align-items: start;
}

.modal-image-container {
    background: var(--color-peach-light);
    border-radius: 10px;
    height: clamp(240px, 46dvh, 460px);
    max-height: min(60dvh, 460px);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-image-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    cursor: zoom-in;
}

.modal-details h2 {
    font-family: 'Cinzel', serif;
    color: var(--color-rose-gold);
    margin-bottom: 1rem;
}

.modal-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text-dark);
    margin-bottom: 1.5rem;
}

.modal-desc {
    color: var(--color-text-light);
    line-height: 1.6;
    margin-bottom: 1.25rem;
    overflow-wrap: anywhere;
}

/* Quantity Selector */
.quantity-selector {
    margin-bottom: 1.5rem;
}

.qty-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.qty-btn {
    width: 35px;
    height: 35px;
    border: 1px solid var(--color-gold);
    background: var(--color-gold);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    color: #FFFFFF;
}

.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2800;
    display: none;
    align-items: center;
    justify-content: center;
    padding: clamp(16px, 4vw, 40px);
    background: rgba(0, 0, 0, 0.82);
}

.image-lightbox.active {
    display: flex;
}

.image-lightbox img {
    max-width: 100%;
    max-height: min(92dvh, 980px);
    object-fit: contain;
    border-radius: 10px;
    background: var(--color-surface);
}

.close-lightbox {
    position: absolute;
    top: clamp(10px, 2vw, 24px);
    right: clamp(10px, 2vw, 24px);
    width: 44px;
    height: 44px;
    border: 1px solid var(--color-gold);
    border-radius: 50%;
    background: var(--color-surface);
    color: var(--color-text-dark);
    cursor: pointer;
    font: inherit;
    font-size: 2rem;
    line-height: 1;
}

.qty-btn:hover {
    background: var(--color-text-dark);
    border-color: var(--color-text-dark);
    color: var(--color-surface);
}

.qty-controls input {
    width: 60px;
    text-align: center;
    padding: 0.4rem;
    border: 1px solid var(--color-border);
    border-radius: 5px;
    background: var(--color-surface);
    color: var(--color-text-dark);
}

/* Cart Sidebar */
.cart-sidebar {
    position: fixed;
    right: min(-480px, -100vw);
    top: 0;
    width: min(480px, 100vw);
    height: 100%;
    background: var(--color-surface);
    box-shadow: -5px 0 20px rgba(0,0,0,0.2);
    z-index: 2500;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.cart-sidebar.active {
    right: 0;
}

.cart-header {
    padding: 1.5rem;
    background: var(--color-beige);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-cart {
    font-size: 1.5rem;
    cursor: pointer;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.cart-item {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr) auto;
    gap: 0.9rem;
    align-items: start;
    padding: 0.9rem;
    margin-bottom: 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.cart-item-image {
    display: grid;
    place-items: center;
    width: 84px;
    height: 96px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
}

.cart-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cart-item-image span {
    display: block;
    width: 100%;
    height: 100%;
}

.cart-item-details {
    min-width: 0;
}

.cart-item-details h4 {
    margin: 0 0 0.75rem;
    color: var(--color-text-dark);
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.cart-item-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
    margin: 0;
}

.cart-item-summary div {
    min-width: 0;
    padding: 0.45rem;
    border-radius: 6px;
    background: var(--color-surface);
}

.cart-item-summary dt {
    color: var(--color-text-light);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.25;
}

.cart-item-summary dd {
    margin: 0.2rem 0 0;
    color: var(--color-text-dark);
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.25;
}

.cart-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--color-border);
    overflow-y: auto;
}

.checkout-fields {
    display: grid;
    gap: 0.45rem;
    margin-bottom: 1rem;
}

.checkout-fields label {
    color: var(--color-text-dark);
    font-weight: 700;
}

.checkout-fields input,
.checkout-fields select,
.checkout-fields textarea {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-sizing: border-box;
    background: var(--color-bg);
    color: var(--color-text-dark);
    font: inherit;
    padding: 0.7rem;
}

.checkout-fields .phone-help {
    color: var(--color-text-light);
    line-height: 1.4;
}

.checkout-fields textarea {
    resize: vertical;
}

.checkout-actions {
    display: grid;
    gap: 0.65rem;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

/* Navbar Cart Button */
.floating-cart-btn {
    position: relative;
    background: var(--color-gold);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    box-shadow: 0 3px 10px rgba(0,0,0,0.18);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.cart-icon {
    font-size: 1.25rem;
}

.cart-count {
    position: absolute;
    top: -7px;
    right: -7px;
    background: white;
    color: var(--color-gold);
    min-width: 22px;
    height: 22px;
    padding: 0 0.2rem;
    box-sizing: border-box;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--color-gold);
}

#checkout-btn:disabled,
#email-checkout-btn:disabled {
    cursor: not-allowed;
    opacity: 0.65;
    transform: none;
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    border-radius: 30px;
    font-size: 1.1rem;
}

.remove-item {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    background: var(--color-surface);
    color: var(--color-text-dark);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

/* Responsive Tablets and Mobile */
@media (max-width: 768px) {
    .modal-body {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
    .modal-content {
        padding: clamp(0.9rem, 4vw, 1.5rem);
    }
    .modal-image-container {
        height: clamp(180px, 32dvh, 260px);
        max-height: 36dvh;
    }
    .cart-sidebar {
        width: 100%;
        right: -100%;
    }
    .cart-items {
        padding: 0.75rem;
    }
    .cart-item {
        grid-template-columns: 68px minmax(0, 1fr) auto;
        gap: 0.7rem;
        padding: 0.75rem;
    }
    .cart-item-image {
        width: 68px;
        height: 82px;
    }
    .cart-item-details h4 {
        margin-bottom: 0.55rem;
    }
    .cart-item-summary {
        grid-template-columns: 1fr;
    }
    .main-nav ul {
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 1rem;
    }
    .product-image-wrap {
        height: clamp(180px, 48vw, 220px);
    }
    .section-title {
        font-size: 1.8rem;
    }
}

@media (max-width: 480px) {
    .modal-body {
        gap: 0.85rem;
    }
    .close-modal {
        right: 0.9rem;
        top: 0.45rem;
    }
    .modal-details h2 {
        margin-bottom: 0.45rem;
        padding-inline-end: 1.5rem;
    }
    .modal-price {
        margin-bottom: 0.65rem;
    }
    .modal-desc {
        max-height: min(18dvh, 110px);
        overflow-y: auto;
        margin-bottom: 0.8rem;
    }
    .quantity-selector {
        margin-bottom: 0.85rem;
    }
    .cart-header,
    .cart-footer {
        padding: 1rem;
    }
    .checkout-fields textarea {
        min-height: 64px;
    }
}

@media (max-height: 720px) {
    .modal {
        padding-top: 8px;
        padding-bottom: 8px;
    }
    .modal-content {
        max-height: calc(100dvh - 16px);
        border-radius: 12px;
    }
    .modal-image-container {
        height: clamp(140px, 25dvh, 190px);
        max-height: 28dvh;
    }
    .modal-details h2 {
        line-height: 1.25;
    }
    .modal-desc {
        max-height: min(14dvh, 76px);
        overflow-y: auto;
    }
}

html[dir="rtl"] body {
    text-align: right;
}

html[dir="rtl"] .navbar,
html[dir="rtl"] .hero,
html[dir="rtl"] .products-section,
html[dir="rtl"] .footer {
    direction: rtl;
}

html[dir="rtl"] .nav-content,
html[dir="rtl"] .main-nav ul,
html[dir="rtl"] .controls,
html[dir="rtl"] .hero-content {
    text-align: center;
}

html[dir="rtl"] .product-card,
html[dir="rtl"] .modal-details,
html[dir="rtl"] .cart-sidebar {
    text-align: right;
}

/* Footer */
.footer {
    background-color: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: var(--spacing-xl) 0 var(--spacing-md);
    margin-top: var(--spacing-xl);
}

.footer-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr);
    align-items: start;
    text-align: start;
    gap: var(--spacing-lg);
}

html[dir="rtl"] .footer-content {
    text-align: right;
}

.footer h4 {
    color: var(--color-gold);
    margin-bottom: var(--spacing-sm);
}

.footer-about,
.footer-contact {
    min-width: 0;
}

.footer-about p {
    max-width: 42ch;
    color: var(--color-text-light);
    line-height: 1.7;
}

.footer-contact-form {
    display: grid;
    gap: 0.55rem;
}

.footer-contact-form label {
    color: var(--color-text-dark);
    font-weight: 700;
}

.footer-contact-form input,
.footer-contact-form textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
    color: var(--color-text-dark);
    padding: 0.75rem;
    font: inherit;
}

.footer-contact-form textarea {
    resize: vertical;
    min-height: 110px;
}

.footer-contact-form .btn-primary {
    justify-self: start;
    margin-top: 0.35rem;
}

.copyright {
    grid-column: 1 / -1;
    width: 100%;
    text-align: center;
    color: var(--color-text-light);
    font-size: 0.9rem;
}

/* Responsive Small Mobile */
@media (max-width: 600px) {
    body {
        padding-top: 150px; /* Larger offset for stacked navbar */
    }
    .hero-content h2 { 
        font-size: 1.6rem; 
        text-align: center;
        padding: 0 10px;
        line-height: 1.4;
    }
    .hero-content p {
        text-align: center;
        padding: 0 10px;
    }
    .nav-content { 
        flex-direction: column; 
        height: auto; 
        padding: 10px 0; 
        gap: 10px; 
    }
    .main-nav ul {
        gap: 0.8rem;
    }
    .main-nav a {
        font-size: 1rem;
    }
    .controls {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.7rem;
    }
    .floating-cart-btn {
        width: 42px;
        height: 42px;
    }
    .hero {
        padding: 2rem 0;
    }
    .hero-logo {
        max-width: 80%;
    }
    .section-title {
        font-size: 1.6rem;
    }
    .footer-content {
        grid-template-columns: 1fr;
    }
    .footer-about p {
        max-width: none;
    }
}
