/* Flipbook Page Styles */
body {
    margin: 0;
    padding: 0;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

.page-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    max-width: 177.78vh; /* 16:9 aspect ratio = 16/9 * 100vh */
    max-height: 56.25vw;  /* 16:9 aspect ratio = 9/16 * 100vw */
    overflow: hidden;
    margin: auto;
    background-image: url('../BG Plain.jpg');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
}

/* Header */
.page-header {
    position: relative;
    z-index: 100;
    padding: 20px 40px;
}

.logo-link {
    display: inline-block;
    transition: transform 0.3s ease;
}

.logo-link:hover {
    transform: scale(1.05);
}

.page-logo {
    height: 60px;
    width: auto;
}

/* Flipbook Content */
.flipbook-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px; /* Reduced padding to save space */
    min-height: 0; /* Important for nested flex scroll/sizing */
    width: 100%;
}

/* Flipbook Container */
.flipbook-container {
    position: relative;
    max-width: 1305px; /* 870px × 1.5 = bigger size, same ratio */
    width: 90%;
    /* Remove fixed height/vh. Use flex to fill available space */
    flex: 1;
    max-height: 915px; /* 610px × 1.5 = bigger size, same ratio */
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    display: flex; /* Ensure internal content fills it */
    flex-direction: column;
    justify-content: center; /* Center flipbook vertically */
    align-items: center; /* Center flipbook horizontally */
}

#flipbook {
    width: 100%;
    height: 100%;
}

/* Placeholder Pages */
.placeholder-page {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #FFF5E4 0%, #FFE4E1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.placeholder-content {
    text-align: center;
}

.placeholder-content h2 {
    color: #E63946;
    font-size: 32px;
    margin-bottom: 20px;
}

.placeholder-content p {
    color: #666;
    font-size: 18px;
    margin-bottom: 30px;
}

/* Flipbook Controls */
.flipbook-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    padding: 10px 30px; /* Reduced vertical padding */
    margin-top: 15px; /* Add spacing from flipbook */
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    position: relative; /* Ensure z-index works */
    z-index: 50; /* Bring above placeholder if overlapping */
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #FF6B6B, #E63946);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(230, 57, 70, 0.4);
}

.control-btn:active {
    transform: scale(0.98);
}

.control-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.page-info {
    color: #333;
    font-size: 16px;
    font-weight: 600;
    min-width: 120px;
    text-align: center;
}

/* Footer */
.page-footer {
    position: relative;
    z-index: 100;
    width: 100%;
    min-height: 100px;
    background-color: #fae6cb;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 0;
}

.footer-buttons {
    position: relative;
    bottom: auto;
    left: auto;
    transform: none;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: stretch; /* Stretch items to same height */
    gap: 10px;
    flex-wrap: nowrap; /* FORCE single line */
    width: 95%; /* Use more width */
    max-width: 1400px;
    padding-right: 120px; /* Space for mascot */
}

.footer-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: linear-gradient(to right, #FF6831, #F79A21);
    border: 2px solid #fff;
    border-radius: 50px;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 3px 12px rgba(255, 104, 49, 0.3);
    flex: 1; /* Distribute space equally */
    min-width: 0; /* Allow shrinking below content size */
    height: auto; /* Let flex stretch handle height */
}

.footer-btn-long {
    flex: 2; /* Balanced width */
}

.footer-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 5px 20px rgba(255, 104, 49, 0.5);
    z-index: 20;
}

.btn-icon {
    font-size: 20px;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.btn-text {
    color: white;
    font-size: 10px; /* Default small size */
    font-weight: 700;
    line-height: 1.1;
    text-align: left;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    
    /* Limit to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word; /* Ensure wrapping */
}

/* Mascot Image */
.mascot-right {
    position: absolute;
    right: 10px;
    bottom: 10px;
    height: 110%; /* Slightly adjusted */
    width: auto;
    object-fit: contain;
    z-index: 5;
    pointer-events: none;
    filter: drop-shadow(-2px 2px 5px rgba(0,0,0,0.1));
}


@media (max-width: 1024px) {
    /* ... existing body/container overrides ... */
    body, .page-container {
        height: auto !important;
        min-height: 100vh;
        overflow-y: auto !important;
        max-width: none !important;
        max-height: none !important;
        display: block !important;
    }

    .flipbook-container {
        height: 50vh;
        max-height: 400px;
    }

    .page-footer {
        padding: 10px 0;
    }
    
    .footer-buttons {
        width: 98%;
        gap: 5px;
        padding-right: 60px; /* Reduced space for mascot */
    }

    .mascot-right {
        right: 0;
        opacity: 1; /* Keep visible */
        height: 100%;
        bottom: 0;
    }

    .footer-btn {
        padding: 5px 8px;
        border-width: 1px;
    }

    .btn-icon {
        font-size: 16px;
    }

    .btn-text {
        font-size: 8px; /* Smaller text for mobile */
    }
}

@media (max-width: 768px) {
    .flipbook-wrapper {
        padding: 10px;
    }

    .flipbook-container {
        height: 40vh;
        max-height: 300px;
        width: 100%;
    }

    /* Force single line even on mobile */
    .footer-buttons {
        flex-wrap: nowrap;
        overflow-x: auto; /* Allow horizontal scroll if REALLY needed, but try to fit */
        padding-right: 0; /* Mascot might overlap or be hidden */
        justify-content: flex-start; /* Align left if scrolling */
    }
    
    /* Actually user said "nằm trên 1 dòng", implying they fit. 
       If they scroll, it's technically 1 line. 
       If they shrink too much, it's unreadable. 
       Let's try to fit them by making text tiny and hiding mascot on tiny screens. */
    
    .mascot-right {
         display: none; /* Hide on smallest screens to give space to buttons */
    }
    
    .footer-buttons {
        padding-right: 0;
        width: 100%;
        padding: 0 5px;
    }
    
    .btn-text {
        font-size: 7px; /* Very small */
    }
    .btn-icon {
        font-size: 14px;
        display: none; /* Maybe hide icon on super small screens? User didn't ask, but it helps fit text. Let's keep for now. */
    }
    .nav-button { /* Header logo */
        height: 30px;
    }
}

/* Loading Spinner */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #ff7e5f;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    font-family: 'Outfit', sans-serif;
    color: #333;
    font-size: 1.1rem;
    font-weight: 500;
    text-align: center;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
