/**
 * GView PDF Viewer - Stylesheet
 * 
 * @package GView_PDF_Viewer
 * @version 1.0.0
 */

/* ============================================================
   PDF Viewer Container & Iframe Styling
   ============================================================ */

.gview-pdf-viewer {
    display: block;
    max-width: 100%;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    margin: 20px 0;
}

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

.gview-error {
    display: block;
    padding: 15px 20px;
    margin: 20px 0;
    background-color: #fee;
    border-left: 4px solid #dc3545;
    border-radius: 4px;
    color: #721c24;
    font-size: 14px;
    line-height: 1.5;
}

.gview-error::before {
    content: "⚠️ ";
    margin-right: 8px;
}

/* ============================================================
   Success Messages (for admin)
   ============================================================ */

.gview-success {
    display: block;
    padding: 15px 20px;
    margin: 20px 0;
    background-color: #d4edda;
    border-left: 4px solid #28a745;
    border-radius: 4px;
    color: #155724;
    font-size: 14px;
    line-height: 1.5;
}

.gview-success::before {
    content: "✓ ";
    margin-right: 8px;
}

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

/* Tablets (768px and up) */
@media (max-width: 768px) {
    .gview-pdf-viewer {
        min-height: 500px;
    }
}

/* Mobile devices (480px and below) */
@media (max-width: 480px) {
    .gview-pdf-viewer {
        min-height: 400px;
        margin: 15px 0;
    }

    .gview-error {
        padding: 12px 15px;
        font-size: 13px;
    }
}

/* ============================================================
   High Resolution Displays (Retina/HiDPI)
   ============================================================ */

@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi) {
    .gview-pdf-viewer {
        border-width: 0.5px;
    }
}

/* ============================================================
   Dark Mode Support
   ============================================================ */

@media (prefers-color-scheme: dark) {
    .gview-pdf-viewer {
        border-color: #444;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    }

    .gview-error {
        background-color: #3d2626;
        border-left-color: #ff6b6b;
        color: #ffb3b3;
    }

    .gview-success {
        background-color: #2d3d2d;
        border-left-color: #51cf66;
        color: #b3ffb3;
    }
}

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

@media print {
    .gview-pdf-viewer {
        display: none;
    }

    .gview-error {
        border: 1px solid #dc3545;
        page-break-inside: avoid;
    }
}

/* ============================================================
   Admin Panel Styles
   ============================================================ */

.wrap .gview-help-section {
    background: #fff;
    padding: 20px;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-top: 20px;
}

.gview-help-section h2 {
    margin-top: 0;
    padding-top: 0;
    color: #0073aa;
    font-size: 24px;
}

.gview-help-section h3 {
    color: #0073aa;
    font-size: 18px;
    margin-top: 25px;
    margin-bottom: 12px;
}

.gview-help-section p {
    line-height: 1.6;
    margin: 12px 0;
}

.gview-help-section ul {
    margin: 15px 0;
    padding-left: 25px;
}

.gview-help-section li {
    margin: 8px 0;
    line-height: 1.6;
}

.gview-help-section code {
    background-color: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.gview-help-section pre {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 4px;
    overflow-x: auto;
    border: 1px solid #ddd;
    font-size: 12px;
    line-height: 1.4;
}

.gview-help-section pre code {
    background: none;
    padding: 0;
}

.gview-help-section table {
    margin: 15px 0;
    width: 100%;
    border-collapse: collapse;
}

.gview-help-section table thead {
    background-color: #f9f9f9;
}

.gview-help-section table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #ddd;
}

.gview-help-section table td {
    padding: 12px;
    border-bottom: 1px solid #ddd;
}

.gview-help-section table tr:hover {
    background-color: #f9f9f9;
}

.gview-help-section details {
    padding: 12px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin: 15px 0;
}

.gview-help-section details summary {
    cursor: pointer;
    font-weight: 600;
    color: #0073aa;
    user-select: none;
}

.gview-help-section details summary:hover {
    color: #005a87;
}

.gview-help-section details[open] summary {
    margin-bottom: 12px;
}

/* Settings form styles */
#gview_allowed_domains,
#gview_viewer_height {
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

#gview_allowed_domains {
    width: 100%;
    max-width: 600px;
    min-height: 150px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.gview-settings-field {
    margin: 20px 0;
    padding: 15px;
    background: #f9f9f9;
    border-left: 4px solid #0073aa;
    border-radius: 4px;
}

.gview-settings-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.gview-settings-field input[type="checkbox"] {
    margin-right: 8px;
}

.gview-settings-field .description {
    display: block;
    margin-top: 8px;
    color: #666;
    font-size: 13px;
    line-height: 1.5;
}

/* ============================================================
   Accessibility & Focus States
   ============================================================ */

.gview-pdf-viewer:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================
   Utility Classes
   ============================================================ */

.gview-text-center {
    text-align: center;
}

.gview-text-right {
    text-align: right;
}

.gview-mt-20 {
    margin-top: 20px;
}

.gview-mb-20 {
    margin-bottom: 20px;
}

.gview-hidden {
    display: none !important;
}

.gview-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================================
   Loading States
   ============================================================ */

.gview-pdf-viewer[loading="lazy"] {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: gview-loading 1.5s infinite;
}

@keyframes gview-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ============================================================
   Compatibility with WordPress Blocks
   ============================================================ */

.wp-block-paragraph .gview-pdf-viewer {
    margin: 20px 0;
}

.wp-block-column .gview-pdf-viewer {
    width: 100%;
}

/* ============================================================
   Mobile-First Container Queries (Future-proofing)
   ============================================================ */

@supports (container-type: inline-size) {
    .gview-container {
        container-type: inline-size;
    }

    @container (max-width: 400px) {
        .gview-pdf-viewer {
            min-height: 300px;
        }
    }

    @container (min-width: 401px) and (max-width: 768px) {
        .gview-pdf-viewer {
            min-height: 450px;
        }
    }
}
