/* =========================================
   1. CSS RESET
   ========================================= */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
body { line-height: 1.5; -webkit-font-smoothing: antialiased; }
img, picture, video, canvas, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; }
p, h1, h2, h3, h4, h5, h6 { overflow-wrap: break-word; }

/* =========================================
   2. VARIABLES & BASE STYLES
   ========================================= */
:root {
    --color-bg: #F4F6F5;
    --color-text: #1E2320;
    --color-brand: #4A6741;
    --color-brand-hover: #364D2F;
    --color-danger: #D8473D;
    --color-danger-hover: #B5362D;
    
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.8);
    --glass-shadow: 0 8px 32px rgba(30, 35, 32, 0.05);
    
    --radius: 16px;
}

@font-face {
    font-family: 'Inter';
    src: url('font/Inter.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    overflow-x: hidden;
    transition: padding-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0 15px 20px 15px;
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(74, 103, 65, 0.06), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(216, 71, 61, 0.04), transparent 25%);
    background-attachment: fixed;
}

@media (min-width: 769px) {
    body.cart-open {
        padding-right: 440px;
    }
}

/* =========================================
   3. HEADER & LOGO
   ========================================= */
header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    margin: 15px auto 25px;
    max-width: 900px;
    position: sticky;
    top: 20px;
    z-index: 100;
    
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
}

.brand {
    display: flex;
    flex-direction: column;
}

.brand h1 {
    font-size: 2.8rem;
    line-height: 0.9;
    letter-spacing: -1.5px;
    color: var(--color-text);
    font-weight: 800;
}

.brand strong {
    color: var(--color-brand);
    font-size: 1.1rem;
    letter-spacing: 3px;
    margin-top: 5px;
    font-weight: 600;
    text-transform: uppercase;
}

.cart-toggle-btn {
    margin-left: auto;
    padding: 12px 24px;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 50px;
    cursor: pointer;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.05rem;
    color: var(--color-text);
    box-shadow: 0 4px 15px rgba(0,0,0,0.04);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.cart-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
    color: var(--color-brand);
}

.cart-badge {
    background: var(--color-brand);
    color: #fff;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.9rem;
    display: inline-block;
    transition: transform 0.2s ease;
}

/* =========================================
   4. MENU ITEMS
   ========================================= */
main {
    max-width: 900px;
    margin: 0 auto;
}

main > div {
    margin-bottom: 30px;
}

main > div > strong {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 15px;
    color: var(--color-text);
    position: relative;
    padding-left: 15px;
}
main > div > strong::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 70%;
    background: var(--color-brand);
    border-radius: 10px;
}

details {
    margin-bottom: 10px;
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--glass-shadow);
    overflow: hidden;
    transition: all 0.3s ease;
}

summary {
    cursor: pointer;
    font-weight: 700;
    font-size: 1.15rem;
    padding: 15px 20px 15px 70px;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
    position: relative;
}
summary::-webkit-details-marker {
    display: none;
}
summary::before {
    content: "";
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background-image: url('img/categories.webp');
    background-size: 600% 100%;
    background-repeat: no-repeat;
    mix-blend-mode: multiply;
    opacity: 0.9;
}
.cat-meat summary::before { background-position: calc(0 * 100% / 5) center; }
.cat-veg summary::before { background-position: calc(1 * 100% / 5) center; }
.cat-legume summary::before { background-position: calc(2 * 100% / 5) center; }
.cat-seed summary::before { background-position: calc(3 * 100% / 5) center; }
.cat-nut summary::before { background-position: calc(4 * 100% / 5) center; }
.cat-salad summary::before { background-position: calc(5 * 100% / 5) center; }

summary::after {
    content: '+';
    font-size: 1.5rem;
    color: var(--color-brand);
    transition: transform 0.3s ease;
}
details[open] summary::after {
    transform: rotate(45deg);
}
summary:hover {
    background: rgba(255,255,255,0.4);
}

details ul {
    list-style: none;
    padding: 0 25px 25px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

details li {
    background: #fff;
    border: 1px solid rgba(0,0,0,0.03);
    padding: 15px 15px 15px 70px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
details li:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.05);
}

details li::before {
    content: "";
    position: absolute;
    left: 10px;
    width: 48px;
    height: 48px;
    background-image: var(--bg-image);
    background-size: calc(var(--items) * 100%) 100%;
    background-position: calc(var(--idx, 0) * 100% / max(1, var(--items) - 1)) center;
    background-repeat: no-repeat;
    border-radius: 50%;
    mix-blend-mode: multiply;
}

/* Base Sprite Mapping per Category */
.cat-meat { --bg-image: url('img/meats.webp'); --items: 7; }
.cat-veg { --bg-image: url('img/vegatables.webp'); --items: 10; }
.cat-legume { --bg-image: url('img/legume.webp'); --items: 4; }
.cat-seed { --bg-image: url('img/seeds.webp'); --items: 6; }
.cat-nut { --bg-image: url('img/nuts.webp'); --items: 7; }
.cat-salad { --bg-image: url('img/salad.webp'); --items: 8; }

.item-0 { --idx: 0; }
.item-1 { --idx: 1; }
.item-2 { --idx: 2; }
.item-3 { --idx: 3; }
.item-4 { --idx: 4; }
.item-5 { --idx: 5; }
.item-6 { --idx: 6; }
.item-7 { --idx: 7; }
.item-8 { --idx: 8; }
.item-9 { --idx: 9; }
.item-10 { --idx: 10; }

/* Old Sprite Positioning Rules Removed */
details li h1 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text);
    flex: 1;
}

