/**
 * PDF Preview Modal Styles
 * Author: Showmik Hassan
 * Version: 3.2.0
 */

/* Animations */
@keyframes pdfPreviewGlow {
    0% {
        background-position-x: 0%;
    }

    50% {
        background-position-x: 289.943%;
    }

    100% {
        background-position-x: 0%;
    }
}

@keyframes pdfLoaderBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* =====================================================
   Body scroll lock - UPDATED with touch-action
   ===================================================== */
body.pdf-modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    top: 0 !important;
    left: 0 !important;
    touch-action: none !important;
}

/* =====================================================
   Preview Button
   ===================================================== */
.pdf-preview-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 999px;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.2s ease;
    box-shadow: none;
    border: none;
    text-decoration: none;
    background: linear-gradient(90deg, #00e5ff, #5b5bff, #8a2be2, #00e5ff);
    background-size: 400% 100%;
    animation: pdfPreviewGlow 7s linear infinite;
}

.pdf-preview-btn:hover {
    color: #fff;
    transform: translateY(-1px);
    text-decoration: none;
}

.pdf-preview-btn:active {
    transform: translateY(0);
}

.pdf-preview-btn:focus,
.pdf-preview-btn:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

/* =====================================================
   Inline placement beside price
   ===================================================== */
.summary .price {
    display: inline !important;
}

.pdf-preview-btn {
    vertical-align: middle;
    margin-left: 12px;
}

/* =====================================================
   Overlay
   ===================================================== */
.pdf-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    z-index: 2147483646;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

.pdf-preview-overlay.pdf-preview-open {
    opacity: 1;
    visibility: visible;
}

/* =====================================================
   Modal Container - Always centered
   ===================================================== */
.pdf-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2147483647;
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
}

.pdf-preview-modal.pdf-preview-open {
    pointer-events: auto;
    overflow: hidden;
}

/* =====================================================
   Modal Panel - Desktop: Full height
   ===================================================== */
.pdf-preview-panel {
    position: relative;
    background: #fff;
    width: 100%;
    max-width: 900px;
    height: calc(100vh - 40px);
    border-radius: 4px;
    overflow: hidden;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    box-shadow: 0 10px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.pdf-preview-modal.pdf-preview-open .pdf-preview-panel {
    opacity: 1;
    transform: translateY(0);
}

/* =====================================================
   Modal Header
   ===================================================== */
.pdf-preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f5f5f5;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
    gap: 12px;
}

.pdf-preview-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    padding: 0;
    color: #222;
    line-height: 1.4;
    flex: 1;
}

/* =====================================================
   Close Button
   ===================================================== */
.pdf-preview-close {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    margin: 0;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    background: #ed2024;
    color: #fff;
    box-shadow: 0 2px 8px rgba(237, 32, 36, 0.3);
    transition: transform 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
}

.pdf-preview-close svg {
    width: 18px;
    height: 18px;
    display: block;
}

.pdf-preview-close:hover {
    background: #d41c1f;
    transform: scale(1.05);
}

.pdf-preview-close:focus {
    outline: none;
}

/* =====================================================
   Modal Body - Fixed height, doesn't grow
   ===================================================== */
.pdf-preview-body {
    flex: 1;
    background: #404040;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* =====================================================
   Loading - Simple blinking text
   ===================================================== */
.pdf-preview-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #404040;
    z-index: 10;
}

.pdf-loader-text {
    color: #fff;
    font-size: 16px;
    font-weight: 500;
    animation: pdfLoaderBlink 1.2s ease-in-out infinite;
}

.pdf-preview-loader.hidden {
    display: none;
}

/* =====================================================
   PDF Scroll Container - UPDATED with better touch support
   ===================================================== */
.pdf-preview-scroll {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: scroll !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.pdf-preview-scroll::-webkit-scrollbar {
    width: 8px;
}

.pdf-preview-scroll::-webkit-scrollbar-track {
    background: #333;
}

.pdf-preview-scroll::-webkit-scrollbar-thumb {
    background: #666;
    border-radius: 4px;
}

.pdf-preview-scroll::-webkit-scrollbar-thumb:hover {
    background: #888;
}

/* =====================================================
   PDF Container
   ===================================================== */
.pdf-preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 10px 70px 10px;
    min-height: 100%;
}

/* =====================================================
   PDF Page Canvas
   ===================================================== */
.pdf-page-wrapper {
    margin-bottom: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    background: #fff;
    flex-shrink: 0;
    line-height: 0;
}

