﻿/* ======================================================
   NEWSPAPER VIEWER – LIGHT THEME (FULL CSS)
   Compatible: PDF.js 5.x + ASP.NET WebForms
   ====================================================== */

/* ================= RESET ================= */

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
    font-family: Arial, Helvetica, sans-serif;
    background: #f5f6f8;
    color: #111;    
}
body {
    overflow: hidden;
}
/* ================= HEADER ================= */

.header {
    height: 48px;
    background: #ffffff;
    color: #111;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid #e5e7eb;
}

.logo {
    font-weight: bold;
    font-size: 16px;
}

.selectors select {
    margin-left: 6px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    background: #fff;
}

/* ================= TOOLBAR ================= */

.toolbar {
    height: 40px;
    background: #f9fafb;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    border-bottom: 1px solid #e5e7eb;
    position: relative;
}

.toolbar input {
    height: 32px;
    padding: 6px 10px;
    border-radius: 2px;
    border: 1px solid #d1d5db;
    font-size: 14px;
}

.toolbar button {
    background: #ffffff;
    border: 1px solid #d1d5db;
    color: #111;
    padding: 6px 10px;
    border-radius: 2px;
    font-size: 14px;
    cursor: pointer;
    transition: all .15s ease;
}

.toolbar button:hover {
    background: #f3f4f6;
    border-color: #2563eb;
    color: #2563eb;
}

.btn-show-sidebar {
    position: absolute;
    top: 1px;
    right: 180px;
    /*background-color: #3a53a5 !important;*/
    border: none !important;
}
.btn-fix-show-sidebar {
    right: 10px;
}
.btn-login svg {
    transform: rotate(180deg);
}

#zoomLevel,
#pageInfo {
    font-size: 13px;
    color: #374151;
    min-width: 56px;
    text-align: center;
}

/* ================= CONTENT ================= */

.content {
    display: flex;
    height: calc(100% - 48px - 40px - 36px);
}

/* ================= PDF VIEW ================= */

.pdf-view {
    flex: 1;
    background: #e5e7eb;
    position: relative;
   
}


#pdfContainer {
    overflow: auto;
    width: 100%;
    height: 100%;
    background: #d1d5db;
    text-align: center;
    white-space: nowrap; /* 🔥 QUAN TRỌNG */
}

#pdfSpread {
    display: inline-flex;   
    align-items: flex-start;
    gap: 0px;
    padding:2px; 
}

#pdfCanvas,
#pdfCanvas2 {
    background: white;
    box-shadow: none;
}
.pdf-loaded #pdfCanvas,
.pdf-loaded #pdfCanvas2 {
    box-shadow: 0 0 6px rgba(0,0,0,0.2); /* ✅ thêm lại sau */
}
/* ================= SIDEBAR ================= */

.page-list {
    width: 220px;
    background: #f1f3f5;
    color: #111;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #e5e7eb;
    height: 100vh;             
    overflow-y: auto;           
    -webkit-overflow-scrolling: touch; 
}

.page-list.hidden {
    display: none;
}

/* ---------- Tabs ---------- */

.sidebar-tabs {
    display: flex;
    background: #f3f4f6;
}

.sidebar-tabs .tab {
    flex: 1;
    text-align: center;
    padding: 8px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    color: #374151;
}

.sidebar-tabs .tab.active {
    border-bottom: 2px solid #2563eb;
    background: #ffffff;
    color: #2563eb;
    font-weight: bold;
}

/* ---------- Body ---------- */

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    display: none;
    padding: 6px 6px 6px 6px;
    background: #cccccc;
}

.sidebar-body.active {
    display: block;
}

/* ================= THUMBNAIL ================= */

.thumbnail {
    width: 100%;
    position: relative;
    margin: 6px 4px;
    padding: 6px;
    cursor: pointer;
    text-align: right;
    background: transparent;
    border-radius: 6px;
    transition: all 0.15s ease;
    will-change: transform; /* 🔥 mượt scroll */
}
/* IMG thumbnail */
.thumb-img1 {
    width: 100%;
    height: auto;
    display: block;
    /* 🔥 tăng nét */
    image-rendering: -webkit-optimize-contrast;

}
/* Loading */
.thumb-loading {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumb-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #ccc;
    border-top: 2px solid #333;
    border-radius: 50%;
    animation: thumb-spin 0.8s linear infinite;
}

@keyframes thumb-spin {
    to {
        transform: rotate(360deg);
    }
}
.thumbnail canvas {
    display: block;
    width: 100%;
    height: auto; /* 🔥 FIX LAG + méo */

    margin: 0 auto;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    filter: contrast(1.05) saturate(1.05);
    border-radius: 4px;
}
.thumbnail:hover {
    background: rgba(0,0,0,0.06);
    transform: translateY(-1px);
}

