/*=========================================
  3D FLIPBOOK MENU STYLES
  Author: Sparta Beer Club
  Description: Realistic 3D book flipping effect
  Structure: Cover (0.png) -> Spreads (1+2, 3+4, 5+6, 7+8, 9+10) -> Back (11.png)
=========================================*/

/* Container chính - sử dụng ảnh bg.png làm background */
.quyen-menu {
    min-height: 100vh;
    padding: 60px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Background image */
    background: url('../images/quyen-menu/bg.webp') no-repeat center center;
    background-size: cover;
    background-attachment: fixed;
    position: relative;
    overflow: hidden;
}

/* Overlay tối nhẹ để menu nổi bật hơn */
.quyen-menu::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 1;
}



/* Flipbook wrapper - container chứa cả 2 trang, căn giữa màn hình */
.flipbook-wrapper {
    perspective: 2500px;
    position: relative;
    z-index: 10;
    /* Tăng kích thước để dễ đọc chữ hơn: 500x707px (Tỷ lệ A4) */
    width: 500px;
    height: 707px;
    margin: 0 auto;
    transition: width 0.5s ease;
}

/* Khi sách mở, wrapper mở rộng để chứa 2 trang */
.flipbook-wrapper.book-open {
    width: 1000px;
    /* 500px x 2 */
}

/* Container chứa các trang sách - nằm bên phải của wrapper */
.flipbook {
    width: 500px;
    height: 707px;
    position: absolute;
    right: 0;
    top: 0;
    transform-style: preserve-3d;
}

/* Trạng thái khi sách đang đóng - căn giữa trong wrapper */
.flipbook.book-closed {
    right: 0;
    left: 0;
    margin: 0 auto;
}

/* Trạng thái khi sách mở - nằm bên phải */
.flipbook.book-open {
    right: 0;
    left: auto;
    margin: 0;
}

/* Trang bên trái (cố định khi sách mở) - nằm bên trái của wrapper */
.left-page-display {
    width: 500px;
    height: 707px;
    position: absolute;
    left: 0;
    top: 0;
    background: #1c1c1c;
    border-radius: 8px 0 0 8px;
    overflow: hidden;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.3);
    display: none;
    z-index: 5;
}

.left-page-display.visible {
    display: block;
}

.left-page-display img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Shadow trên trang trái */
.left-page-display::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 30px;
    height: 100%;
    background: linear-gradient(to left, rgba(0, 0, 0, 0.15) 0%, transparent 100%);
    pointer-events: none;
}

/* Mỗi trang sách */
.flipbook-page {
    width: 500px;
    height: 707px;
    position: absolute;
    top: 0;
    right: 0;
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.645, 0.045, 0.355, 1);
    cursor: pointer;
}

.flipbook-page.flipped {
    transform: rotateY(-180deg);
}

/* Front side (mặt trước) và Back side (mặt sau) */
.page-front,
.page-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    overflow: hidden;
    border-radius: 0 8px 8px 0;
    background: #1c1c1c;
}

.page-front {
    z-index: 2;
}

.page-back {
    transform: rotateY(180deg);
    border-radius: 8px 0 0 8px;
}

/* Image trong trang */
.page-front img,
.page-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Page edge effect - hiệu ứng mép trang bên phải */
.page-front::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 30px;
    height: 100%;
    background: linear-gradient(to left,
            rgba(0, 0, 0, 0.2) 0%,
            transparent 100%);
    pointer-events: none;
}

/* Hiệu ứng mép trang bên trái (cho page-back) */
.page-back::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 30px;
    height: 100%;
    background: linear-gradient(to right,
            rgba(0, 0, 0, 0.2) 0%,
            transparent 100%);
    pointer-events: none;
    z-index: 10;
}