.pdf-page-wrapper canvas {
    display: block;
    max-width: 100%;
    height: auto !important;
}

/* =====================================================
   Floating Toolbar
   ===================================================== */
.pdf-preview-toolbar {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 8px;
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.pdf-preview-body:hover .pdf-preview-toolbar,
.pdf-preview-toolbar:hover,
.pdf-preview-toolbar.visible {
    opacity: 1;
    visibility: visible;
}

.pdf-toolbar-pages {
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.pdf-toolbar-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pdf-toolbar-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    margin: 0;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.pdf-toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.pdf-toolbar-btn:focus {
    outline: none;
}

.pdf-toolbar-btn svg {
    width: 18px;
    height: 18px;
}

.pdf-zoom-level {
    color: #fff;
    font-size: 12px;
    min-width: 40px;
    text-align: center;
}

/* =====================================================
   Responsive - Tablets (1024px)
   ===================================================== */
@media screen and (max-width: 1024px) {
    .pdf-preview-modal {
        padding: 16px;
    }

    .pdf-preview-panel {
        height: calc(100vh - 32px);
    }

    .pdf-preview-head {
        padding: 10px 14px;
    }

    .pdf-preview-title {
        font-size: 14px;
    }

    .pdf-preview-close {
        width: 34px;
        height: 34px;
        min-width: 34px;
        min-height: 34px;
    }

    .pdf-preview-close svg {
        width: 16px;
        height: 16px;
    }
}

/* =====================================================
   Responsive - Mobile (768px) - Fixed 85vh
   ===================================================== */
@media screen and (max-width: 768px) {
    .pdf-preview-modal {
        padding: 12px;
    }

    .pdf-preview-panel {
        height: 85vh;
        max-height: 85vh;
        border-radius: 3px;
    }

    .pdf-preview-head {
        padding: 10px 12px;
    }

    .pdf-preview-close {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
    }

    .pdf-preview-close svg {
        width: 15px;
        height: 15px;
    }

    .pdf-preview-container {
        padding: 10px 8px 60px 8px;
    }

    .pdf-preview-toolbar {
        padding: 6px 12px;
        gap: 12px;
        bottom: 8px;
        opacity: 1;
        visibility: visible;
    }

    .pdf-toolbar-pages {
        font-size: 12px;
    }

    .pdf-toolbar-btn {
        width: 28px;
        height: 28px;
    }

    .pdf-toolbar-btn svg {
        width: 16px;
        height: 16px;
    }

    .pdf-zoom-level {
        font-size: 11px;
        min-width: 36px;
    }

    .pdf-loader-text {
        font-size: 14px;
    }
}

/* =====================================================
   Responsive - Small Mobile (480px) - Fixed 85vh
   ===================================================== */
@media screen and (max-width: 480px) {
    .pdf-preview-modal {
        padding: 8px;
    }

    .pdf-preview-panel {
        height: 85vh;
        max-height: 85vh;
    }

    .pdf-preview-head {
        padding: 8px 10px;
        gap: 8px;
    }

    .pdf-preview-title {
        font-size: 13px;
    }

    .pdf-preview-close {
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
    }

    .pdf-preview-close svg {
        width: 14px;
        height: 14px;
    }

    .pdf-preview-btn {
        padding: 10px 14px;
        font-size: 12px;
    }

    .pdf-preview-container {
        padding: 8px 6px 55px 6px;
    }

    .pdf-page-wrapper {
        margin-bottom: 8px;
    }

    .pdf-preview-toolbar {
        gap: 8px;
        padding: 5px 10px;
    }

    .pdf-toolbar-buttons {
        gap: 4px;
    }

    .pdf-toolbar-btn {
        width: 26px;
        height: 26px;
    }

    .pdf-toolbar-btn svg {
        width: 14px;
        height: 14px;
    }
}

/* =====================================================
   Landscape Mode
   ===================================================== */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .pdf-preview-modal {
        padding: 8px;
    }

    .pdf-preview-panel {
        height: calc(100vh - 16px);
        max-height: calc(100vh - 16px);
    }

    .pdf-preview-head {
        padding: 6px 10px;
    }

    .pdf-preview-title {
        font-size: 12px;
    }

    .pdf-preview-close {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
    }
}

/* =====================================================
   Print & Reduced Motion
   ===================================================== */
@media print {

    .pdf-preview-overlay,
    .pdf-preview-modal {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pdf-preview-btn {
        animation: none;
    }

    .pdf-loader-text {
        animation: none;
    }
}