/* Magazine / Book Flip CSS */
:root {
    --book-width: 900px;
    --book-height: 600px;
    --page-bg: #fff;
    --cover-bg: #800000;
    --text-color: #333;
    --primary-color: #800000;
}

body {
    background-color: #f0f0f0;
    display: block; /* Removed flex for body to prevent centering issues with scroll */
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    font-family: 'Poppins', sans-serif;
}

.magazine-container {
    -webkit-perspective: 2000px;
    perspective: 2000px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 50px 0;
    min-height: 100vh;
    min-height: 100svh;
}

.magazine {
    width: var(--book-width);
    height: var(--book-height);
    position: relative;
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    -webkit-transition: -webkit-transform 1s cubic-bezier(0.645, 0.045, 0.355, 1);
    transition: transform 1s cubic-bezier(0.645, 0.045, 0.355, 1);
}

.page {
    width: 50%;
    height: 100%;
    position: absolute;
    top: 0;
    right: 0;
    -webkit-transform-origin: left;
    transform-origin: left;
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    -webkit-transition: -webkit-transform 0.8s cubic-bezier(0.645, 0.045, 0.355, 1);
    transition: transform 0.8s cubic-bezier(0.645, 0.045, 0.355, 1);
    z-index: 1;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.page-front, .page-back {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    padding: 0; /* Padding moves to inner scroll wrapper */
    box-sizing: border-box;
    background: var(--page-bg);
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    box-shadow: inset 5px 0 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* NO scroll here — Chrome blocks it under preserve-3d */
}

/* Inner scroll wrapper — this is a GRANDCHILD of the 3D context, so Chrome allows overflow */
.page-inner-scroll {
    flex: 1;
    min-height: 0; /* Crucial: allows flex child to shrink below content height */
    width: 100%;
    padding: 40px;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y; /* Tell mobile browser: vertical touch = scroll this element */
    display: flex;
    flex-direction: column;
}

.page-back {
    transform: rotateY(180deg);
}

.page.flipped {
    transform: rotateY(-180deg);
    z-index: 2;
}

/* Page Indexing */
.page:nth-child(1) { z-index: 20; }
.page:nth-child(2) { z-index: 19; }
.page:nth-child(3) { z-index: 18; }
.page:nth-child(4) { z-index: 17; }
.page:nth-child(5) { z-index: 16; }
.page:nth-child(6) { z-index: 15; }
.page:nth-child(7) { z-index: 14; }
.page:nth-child(8) { z-index: 13; }
.page:nth-child(9) { z-index: 12; }
.page:nth-child(10) { z-index: 11; }

/* Cover Styling */
.page.cover .page-front {
    background: var(--cover-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.magazine-nav {
    position: fixed;
    top: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 30px;
    z-index: 1000;
    transition: all 0.3s ease;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    padding: 10px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    z-index: 5000 !important; /* Extremely high to stay above everything */
}

.magazine-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: #888;
    text-decoration: none;
    transition: all 0.2s ease;
    min-width: 60px;
}

.magazine-nav a i {
    font-size: 1.2rem;
}

.magazine-nav a span {
    font-size: 0.75rem;
    font-weight: 600;
}

.magazine-nav a:hover, .magazine-nav a.active {
    color: var(--primary-color);
}

.magazine-nav a.active i {
    transform: translateY(-2px);
}

/* Tablet Viewport */
@media (max-width: 992px) {
    :root {
        --book-width: 95vw;
        --book-height: 70vh;
    }
    
    .magazine-nav {
        top: auto;
        bottom: 0; /* Sticky Bottom Tab Bar */
        justify-content: space-around;
        padding: 5px 2px;
        box-shadow: 0 -2px 15px rgba(0,0,0,0.1);
        border-top: 1px solid #eee;
        overflow-x: hidden; /* Prevent horizontal scroll for the whole bar */
        white-space: nowrap;
        scrollbar-width: none;
    }
    .magazine-nav::-webkit-scrollbar { display: none; }
    
    .magazine-nav a {
        flex: 1;
        padding: 5px;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
        z-index: 5001;
    }
    
    .magazine-nav a span {
        font-size: 0.65rem;
    }
}

/* Smartphone Viewport Special Refinement */
@media (max-width: 768px) {
    :root {
        --book-width: 92vw; /* Slight margin for better look */
        --book-height: 75vh;
    }
    
    .magazine-container {
        padding: 20px 0 80px 0;
        perspective: none;
        overflow: visible; /* No clipping needed — JS hides non-active pages */
        width: 100vw;
    }

    .magazine {
        margin: 0 auto;
    }

    .page {
        width: 100%; 
        left: 0;
        right: auto;
        border: none !important;
        box-shadow: 0 4px 15px rgba(0,0,0,0.1) !important;
    }

    /* Hide flipped pages on mobile (single-page mode, they're behind anyway) */
    .page.flipped {
        visibility: hidden;
        pointer-events: none;
    }

    .page-front, .page-back {
        box-shadow: none !important;
    }

    .page-inner-scroll {
        padding: 15px;
    }

    .magazine-nav {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        padding: 5px 0;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        width: 100vw;
        max-width: 100%;
        left: 0;
        z-index: 9999 !important;
        scrollbar-width: none;
    }

    .magazine-nav a {
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 5px 12px;
        min-width: 65px;
        position: relative;
        z-index: 10000 !important;
        flex-shrink: 0;
    }
    
    .magazine-nav a.active {
        background: rgba(128,0,0,0.05);
    }
    
    .magazine-nav a i {
        font-size: 1.15rem;
        pointer-events: none; /* Let the link handle it */
    }

    .magazine-nav a span {
        font-size: 0.55rem; /* Even smaller for 8 items */
        white-space: nowrap;
        pointer-events: none;
        margin-top: 2px;
    }

    .pos-product-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }
    
    /* Cover Refinement */
    .cover-title {
        font-size: 3.5rem !important;
        margin-bottom: 5px !important;
    }
    .magazine-subtitle {
        font-size: 0.7rem !important;
        letter-spacing: 2px !important;
    }
    .cover-quote {
        font-size: 0.85rem !important;
        margin-top: 20px !important;
    }
    .cover-footer {
        bottom: 50px !important;
        font-size: 0.75rem !important;
    }
}

/* Fine-Dining Product Layout */
.product-layout-left {
    padding: 40px;
    display: flex;
    flex-direction: column;
}
.product-showcase {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 30px;
}
.product-showcase .img-box {
    aspect-ratio: 1/1.2;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.product-showcase img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}
.product-showcase .img-box:hover img {
    transform: scale(1.1);
}
.fine-dining-title {
    font-family: 'Playfair Display', serif;
    font-size: 2.8rem;
    font-weight: 900;
    line-height: 1.1;
    color: #000;
    margin-bottom: 15px;
}
.fine-dining-subtitle {
    font-family: 'Poppins', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 25px;
    color: #333;
}
.fine-dining-desc {
    font-size: 0.85rem;
    color: #555;
    line-height: 1.7;
    margin-bottom: 30px;
    max-width: 90%;
}
.btn-more-info {
    background: #3b3b1c;
    color: #fff;
    padding: 12px 35px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: opacity 0.3s;
}
.btn-more-info:hover {
    opacity: 0.9;
}

/* About Grid 2x2 */
.about-grid-2x2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 15px;
    height: 100%;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
}
.about-grid-2x2 .grid-item {
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.about-grid-2x2 img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}
.about-grid-2x2 .grid-item:hover img {
    transform: scale(1.05);
}

