/* ============================================================
   MANA VARTHA - E-Paper Reader Stylesheet
   Full Screen, Zoom Engine, Thumbnails Drawer, Responsive Controls
   ============================================================ */

.reader-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background-color: #1e293b;
    color: #ffffff;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
}

/* Top Toolbar */
.reader-topbar {
    height: 56px;
    background-color: #0f172a;
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 1010;
    flex-shrink: 0;
}

.reader-topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.reader-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #94a3b8;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.35rem 0.6rem;
    border-radius: 4px;
    background: #1e293b;
}

.reader-back-btn:hover {
    color: #ffffff;
    background: #334155;
}

.reader-meta-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 450px;
}

.reader-meta-date {
    font-size: 0.8rem;
    color: #94a3b8;
}

.reader-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-reader-action {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    font-size: 0.825rem;
    font-weight: 600;
    color: #ffffff;
    background-color: #334155;
    transition: background 0.15s ease;
    white-space: nowrap;
}

.btn-reader-action:hover {
    background-color: #475569;
}

.btn-reader-action.btn-primary {
    background-color: #b91c1c;
}

.btn-reader-action.btn-primary:hover {
    background-color: #dc2626;
}

/* Reader Main Body */
.reader-body {
    display: flex;
    flex: 1;
    position: relative;
    overflow: hidden;
    background-color: #0b0f19;
}

/* Thumbnails Sidebar */
.reader-sidebar {
    width: 260px;
    background-color: #111827;
    border-right: 1px solid #1f2937;
    display: flex;
    flex-direction: column;
    z-index: 1005;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.reader-sidebar.collapsed {
    transform: translateX(-100%);
    position: absolute;
    height: 100%;
}

.sidebar-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #1f2937;
    font-size: 0.875rem;
    font-weight: 700;
    color: #f3f4f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-thumbnails-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.thumb-card {
    background-color: #1f2937;
    border: 2px solid transparent;
    border-radius: 6px;
    padding: 0.5rem;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
}

.thumb-card:hover {
    background-color: #374151;
    border-color: #6b7280;
}

.thumb-card.active {
    border-color: #b91c1c;
    background-color: #271216;
}

.thumb-img {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: 3px;
    background-color: #374151;
}

.thumb-info {
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 0.35rem;
    color: #e5e7eb;
}

/* Page Viewer Stage */
.reader-stage {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.reader-stage.grabbing {
    cursor: grabbing;
}

.page-viewport {
    position: relative;
    transform-origin: center center;
    transition: transform 0.08s ease-out;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    max-width: 90%;
    max-height: 90%;
}

.newspaper-page-img {
    display: block;
    max-height: calc(100vh - 120px);
    width: auto;
    object-fit: contain;
    background-color: #ffffff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    border-radius: 2px;
}

/* Loading Spinner */
.page-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(11, 15, 25, 0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1008;
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.page-loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.reader-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #b91c1c;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 0.75rem;
}

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

/* Bottom Control Bar */
.reader-bottombar {
    height: 56px;
    background-color: #0f172a;
    border-top: 1px solid #334155;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 1010;
    flex-shrink: 0;
}

.reader-ctrl-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-ctrl {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background-color: #1e293b;
    color: #f1f5f9;
    font-size: 1.1rem;
    transition: background 0.15s ease;
}

.btn-ctrl:hover {
    background-color: #334155;
}

.btn-ctrl:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-jump-select {
    padding: 0.35rem 0.6rem;
    background-color: #1e293b;
    border: 1px solid #475569;
    color: #ffffff;
    border-radius: 4px;
    font-size: 0.875rem;
    cursor: pointer;
}

.page-indicator-text {
    font-size: 0.9rem;
    font-weight: 700;
    color: #cbd5e1;
    min-width: 90px;
    text-align: center;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .reader-sidebar {
        position: fixed;
        left: 0;
        top: 56px;
        bottom: 56px;
        width: 80%;
        max-width: 300px;
        box-shadow: 10px 0 30px rgba(0,0,0,0.8);
        transform: translateX(-100%);
    }
    .reader-sidebar.open-mobile {
        transform: translateX(0);
    }
    .reader-meta-title {
        max-width: 180px;
        font-size: 0.85rem;
    }
    .btn-reader-action span {
        display: none;
    }
    .reader-bottombar {
        padding: 0 0.5rem;
    }
    .btn-ctrl {
        width: 34px;
        height: 34px;
        font-size: 0.95rem;
    }
}

/* Print CSS */
@media print {
    body * {
        visibility: hidden;
    }
    .page-viewport, .newspaper-page-img {
        visibility: visible;
        position: absolute;
        left: 0;
        top: 0;
        width: 100% !important;
        max-height: none !important;
    }
}
