/**
 * Bafha PDF Viewer Frontend Styles
 * Premium, minimal, and fully responsive flipbook interface
 */

 .bafha-pdf-viewer-container {
     position: relative;
     width: 100%;
     max-width: 100%;
     height: 100%; /* Will be strictly controlled by inline styles or height CSS */
     min-height: 400px;
     margin: 0 auto;
     overflow: hidden;
     display: flex;
     flex-direction: column;
     font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
     border-radius: 0;
     box-sizing: border-box;
 }

 .bafha-pdf-viewer-container--fit-parent {
     width: 100%;
     height: 100%;
     min-height: 0;
     align-self: stretch;
 }
 
 .bafha-pdf-viewer-container:fullscreen {
     max-width: 100%;
     height: 100vh !important;
     width: 100vw !important;
     background-color: #111 !important;
     border-radius: 0;
 }
 
 /* Loading State */
 .bafha-pdf-loader {
     position: absolute;
     inset: 0;
     display: flex;
     flex-direction: column;
     align-items: center;
     justify-content: center;
     z-index: 10;
     background: inherit;
 }
 
 .bafha-spinner {
     width: 40px;
     height: 40px;
     border: 3px solid rgba(0, 0, 0, 0.1);
     border-radius: 50%;
     border-top-color: #333;
     animation: bafha-spin 1s ease-in-out infinite;
     margin-bottom: 12px;
 }
 
 .theme-dark .bafha-spinner {
     border: 3px solid rgba(255, 255, 255, 0.1);
     border-top-color: #fff;
 }
 
 .bafha-loader-text {
     font-size: 14px;
     color: #555;
     letter-spacing: 0.5px;
 }
 
 .theme-dark .bafha-loader-text {
     color: #aaa;
 }
 
 @keyframes bafha-spin {
     to { transform: rotate(360deg); }
 }
 
 /* Book Shell & Flip Book */
 .bafha-pdf-book {
     flex: 1 1 auto;
     position: relative;
     width: 100%;
     /* height intentionally omitted - Page-Flip manages its own height */
     overflow: hidden;
     transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
     transform-origin: center center;
     display: flex;
     align-items: center;
     justify-content: center;
     padding: 16px;
     box-sizing: border-box;
 }

 .bafha-pdf-book.is-zoomed {
     cursor: grab;
 }

 .bafha-pdf-book.is-panning {
     cursor: grabbing;
 }
 
 .flip-book {
     width: 100%;
     height: 100%;
     display: flex;
     align-items: center;
     justify-content: center;
     margin: 0 auto;
 }
 
 /* Pages rendered by StPageFlip */
 .flip-book .page {
     background-color: transparent;
     box-shadow: 0 0 10px rgba(0, 0, 0, 0.05); /* Soft premium shadow for pages */
     cursor: grab;
     user-select: none; /* Prevent text highlight while turning */
 }
 
 .flip-book .page:active {
     cursor: grabbing;
 }
 
.flip-book .page-content {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #fff; /* Pages are white natively */
}

.flip-book .page-content.bafha-pdf-blank-page {
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}

.flip-book .page-content.bafha-pdf-blank-page--leading {
    justify-content: center;
}

.bafha-pdf-blank-page-branding {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: rgba(31, 41, 55, 0.72);
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
    letter-spacing: 0.04em;
    font-weight: 400;
    text-decoration: none;
}

.bafha-pdf-blank-page-branding:hover {
    color: rgba(31, 41, 55, 0.92);
}

.bafha-pdf-blank-page-branding-title {
    font-weight: 600;
}

.bafha-pdf-blank-page-branding-url {
    font-weight: 400;
}
 
 .flip-book .page-content canvas {
     display: block;
     /* Let Page-Flip control canvas sizing via JS. Forcing 100% breaks aspect ratio. */
     max-width: 100%;
     user-select: none;
     -webkit-user-drag: none;
 }
 
 /* Cover realistic effects (Darkens inner spine slightly) */
 .flip-book .page.-left {
     border-right: 1px solid rgba(0,0,0,0.1);
 }
 .flip-book .page.-right {
     border-left: 1px solid rgba(0,0,0,0.1);
 }
 
 /* Toolbar - Glassmorphism Floating Pill */
 .bafha-pdf-toolbar {
     position: absolute;
     bottom: 24px;
     left: 50%;
     transform: translateX(-50%);
     height: 48px;
     display: flex;
     align-items: center;
     justify-content: space-between;
     padding: 0 16px;
     background: rgba(255, 255, 255, 0.75);
     backdrop-filter: blur(12px);
     -webkit-backdrop-filter: blur(12px);
     border: 1px solid rgba(255, 255, 255, 0.5);
     border-radius: 48px;
     z-index: 5;
     box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0,0,0,0.04);
     transition: background 0.3s ease, border 0.3s ease;
     width: max-content;
     gap: 20px;
 }
 
 .bafha-pdf-toolbar.theme-dark {
     background: rgba(30, 30, 30, 0.65);
     border: 1px solid rgba(255, 255, 255, 0.08);
     box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0,0,0,0.2);
 }
 
 .bafha-pdf-toolbar-left, 
 .bafha-pdf-toolbar-center, 
 .bafha-pdf-toolbar-right {
     display: flex;
     align-items: center;
     gap: 6px;
 }

 .bafha-pdf-toolbar-right {
     position: relative;
 }

 .bafha-pdf-toolbar-menu {
     position: relative;
 }

 .bafha-pdf-menu-icon {
     display: inline-flex;
     flex-direction: column;
     justify-content: center;
     gap: 4px;
     width: 16px;
     height: 16px;
 }

 .bafha-pdf-menu-icon span {
     display: block;
     width: 16px;
     height: 1.5px;
     border-radius: 999px;
     background: currentColor;
     opacity: 0.92;
 }

 .bafha-pdf-toolbar button {
     background: transparent;
     border: none;
     color: #4a4a4a;
     cursor: pointer;
     display: flex;
     align-items: center;
     justify-content: center;
     width: 36px;
     height: 36px;
     padding: 0;
     border-radius: 50%;
     transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
 }
 
 .bafha-pdf-toolbar button:hover {
     background: rgba(0, 0, 0, 0.06);
     color: #000;
     transform: scale(1.05);
 }
 
 .bafha-pdf-toolbar.theme-dark button {
     color: #d1d1d1;
 }
 
 .bafha-pdf-toolbar.theme-dark button:hover {
     background: rgba(255, 255, 255, 0.12);
     color: #fff;
 }

 .bafha-pdf-btn-menu {
     position: relative;
 }
 
 .bafha-pdf-page-indicator {
     font-size: 13px;
     font-weight: 500;
     color: #555;
     letter-spacing: 0.3px;
     min-width: 50px;
     text-align: center;
     user-select: none;
     margin: 0 4px;
 }
 
 .bafha-pdf-toolbar.theme-dark .bafha-pdf-page-indicator {
     color: #ccc;
 }

 .bafha-pdf-toolbar-dropdown {
     position: absolute;
     right: 0;
     bottom: calc(100% + 10px);
     min-width: 190px;
     display: flex;
     flex-direction: column;
     gap: 4px;
     padding: 8px;
     background: rgba(255, 255, 255, 0.96);
     border: 1px solid rgba(0, 0, 0, 0.08);
     border-radius: 14px;
     box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
     backdrop-filter: blur(14px);
     -webkit-backdrop-filter: blur(14px);
 }

 .bafha-pdf-toolbar.theme-dark .bafha-pdf-toolbar-dropdown {
     background: rgba(28, 28, 28, 0.96);
     border-color: rgba(255, 255, 255, 0.08);
 }

