/* ==========================================================================
   NSSF PDF Viewer - Dedicated Mobile & Tablet Screen & Filter Bottom Sheet
   Applies to Mobile phones and Tablets (iPad, iPad Mini, iPad Air, iPad Pro).
   Desktop (> 1200px) retains full side-by-side layout with side document list.
   This file does NOT override other CSS files.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Desktop Guard (Screens > 1200px with fine pointer / mouse)
   Completely hides mobile & tablet filter bars, FABs, and bottom sheets.
   -------------------------------------------------------------------------- */
@media only screen and (min-width: 1201px) {
    .nssf-pdf-mobile-filter-bar,
    .nssf-pdf-mobile-fab-wrapper,
    .nssf-pdf-bottom-sheet {
        display: none !important;
    }

    .nssf-desktop-doc-col {
        display: block !important;
    }
}

/* --------------------------------------------------------------------------
   Mobile & Tablet Specific Styles (Screens <= 1200px or touch tablets)
   -------------------------------------------------------------------------- */
@media only screen and (max-width: 1200px),
       only screen and (hover: none) and (pointer: coarse) and (max-width: 1366px) {

    /* Hide desktop document list column on mobile & tablet */
    .nssf-desktop-doc-col {
        display: none !important;
    }

    /* Container & Layout Optimization */
    .preview-pdf-container {
        padding-left: 8px !important;
        padding-right: 8px !important;
        padding-bottom: 76px !important;
        max-width: 100% !important;
    }

    .preview-pdf-paper {
        background: transparent !important;
        padding: 0 !important;
        box-shadow: none !important;
    }

    .preview-pdf-card {
        margin-top: 6px !important;
        border-radius: 12px !important;
        overflow: hidden !important;
        box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08) !important;
        border: 1px solid #e2e8f0 !important;
    }

    /* Full-Screen PDF Container on Mobile & Tablet */
    .nssf-pdf-container {
        width: 100% !important;
        height: calc(100dvh - 130px) !important;
        min-height: 580px !important;
        max-height: 92vh !important;
        border-radius: 12px 12px 0 0 !important;
        margin: 0 !important;
        position: relative !important;
        background: #525659 !important;
    }

    .nssf-pdf-native-wrapper,
    .nssf-pdf-native-frame,
    .nssf-pdf-viewer-root {
        width: 100% !important;
        height: calc(100dvh - 130px) !important;
        min-height: 580px !important;
        max-height: 92vh !important;
        border-radius: 12px 12px 0 0 !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .nssf-pdf-canvas-viewport {
        height: calc(100% - 44px) !important;
        flex: 1 1 auto !important;
        padding: 8px 4px !important;
        background: #525659 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Toolbar adjustments */
    .nssf-pdf-toolbar {
        padding: 6px 10px !important;
        gap: 6px !important;
        background: #2a2d30 !important;
    }

    /* --------------------------------------------------------------------------
       Filter Bar (Positioned above PDF viewer on mobile & tablet/iPad)
       -------------------------------------------------------------------------- */
    .nssf-pdf-mobile-filter-bar {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 10px !important;
        margin-top: 6px !important;
        margin-bottom: 6px !important;
        padding: 8px 14px !important;
        background: #ffffff !important;
        border-radius: 10px !important;
        border: 1px solid #e2e8f0 !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04) !important;
    }

    .nssf-pdf-mobile-filter-info {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        color: #1e293b !important;
        font-weight: 600 !important;
        font-size: 13px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    .nssf-pdf-mobile-filter-info svg {
        color: #0f4c81 !important;
        flex-shrink: 0 !important;
    }

    .nssf-pdf-mobile-doc-count {
        color: #64748b !important;
        font-size: 12px !important;
        font-weight: 500 !important;
    }

    .nssf-pdf-mobile-filter-btn {
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
        padding: 6px 14px !important;
        background: linear-gradient(135deg, #09346d 0%, #1e5ba4 100%) !important;
        color: #ffffff !important;
        border: none !important;
        border-radius: 20px !important;
        font-size: 12.5px !important;
        font-weight: 600 !important;
        cursor: pointer !important;
        box-shadow: 0 2px 8px rgba(9, 52, 109, 0.25) !important;
        transition: transform 0.15s ease, box-shadow 0.15s ease !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
        font-family: inherit !important;
    }

    .nssf-pdf-mobile-filter-btn:active {
        transform: scale(0.96) !important;
    }

    .nssf-pdf-mobile-filter-badge {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        min-width: 18px !important;
        height: 18px !important;
        padding: 0 5px !important;
        border-radius: 9px !important;
        background: rgba(255, 255, 255, 0.25) !important;
        color: #ffffff !important;
        font-size: 11px !important;
        font-weight: 700 !important;
    }

    /* --------------------------------------------------------------------------
       Floating Action Button (FAB) (Visible on mobile & tablet/iPad)
       -------------------------------------------------------------------------- */
    .nssf-pdf-mobile-fab-wrapper {
        position: fixed !important;
        right: 16px !important;
        bottom: 74px !important;
        z-index: 1050 !important;
        pointer-events: auto !important;
        display: block !important;
    }

    .nssf-pdf-mobile-fab {
        display: inline-flex !important;
        align-items: center !important;
        gap: 7px !important;
        padding: 9px 16px !important;
        border-radius: 24px !important;
        background: linear-gradient(135deg, #09346d 0%, #1e5ba4 100%) !important;
        color: #ffffff !important;
        border: 2px solid rgba(255, 255, 255, 0.85) !important;
        box-shadow: 0 6px 18px rgba(9, 52, 109, 0.38), 0 2px 6px rgba(0, 0, 0, 0.15) !important;
        cursor: pointer !important;
        font-family: inherit !important;
        font-size: 13px !important;
        font-weight: 600 !important;
        transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease !important;
    }

    .nssf-pdf-mobile-fab:active {
        transform: scale(0.93) !important;
    }

    .nssf-pdf-mobile-fab-badge {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        min-width: 19px !important;
        height: 19px !important;
        padding: 0 5px !important;
        border-radius: 10px !important;
        background: #ef4444 !important;
        color: #ffffff !important;
        font-size: 11px !important;
        font-weight: 700 !important;
    }

    /* --------------------------------------------------------------------------
       Interactive Bottom Sheet Modal (Other Documents List - Full Width)
       -------------------------------------------------------------------------- */
    .nssf-pdf-bottom-sheet {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: 82vh !important;
        background: #ffffff !important;
        border-radius: 22px 22px 0 0 !important;
        box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.35) !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        z-index: 1402 !important;
        animation: nssfPdfSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
        padding-bottom: max(24px, env(safe-area-inset-bottom, 24px)) !important;
        margin: 0 !important;
    }

    @keyframes nssfPdfSlideUp {
        from {
            transform: translateY(100%);
            opacity: 0.6;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    .nssf-pdf-bs-header {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 14px 18px !important;
        background: linear-gradient(135deg, #09346d 0%, #1e5ba4 100%) !important;
        color: #ffffff !important;
        border-radius: 22px 22px 0 0 !important;
        position: relative !important;
        flex-shrink: 0 !important;
        width: 100% !important;
    }

    .nssf-pdf-bs-title-group {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        flex: 1 !important;
        overflow: hidden !important;
    }

    .nssf-pdf-bs-title {
        font-size: 15px !important;
        font-weight: 700 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        line-height: 1.4 !important;
        color: #ffffff !important;
    }

    .nssf-pdf-bs-count {
        display: inline-flex !important;
        align-items: center !important;
        padding: 2px 8px !important;
        border-radius: 12px !important;
        background: rgba(255, 255, 255, 0.22) !important;
        font-size: 11.5px !important;
        font-weight: 600 !important;
        white-space: nowrap !important;
        color: #ffffff !important;
    }

    .nssf-pdf-bs-close {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 32px !important;
        height: 32px !important;
        border-radius: 50% !important;
        border: none !important;
        background: rgba(255, 255, 255, 0.18) !important;
        color: #ffffff !important;
        cursor: pointer !important;
        transition: background 0.15s ease !important;
        margin-left: 8px !important;
        flex-shrink: 0 !important;
    }

    .nssf-pdf-bs-close:active {
        background: rgba(255, 255, 255, 0.35) !important;
    }

    .nssf-pdf-bs-body {
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 12px 14px 20px 14px !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        background: #f8fafc !important;
    }

    /* Active thumbnail indicator badge */
    .nssf-doc-active-badge {
        position: absolute !important;
        top: 4px !important;
        right: 4px !important;
        width: 20px !important;
        height: 20px !important;
        border-radius: 50% !important;
        background: #10b981 !important;
        color: #ffffff !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25) !important;
    }
}

/* --------------------------------------------------------------------------
   Tablet & iPad Specific Enhancements (768px to 1200px)
   Full-width dialog and enhanced spacing for iPad portrait and landscape.
   -------------------------------------------------------------------------- */
@media only screen and (min-width: 768px) and (max-width: 1200px) {
    .nssf-pdf-container,
    .nssf-pdf-native-wrapper,
    .nssf-pdf-native-frame,
    .nssf-pdf-viewer-root {
        min-height: 680px !important;
        height: calc(100dvh - 150px) !important;
    }

    .nssf-pdf-mobile-filter-bar {
        padding: 10px 18px !important;
        margin-top: 8px !important;
        margin-bottom: 8px !important;
    }

    .nssf-pdf-mobile-filter-info {
        font-size: 14px !important;
    }

    .nssf-pdf-mobile-filter-btn {
        padding: 8px 18px !important;
        font-size: 13.5px !important;
    }

    .nssf-pdf-mobile-fab-wrapper {
        right: 24px !important;
        bottom: 84px !important;
    }

    .nssf-pdf-mobile-fab {
        padding: 11px 20px !important;
        font-size: 14px !important;
    }

    /* Explicit Full-Width Dialog for Tablet and iPad like mobile */
    .nssf-pdf-bottom-sheet {
        width: 100% !important;
        max-width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        border-radius: 22px 22px 0 0 !important;
        margin: 0 !important;
    }

    .nssf-pdf-bs-header {
        padding: 16px 24px !important;
    }

    .nssf-pdf-bs-title {
        font-size: 16px !important;
    }

    .nssf-pdf-bs-body {
        padding: 16px 24px 24px 24px !important;
    }
}
