/**
 * PDF Viewer Styles
 * 
 * Styles for the [display_pdf] shortcode.
 * Mobile-first responsive design with Bootstrap 5 integration.
 * 
 * @package Salisbury_Academy_Tools
 */

/* ==========================================================================
   Wrapper & Container
   ========================================================================== */

.sa-pdf-viewer-wrapper {
    position: relative;
    width: 100%;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sa-pdf-viewer-wrapper.sa-pdf-fullscreen-active {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    margin: 0;
    border-radius: 0;
}

.sa-pdf-viewer-wrapper.sa-pdf-fullscreen-active .sa-pdf-container {
    height: calc(100vh - 60px) !important;
}

/* ==========================================================================
   Header
   ========================================================================== */

.sa-pdf-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.sa-pdf-title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #212529;
    flex: 1;
}

.sa-pdf-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.sa-pdf-download,
.sa-pdf-fullscreen {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.sa-pdf-download-icon,
.sa-pdf-fullscreen-icon {
    font-size: 1rem;
    line-height: 1;
}

.sa-pdf-download:hover {
    transform: translateY(-1px);
}

.sa-pdf-fullscreen:hover {
    background-color: #6c757d;
    border-color: #6c757d;
    color: #fff;
}

/* ==========================================================================
   PDF Container
   ========================================================================== */

.sa-pdf-container {
    position: relative;
    width: 100%;
    height: 600px;
    background: #e9ecef;
}

.sa-pdf-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.sa-pdf-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sa-pdf-loading p {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: #6c757d;
}

.sa-pdf-viewer-wrapper.sa-pdf-loaded .sa-pdf-loading {
    opacity: 0;
}

.sa-pdf-spinner {
    width: 3rem;
    height: 3rem;
    margin: 0 auto;
    border: 4px solid rgba(0, 123, 255, 0.2);
    border-top-color: #007bff;
    border-radius: 50%;
    animation: sa-pdf-spin 0.8s linear infinite;
}

@keyframes sa-pdf-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Fallback
   ========================================================================== */

.sa-pdf-fallback {
    display: none;
    padding: 3rem 1.5rem;
    text-align: center;
}

.sa-pdf-fallback p {
    margin-bottom: 1rem;
    color: #6c757d;
}

/* Show fallback if iframe fails (no support) */
@supports not (display: contents) {
    /* Modern browsers support this, so this won't trigger */
}

/* ==========================================================================
   Error Messages
   ========================================================================== */

.sa-pdf-error {
    padding: 1.5rem;
    margin: 1rem 0;
    background: #f8d7da;
    border: 1px solid #f5c2c7;
    border-radius: 0.375rem;
    color: #842029;
    font-size: 0.875rem;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Mobile: Stack header elements */
@media (max-width: 575.98px) {
    .sa-pdf-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .sa-pdf-actions {
        width: 100%;
        justify-content: space-between;
    }

    .sa-pdf-download,
    .sa-pdf-fullscreen {
        font-size: 0.875rem;
        padding: 0.375rem 0.75rem;
    }

    .sa-pdf-container {
        height: 400px;
    }

    .sa-pdf-title {
        font-size: 1rem;
    }
}

/* Tablet */
@media (min-width: 576px) and (max-width: 767.98px) {
    .sa-pdf-container {
        height: 500px;
    }
}

/* Desktop: Optimal viewing */
@media (min-width: 768px) {
    .sa-pdf-viewer-wrapper {
        margin: 2.5rem 0;
    }

    .sa-pdf-container {
        min-height: 600px;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .sa-pdf-viewer-wrapper {
        border: none;
        box-shadow: none;
    }

    .sa-pdf-header,
    .sa-pdf-loading {
        display: none !important;
    }

    .sa-pdf-container {
        height: auto !important;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Focus styles for keyboard navigation */
.sa-pdf-download:focus,
.sa-pdf-fullscreen:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .sa-pdf-spinner {
        animation: none;
        border-top-color: transparent;
    }

    .sa-pdf-download:hover {
        transform: none;
    }

    .sa-pdf-loading,
    * {
        transition: none !important;
    }
}