/* Premium Grid Pattern Accent (Square Grid) */
.grid-pattern-bg {
    background-color: #ffffff;
    background-image: 
        linear-gradient(#f0f0f0 1.5px, transparent 1.5px),
        linear-gradient(90deg, #f0f0f0 1.5px, transparent 1.5px);
    background-size: 30px 30px;
}

/* POS-Style Product Grid inside Magazine */
.pos-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
    margin-top: 20px;
}
.pos-product-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    border: 1.5px solid #ddd;
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 125px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.pos-product-card:hover {
    border-color: #800000;
    box-shadow: 0 8px 20px rgba(128,0,0,0.2);
    transform: translateY(-5px);
}
.pos-product-card h4 {
    font-size: 0.95rem;
    margin: 0 0 10px 0;
    color: #000;
    font-weight: 700;
    line-height: 1.3;
}
.pos-product-card .price {
    font-size: 0.9rem;
    color: #800000;
    font-weight: 800;
    margin-bottom: 5px;
}
.btn-add-cart-pos {
    background: #800000;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    width: 100%;
    cursor: pointer;
    font-weight: 700;
}

/* Premium Mitra-Style Cart Container (for Right Page) */
.mag-cart-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    border: 2px solid #eee;
}
.mag-cart-header {
    background: #800000;
    color: white;
    padding: 15px 20px;
    font-weight: 700;
    font-size: 1.2rem;
}
.mag-cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}
.mag-cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    margin-bottom: 15px;
    border-bottom: 2px dashed #ccc !important; /* Forces visible dashed lines */
}
.mag-cart-item-info h5 { margin: 0; font-size: 0.9rem; color: #333; font-weight: 600; }
.mag-cart-item-info p { margin: 2px 0 0 0; font-size: 0.85rem; color: #800000; font-weight: 700; }
.mag-cart-qty-control {
    display: flex;
    align-items: center;
    gap: 10px;
}
.mag-qty-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #e0e0e0;
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border-radius: 8px;
    font-weight: bold;
    transition: all 0.2s;
}
.mag-qty-btn:hover { 
    background: #800000; 
    color: white; 
    border-color: #800000;
}

.mag-cart-summary {
    padding: 20px;
    background: #fff;
    border-top: 1px solid #eee;
}
.mag-total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 1.2rem;
}
.mag-total-label { font-weight: 600; color: #666; font-size: 0.95rem; }
.mag-total-val { font-weight: 900; color: #800000; }

.mag-btn-checkout {
    background: #25D366;
    color: white;
    border: none;
    width: 100%;
    padding: 15px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    box-shadow: 0 5px 15px rgba(37, 211, 102, 0.3);
    transition: all 0.3s;
}
.mag-btn-checkout:hover { 
    background: #1ebe57; 
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(37, 211, 102, 0.4);
}

/* Stock Badge on Product Cards */
.stock-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
    justify-content: center;
}
.stock-badge i {
    font-size: 0.6rem;
}
.stock-badge.stock-ok {
    background: #d1fae5;
    color: #065f46;
}
.stock-badge.stock-low {
    background: #fef3c7;
    color: #92400e;
    animation: pulse-low 2s infinite;
}
.stock-badge.stock-empty {
    background: #fee2e2;
    color: #991b1b;
}

@keyframes pulse-low {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Out of Stock Product Card */
.pos-product-card.out-of-stock {
    opacity: 0.55;
    cursor: not-allowed;
    border-color: #e5e7eb;
    background: #f9fafb;
}
.pos-product-card.out-of-stock:hover {
    transform: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    border-color: #e5e7eb;
}
.pos-product-card.out-of-stock .price {
    color: #9ca3af;
}

/* Disabled Add Button */
.btn-add-cart-pos:disabled {
    background: #d1d5db;
    color: #6b7280;
    cursor: not-allowed;
    pointer-events: none;
}
