/**
 * LIMSys File Preview Styles
 *
 * @package LIMSys
 * @since 1.0.0
 */

/* Document Card Preview */
.limsys-document-card {
    display: flex;
    flex-direction: column;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
}

.limsys-document-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.limsys-document-preview {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
}

/* File Preview Styles */
.limsys-preview {
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.limsys-preview-content {
    text-align: center;
    padding: 10px;
}

.limsys-preview-icon {
    font-size: 2em;
    margin-bottom: 5px;
    display: block;
}

.limsys-preview-type {
    font-size: 0.8em;
    font-weight: bold;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.limsys-preview-text {
    font-size: 0.7em;
    color: #888;
    line-height: 1.2;
    margin-top: 5px;
    max-height: 60px;
    overflow: hidden;
}

/* Preview Types */
.limsys-preview-pdf {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
}

.limsys-preview-pdf .limsys-preview-type {
    color: white;
}

.limsys-preview-image img {
    border-radius: 4px;
}

.limsys-preview-document {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
}

.limsys-preview-document .limsys-preview-type {
    color: white;
}

.limsys-preview-spreadsheet {
    background: linear-gradient(135deg, #45b7d1, #96c93d);
    color: white;
}

.limsys-preview-spreadsheet .limsys-preview-type {
    color: white;
}

.limsys-preview-presentation {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
}

.limsys-preview-presentation .limsys-preview-type {
    color: white;
}

.limsys-preview-text {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.limsys-preview-text .limsys-preview-type {
    color: white;
}

/* Inline Preview Styles */
.limsys-document-preview-section {
    margin-top: 20px;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.limsys-document-preview-section h4 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.2em;
}

.limsys-inline-preview {
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.limsys-inline-preview-pdf iframe,
.limsys-inline-preview-pdf embed,
.limsys-inline-preview-pdf object {
    border-radius: 8px;
    width: 100%;
    max-width: 100%;
    border: none;
}

/* Mobile-specific styles for PDF preview */
@media screen and (max-width: 768px) {
    .limsys-inline-preview-pdf iframe,
    .limsys-inline-preview-pdf embed,
    .limsys-inline-preview-pdf object {
        height: 600px !important;
        min-height: 600px;
        -webkit-overflow-scrolling: touch;
    }
    
    .limsys-subscriber-view .limsys-pdf-container {
        height: 600px !important;
        max-height: 600px !important;
        min-height: 600px !important;
    }
    
    .limsys-subscriber-view .limsys-pdf-iframe {
        height: 600px !important;
        max-height: 600px !important;
        min-height: 600px !important;
    }
    
    .limsys-subscriber-view .limsys-watermark-line1 {
        font-size: 24px;
        letter-spacing: 1px;
        word-spacing: 2px;
    }
    
    .limsys-subscriber-view .limsys-watermark-line2 {
        font-size: 18px;
        letter-spacing: 0.5px;
        word-spacing: 1px;
    }
}

/* Subscriber PDF View - Hide/Blur Second Page */
.limsys-subscriber-view {
    position: relative;
    overflow: hidden !important;
    scrollbar-width: none !important; /* Firefox */
    -ms-overflow-style: none !important; /* IE and Edge */
}

.limsys-subscriber-view::-webkit-scrollbar {
    display: none !important; /* Chrome, Safari, Opera */
    width: 0 !important;
    height: 0 !important;
}

/* Hide all scrollbars in subscriber view */
.limsys-subscriber-view *,
.limsys-subscriber-view *::before,
.limsys-subscriber-view *::after {
    scrollbar-width: none !important; /* Firefox */
    -ms-overflow-style: none !important; /* IE and Edge */
}

.limsys-subscriber-view *::-webkit-scrollbar,
.limsys-subscriber-view *::before::-webkit-scrollbar,
.limsys-subscriber-view *::after::-webkit-scrollbar {
    display: none !important; /* Chrome, Safari, Opera */
    width: 0 !important;
    height: 0 !important;
    background: transparent !important;
}

.limsys-subscriber-view .limsys-pdf-container {
    position: relative;
    overflow: hidden !important; /* Hide overflow to prevent scrolling */
    height: 1100px !important; /* Increased height to fit full first page */
    max-height: 1100px !important; /* Strictly limit to one page */
    min-height: 1100px; /* Ensure minimum height for one page */
    scroll-behavior: auto !important;
    -webkit-overflow-scrolling: none !important; /* Disable momentum scrolling on iOS */
    overscroll-behavior: none !important; /* Prevent scroll chaining */
    /* Hide scrollbars */
    scrollbar-width: none !important; /* Firefox */
    -ms-overflow-style: none !important; /* IE and Edge */
    /* Clip scrollbar area */
    clip-path: inset(0 0 0 0) !important;
    -webkit-clip-path: inset(0 0 0 0) !important;
}

.limsys-subscriber-view .limsys-pdf-container::-webkit-scrollbar {
    display: none !important; /* Chrome, Safari, Opera */
    width: 0 !important;
    height: 0 !important;
    background: transparent !important;
}

/* Overlay to hide scrollbar area on the right */
.limsys-subscriber-view .limsys-pdf-container::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 20px; /* Width of typical scrollbar */
    height: 100%;
    background: #fff;
    z-index: 1000;
    pointer-events: none;
}

.limsys-subscriber-view .limsys-pdf-iframe {
    position: relative;
    z-index: 1;
    height: 1100px !important; /* Match container height - increased to fit full first page */
    max-height: 1100px !important; /* Strictly limit to one page */
    min-height: 1100px; /* Ensure minimum height for one page */
    width: 100%;
    pointer-events: none !important; /* Disable all pointer events to prevent scrolling */
    transition: filter 0.3s ease;
    border: none;
    overflow: hidden !important; /* Disable scrolling in iframe */
    object-fit: contain; /* Ensure content fits within one page */
    -webkit-overflow-scrolling: none !important; /* Disable momentum scrolling on iOS */
    overscroll-behavior: none !important; /* Prevent scroll chaining */
    /* Hide scrollbars */
    scrollbar-width: none !important; /* Firefox */
    -ms-overflow-style: none !important; /* IE and Edge */
    /* Additional scrollbar hiding */
    scrollbar-gutter: stable !important;
    /* Prevent any scrolling behavior */
    touch-action: none !important; /* Disable touch gestures */
    -ms-touch-action: none !important;
    -webkit-touch-callout: none !important;
}

/* Overlay blocker to prevent any interaction with PDF viewer */
.limsys-subscriber-view .limsys-pdf-overlay-blocker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    pointer-events: auto;
    background: transparent;
    cursor: not-allowed;
}

/* Watermark overlay */
.limsys-subscriber-view .limsys-pdf-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    pointer-events: none;
    text-align: center;
    font-family: Arial, sans-serif;
    opacity: 0.5;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    line-height: 1.6;
}

.limsys-subscriber-view .limsys-watermark-line1 {
    font-size: 36px;
    font-weight: bold;
    color: #000000;
    margin-bottom: 20px;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5);
    letter-spacing: 2px;
    line-height: 1.5;
    word-spacing: 3px;
    -webkit-text-stroke: 2px #ffffff;
    paint-order: stroke fill;
}

.limsys-subscriber-view .limsys-watermark-line2 {
    font-size: 28px;
    font-weight: normal;
    color: #000000;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5);
    letter-spacing: 1px;
    line-height: 1.6;
    word-spacing: 2px;
    -webkit-text-stroke: 1.5px #ffffff;
    paint-order: stroke fill;
}

.limsys-subscriber-view .limsys-pdf-iframe::-webkit-scrollbar {
    display: none !important; /* Chrome, Safari, Opera */
    width: 0 !important;
    height: 0 !important;
    background: transparent !important;
}

.limsys-subscriber-view .limsys-pdf-iframe::-webkit-scrollbar-track {
    display: none !important;
    background: transparent !important;
}

.limsys-subscriber-view .limsys-pdf-iframe::-webkit-scrollbar-thumb {
    display: none !important;
    background: transparent !important;
}

/* Hide print and download buttons in PDF viewer */
.limsys-subscriber-view .limsys-pdf-iframe {
    pointer-events: auto;
}

/* Hide PDF viewer controls via iframe content */
.limsys-subscriber-view iframe[src*=".pdf"],
.limsys-subscriber-view iframe[src*="limsys_preview"] {
    overflow: hidden !important;
}

/* Disable context menu (right-click) for print/download */
.limsys-subscriber-view .limsys-pdf-container,
.limsys-subscriber-view .limsys-pdf-iframe {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

/* Disable right-click context menu */
.limsys-subscriber-view .limsys-pdf-container,
.limsys-subscriber-view .limsys-pdf-iframe {
    pointer-events: auto;
}

/* Hide PDF viewer toolbar controls */
.limsys-subscriber-view iframe {
    overflow: hidden !important;
}

/* Hide blur overlay - removed to show full PDF */
.limsys-subscriber-view .limsys-pdf-blur-overlay {
    display: none !important;
    visibility: hidden !important;
}

/* Hide overlay only when we're absolutely sure it's page 1 */
.limsys-subscriber-view.limsys-page-1-confirmed .limsys-pdf-blur-overlay {
    display: none;
}

/* Keep overlay at bottom 40% even when page 2 is detected */
.limsys-subscriber-view.limsys-page-2-visible .limsys-pdf-blur-overlay {
    display: flex !important;
    visibility: visible !important;
    top: 60% !important; /* Keep at bottom 40% */
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: auto; /* Enable pointer events when visible */
}

/* Don't blur the iframe itself - only the overlay blurs */
.limsys-subscriber-view .limsys-pdf-iframe {
    filter: none !important; /* No blur on iframe itself */
    pointer-events: auto;
}

/* Hide subscriber message - removed to show full PDF */
.limsys-subscriber-view .limsys-subscriber-message {
    display: none !important;
    visibility: hidden !important;
}

.limsys-subscriber-view .limsys-subscriber-message p {
    margin: 0;
    color: #333;
    font-size: 16px;
    line-height: 1.8;
    font-weight: 500;
    text-align: center;
    white-space: normal;
    word-wrap: break-word;
}

.limsys-subscriber-view .limsys-overlay-content {
    text-align: center;
    max-width: 700px;
    width: 100%;
    z-index: 11;
}

.limsys-subscriber-view .limsys-overlay-message {
    font-size: 16px;
    line-height: 1.8;
    color: #333;
    font-weight: 500;
    margin: 0;
}

/* Image preview blur overlay for subscribers */
.limsys-subscriber-view .limsys-image-container {
    position: relative;
    overflow: hidden;
}

.limsys-subscriber-view .limsys-image-blur-overlay {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px); /* Reduced to 50% (was 20px) */
    -webkit-backdrop-filter: blur(10px); /* Reduced to 50% (was 20px) */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 30px;
    box-sizing: border-box;
    pointer-events: auto;
}

.limsys-subscriber-view .limsys-preview-image {
    filter: blur(5px);
    transition: filter 0.3s ease;
}

/* Text preview blur overlay for subscribers */
.limsys-subscriber-view .limsys-text-blur-overlay {
    position: relative;
    margin-top: 20px;
    padding: 40px 30px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px); /* Reduced to 50% (was 20px) */
    -webkit-backdrop-filter: blur(10px); /* Reduced to 50% (was 20px) */
    border-top: 2px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    pointer-events: auto;
}

.limsys-inline-preview-image img {
    border-radius: 8px;
    display: block;
    margin: 0 auto;
}

.limsys-inline-preview-text {
    padding: 20px;
}

.limsys-text-content {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    max-height: 400px;
    overflow-y: auto;
}

/* Preview Overlay */
.limsys-preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.limsys-preview:hover .limsys-preview-overlay {
    opacity: 1;
}

/* Preview Error States */
.limsys-preview-error,
.limsys-preview-unavailable {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .limsys-document-card {
        padding: 10px;
    }
    
    .limsys-preview {
        width: 80px !important;
        height: 100px !important;
    }
    
    .limsys-preview-icon {
        font-size: 1.5em;
    }
    
    .limsys-preview-type {
        font-size: 0.7em;
    }
}

/* Grid Layout for Document Library */
.limsys-documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

@media (max-width: 768px) {
    .limsys-documents-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}