details li > div {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

details li button {
    padding: 8px 14px;
    border: none;
    background: #f4f6f5;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
    transition: all 0.2s ease;
}

details li button:hover {
    background: var(--color-brand);
    color: #fff;
    transform: scale(1.05);
}

.not-available, .non-season {
    opacity: 0.5;
    filter: grayscale(100%);
    pointer-events: none;
}

.status-msg {
    font-size: 0.85rem;
    color: var(--color-danger);
    font-weight: 600;
    background: rgba(216, 71, 61, 0.1);
    padding: 4px 10px;
    border-radius: 6px;
}

/* =========================================
   5. CART SECTION (DRAWER)
   ========================================= */
#cart-section {
    position: fixed;
    top: 0;
    right: -450px;
    width: 420px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--glass-border);
    padding: 35px 25px;
    box-shadow: -10px 0 40px rgba(0,0,0,0.05);
    z-index: 1000;
    overflow-y: auto;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

#cart-section.open {
    right: 0;
}

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.cart-header h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--color-text);
}

.cart-actions {
    display: flex;
    gap: 10px;
}

.cart-actions button {
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

#suggest-meal-btn {
    background: var(--color-brand);
    color: #fff;
    box-shadow: 0 4px 12px rgba(74, 103, 65, 0.2);
}
#suggest-meal-btn:hover {
    background: var(--color-brand-hover);
    transform: translateY(-2px);
}

#clear-cart-btn {
    background: rgba(216, 71, 61, 0.1);
    color: var(--color-danger);
}
#clear-cart-btn:hover {
    background: var(--color-danger);
    color: #fff;
}

.close-cart-btn {
    background: #fff;
    color: var(--color-text);
    border: 1px solid rgba(0,0,0,0.05) !important;
}
.close-cart-btn:hover {
    background: #f0f0f0;
}

/* =========================================
   6. CART ITEMS (MEALS & JARS)
   ========================================= */
.meal-group {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    border: 1px solid rgba(0,0,0,0.02);
}

.meal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.meal-header h3 {
    color: var(--color-text);
    font-size: 1.25rem;
    font-weight: 800;
}

.meal-delete-btn {
    background: transparent;
    color: var(--color-danger);
    border: none;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 6px;
    transition: all 0.2s;
}
.meal-delete-btn:hover {
    background: rgba(216, 71, 61, 0.1);
}

fieldset {
    margin-bottom: 15px;
    padding: 15px;
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 12px;
    background: #f9fafa;
}

legend {
    font-weight: 700;
    padding: 4px 12px;
    color: var(--color-brand);
    font-size: 0.9rem;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.cart-item {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.cart-item:last-child {
    margin-bottom: 0;
}

.cart-item span {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 600;
}

.cart-item select {
    padding: 6px 10px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 6px;
    background: #f9fafa;
    color: var(--color-text);
    font-weight: 600;
}

.cart-item button {
    padding: 6px;
    border: none;
    background: transparent;
    color: var(--color-danger);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 4px;
    transition: all 0.2s;
}
.cart-item button:hover {
    background: rgba(216, 71, 61, 0.1);
}

#empty-cart-msg {
    color: var(--color-text);
    opacity: 0.5;
    text-align: center;
    margin: 40px 0;
    font-weight: 500;
    font-size: 1.1rem;
}

#new-meal-btn, #checkout-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-weight: 800;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

#new-meal-btn {
    margin: 15px 0;
    background: #fff;
    color: var(--color-brand);
    border: 2px solid var(--color-brand);
}
#new-meal-btn:hover {
    background: var(--color-brand);
    color: #fff;
}

#checkout-btn {
    background: var(--color-text);
    color: #fff;
    margin-top: auto;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}
#checkout-btn:disabled {
    background: #d0d0d0;
    color: #888;
    box-shadow: none;
    cursor: not-allowed;
}
#checkout-btn:hover:not(:disabled) {
    background: #000;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

/* =========================================
   7. FOOTER
   ========================================= */
footer {
    margin-top: 60px;
    padding-top: 30px;
    text-align: center;
    color: var(--color-text);
    opacity: 0.6;
    font-size: 0.95rem;
    font-weight: 500;
}

footer a {
    color: var(--color-brand);
    text-decoration: none;
    font-weight: 700;
}
footer a:hover {
    text-decoration: underline;
}

/* =========================================
   8. RESPONSIVE
   ========================================= */
@media (max-width: 768px) {
    #cart-section {
        width: 100vw;
        right: -100vw;
        border-left: none;
    }
    
    header {
        padding: 20px;
        margin: 10px;
        border-radius: 20px;
    }
    
    details li {
        flex-direction: column;
        align-items: flex-start;
        padding-left: 20px;
        padding-top: 60px;
    }
    
    details li::before {
        left: 20px;
        top: 15px;
        width: 36px;
        height: 36px;
    }
}

/* =========================================
   9. MODAL OVERLAY
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #fff;
    padding: 35px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 90%;
    width: 380px;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-content h3 {
    margin-bottom: 30px;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--color-text);
    line-height: 1.4;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.modal-actions button {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    font-size: 1.05rem;
    transition: all 0.2s ease;
}

#confirm-cancel-btn {
    background: #f0f0f0;
    color: var(--color-text);
}
#confirm-cancel-btn:hover {
    background: #e0e0e0;
}

#confirm-yes-btn {
    background: var(--color-danger);
    color: #fff;
    box-shadow: 0 4px 15px rgba(216, 71, 61, 0.3);
}
#confirm-yes-btn:hover {
    background: var(--color-danger-hover);
    transform: translateY(-2px);
}
