/* ============================================
   BENGALI BOOK READER - MAIN STYLES
   ============================================ */

* {
    font-family: 'Noto Serif Bengali', 'Tiro Bangla', serif;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background-color: #FAFAF5;
    color: #2C2416;
    overflow-x: hidden;
}

/* ============================================
   LOADING SCREEN
   ============================================ */

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #FAFAF5;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeOut 0.8s ease-in-out 2s forwards;
}

.loading-screen.hidden {
    display: none;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        pointer-events: none;
    }
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid #E8E5DB;
    border-top: 3px solid #6B4423;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    color: #6B4423;
    margin-top: 16px;
    font-size: 16px;
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* ============================================
   FADE IN ANIMATION
   ============================================ */

.fade-in {
    animation: fadeInContent 0.8s ease-in 2s forwards;
    opacity: 0;
}

@keyframes fadeInContent {
    to { opacity: 1; }
}

/* ============================================
   HEADER & TYPOGRAPHY
   ============================================ */

.header-title {
    animation: slideDown 0.6s ease-out 2.3s forwards;
    opacity: 0;
    transform: translateY(-20px);
}

@keyframes slideDown {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   BUTTONS
   ============================================ */

.btn-elegant {
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
    user-select: none;
}

.btn-elegant:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(107, 68, 35, 0.15);
}

.btn-elegant:active:not(:disabled) {
    transform: translateY(0);
}

.btn-elegant:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   DIVIDER
   ============================================ */

.divider {
    animation: expandWidth 0.6s ease-out 2.5s forwards;
    transform-origin: center;
    transform: scaleX(0);
}

@keyframes expandWidth {
    to { transform: scaleX(1); }
}

/* ============================================
   PDF CONTAINER
   ============================================ */

.pdf-container {
    animation: fadeInContent 0.8s ease-in 2.8s forwards;
    opacity: 0;
}

/* ============================================
   PROGRESS BAR
   ============================================ */

.progress-bar {
    height: 4px;
    background-color: #E8E5DB;
    border-radius: 2px;
    overflow: hidden;
    width: 100%;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #D97706, #F59E0B);
    transition: width 0.3s ease;
    border-radius: 2px;
    min-width: 0;
}

/* ============================================
   PDF CANVAS
   ============================================ */

#pdfCanvas {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    background: white;
}

/* ============================================
   PDF CONTROLS
   ============================================ */

.pdf-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 16px;
    background-color: white;
    border-radius: 8px;
    border: 1px solid #E5E7EB;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.page-info {
    background-color: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    padding: 8px 16px;
    min-width: 120px;
    text-align: center;
    font-weight: 500;
    color: #6B4423;
    font-size: 14px;
}

.control-btn {
    padding: 8px 16px;
    background-color: white;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    color: #374151;
    font-family: 'Noto Serif Bengali', 'Tiro Bangla', serif;
    font-weight: 500;
    white-space: nowrap;
}

.control-btn:hover:not(:disabled) {
    background-color: #FEF3C7;
    border-color: #FCD34D;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.control-btn:active:not(:disabled) {
    transform: translateY(0);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#pageInput {
    padding: 8px 10px;
    text-align: center;
    width: 70px;
}

/* ============================================
   PDF CANVAS CONTAINER
   ============================================ */

#pdfCanvasContainer {
    background-color: white;
    border-radius: 8px;
    border: 1px solid #E5E7EB;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 20px;
    overflow: auto;
    max-height: 85vh;
    margin-top: 20px;
}

/* ============================================
   LOADING INDICATOR
   ============================================ */

.pdf-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 400px;
    gap: 12px;
    flex-direction: column;
}

.pdf-loading.hidden {
    display: none;
}

.pdf-loading-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #E8E5DB;
    border-top: 3px solid #F59E0B;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============================================
   ERROR MESSAGE
   ============================================ */

.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #FEF3C7 0%, #FED7AA 100%);
    border-radius: 8px;
    border: 1px solid #FDBA74;
}

.error-container h3 {
    color: #B45309;
    font-size: 20px;
    margin: 0 0 12px 0;
}

.error-container p {
    color: #92400E;
    font-size: 14px;
    margin: 0 0 20px 0;
}

.error-container a,
.error-container button {
    display: inline-block;
    padding: 10px 24px;
    background-color: #D97706;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.error-container a:hover,
.error-container button:hover {
    background-color: #B45309;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .button-group {
        flex-direction: column;
        gap: 10px;
    }

    .btn-elegant {
        width: 100%;
        padding: 0.45rem 0.9rem !important;
        font-size: 0.85rem !important;
        height: 36px !important;
        line-height: 1 !important;
        white-space: nowrap !important;
    }

    .header-title {
        font-size: 28px !important;
    }

    .pdf-controls {
        gap: 6px;
        padding: 12px;
    }

    .control-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    #pageInput {
        width: 50px;
        padding: 6px 8px;
    }

    .page-info {
        padding: 6px 12px;
        font-size: 12px;
        min-width: auto;
    }

    #pdfCanvas {
        max-height: 500px;
    }

    #pdfCanvasContainer {
        padding: 12px;
        max-height: 70vh;
    }

    .error-container {
        min-height: 300px;
    }
}

@media (max-width: 480px) {
    .control-btn {
        padding: 5px 8px;
        font-size: 11px;
    }

    #pageInput {
        width: 45px;
        padding: 5px 6px;
    }

    .page-info {
        padding: 5px 10px;
        font-size: 11px;
    }

    .btn-elegant {
        padding: 0.4rem 0.8rem !important;
        font-size: 0.8rem !important;
        height: 34px !important;
    }

    .header-title {
        font-size: 24px !important;
    }

    #pdfCanvasContainer {
        max-height: 60vh;
    }
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */

#pdfCanvasContainer::-webkit-scrollbar {
    width: 8px;
}

#pdfCanvasContainer::-webkit-scrollbar-track {
    background: #F3F4F6;
    border-radius: 4px;
}

#pdfCanvasContainer::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 4px;
}

#pdfCanvasContainer::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}
