/* ==========================================================================
   ePaper Preview Styles — Dark, professional document-viewer aesthetic
   Controls at bottom, zoom via mouse/touch gestures
   ========================================================================== */

/* ---------- Reset & Global ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    /* Prevent browser-level pinch zoom on the page itself */
    touch-action: none;
}

/* ---------- Header (title & controls) ---------- */
.epaper-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
    padding: 6px 16px;
    background: rgba(16, 16, 36, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    z-index: 1000;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.epaper-header::-webkit-scrollbar {
    display: none;
}
.epaper-header-controls {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    margin: 0 auto;
}

/* ---------- Thumbnails Strip ---------- */
.epaper-thumbnails-container {
    display: none !important;
}
.epaper-thumbnails-container::-webkit-scrollbar {
    display: none;
}
.epaper-thumbnail {
    flex-shrink: 0;
    width: 60px;
    height: 80px;
    background: #fff;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    opacity: 0.7;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.epaper-thumbnail:hover {
    opacity: 1;
    transform: translateY(-2px);
}
.epaper-thumbnail.active {
    border-color: #6366f1;
    opacity: 1;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}
.epaper-thumbnail canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.epaper-thumbnail-num {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 2px;
    pointer-events: none;
}

/* Controls */
.epaper-control-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.epaper-control-divider {
    width: 1px;
    height: 28px;
    background: rgba(255,255,255,0.1);
    margin: 0 6px;
}

/* Buttons */
.epaper-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 0;
    color: #ccc;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;

    line-height: 1;
    white-space: nowrap;
}
.epaper-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.12);
    color: #fff;
}
.epaper-btn:active:not(:disabled) {
}
.epaper-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.epaper-btn.active {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(99, 102, 241, 0.5);
    color: #a5b4fc;
}
.epaper-btn svg {
    flex-shrink: 0;
}
.epaper-btn-text {
    font-size: 12px;
    font-weight: 500;
}
.epaper-btn-primary {
    background: #6366f1 !important;
    border-color: #6366f1 !important;
    color: #fff !important;
}
.epaper-btn-primary:hover:not(:disabled) {
    background: #4f46e5 !important;
}

/* Page info */
.epaper-page-info {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #aaa;
}
.epaper-page-input {
    width: 42px;
    text-align: center;
    font-size: 13px;
    font-family: inherit;
    padding: 4px 2px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 0;
    color: #e0e0e0;
    -moz-appearance: textfield;
}
.epaper-page-input::-webkit-inner-spin-button,
.epaper-page-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.epaper-page-separator {
    color: #555;
}

/* ---------- Viewer ---------- */
.epaper-viewer {
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: auto;
    display: block;
    text-align: center;
    padding: 24px 24px 120px 24px;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 50%, #1a1a2e 100%);
    /* Allow touch scrolling/panning within the viewer */
    touch-action: none;
    cursor: grab;
    border-radius: 0;
}
.epaper-viewer.is-panning {
    cursor: grabbing;
}
.epaper-canvas-container {
    position: relative;
    display: inline-block;
    text-align: left;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
    border-radius: 0;
    line-height: 0;
}
#pdf-canvas {
    display: block;
    border-radius: 0;
}

/* Loading */
.epaper-loading {
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 500;
    background: #1a1a2e;
}
.epaper-spinner {
    width: 44px;
    height: 44px;
    border: 2px solid rgba(99, 102, 241, 0.3);
    border-radius: 50%;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.08);
}
.epaper-spinner::after {
    content: '';
    width: 10px;
    height: 10px;
    background: #6366f1;
    border-radius: 50%;
}
.epaper-loading p {
    font-size: 14px;
    color: #888;
    font-weight: 500;
}

/* ---------- Crop canvas overlay ---------- */
.epaper-crop-canvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: crosshair;
    z-index: 10;
}

/* ---------- Crop action bar ---------- */
.epaper-crop-actions {
    position: fixed;
    bottom: 72px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(16, 16, 36, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 0;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 1100;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.epaper-crop-actions p {
    font-size: 13px;
    color: #aaa;
    white-space: nowrap;
}
.epaper-crop-btns {
    display: flex;
    gap: 8px;
}

/* ---------- Share modal ---------- */
.epaper-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.epaper-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}
.epaper-modal-dialog {
    position: relative;
    background: #1e1e3a;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 0;
    width: 440px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    overflow: hidden;
}
.epaper-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.epaper-modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #f0f0f0;
}
.epaper-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #888;
    cursor: pointer;
    line-height: 1;

}
.epaper-modal-close:hover {
    color: #fff;
}
.epaper-modal-body {
    padding: 24px;
}