.bafha-pdf-toolbar-dropdown button {
    width: 100%;
    height: auto;
    min-height: 42px;
     border-radius: 10px;
     justify-content: flex-start;
     gap: 10px;
     padding: 10px 12px;
     font-size: 13px;
    font-weight: 500;
}

.bafha-pdf-go-to-page-modal {
    position: absolute;
    inset: 0;
    z-index: 12;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.bafha-pdf-go-to-page-modal[hidden] {
    display: none !important;
}

.bafha-pdf-go-to-page-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.08);
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
}

.bafha-pdf-go-to-page-form {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(460px, 100%);
    padding: 10px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.52);
    border-radius: 999px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.10), 0 2px 8px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-sizing: border-box;
    z-index: 1;
}

.bafha-pdf-go-to-page-input {
    flex: 1 1 auto;
    width: auto;
    height: 40px;
    padding: 0 14px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: #2f2f2f;
    font-size: 16px;
    outline: none;
    box-sizing: border-box;
}

.bafha-pdf-go-to-page-input:focus {
    border-color: rgba(0, 0, 0, 0.28);
}

.bafha-pdf-go-to-page-actions {
    display: flex;
    justify-content: flex-end;
    flex: 0 0 auto;
}

.bafha-pdf-go-to-page-submit {
    width: auto !important;
    min-width: 64px;
    height: 40px !important;
    min-height: 40px !important;
    padding: 0 16px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 999px !important;
    background: rgba(0, 0, 0, 0.08) !important;
    color: #3f3f46 !important;
    font-size: 13px !important;
    line-height: 1 !important;
    text-align: center !important;
}

.bafha-pdf-toolbar.theme-dark .bafha-pdf-go-to-page-input {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.14);
    color: #f3f3f3;
}

.bafha-pdf-toolbar.theme-dark + .bafha-pdf-go-to-page-modal .bafha-pdf-go-to-page-form,
.bafha-pdf-viewer-container .theme-dark ~ .bafha-pdf-go-to-page-modal .bafha-pdf-go-to-page-form {
    background: rgba(28, 28, 28, 0.82);
    border-color: rgba(255, 255, 255, 0.08);
}

.bafha-pdf-toolbar.theme-dark + .bafha-pdf-go-to-page-modal .bafha-pdf-go-to-page-submit,
.bafha-pdf-viewer-container .theme-dark ~ .bafha-pdf-go-to-page-modal .bafha-pdf-go-to-page-submit {
    background: rgba(255, 255, 255, 0.12) !important;
    color: #f3f4f6 !important;
}

@media (max-width: 768px) {
    .bafha-pdf-go-to-page-form {
        width: min(320px, 100%);
        flex-direction: column;
        align-items: stretch;
        border-radius: 22px;
    }

    .bafha-pdf-go-to-page-input {
        width: 100%;
    }

    .bafha-pdf-go-to-page-actions {
        width: 100%;
        justify-content: stretch;
    }

    .bafha-pdf-go-to-page-submit {
        flex: 1 1 0;
        width: 100% !important;
    }
}

.bafha-pdf-toolbar-dropdown[hidden] {
    display: none;
}
 
 .bafha-pdf-error {
     color: #cc0000;
     background-color: rgba(204, 0, 0, 0.1);
     padding: 10px 15px;
     border-radius: 4px;
     font-size: 14px;
 }
 
 /* Responsive overrides */
 @media (max-width: 768px) {
     .bafha-pdf-toolbar {
         bottom: 16px;
         padding: 0 12px;
         gap: 12px;
     }
     .bafha-pdf-toolbar-left, 
     .bafha-pdf-toolbar-right,
     .bafha-pdf-toolbar-center {
         gap: 2px;
     }
     .bafha-pdf-page-indicator {
         margin: 0;
         min-width: 44px;
     }
 }