.thumbnail.active {
    background: #dbeafe;
    outline: 2px solid #3b82f6;
}

.thumb-page {
    position: absolute;
    right: 2px;
    bottom: 2px;
    background: rgba(0,0,0,0.65);
    color: #fff;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 3px;
    pointer-events: none;
    backdrop-filter: blur(2px); /* 🔥 nhìn xịn hơn */
}
.thumb-inner {
    position: relative;
    display: inline-block;
}
#thumbPanel {
    overflow-y: auto;
    will-change: transform;
    contain: content; /* 🔥 giảm repaint */
}
/* ================= OUTLINE ================= */

.outline-item {
    padding: 8px;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
}

.outline-item:hover {
    background: #f3f4f6;
}

.outline-item.active {
    background: #dbeafe;
}

.outline-title {
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 13px;
    line-height: 1.4;    
}

.outline-page {
    font-size: 12px;
    color: #6b7280;
}

/* ================= FOOTER ================= */

.footer {
    height: 36px;
    background: #f9fafb;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border-top: 1px solid #e5e7eb;
}

/* ================= ARTICLE HIGHLIGHT ================= */

.article-highlight {
    outline: 3px solid #2563eb;
}
/* ================= TEXT HIGHLIGHT ================= */
/* ================= PDF PAGE ================= */
.pdf-page {
    position: relative;
    margin: 24px auto;
    height:100vh;
}

/* ================= TEXT LAYER (ẨN HOÀN TOÀN) ================= */
.textLayer {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    transform-origin: 0 0;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.textLayer span {
    position: absolute;
    white-space: pre;
    transform-origin: 0 0;
    line-height: 1;
}


.pdf-highlight {
    background: rgba(255, 230, 0, 0.6);
    border-radius: 2px;
}

/* Chỉ hiện dòng được scroll tới (debug / optional) */
.textLayer span.text-hit {
    opacity: 1 !important;
    background: rgba(255, 230, 150, 0.85);
    border-radius: 2px;
}

/* ================= MOBILE SIDEBAR ================= */

@media (max-width: 768px) {

    .content {
        position: relative;        
    }

    .page-list {
        position: absolute;
        right: -280px;
        top: 0;
        height: 100%;
        z-index: 20;
        transition: right .3s ease;
        box-shadow: -6px 0 16px rgba(0,0,0,.2);
        background: #f1f3f5; /* 👈 nền xám */
    }

    .page-list.show {
        right: 0;
    }

    .pdf-view {
        width: 100%;
    }
}

/* ================= PAGE FLIP EFFECT ================= */

.flip-wrapper {
    position: relative;
    perspective: 1200px;
}

#pdfCanvas {
    display: block;
    transition: opacity 0.25s ease;
    image-rendering: auto;
}



/*
canvas {
            image-rendering: optimizeSpeed;
        }
*/

        .ttx-fix-btn{
    width:28px;
    height:28px;
    padding:0;
    display:flex;
    align-items:center;
    justify-content:center;
}
.sidebar-panel{
    display:none;
}

.sidebar-panel.active{
    display:block;
}
.pdf-loading{
    position: fixed;
    top:0;
    left:0;
    width:100%;
    height:100%;
    background: rgba(255,255,255,0.7);
    display:none;
    align-items:center;
    justify-content:center;
    z-index:9999;
}

.spinner{
    width:50px;
    height:50px;
    border:5px solid #ccc;
    border-top:5px solid #007bff;
    border-radius:50%;
    animation: spin 1s linear infinite;
}

@keyframes spin{
    0%{transform:rotate(0deg);}
    100%{transform:rotate(360deg);}
}
/* Container phải relative */
.content {
    position: relative;
}

/* Nút điều hướng */
.page-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    
    z-index: 999;
    background: rgba(0,0,0,0.35);
    color: #fff;
    border: none;
    padding: 14px 18px;
    font-size: 22px;
    cursor: pointer;
    border-radius: 8px;

    transition: all 0.2s ease;
}

/* Bên trái */
.prev-page {
    left: 20px;
}

/* Bên phải */
.next-page {
    right: 30px;
}

/* Hover đẹp hơn */
.page-nav:hover {
    background: rgba(0,0,0,0.7);
    transform: translateY(-50%) scale(1.1);
}
.page-nav {
    opacity: 0;
}

.content:hover .page-nav {
    opacity: 1;
}
.pdf-view:hover ~ .page-nav,
.content:hover .page-nav {
    opacity: 1;
}

