/* Menu Gallery System with Italian Flag Border Styling */

/* Italian Flag Gradient Definition */
:root {
    --italian-flag-gradient: linear-gradient(90deg, #009246 0%, #FFFFFF 50%, #CE2B37 100%);
    --italian-flag-gradient-vertical: linear-gradient(180deg, #009246 0%, #FFFFFF 50%, #CE2B37 100%);
    --section-spacing: 20px;
    --item-spacing: 20px;
}

/* Unified Menu Grid - Same layout for all categories */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    width: 100%;
}

/* Category Gallery - Reusing Homepage Gallery Logic with 16:9 Landscape */
.category-gallery-wrapper {
    width: 100%;
    margin-top: var(--section-spacing);
    margin-bottom: var(--section-spacing);
    position: relative;
    overflow: hidden;
    clear: both;
    box-sizing: border-box;
}

.category-gallery-viewport {
    width: 280px !important;
    height: 180px !important;
    max-width: 280px !important;
    max-height: 180px !important;
    overflow: hidden !important;
    position: relative !important;
    border: 3px solid transparent;
    border-image: linear-gradient(90deg, #009246 0%, #FFFFFF 50%, #CE2B37 100%) 1;
    border-image-slice: 1;
    border-radius: 0;
    background: linear-gradient(90deg, #008c45 0%, #f4f5f0 50%, #cd212a 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: box-shadow 0.3s ease;
    box-sizing: border-box;
    margin: 0 auto;
}

.category-gallery-viewport:hover {
    box-shadow: 0 8px 24px rgba(0, 146, 70, 0.4);
}

/* Category Gallery Slide - Using homepage fade transition approach */
.category-slide {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    opacity: 0 !important;
    transition: opacity 0.5s ease-in-out;
    z-index: 1 !important;
    visibility: hidden !important;
    background: transparent !important;
    border-radius: 0;
}

.category-slide.active {
    opacity: 1 !important;
    z-index: 2 !important;
    visibility: visible !important;
}

.category-slide img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    display: block;
    background: transparent !important;
    cursor: pointer;
}

/* Menu Item Image Display - Vertical Layout */
.menu-item-layout {
    display: flex;
    align-items: stretch;
    gap: 16px;
    width: 100%;
    flex-direction: column !important;
}

/* Layout fix: Make menu-card-body a proper vertical flex container */
.menu-card-body {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Layout fix: Badge below image - centered with proper spacing */
.menu-item-layout > .item-badge {
    position: static;
    align-self: center;
    margin-top: 0.75rem;
    margin-bottom: 1rem;
}

/* Layout fix: Content area takes remaining space */
.menu-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    text-align: center;
}

/* Layout fix: Center title and description */
.item-name {
    text-align: center;
}

.item-description {
    text-align: center;
}

/* Badge styling - preserved from inline styles */
.item-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
}

.item-badge.available {
    background: rgba(14, 107, 59, 0.2);
    color: var(--accent-green);
    border: 1px solid var(--accent-green);
}

.item-badge.out-of-stock {
    background: rgba(198, 40, 40, 0.2);
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
}

/* Layout fix: Push price row to bottom of content area */
.item-price-row {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.menu-item-image-slot {
    flex-shrink: 0;
    width: 120px !important;
    height: 120px !important;
    max-width: 120px !important;
    max-height: 120px !important;
    border: 3px solid transparent;
    border-image: linear-gradient(90deg, #009246 0%, #FFFFFF 50%, #CE2B37 100%) 1;
    border-image-slice: 1;
    border-radius: 10px;
    overflow: hidden !important;
    background: linear-gradient(90deg, #008c45 0%, #f4f5f0 50%, #cd212a 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    margin: 0 auto;
}

.menu-item-image-wrapper {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-item-image-wrapper img {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    margin: auto;
}

/* Ensure single images in wrapper also work correctly */
.menu-item-image-wrapper:not(.menu-item-carousel) {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Menu Item Carousel for Multiple Images */
.menu-item-carousel {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
}

.menu-item-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    z-index: 0;
    visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-item-slide.active {
    opacity: 1;
    z-index: 10;
    visibility: visible;
}

.menu-item-slide img {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    margin: auto;
}

/* Responsive Design - Maintain small photo layout */
@media (max-width: 1024px) {
    :root {
        --section-spacing: 16px;
        --item-spacing: 16px;
    }

    .category-gallery-viewport {
        border-radius: 10px;
    }

    .menu-item-image-slot {
        width: 100px !important;
        height: 100px !important;
        max-width: 100px !important;
        max-height: 100px !important;
    }

    .menu-item-layout {
        gap: 14px;
    }
}

@media (max-width: 768px) {
    :root {
        --section-spacing: 14px;
        --item-spacing: 14px;
    }

    .category-gallery-wrapper {
        margin-top: var(--section-spacing);
        margin-bottom: var(--section-spacing);
    }

    .category-gallery-viewport {
        border-radius: 8px;
        aspect-ratio: 16 / 9;
    }

    .menu-item-layout {
        flex-direction: column !important;
        gap: 12px;
    }

    .menu-item-image-slot {
        width: 90px !important;
        height: 90px !important;
        max-width: 90px !important;
        max-height: 90px !important;
        flex-shrink: 0;
    }

    .menu-item-image-slot img {
        max-width: 100% !important;
        max-height: 100% !important;
    }

    .menu-item-slide img {
        max-width: 100% !important;
        max-height: 100% !important;
    }

    .menu-item-content {
        width: 100%;
    }

    .lightbox-nav {
        font-size: 36px;
        padding: 15px;
    }

    .lightbox-prev {
        left: -50px;
    }

    .lightbox-next {
        right: -50px;
    }
}

@media (max-width: 480px) {
    :root {
        --section-spacing: 12px;
        --item-spacing: 12px;
    }

    .category-gallery-viewport {
        border-radius: 6px;
        aspect-ratio: 16 / 9;
    }

    .menu-item-image-slot {
        width: 80px !important;
        height: 80px !important;
        max-width: 80px !important;
        max-height: 80px !important;
    }
    
    .lightbox-nav {
        font-size: 28px;
        padding: 10px;
    }
    
    .lightbox-prev {
        left: -40px;
    }
    
    .lightbox-next {
        right: -40px;
    }
    
    .lightbox-counter {
        font-size: 14px;
        bottom: -35px;
    }
}

/* Lightbox Styles */
.gallery-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.gallery-lightbox.show {
    display: block;
}

.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(4px);
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    margin: 0 auto;
    top: 50%;
    transform: translateY(-50%);
    position: relative;
}

.lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    display: block;
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    transition: color 0.2s ease;
    z-index: 10;
}

.lightbox-close:hover {
    color: var(--accent-red, #CE2B37);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 48px;
    cursor: pointer;
    padding: 20px;
    transition: background 0.2s ease;
    border-radius: 50%;
    z-index: 10;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
    left: -60px;
}

.lightbox-next {
    right: -60px;
}

.lightbox-counter {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 16px;
    font-weight: 500;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Touch swipe indicators */
.swipe-indicator {
    display: none;
}

@media (hover: none) and (pointer: coarse) {
    .swipe-indicator {
        display: block;
        position: absolute;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 4px 12px;
        border-radius: 20px;
        font-size: 12px;
        pointer-events: none;
    }
}