/* Spine (gáy sách) */
.book-spine {
    position: absolute;
    left: -5px;
    top: 0;
    width: 10px;
    height: 100%;
    background: linear-gradient(90deg,
            #1a1a1a 0%,
            #333 30%,
            #1a1a1a 50%,
            #333 70%,
            #1a1a1a 100%);
    border-radius: 2px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    z-index: 100;
}

/* Cover page - Trang bìa với ảnh */
.flipbook-page.cover-page .page-front {
    border-radius: 0 8px 8px 0;
}

.flipbook-page.cover-page .page-front img {
    border-radius: 0 8px 8px 0;
}

/* Navigation buttons - ẨN trên desktop (sẽ dùng edge arrows) */
.flipbook-nav {
    display: none;
    justify-content: center;
    gap: 15px;
    margin-top: 30px;
    position: relative;
    z-index: 10;
}

.nav-btn {
    background: linear-gradient(135deg, #ffca05 0%, #d4a800 100%);
    border: none;
    color: #1a1a2e;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Quicksand', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    border-radius: 30px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(255, 202, 5, 0.3);
}

.nav-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.nav-btn:hover::before {
    left: 100%;
}

.nav-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 202, 5, 0.4);
}

.nav-btn:active {
    transform: translateY(-1px);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.nav-btn i {
    margin: 0 5px;
    font-size: 14px;
}

/* Page indicator - ẨN trên desktop */
.page-indicator {
    display: none;
    text-align: center;
    margin-top: 25px;
    color: #fff;
    font-family: 'Quicksand', sans-serif;
    font-size: 16px;
    letter-spacing: 1px;
    position: relative;
    z-index: 10;
}

.page-indicator .current-page {
    color: #ffca05;
    font-weight: 700;
    font-size: 20px;
}

/* Thumbnail navigation - ẨN trên desktop */
.flipbook-thumbnails {
    display: none;
    justify-content: center;
    gap: 10px;
    margin-top: 30px;
    flex-wrap: wrap;
    max-width: 800px;
    padding: 0 20px;
    position: relative;
    z-index: 10;
}

.thumbnail-item {
    width: 60px;
    height: 45px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.6;
}

.thumbnail-item:hover,
.thumbnail-item.active {
    border-color: #ffca05;
    transform: scale(1.1);
    opacity: 1;
    box-shadow: 0 0 15px rgba(255, 202, 5, 0.4);
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Flip animation */
@keyframes pageFlip {
    0% {
        transform: rotateY(0deg);
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    }

    50% {
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    }

    100% {
        transform: rotateY(-180deg);
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    }
}

@keyframes pageFlipReverse {
    0% {
        transform: rotateY(-180deg);
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    }

    50% {
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    }

    100% {
        transform: rotateY(0deg);
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    }
}

.flipbook-page.flipping {
    animation: pageFlip 0.8s cubic-bezier(0.645, 0.045, 0.355, 1) forwards;
}

.flipbook-page.flipping-back {
    animation: pageFlipReverse 0.8s cubic-bezier(0.645, 0.045, 0.355, 1) forwards;
}

/* Hover effect on page */
.flipbook-page:not(.flipped):hover .page-front {
    box-shadow: inset -5px 0 20px rgba(0, 0, 0, 0.2);
}

/* Z-index management */
.flipbook-page.flipped {
    z-index: 1 !important;
}

/* Loading state */
.flipbook-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ffca05;
    font-size: 18px;
    font-family: 'Quicksand', sans-serif;
    z-index: 200;
    background: rgba(0, 0, 0, 0.8);
    padding: 20px 40px;
    border-radius: 10px;
}

.flipbook-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #ffca05;
    border-top-color: transparent;
    border-radius: 50%;
    margin-left: 10px;
    animation: spin 1s linear infinite;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/*=========================================
  EDGE NAVIGATION ARROWS - Nút ở rìa menu
=========================================*/

/* Container cho edge arrows */
.edge-arrows {
    position: relative;
    z-index: 15;
}

/* Nút arrow chung */
.edge-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 120px;
    background: rgba(255, 202, 5, 0.15);
    border: none;
    color: #ffca05;
    font-size: 32px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

/* Nút Next - bên phải */
.edge-arrow.next-arrow {
    right: -40px;
    border-radius: 0px 8px 8px 0px;
    animation: pulseRight 2s ease-in-out infinite;
}

/* Nút Prev - bên trái (ẩn mặc định) */
.edge-arrow.prev-arrow {
    left: -40px;
    border-radius: 8px 0px 0px 8px;
    display: none;
}

/* Hiện prev arrow khi sách đã mở */
.flipbook-wrapper.book-open .edge-arrow.prev-arrow {
    display: flex;
}

/* Ẩn next arrow khi ở trang cuối */
.edge-arrow.next-arrow.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Hover effects */
.edge-arrow:hover {
    background: rgba(255, 202, 5, 0.3);
    transform: translateY(-50%) scale(1.05);
}

.edge-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

/* Pulse animation cho next arrow (nhấp nháy nhẹ) */
@keyframes pulseRight {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(255, 202, 5, 0.4);
    }

    50% {
        box-shadow: 0 0 20px 5px rgba(255, 202, 5, 0.2);
    }
}

