/* =========================================
   COCO CAFE - CUSTOMER STOREFRONT STYLES
   ========================================= */

:root {
    --coco-dark: #23303d;
    --coco-green: #1abc9c;
    --coco-orange: #d35400;
    --bg-light: #f4f7f6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Smooth scrolling for anchor links */
html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-light);
    color: #333;
    line-height: 1.6;
    /* Adds space at the bottom so the floating cart doesn't block the last item */
    padding-bottom: 90px; 
}

/* --- HEADER --- */
header {
    background-color: var(--coco-dark);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 22px;
    font-weight: bold;
    letter-spacing: 1px;
}

.logo-area img {
    height: 45px;
    border-radius: 50%;
    background: white;
    padding: 2px;
}

/* --- FLOATING CART BUTTON --- */
.cart-btn {
    position: fixed;
    bottom: 30px;
    right: 20px;
    z-index: 1500; /* Ensures it floats above the cards and sticky nav */
    background-color: var(--coco-dark); 
    color: white;
    text-decoration: none;
    padding: 15px 25px;
    border-radius: 30px;
    font-weight: bold;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
}

.cart-btn:hover {
    background-color: var(--coco-green);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

/* --- STICKY CATEGORY NAVIGATION --- */
.category-nav {
    position: -webkit-sticky; /* Safari support */
    position: sticky;
    top: 0;
    z-index: 999; /* Keeps it above the food cards */
    background-color: #ffffff; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.08); 
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    padding: 15px 20px;
    gap: 15px;
}

/* Hide scrollbar for category nav but keep functionality */
.category-nav::-webkit-scrollbar {
    display: none;
}

.category-nav a {
    text-decoration: none;
    color: #555;
    font-weight: 600;
    font-size: 15px;
    padding: 8px 16px;
    border-radius: 20px;
    transition: all 0.3s ease;
    background: #f0f4f8;
    border: 1px solid transparent;
}

.category-nav a:hover, 
.category-nav a:active {
    background: var(--coco-green);
    color: white;
    border-color: var(--coco-green);
}

/* --- MENU SECTION & GRID --- */
.menu-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.category-title {
    margin: 40px 0 20px 0;
    border-bottom: 3px solid var(--coco-green);
    display: inline-block;
    padding-bottom: 5px;
    color: var(--coco-dark);
    /* Stops the sticky nav from covering the title when scrolling */
    scroll-margin-top: 80px; 
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

/* --- FOOD CARDS --- */
.card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid #fcfcfc;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.card-media {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background-color: #eee;
}

.card-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.card-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    font-size: 18px;
    margin-bottom: 10px;
    color: var(--coco-dark);
    gap: 10px;
}

.card-price {
    font-weight: bold;
    color: var(--coco-green);
    font-size: 16px;
}

.card-desc {
    color: #666;
    font-size: 14px;
    margin-bottom: 20px;
    flex-grow: 1;
    /* Limit description to 3 lines with an ellipsis */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- BADGES --- */
.status-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    color: white;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.badge-sold-out { background: #e74c3c; }
.badge-low-stock { background: #f39c12; }

/* --- BUTTONS --- */
.btn-add {
    background: var(--coco-green);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 6px;
    font-weight: bold;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.3s;
    text-align: center;
    width: 100%;
}

.btn-add:hover:not(:disabled) {
    background: #16a085;
}

.btn-add:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* --- MODAL (POP-UP) SYSTEM --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: none;
    justify-content: center;
    align-items: flex-end; /* Slides up from bottom on mobile */
    z-index: 2000;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

/* Fixes the scrolling issue by forcing the form to stay inside the modal limits */
.modal-content form {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    padding: 20px;
    background: var(--coco-green);
    color: white;
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-modal {
    background: none;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
}

.close-modal:hover {
    opacity: 1;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
}

.modifier-group {
    margin-bottom: 25px;
    border: 1px solid transparent;
    padding: 10px 0;
}

.modifier-group h4 {
    margin-bottom: 15px;
    color: var(--coco-dark);
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
    font-size: 16px;
}

.modifier-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 10px;
    border-bottom: 1px dashed #f0f0f0;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

.modifier-option:hover {
    background: #f9f9f9;
}

.modifier-option:last-child {
    border-bottom: none;
}

.modifier-option input[type="checkbox"], 
.modifier-option input[type="radio"] {
    margin-right: 10px;
    transform: scale(1.2);
    cursor: pointer;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 15px;
    align-items: center;
    background: #fff;
}

/* --- QUANTITY CONTROLS --- */
.qty-controls {
    display: flex;
    align-items: center;
    border: 1px solid #ccc;
    border-radius: 6px;
    overflow: hidden;
}

.btn-qty {
    background: #f9f9f9;
    border: none;
    padding: 12px 18px;
    font-size: 20px;
    cursor: pointer;
    color: #333;
    transition: background 0.2s;
}

.btn-qty:hover {
    background: #eee;
}

.qty-input {
    width: 50px;
    text-align: center;
    border: none;
    border-left: 1px solid #ccc;
    border-right: 1px solid #ccc;
    font-size: 16px;
    font-weight: bold;
    color: var(--coco-dark);
    background: white;
    -moz-appearance: textfield; /* Firefox hide arrows */
}

/* Chrome/Safari/Edge hide arrows */
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* --- CHECKOUT LAYOUT --- */
.checkout-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

/* --- RESPONSIVE DESKTOP ADJUSTMENTS --- */
@media (min-width: 768px) {
    .modal-content {
        border-radius: 12px;
        margin: 20px;
        align-self: center; /* Centers modal on screen instead of bottom */
        height: auto;
    }
    .modal-header {
        border-radius: 12px 12px 0 0;
    }
    
    .category-nav {
        justify-content: center; /* Centers the links on large screens */
    }
}