/* brochure/css/flipbook.css */
:root {
    --bg-dark: #0e0b08;
    --bg-surface: #1a1511;
    --gold-primary: #d4af37;
    --gold-hover: #f3e5ab;
    --gold-dark: #997921;
    --text-light: #f5f5f5;
    --text-muted: #b0a89d;
    --toolbar-height: 52px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-dark);
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    color: var(--text-light);
    user-select: none;
    -webkit-user-select: none;
}

/* APP CONTAINER */
.flipbook-app {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    background: radial-gradient(circle at center, #2b231b 0%, #17130f 65%, #0a0806 100%);
}

/* TOP NAVBAR */
.top-navbar {
    flex: 0 0 var(--toolbar-height);
    height: var(--toolbar-height);
    width: 100%;
    background: rgba(18, 14, 11, 0.98);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(212, 175, 55, 0.35);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    line-height: 1;
}

.brand-logo img {
    height: 32px;
    max-width: 150px;
    object-fit: contain;
    display: block;
}

.book-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    border-left: 1px solid rgba(212, 175, 55, 0.3);
    padding-left: 12px;
    font-weight: 500;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* BUTTONS */
.btn-tool {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: var(--text-light);
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-tool:hover {
    background: rgba(212, 175, 55, 0.25);
    border-color: var(--gold-primary);
    color: var(--gold-hover);
}

.btn-tool.active {
    background: var(--gold-primary);
    color: #111;
    border-color: var(--gold-primary);
    font-weight: 600;
}

.btn-tool i {
    font-size: 1rem;
}

/* MAIN STAGE */
.book-stage {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 10px 15px;
    background: radial-gradient(ellipse at center, rgba(65, 52, 38, 0.6) 0%, rgba(15, 12, 9, 0.96) 100%);
}

.book-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    transform-origin: center center;
}

/* PAGE FLIP CONTAINER (Quyển sách 3D) */
#flipbook {
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9), 0 5px 25px rgba(0, 0, 0, 0.6);
    margin: 0 auto;
    background: transparent;
    border-radius: 4px;
}

/* TỪNG TRANG SÁCH */
.page {
    background-color: #ffffff;
    overflow: hidden;
    position: relative;
}

/* Hiệu ứng bóng gáy sách 3D ở giữa (Spine Crease) */
.page.-left {
    box-shadow: inset -25px 0 35px -10px rgba(0, 0, 0, 0.25), inset -6px 0 10px rgba(0, 0, 0, 0.35);
    border-right: 1px solid rgba(0, 0, 0, 0.15);
}

.page.-right {
    box-shadow: inset 25px 0 35px -10px rgba(0, 0, 0, 0.25), inset 6px 0 10px rgba(0, 0, 0, 0.35);
    border-left: 1px solid rgba(0, 0, 0, 0.15);
}

.page[data-density="hard"] {
    background-color: #fcfcfc;
}

.page-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: #ffffff;
}

.page-content canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.page-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #888;
    font-size: 0.85rem;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(212, 175, 55, 0.2);
    border-top-color: var(--gold-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* NAV ARROWS (NÚT LẬT NỔI 2 BÊN) */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 54px;
    height: 84px;
    background: rgba(18, 14, 11, 0.8);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(212, 175, 55, 0.4);
    color: var(--gold-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    cursor: pointer;
    z-index: 50;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
}

.nav-arrow:hover {
    background: rgba(212, 175, 55, 0.35);
    color: #fff;
    border-color: var(--gold-primary);
    width: 62px;
}

.nav-arrow.nav-prev {
    left: 15px;
    border-radius: 0 10px 10px 0;
}

.nav-arrow.nav-next {
    right: 15px;
    border-radius: 10px 0 0 10px;
}

.nav-arrow.disabled {
    opacity: 0.15;
    pointer-events: none;
}

/* BOTTOM TOOLBAR */
.bottom-navbar {
    flex: 0 0 var(--toolbar-height);
    height: var(--toolbar-height);
    width: 100%;
    background: rgba(18, 14, 11, 0.98);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(212, 175, 55, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 0 16px;
    z-index: 1000;
}

.page-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-input-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.page-input-wrapper input {
    width: 70px;
    padding: 4px 6px;
    background: #25201a;
    border: 1px solid rgba(212, 175, 55, 0.45);
    border-radius: 4px;
    color: var(--gold-primary);
    font-weight: 700;
    text-align: center;
    font-size: 0.9rem;
}

.page-input-wrapper input:focus {
    outline: none;
    border-color: var(--gold-primary);
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.6);
}

/* NÚT THOÁT TOÀN MÀN HÌNH NỔI */
.btn-exit-fullscreen {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 1200;
    background: rgba(18, 14, 11, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--gold-primary);
    color: var(--gold-primary);
    border-radius: 30px;
    padding: 8px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.8);
    transition: all 0.2s ease;
}

.btn-exit-fullscreen:hover {
    background: var(--gold-primary);
    color: #111;
    transform: scale(1.05);
}

/* KHI Ở CHẾ ĐỘ TOÀN MÀN HÌNH (FULLSCREEN ACTIVE) */
.flipbook-app.fullscreen-active .top-navbar,
.flipbook-app.fullscreen-active .bottom-navbar {
    display: none !important;
}

.flipbook-app.fullscreen-active .btn-exit-fullscreen {
    display: inline-flex;
}

.flipbook-app.fullscreen-active .book-stage {
    padding: 0;
    width: 100vw;
    height: 100vh;
}

.flipbook-app.fullscreen-active .nav-arrow {
    background: rgba(18, 14, 11, 0.4);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(212, 175, 55, 0.25);
    width: 44px;
    height: 74px;
    opacity: 0.7;
    transition: all 0.2s ease;
}

.flipbook-app.fullscreen-active .nav-arrow:hover {
    opacity: 1;
    background: rgba(212, 175, 55, 0.4);
    color: #fff;
    border-color: var(--gold-primary);
    width: 50px;
}

.flipbook-app.fullscreen-active .nav-arrow.nav-prev {
    left: 0;
    border-radius: 0 10px 10px 0;
}

.flipbook-app.fullscreen-active .nav-arrow.nav-next {
    right: 0;
    border-radius: 10px 0 0 10px;
}

/* LOADING OVERLAY */
.global-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0f0d0b;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    z-index: 2000;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.global-loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-logo {
    font-size: 2rem;
    font-weight: bold;
    color: var(--gold-primary);
    letter-spacing: 3px;
    text-transform: uppercase;
    text-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
}

.progress-bar-container {
    width: 280px;
    height: 6px;
    background: #25201a;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--gold-dark), var(--gold-primary), var(--gold-hover));
    transition: width 0.2s ease;
}

.loader-text {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .book-title {
        display: none;
    }
    .top-navbar, .bottom-navbar {
        padding: 0 8px;
    }
    .btn-tool span {
        display: none;
    }
    .btn-tool {
        padding: 6px 10px;
    }
    .nav-arrow {
        width: 38px;
        height: 55px;
        font-size: 1.2rem;
    }
}
