/* =========================================================
   🌟 1. IMPORT FONTS & ROOT VARIABLES 🌟
   ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Mallanna&family=Ramabhadra&display=swap');

:root { 
    --primary: #0284c7; --brand: #e11d48; --bg-body: #e2e8f0; --bg-topbar: #ffffff; 
    --bg-sidebar: #ffffff; --text-main: #0f172a; --text-muted: #475569; --border: #cbd5e1;
}

body.dark-theme {
    --primary: #0ea5e9; --brand: #f43f5e; --bg-body: #0f172a; --bg-topbar: #1e293b; 
    --bg-sidebar: #1e293b; --text-main: #f8fafc; --text-muted: #94a3b8; --border: rgba(255,255,255,0.1);
}

body { font-family: 'Mallanna', 'Inter', sans-serif; font-size: 18px; margin: 0; padding: 0; background: var(--bg-body); color: var(--text-main); display: flex; flex-direction: column; min-height: 100vh; overflow-x: hidden; transition: background 0.3s; }
h1, h2, h3, h4, h5, h6, .heading-font, .modal-brand { font-family: 'Ramabhadra', sans-serif; font-weight: normal; letter-spacing: 0.5px; }

/* =========================================================
   🌟 2. HEADER & DATE BOX 🌟
   ========================================================= */
.clean-date-wrapper { position: relative; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); background: var(--bg-body); padding: 6px 15px; border-radius: 6px; overflow: hidden; cursor: pointer; user-select: none; -webkit-user-select: none; }
.clean-date-text { font-family: 'Inter', sans-serif; font-weight: 700; font-size: 14px; color: var(--text-main); pointer-events: none; }
.clean-date-input { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; box-sizing: border-box; }
.clean-date-input::-webkit-calendar-picker-indicator { position: absolute; top: -10px; left: -10px; width: 200%; height: 200%; cursor: pointer; }

.menu-item { font-family: 'Inter', sans-serif; padding: 6px 10px; border-radius: 6px; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--text-muted); background: transparent; border: 1px solid transparent; font-size: 14px; font-weight: 600; white-space: nowrap; }
.menu-item:hover { background: var(--bg-body); color: var(--primary); border-color: var(--border); }

/* =========================================================
   🌟 3. GLOBAL SLIDE-OUT MENU SHEET 🌟
   ========================================================= */
.mobile-menu-sheet {
    position: fixed !important;
    top: 0 !important;
    left: -100% !important;
    width: 280px !important;
    height: 100vh !important;
    background: var(--bg-topbar) !important;
    z-index: 99999 !important;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 10px 0 30px rgba(0,0,0,0.2) !important;
    display: flex !important;
    flex-direction: column !important;
    border-right: 1px solid var(--border) !important;
    overflow-y: auto !important;
}
.mobile-menu-sheet.open { left: 0 !important; }

/* =========================================================
   🌟 4. MAIN VIEWER & FLEXBOX LAYOUT 🌟
   ========================================================= */
.viewer-wrapper { display: flex; flex-direction: row; width: 100%; position: relative; flex: 1; overflow: hidden; align-items: stretch; }

.desktop-sidebar { position: sticky; top: 65px; width: 140px; flex: 0 0 140px; height: calc(100vh - 65px); background: var(--bg-sidebar); border-right: 1px solid var(--border); overflow-y: auto; padding: 15px 0; flex-shrink: 0; display: block; z-index: 40; }
.desktop-sidebar::-webkit-scrollbar { width: 5px; } .desktop-sidebar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.thumb-wrapper { margin-bottom: 15px; padding: 0 10px; text-align: center; }
.thumb { display: block; border-radius: 6px; overflow: hidden; border: 2px solid transparent; transition: 0.2s; background: white; text-decoration: none; }
.thumb img { 
    width: 100%; 
    height: 160px; 
    object-fit: cover; 
    object-position: top; /* 🌟 పేపర్ పై భాగం కట్ అవ్వదు 🌟 */
    display: block; 
    transition: 0.2s; 
}
.thumb:hover { transform: scale(1.05); } .thumb.active { border-color: var(--brand); box-shadow: 0 0 10px rgba(225, 29, 72, 0.4); }
.page-num { font-size: 11px; font-family: 'Inter', sans-serif; color: var(--text-main); font-weight: 600; margin-top: 6px; background: var(--bg-body); border-radius: 10px; display: inline-block; padding: 3px 10px; border: 1px solid var(--border); }

