/* =========================================
   HM PDF Reader - Virtual Scrolling & UX CSS
========================================= */

.hm-pdf-reader-container { width: 100%; max-width: 1000px; margin: 0 auto; border: 1px solid #ddd; border-radius: 8px; overflow: hidden; font-family: inherit; background: #f5f5f5; display: flex; flex-direction: column; position: relative; }
.hm-pdf-toolbar { display: flex; justify-content: space-between; align-items: center; background-color: #0d47a1; color: white; padding: 10px 15px; }
.hm-pdf-title { font-weight: bold; font-size: 16px; margin-left: 10px; }
.toolbar-center { display: flex; align-items: center; gap: 10px; }
.hm-btn { background: rgba(255,255,255,0.2); border: none; color: white; padding: 5px 10px; cursor: pointer; border-radius: 4px; font-size: 14px; transition: 0.3s; }
.hm-btn:hover { background: rgba(255,255,255,0.4); }
.hm-pdf-page-info { font-size: 14px; }
.hm-pdf-progress-bar-container { width: 100%; height: 4px; background: #ddd; }
.hm-pdf-progress-bar { height: 100%; background: #ffeb3b; width: 0%; transition: width 0.3s; }
.hm-pdf-main-wrapper { position: relative; display: flex; height: calc(100vh - 65px); min-height: 600px; overflow: hidden; }

/* সাইডবার (TOC) */
.hm-pdf-sidebar { position: absolute; left: -300px; top: 0; width: 250px; height: 100%; background-color: #f8f9fa; border-right: 1px solid #ddd; box-shadow: 2px 0 5px rgba(0,0,0,0.1); transition: left 0.3s ease-in-out; z-index: 100; display: flex; flex-direction: column; }
.hm-pdf-sidebar.open { left: 0; }
.hm-sidebar-header { display: flex; justify-content: space-between; align-items: center; padding: 15px; background-color: #0d47a1; color: white; }
.hm-sidebar-header h3 { margin: 0; font-size: 16px; }
.hm-btn-close { background: none; border: none; color: white; font-size: 20px; cursor: pointer; }
.hm-pdf-toc-list { list-style: none; padding: 0; margin: 0; overflow-y: auto; flex-grow: 1; }
.hm-pdf-toc-list li { padding: 12px 15px; border-bottom: 1px solid #eee; cursor: pointer; transition: 0.2s; font-size: 14px; line-height: 1.4; }
.hm-pdf-toc-list li:hover { background-color: #e3f2fd; }

/* ভিউয়ার এরিয়া এবং লেজি লোড কন্টেইনার */
.hm-pdf-viewer-area { flex: 1; width: 100%; height: 100%; position: relative; overflow-y: auto; overflow-x: auto; background-color: #e9ecef; scroll-behavior: smooth; }
.hm-pdf-pages-container { display: flex; flex-direction: column; align-items: center; padding: 20px 0; gap: 20px; }
.hm-pdf-page-container { position: relative; background: #fff; box-shadow: 0 4px 15px rgba(0,0,0,0.1); display: flex; justify-content: center; align-items: center; }
.hm-pdf-page-container canvas { display: block; width: 100%; height: 100%; z-index: 1; }

/* ডার্ক এবং সেপিয়া মোড */
.hm-pdf-reader-container.dark-mode { background-color: #1a1a1a; border-color: #333; }
.hm-pdf-reader-container.dark-mode .hm-pdf-viewer-area { background-color: #2c2c2c; }
.hm-pdf-reader-container.dark-mode canvas { filter: invert(0.8) hue-rotate(180deg); }
.hm-pdf-reader-container.sepia-mode .hm-pdf-viewer-area { background-color: #fdf6e3; }
.hm-pdf-reader-container.sepia-mode canvas { filter: sepia(0.4) contrast(0.95) brightness(0.95); }

/* ফুলস্ক্রিন */
.hm-pdf-reader-container:fullscreen { width: 100vw !important; height: 100vh !important; background-color: #f5f5f5; z-index: 999999 !important; border: none; border-radius: 0; max-width: none; }
.hm-pdf-reader-container:fullscreen .hm-pdf-main-wrapper { height: calc(100vh - 60px); }

/* টেক্সট লেয়ার ও হাইলাইটস (FIXED: opacity & selection issues) */
.hm-pdf-text-layer { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: hidden; z-index: 10; line-height: 1; user-select: text !important; -webkit-user-select: text !important; }
.hm-pdf-text-layer span { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; pointer-events: auto; }
.hm-pdf-text-layer ::selection { background: rgba(0, 102, 204, 0.4); color: transparent; }

.hm-highlighted-text { border-radius: 2px; z-index: 5; transition: background-color 0.2s; }
.hm-highlighted-text:hover { filter: brightness(0.9); }

/* লোডার এবং টুলটিপ */
#hm-pdf-loading { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 18px; font-weight: bold; z-index: 10; }
.loader-spinner { display: inline-block; width: 20px; height: 20px; border: 3px solid rgba(0,0,0,0.3); border-radius: 50%; border-top-color: #0d47a1; animation: spin 1s ease-in-out infinite; margin-right: 10px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.hm-selection-tooltip { position: fixed; background: #2c3e50; padding: 6px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.3); display: none; gap: 5px; z-index: 999999; transform: translateX(-50%); font-family: inherit; }
.hm-selection-tooltip::after { content: ''; position: absolute; top: 100%; left: 50%; margin-left: -6px; border-width: 6px; border-style: solid; border-color: #2c3e50 transparent transparent transparent; }
.tooltip-btn { background: none; border: none; color: #ecf0f1; font-size: 13px; cursor: pointer; padding: 5px 10px; border-radius: 4px; font-family: inherit; }
.tooltip-btn:hover { background: #34495e; color: #fff; }

.hm-note-modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.6); z-index: 9999999; display: none; justify-content: center; align-items: center; }
.hm-note-modal { background: #fff; width: 400px; padding: 20px; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); font-family: inherit; }
.hm-note-modal h3 { margin: 0 0 15px 0; font-size: 18px; color: #333; }
.hm-note-selected-text { background: #f8f9fa; padding: 10px; border-left: 3px solid #0d47a1; font-style: italic; font-size: 15px; color: #555; margin-bottom: 15px; max-height: 80px; overflow-y: auto; font-family: inherit; }
.hm-note-textarea { width: 100%; height: 100px; padding: 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; resize: none; margin-bottom: 15px; font-family: inherit; box-sizing: border-box; }
.hm-color-picker { display: flex; gap: 10px; margin-bottom: 15px; }
.hm-color-btn { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; transition: 0.2s; }
.hm-color-btn.active { border-color: #333; transform: scale(1.1); }
.color-yellow { background: #ffeb3b; } .color-green { background: #4caf50; } .color-pink { background: #e91e63; } .color-cyan { background: #00bcd4; }
.hm-modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.hm-btn-cancel { background: #e0e0e0; color: #333; border: none; padding: 8px 15px; border-radius: 4px; cursor: pointer; font-family: inherit;}
.hm-btn-save { background: #0d47a1; color: #fff; border: none; padding: 8px 15px; border-radius: 4px; cursor: pointer; font-family: inherit;}

/* =========================================
   HM PDF Reader - Dynamic Moving Watermark
========================================= */
.hm-dynamic-wm { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 9998; font-size: 16px; font-weight: bold; color: rgba(150, 150, 150, 0.12); white-space: nowrap; user-select: none; -webkit-user-select: none; will-change: transform; text-shadow: 1px 1px 0 rgba(255,255,255,0.05), -1px -1px 0 rgba(0,0,0,0.05); }
.hm-pdf-reader-container.dark-mode .hm-dynamic-wm { color: rgba(200, 200, 200, 0.1); }
/* =========================================
   HM PDF Reader - Search Feature CSS
========================================= */
.hm-search-highlight { background-color: rgba(255, 152, 0, 0.4) !important; border-bottom: 2px solid #ff9800; border-radius: 2px; }
.hm-search-result-item { padding: 15px; border-bottom: 1px solid #eee; cursor: pointer; transition: 0.2s; font-size: 14px; line-height: 1.6; }
.hm-search-result-item:hover { background-color: #e3f2fd; border-left: 3px solid #0d47a1; }
.hm-search-result-page { font-weight: bold; color: #0d47a1; margin-bottom: 5px; display: block; font-size: 15px; }
.hm-search-snippet { color: #555; }
.hm-search-snippet mark { background-color: #ffeb3b; color: #000; padding: 0 3px; border-radius: 2px; font-weight: bold; }

/* Dark Mode Support */
.hm-pdf-reader-container.dark-mode .hm-search-result-item { border-bottom-color: #444; }
.hm-pdf-reader-container.dark-mode .hm-search-result-item:hover { background-color: #333; border-left-color: #64b5f6; }
.hm-pdf-reader-container.dark-mode .hm-search-result-page { color: #64b5f6; }
.hm-pdf-reader-container.dark-mode .hm-search-snippet { color: #ccc; }
.hm-pdf-reader-container.dark-mode .hm-search-snippet mark { background-color: #f57c00; color: #fff; }
/* =========================================
   HM PDF Reader - Premium Two-Page Spread
========================================= */
@media (min-width: 900px) {
    .hm-two-page-mode {
        display: grid !important;
        grid-template-columns: max-content max-content !important;
        justify-content: center !important;
        gap: 30px 0 !important;
        padding: 40px !important;
        background-color: #cfd8dc !important; /* পড়ার টেবিলের মতো ব্যাকগ্রাউন্ড */
    }
    
    .hm-two-page-mode .hm-pdf-page-container {
        margin: 0 !important;
        transition: transform 0.3s ease;
    }
    
    /* Cover Page (Page 1): মাঝখানে একা থাকবে */
    .hm-two-page-mode .hm-pdf-page-container:first-child {
        grid-column: 1 / -1 !important;
        justify-self: center !important;
        border-radius: 4px !important;
        box-shadow: 0 10px 25px rgba(0,0,0,0.3) !important;
        border: none !important;
    }
    
    /* Left Page */
    .hm-two-page-mode .hm-pdf-page-container:nth-child(even) {
        box-shadow: -10px 10px 20px rgba(0,0,0,0.15) !important;
        border-right: 1px solid rgba(0,0,0,0.1) !important;
        border-radius: 8px 0 0 8px !important;
        position: relative;
    }
    .hm-two-page-mode .hm-pdf-page-container:nth-child(even)::after {
        content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 25px;
        background: linear-gradient(to left, rgba(0,0,0,0.1) 0%, transparent 100%);
        pointer-events: none; z-index: 9;
    }
    
    /* Right Page */
    .hm-two-page-mode .hm-pdf-page-container:nth-child(odd):not(:first-child) {
        box-shadow: 10px 10px 20px rgba(0,0,0,0.15) !important;
        border-left: 1px solid rgba(255,255,255,0.8) !important;
        border-radius: 0 8px 8px 0 !important;
        position: relative;
    }
    .hm-two-page-mode .hm-pdf-page-container:nth-child(odd):not(:first-child)::after {
        content: ''; position: absolute; top: 0; left: 0; bottom: 0; width: 25px;
        background: linear-gradient(to right, rgba(0,0,0,0.1) 0%, transparent 100%);
        pointer-events: none; z-index: 9;
    }
}
/* =========================================
   HM PDF Reader - Premium Lock (Teaser Mode)
========================================= */
.hm-premium-lock-box {
    text-align: center;
    background: #ffffff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    max-width: 400px;
    border: 2px dashed #cbd5e1;
    font-family: inherit;
}
.hm-premium-lock-box .lock-icon {
    font-size: 50px;
    margin-bottom: 15px;
    color: #f59e0b;
}
.hm-premium-lock-box h2 {
    font-size: 24px;
    color: #1e293b;
    margin: 0 0 10px 0;
    font-weight: 800;
}
.hm-premium-lock-box p {
    font-size: 15px;
    color: #64748b;
    line-height: 1.6;
    margin-bottom: 25px;
}
.hm-buy-now-btn {
    display: inline-block;
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: #fff !important;
    padding: 12px 25px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    font-size: 16px;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.4);
}
.hm-buy-now-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.6);
}

.hm-pdf-reader-container.dark-mode .hm-premium-lock-box {
    background: #1e293b;
    border-color: #475569;
}
.hm-pdf-reader-container.dark-mode .hm-premium-lock-box h2 {
    color: #f8fafc;
}