/* Share link row */
.epaper-share-link-group {
    margin-bottom: 24px;
}
.epaper-share-link-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #aaa;
    margin-bottom: 8px;
}
.epaper-share-link-row {
    display: flex;
    gap: 8px;
}
.epaper-share-link-row input {
    flex: 1;
    padding: 10px 14px;
    font-size: 13px;
    font-family: inherit;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 0;
    color: #e0e0e0;
    min-width: 0;
}

/* Social buttons */
.epaper-share-social {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.epaper-social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 0;
    text-decoration: none;
}
.epaper-social-btn:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.epaper-social-facebook { background: #1877f2; color: #fff; }
.epaper-social-twitter  { background: #1da1f2; color: #fff; }
.epaper-social-whatsapp { background: #25d366; color: #fff; }
.epaper-social-email    { background: rgba(255,255,255,0.1); color: #ccc; }
.epaper-social-email:hover { background: rgba(255,255,255,0.18); }

/* Share message textarea */
.epaper-share-message-group {
    margin-bottom: 24px;
}
.epaper-share-message-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #aaa;
    margin-bottom: 8px;
}
.epaper-share-message {
    width: 100%;
    padding: 10px 14px;
    font-size: 13px;
    font-family: inherit;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 0;
    color: #e0e0e0;
    resize: vertical;
    min-height: 60px;
    max-height: 160px;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.2s ease;
}
.epaper-share-message:focus {
    border-color: rgba(99, 102, 241, 0.5);
}
.epaper-share-message::placeholder {
    color: #666;
}

/* ---------- Toast ---------- */
.epaper-toast {
    position: fixed;
    bottom: 72px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(16, 16, 36, 0.95);
    backdrop-filter: blur(12px);
    color: #e0e0e0;
    padding: 12px 28px;
    border-radius: 0;
    font-size: 14px;
    font-weight: 500;
    z-index: 3000;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 6px 24px rgba(0,0,0,0.4);
}

/* ---------- Side navigation arrows ---------- */
.epaper-side-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(16, 16, 36, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    outline: none;
}
.epaper-side-nav:hover:not(:disabled) {
    background: rgba(99, 102, 241, 0.35);
    color: #fff;
    border-color: rgba(99, 102, 241, 0.5);
}
.epaper-side-nav:active:not(:disabled) {
    background: rgba(99, 102, 241, 0.5);
}
.epaper-side-nav:disabled {
    opacity: 0.2;
    cursor: not-allowed;
}
.epaper-side-prev {
    left: 12px;
    border-radius: 50%;
}
.epaper-side-next {
    right: 12px;
    border-radius: 50%;
}
.epaper-side-nav svg {
    flex-shrink: 0;
}

/* ---------- Zoom level label ---------- */
.epaper-zoom-level {
    font-size: 12px;
    font-weight: 600;
    color: #aaa;
    min-width: 40px;
    text-align: center;
    user-select: none;
}

/* ---------- Embed mode adjustments ---------- */
.epaper-embed-mode .epaper-viewer {
    top: 0;
    bottom: 0;
}
.epaper-embed-mode .epaper-loading {
    top: 0;
    bottom: 0;
}
.epaper-embed-mode .epaper-btn-text {
    display: none;
}

/* ---------- No header mode (embed) ---------- */
body:not(.epaper-embed-mode) .epaper-viewer {
    top: 48px;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .epaper-header {
        height: 42px;
        padding: 6px 12px;
        justify-content: flex-start;
    }
    .epaper-header-controls {
        margin: 0;
        justify-content: flex-start;
    }
    .epaper-btn {
        padding: 6px 8px;
    }
    .epaper-btn-text {
        display: none;
    }
    .epaper-viewer {
        top: 42px;
        bottom: 0;
        padding: 12px 12px 120px 12px;
    }
    .epaper-loading {
        top: 42px;
        bottom: 0;
    }
    .epaper-control-divider {
        display: none;
    }
    .epaper-crop-actions {
        bottom: 64px;
        flex-direction: column;
        border-radius: 12px;
        padding: 12px 16px;
        gap: 8px;
    }
    .epaper-side-nav {
        width: 40px;
        height: 40px;
    }
    .epaper-side-nav svg {
        width: 18px;
        height: 18px;
    }
}
@media (max-width: 480px) {
    .epaper-viewer {
        padding: 8px;
    }
    .epaper-side-nav {
        width: 36px;
        height: 36px;
    }
    .epaper-side-nav svg {
        width: 16px;
        height: 16px;
    }
}