.main-paper { flex: 1; min-width: 0; padding: 20px; display: flex; justify-content: center; align-items: flex-start; overflow-y: auto; overflow-x: hidden; position: relative; }
.paper-wrapper { position: relative; box-shadow: 0 15px 40px rgba(0,0,0,0.15); background: white; width: 100%; max-width: 950px; display: block; margin: 0 auto; transition: max-width 0.3s ease; border-radius: 4px; overflow: hidden; }
#pdfCanvas { display: block; width: 100% !important; height: auto !important; } 

.nav-arrow { position: fixed; top: 50%; transform: translateY(-50%); background: rgba(15, 23, 42, 0.7); color: white; border: none; width: 45px; height: 45px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; cursor: pointer; transition: 0.2s; z-index: 30; backdrop-filter: blur(4px); }
.left-arrow { left: 155px; } .right-arrow { right: 175px; }
.nav-arrow:hover { background: var(--brand); transform: translateY(-50%) scale(1.1); } .nav-arrow.disabled { opacity: 0; pointer-events: none; }

.main-zoom-btn { position: fixed; bottom: 30px; right: 180px; background: var(--primary); color: white; border: none; width: 50px; height: 50px; border-radius: 50%; font-size: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.3); cursor: pointer; z-index: 40; transition: 0.3s; display: flex; justify-content: center; align-items: center; }
.main-zoom-btn:hover { background: var(--brand); transform: scale(1.1); }
#loaderSpinner { display: none; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: var(--primary); font-size: 40px; z-index: 10; }

.article-zone { position: absolute; background: rgba(2, 132, 199, 0.0); cursor: pointer; z-index: 5; transition: 0.2s; }
.article-zone:hover { background: rgba(2, 132, 199, 0.12); box-shadow: inset 0 0 0 2px rgba(2, 132, 199, 0.6); }

/* =========================================================
   🌟 5. ADVERTISEMENTS (PROPORTIONAL & LIGHT BORDER) 🌟
   ========================================================= */
.ad-sidebar {
    width: 160px; min-width: 160px; max-width: 160px; flex: 0 0 160px;
    background: var(--bg-body); padding: 10px; box-sizing: border-box;
    overflow-y: auto; text-align: center; z-index: 25; display: block;
}
.left-ad { border-right: 1px solid var(--border); }
.right-ad { border-left: 1px solid var(--border); }

.ad-sidebar img, .mobile-bottom-ad img {
    width: 100% !important; max-width: 100% !important; height: auto !important; max-height: 500px;
    display: block !important; margin: 0 auto;
    object-fit: contain !important;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--bg-topbar); padding: 4px; box-sizing: border-box;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); transition: transform 0.2s ease;
}
.ad-sidebar img:hover, .mobile-bottom-ad img:hover { transform: scale(1.02); }

.mobile-top-bar, .mobile-bottom-nav, .mobile-bottom-ad { display: none !important; }

/* =========================================================
   🌟 6. POPUP READER & SHARE MODALS 🌟
   ========================================================= */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.8); z-index: 1000; align-items: center; justify-content: center; backdrop-filter: blur(5px); }