/* Icon mũi tên */
.edge-arrow i {
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/*=========================================
  MOBILE SLIDESHOW - Chỉ hiện trên mobile
=========================================*/

/* Ẩn mobile slideshow trên desktop */
.mobile-slideshow {
    display: none;
}

/* Hiện desktop elements */
.desktop-only {
    display: block;
}

.flipbook-nav.desktop-only {
    display: flex;
}

.flipbook-thumbnails.desktop-only {
    display: flex;
}

/* Mobile Slideshow Container */
.mobile-slideshow {
    position: relative;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    z-index: 10;
}

/* Slide Container */
.mobile-slide-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* Mỗi slide */
.mobile-slide {
    display: none;
    width: 100%;
}

.mobile-slide.active {
    display: block;
}

.mobile-slide img {
    width: 100%;
    height: auto;
    display: block;
}

/* Nút điều hướng Mobile - đè lên menu với opacity mờ */
.mobile-nav {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50px;
    background: rgba(0, 0, 0, 0.3);
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    z-index: 20;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-nav:hover,
.mobile-nav:active {
    background: rgba(0, 0, 0, 0.5);
}

.mobile-prev {
    left: 0;
    border-radius: 8px 0 0 8px;
}

.mobile-next {
    right: 0;
    border-radius: 0 8px 8px 0;
}

.mobile-nav i {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Page indicator cho mobile */
.mobile-page-indicator {
    text-align: center;
    margin-top: 15px;
    color: #fff;
    font-family: 'Quicksand', sans-serif;
    font-size: 14px;
}

.mobile-page-indicator .mobile-current {
    color: #ffca05;
    font-weight: 700;
    font-size: 18px;
}

.mobile-page-indicator .mobile-total {
    color: rgba(255, 255, 255, 0.7);
}

/* Responsive Design - TABLET & MOBILE */
@media screen and (max-width: 768px) {

    /* ẨN desktop flipbook và các thành phần */
    .flipbook-wrapper {
        display: none !important;
    }

    .desktop-only {
        display: none !important;
    }

    .flipbook-nav.desktop-only {
        display: none !important;
    }

    .flipbook-thumbnails.desktop-only {
        display: none !important;
    }

    /* HIỆN mobile slideshow */
    .mobile-slideshow {
        display: block !important;
        max-width: 85vw;
    }

    .mobile-slide-container {
        max-height: 70vh;
    }

    .mobile-slide img {
        max-height: 70vh;
        object-fit: contain;
    }

    /* Fullscreen button nhỏ hơn */
    .fullscreen-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
        top: 10px;
        right: 10px;
    }
}

/* Responsive Design - MOBILE NHỎ */
@media screen and (max-width: 480px) {
    .quyen-menu {
        padding: 15px 0;
    }

    /* Mobile slideshow điều chỉnh cho màn hình nhỏ */
    .mobile-slideshow {
        max-width: 95vw;
    }

    .mobile-nav {
        width: 40px;
        font-size: 20px;
    }

    .mobile-page-indicator {
        font-size: 12px;
        margin-top: 10px;
    }

    .mobile-page-indicator .mobile-current {
        font-size: 16px;
    }

    /* Fullscreen button nhỏ hơn */
    .fullscreen-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
        top: 8px;
        right: 8px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .flipbook-page {
        transition: transform 0.6s cubic-bezier(0.645, 0.045, 0.355, 1);
    }

    .nav-btn:hover {
        transform: none;
    }

    .nav-btn:active {
        transform: scale(0.98);
        background: linear-gradient(135deg, #d4a800 0%, #ffca05 100%);
    }
}

/* Dark overlay for dramatic effect - chỉnh để bao quanh đúng wrapper */
.flipbook-wrapper::after {
    content: '';
    position: absolute;
    top: -50px;
    left: -50px;
    right: -50px;
    bottom: -50px;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.15) 100%);
    pointer-events: none;
    z-index: -1;
    border-radius: 20px;
}

/* Fullscreen mode */
.quyen-menu.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 100000 !important;
    padding: 10px;
    margin: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100vw !important;
    height: 100vh !important;
    box-sizing: border-box;
    overflow: hidden;
}

