/* ==========================================================================
   1. CSS Variables (Theming Engine)
   ========================================================================== */
:root {
    --bg-color: #f8f9fa;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --brand-color: #d97706; /* A warm, appetizing cafe color */
    --card-bg: #ffffff;
    --border-radius: 12px;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 2rem;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-color: #1e1e24; /* A soft, premium slate instead of pitch black */
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --card-bg: #2b2b36;
    --border-radius: 12px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   2. Base Reset & Typography
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==========================================================================
   3. Header & Navigation (Flexbox)
   ========================================================================== */
.menu-header {
    background-color: var(--card-bg);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.3s ease;
    padding: 0.75rem 0; /* Reduced vertical padding */
}

.header-container {
    max-width: 800px;
    margin: 0 auto;
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100%;
    padding: 0 var(--spacing-md);
}

.menu-header h1 {
    font-size: 1.5rem;
    font-weight: 800; /* Extra bold as in Naboo Cafe */
    color: var(--brand-color);
    margin: 0;
    line-height: 1;
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-container img {
    /* Border removed as requested */
}

.header-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.theme-btn {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    line-height: 1;
}

.theme-btn:hover {
    transform: scale(1.1);
}

/* Language Toggle Buttons */
.lang-selector {
    display: flex;
    gap: 0.25rem;
    background: #e9ecef;
    padding: 0.25rem;
    border-radius: 20px;
}

.lang-btn {
    border: none;
    background: transparent;
    padding: 0.4rem 0.8rem;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.lang-btn.active {
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   4. Main Container & Categories
   ========================================================================== */
.menu-container {
    max-width: 800px; /* Keeps line lengths readable on desktop */
    margin: 0 auto;
    padding: var(--spacing-lg) var(--spacing-md);
}

.category-section {
    margin-bottom: 3rem;
}

.category-title {
    font-size: 1.75rem;
    border-bottom: 2px solid var(--brand-color);
    padding-bottom: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.sub-category-title {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

/* ==========================================================================
   5. Items Grid (CSS Grid)
   ========================================================================== */
.items-grid {
    display: grid;
    /* Mobile First: 1 column. Desktop: Auto-fits to 2 columns if space allows */
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-md);
}

/* ==========================================================================
   5.5 Items Horizontal Scroll (Sub-Categories)
   ========================================================================== */
.items-horizontal {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: var(--spacing-md);
    padding: 0.5rem 0.25rem 1.5rem 0.25rem; /* Space for shadow & scrollbar */
    margin: -0.5rem -0.25rem 0 -0.25rem; /* Offset padding so edges align */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    
    /* Desktop drag functionality */
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.items-horizontal.active-drag {
    cursor: grabbing;
}

.items-horizontal::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Edge */
}

.items-horizontal > .menu-item {
    flex: 0 0 85%; /* Let the next item peek in */
    max-width: 320px;
    scroll-snap-align: start;
    height: auto; /* ensure they stretch if needed */
}

@media (min-width: 769px) {
    .items-horizontal > .menu-item {
        flex: 0 0 45%; /* Show more items on desktop */
    }
}

/* ==========================================================================
   6. Menu Item Cards
   ========================================================================== */
.menu-item {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.3s ease;
}

.menu-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.item-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.item-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

.item-price {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--brand-color);
    margin-top: auto; /* Pushes price to the bottom of the card */
}

/* ==========================================================================
   7. Dietary Badges
   ========================================================================== */
.item-badges {
    display: flex;
    gap: 0.5rem;
    margin-bottom: var(--spacing-sm);
}

.badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-vegan {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-vej {
    background-color: #ecfccb; /* Lime green background */
    color: #3f6212;            /* Dark olive/lime text */
}

.badge-gf {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-special { background: #fef9c3; color: #854d0e; } /* Gold/Yellow theme for special */

.badge-spicy {
    background: transparent;
    padding: 0;
    font-size: 0.8rem;
}

/* ==========================================================================
   8. Utility Classes
   ========================================================================== */
.loading-text, .error-text {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.error-text {
    color: #991b1b;
}

/* ==========================================================================
   9. Mobile App-Like Interface (Bottom Navigation & PWA)
   ========================================================================== */
.bottom-nav {
    display: none; /* Hidden on desktop by default */
}

/* Base styles for bottom nav items */
.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: color 0.2s ease;
    cursor: pointer;
    border: none;
    background: transparent;
}

.nav-item.active {
    color: var(--brand-color);
}

.cat-icon {
    font-size: 1.4rem;
    line-height: 1;
    margin-bottom: 4px;
    filter: grayscale(100%) opacity(0.5);
    transition: all 0.2s ease;
}

.nav-item.active .cat-icon {
    filter: grayscale(0%) opacity(1);
    transform: scale(1.1);
}

@media (max-width: 768px) {
    /* Make body fill the screen and disable text selection for app-like feel */
    body {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
        -webkit-overflow-scrolling: touch; /* Smooth iOS scrolling */
        scroll-behavior: smooth; /* Smooth scrolling to sections */
    }

    /* Bottom Navigation Bar */
    .bottom-nav {
        display: flex;
        overflow-x: auto;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background-color: var(--card-bg);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
        z-index: 1000;
        padding-bottom: env(safe-area-inset-bottom); /* iOS safe area */
        transition: background-color 0.3s ease;
        scrollbar-width: none; /* Firefox */
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
    }

    .bottom-nav::-webkit-scrollbar {
        display: none; /* Chrome, Safari, Edge */
    }

    .nav-item {
        flex: 0 0 33.33%; /* Show exactly 3 items, or slightly less for peeking */
        scroll-snap-align: center;
        min-width: 100px;
    }

    /* Adjust container padding - reduced on mobile to tighten gap with footer */
    .menu-container {
        padding-bottom: var(--spacing-md);
    }
    
    .category-section:last-child {
        margin-bottom: 1rem;
    }

    .social-icons-footer {
        padding: 0.5rem 1rem 100px 1rem !important; /* Balanced bottom space for nav bar */
    }
    
    /* Make header slightly more compact on mobile */
    .menu-header {
        padding: var(--spacing-sm) 0;
    }

    .header-controls {
        gap: 0.5rem !important; /* Tighter gap on mobile */
    }

    .lang-selector {
        padding: 0.15rem;
        border-radius: 12px; /* Slightly sharper corners for smaller size */
    }

    .lang-btn {
        padding: 0.2rem 0.5rem;
        font-size: 0.75rem;
        border-radius: 10px;
    }
}

/* ==========================================================================
   10. Admin Mobile Sidebar
   ========================================================================== */
.hamburger-btn {
    display: block;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.75rem;
    cursor: pointer;
    margin-right: 0.75rem;
    padding: 0;
    line-height: 1;
}

.admin-header {
    padding: 0.75rem var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-header .hamburger-btn {
    color: white;
}

.admin-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.admin-sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: var(--card-bg);
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.admin-sidebar.active {
    transform: translateX(0);
}

.admin-sidebar-header {
    padding: 1.5rem;
    background: #1e293b;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.admin-sidebar-header h2 {
    font-size: 1.25rem;
    margin: 0;
    color: white;
}

.close-sidebar-btn {
    background: none;
    border: none;
    color: #cbd5e1;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.admin-sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.admin-nav-link {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
    border-left: 4px solid transparent;
}

.admin-nav-link:hover {
    background: #f1f5f9;
}

.admin-nav-link.active {
    background: #f8fafc;
    color: var(--brand-color);
    border-left-color: var(--brand-color);
}

.admin-nav-icon {
    margin-right: 1rem;
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

@media (max-width: 768px) {
    .hamburger-btn {
        display: block;
    }
    
    .admin-header h1 {
        font-size: 1.25rem;
    }
}

/* ==========================================================================
   10. Image Cropper Styles
   ========================================================================== */
.cropper-container {
    position: relative;
    max-width: 100%;
    overflow: hidden; /* To clip the dark shadow of the mask */
    background: #e2e8f0;
    border: 1px dashed #cbd5e1;
    border-radius: 4px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; /* Prevent browser scroll while dragging mask */
}

.cropper-container img {
    display: block;
    max-width: 100%;
    height: auto;
    pointer-events: none; /* Events pass through to mask */
}

.circle-mask {
    position: absolute;
    width: 200px; 
    height: 200px;
    border-radius: 50%;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.65);
    border: 2px dashed rgba(255, 255, 255, 0.8);
    cursor: grab;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Start centered */
}

.circle-mask:active {
    cursor: grabbing;
}

/* ==========================================================================
   11. Drag and Drop Upload Zone
   ========================================================================== */
.upload-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    padding: 3rem 2rem;
    text-align: center;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
    border-color: var(--brand-color);
    background: #f1f5f9;
}

.upload-icon {
    font-size: 3rem;
    color: #94a3b8;
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.1rem;
    color: #475569;
    font-weight: 500;
}

.upload-subtext {
    font-size: 0.9rem;
    color: #94a3b8;
    margin-top: 0.5rem;
}

.upload-dropzone input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.footer-copyright {
    text-align: center;
    padding: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .footer-copyright {
    border-top-color: rgba(255, 255, 255, 0.05);
}

/* Admin Social Section */
.social-input-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #f8fafc;
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.admin-social-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

/* Footer Social Icons */
.social-icons-footer {
    padding: 1rem 1rem 2rem 1rem;
    text-align: center;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.social-links img {
    width: 32px;
    height: 32px;
    transition: transform 0.2s ease;
}

.social-links a:hover img {
    transform: scale(1.1);
}

.social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
}

.social-links img {
    width: 42px !important;
    height: 42px !important;
    object-fit: contain;
}

.social-links a:hover {
    transform: translateY(-4px) scale(1.1);
}

/* ==========================================================================
   11. Admin Accordion Styles
   ========================================================================== */
.admin-accordion {
    margin-bottom: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.accordion-header {
    background: #f8fafc;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.accordion-header:hover {
    background: #f1f5f9;
}

.accordion-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.accordion-icon {
    font-size: 1.2rem;
    transition: transform 0.3s;
}

.admin-accordion.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s;
    background: white;
}

.admin-accordion.active .accordion-content {
    max-height: 20000px; /* Large enough to fit content */
    padding-bottom: 1rem;
}

.admin-subcat-title {
    background: #f8fafc;
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--brand-color);
    border-top: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-subcat-title span {
    font-size: 1.1rem;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1));
}