.modal-content { background: var(--bg-topbar); border-radius: 12px; width: 95vw; max-width: 1000px; max-height: 90vh; box-shadow: 0 30px 60px rgba(0,0,0,0.5); display: flex; flex-direction: column; position: relative; animation: modalPop 0.3s ease-out; overflow: hidden; border: 1px solid var(--border); }
@keyframes modalPop { 0% { transform: scale(0.95); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.modal-header { padding: 12px 20px; background: var(--bg-body); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-brand { font-size: 18px; color: var(--text-main); display: flex; align-items: center; gap: 10px; }
.btn-close { background: transparent; color: #ef4444; font-size: 20px; border: none; cursor: pointer; transition: 0.2s; }
.btn-close:hover { transform: scale(1.1); }

.modal-toolbar { padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); gap: 10px; flex-wrap: wrap; }
.action-group { display: flex; gap: 8px; align-items: center; }
.btn-action { padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border); font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 6px; color: var(--text-main); background: var(--bg-body); transition: 0.2s; }
.btn-action:hover { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary { background: var(--brand) !important; color: white !important; border:none; }

.zoom-controls { display: flex; align-items: center; background: var(--bg-body); border-radius: 6px; padding: 2px; border: 1px solid var(--border); }
.zoom-btn { background: transparent; border: none; color: var(--text-main); width: 30px; height: 30px; font-size: 15px; cursor: pointer; border-radius: 4px; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.zoom-btn:hover { background: var(--primary); color: white; }

.modal-grid-body { display: block; padding: 15px; overflow: auto; background: var(--bg-body); flex: 1; -webkit-overflow-scrolling: touch; text-align: center; }
.modal-image-area { display: inline-block; margin: 0 auto; box-shadow: 0 4px 20px rgba(0,0,0,0.15); border-radius: 4px; background: white; transform-origin: top left; }
#articleCanvas { display: block; width: 100%; height: auto; transition: width 0.1s ease-out; }

.modal-nav { position: absolute; top: 50%; transform: translateY(-50%); background: var(--bg-topbar); color: var(--text-main); border: 1px solid var(--border); width: 36px; height: 36px; border-radius: 50%; font-size: 14px; cursor: pointer; z-index: 10; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.modal-nav:hover { background: var(--primary); color: white; }
.modal-nav.left { left: 10px; } .modal-nav.right { right: 10px; }
.modal-footer { background: var(--bg-body); padding: 10px 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-family: 'Inter', sans-serif; color: var(--text-muted); }

.share-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1999; }
.share-modal { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--bg-topbar); padding: 25px; border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,0.3); z-index: 2000; width: 280px; text-align: center; border: 1px solid var(--border); }
.share-grid { display: flex; justify-content: center; gap: 15px; }
.sh-btn { width: 45px; height: 45px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; color: white; text-decoration: none; cursor: pointer; border: none; transition: 0.2s; }
.sh-btn:hover { transform: scale(1.1); }

/* =========================================================
   🌟 7. UNIVERSAL RESPONSIVE BREAKPOINTS (CLEAN & PERFECT) 🌟
   ========================================================= */

/* 🖥️ DESKTOP SCREENS (1025px and above) - ల్యాప్‌టాప్‌లు & కంప్యూటర్ల కోసం */
@media screen and (min-width: 1025px) {
    .hide-desktop { display: none !important; }
    .hide-mobile { display: block !important; }
    .mobile-bottom-ad, .mobile-bottom-nav, .mobile-top-bar { display: none !important; }
}

/* 📱 MOBILE & TABLETS (1024px and below) - మొబైల్ & ట్యాబ్లెట్ యాప్ లుక్ */
@media screen and (max-width: 1024px) {
    .hide-desktop { display: block !important; }
    .hide-mobile { display: none !important; }
    
    /* 🌟 ఫుటర్ (Footer) పూర్తిగా మాయం 🌟 */
    footer, .main-footer, #footer { display: none !important; }

    /* డెస్క్‌టాప్ సైడ్ బార్లు పూర్తిగా మాయం */
    .desktop-sidebar, .ad-sidebar.left-ad, .ad-sidebar.right-ad { display: none !important; }
    
    /* 🌟 పేపర్ కింద గ్యాప్ బాగా తగ్గించాం 🌟 */
    .main-paper { padding: 10px !important; padding-bottom: 25px !important; }
    .paper-wrapper { width: 100%; max-width: 100%; }
    
    .left-arrow { left: 10px; } .right-arrow { right: 10px; }
    .main-zoom-btn { bottom: 80px; right: 15px; width: 45px; height: 45px; font-size: 18px; }
    
    .mobile-top-bar { display: flex !important; width: 100%; justify-content: space-between; align-items: center; }
    
    /* 🌟 మొబైల్ బాటమ్ యాడ్ - గ్యాప్ తగ్గించి పర్ఫెక్ట్ గా సెట్ చేసాం 🌟 */
    .mobile-bottom-ad {
        display: block !important; width: 96% !important; 
        margin: 0 auto 75px auto !important; /* పైన జీరో, కింద నావ్ బార్ కి సరిపడా 75px గ్యాప్ */
        max-height: 120px; z-index: 90;
    }
    .mobile-bottom-ad img { max-height: 100px; }

    .mobile-bottom-nav {
        display: flex !important; position: fixed !important; bottom: 0 !important; left: 0 !important;
        width: 100% !important; height: 65px !important; background: var(--bg-topbar) !important;
        border-top: 1px solid var(--border) !important; box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08) !important;
        z-index: 1000 !important; justify-content: space-around !important; align-items: center !important;
        padding-bottom: max(5px, env(safe-area-inset-bottom)); box-sizing: border-box;
    }
    
    .nav-bottom-item {
        display: flex !important; flex-direction: column !important; align-items: center !important;
        justify-content: center !important; color: var(--text-muted) !important; text-decoration: none !important;
        background: transparent !important; border: none !important; cursor: pointer !important;
        width: 20%; height: 100%; transition: all 0.2s ease; padding: 4px 0;
    }
    .nav-bottom-item i { font-size: 20px !important; margin-bottom: 4px !important; color: inherit; transition: transform 0.2s; }
    .nav-bottom-item span { font-size: 11px !important; font-family: 'Inter', sans-serif !important; font-weight: 600 !important; color: inherit; line-height: 1; }
    .nav-bottom-item:hover, .nav-bottom-item.active { color: var(--brand) !important; }
    .nav-bottom-item:hover i, .nav-bottom-item.active i { transform: translateY(-2px); }
    
    .modal-content { max-width: 98vw; width: 98vw; height: 95vh; max-height: 95vh; }
    .hide-mobile-modal { display: none; }
}

/* 🌟 8. SCROLL FIX & STICKY ADS 🌟 */
body { overflow: auto !important; }

.viewer-wrapper { 
    display: flex; 
    align-items: flex-start; 
    height: auto !important; 
    min-height: calc(100vh - 105px); 
    overflow: visible !important; 
}

.desktop-sidebar, .ad-sidebar {
    position: sticky !important;
    top: 105px !important; 
    height: calc(100vh - 110px) !important;
    overflow-y: auto !important;
    align-self: flex-start;
}

.main-paper { flex: 1; padding: 20px; overflow: visible !important; }

/* 🌟 9. PERFECT PRINT CSS 🌟 */
@media print {
    body { background: white !important; padding: 0 !important; margin: 0 !important; }
    
    .main-header, .desktop-sidebar, .ad-sidebar, .mobile-bottom-ad, 
    .mobile-bottom-nav, .nav-arrow, .main-zoom-btn, .pdf-action-toolbar, 
    .mobile-menu-sheet, .menu-overlay, footer, .main-footer { 
        display: none !important; 
    }
    
    .viewer-wrapper { display: block !important; padding: 0 !important; margin: 0 !important; }
    .main-paper { padding: 0 !important; width: 100% !important; display: block !important; }
    .paper-wrapper { width: 100% !important; max-width: 100% !important; box-shadow: none !important; border: none !important; }
    #pdfCanvas { width: 100% !important; max-width: 100% !important; page-break-inside: avoid; }
}

/* 🌟 THE MASTER ANDROID TOUCH ZOOM FIX 🌟 */
#paperContainer, #pdfCanvas, .main-paper {
    touch-action: pan-x pan-y !important;
    -webkit-user-select: none;
    user-select: none;
}