/* Khi fullscreen: phóng to tối đa nhưng giữ đúng tỷ lệ */
.quyen-menu.fullscreen .flipbook-wrapper {
    margin: auto;
    /* Tính width dựa trên height và tỷ lệ A4 (1:1.414) */
    width: calc(90vh / 1.414) !important;
    height: 90vh !important;
}

/* Khi fullscreen + sách mở: rộng gấp đôi */
.quyen-menu.fullscreen .flipbook-wrapper.book-open {
    width: calc(180vh / 1.414) !important;
    height: 90vh !important;
    transform: none;
}

/* Flipbook và các trang giữ đúng kích thước */
.quyen-menu.fullscreen .flipbook,
.quyen-menu.fullscreen .flipbook-page {
    width: calc(90vh / 1.414) !important;
    height: 90vh !important;
}

.quyen-menu.fullscreen .left-page-display {
    width: calc(90vh / 1.414) !important;
    height: 90vh !important;
}

/* Đảm bảo ảnh phủ đầy trang */
.quyen-menu.fullscreen .flipbook-page img,
.quyen-menu.fullscreen .left-page-display img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

.fullscreen-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 202, 5, 0.9);
    border: none;
    color: #1a1a2e;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    z-index: 100;
    transition: all 0.3s ease;
}

.fullscreen-btn:hover {
    background: #ffca05;
    transform: scale(1.1);
}

/* Auto-flip indicator */
.auto-flip-indicator {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(0, 0, 0, 0.5);
    color: #ffca05;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 12px;
    font-family: 'Quicksand', sans-serif;
    z-index: 100;
    display: none;
}

.auto-flip-indicator.active {
    display: block;
}

.auto-flip-indicator i {
    margin-right: 5px;
    animation: pulse 1s ease infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Book shadow effect */
.flipbook::before {
    content: '';
    position: absolute;
    bottom: -20px;
    left: -50px;
    right: -50px;
    height: 30px;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.4) 0%, transparent 70%);
    z-index: -1;
}

/* Page number overlay */
.page-number {
    position: absolute;
    bottom: 15px;
    font-family: 'Old Standard TT', serif;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
}

.page-front .page-number {
    right: 15px;
}

.page-back .page-number {
    left: 15px;
}

/*=========================================
  CSS ĐẶC BIỆT CHO TRANG THỰC ĐƠN - CHỈ DESKTOP
  Chỉ áp dụng cho function page() trong controller Thucdon
=========================================*/
@media screen and (min-width: 992px) {

    /* Header adjustments */
    .fixTopHead {
        height: auto;
        padding: 50px 32px 0px 32px;
    }

    /* Order button */
    .buttonOrder {
        padding: 0px 10px;
    }

    /* Logo */
    .leftTopHead img {
        max-width: 100%;
    }

    /* Right header section */
    .rightTopHead {
        padding-top: 10px;
    }

    /* Menu section */
    .quyen-menu {
        padding: 20px 0;
    }

    /* Menu navigation links */
    .menuTopHead ul li a {
        font-size: 12px;
    }

    /* Top bar - phone/info */
    .topMapPhone .title_call a {
        font-size: 12px;
    }

    .topMapPhone .cpnHead .fRight .infoHeader {
        font-size: 12px;
    }

    .fixTopHead {
        padding: 50px 32px 0px 32px !important;
    }
}