/**
 * Policy Preview Modal — file preview for artifact-backed policies.
 * Used by both the modal (PolicyPreviewModal.open via ModalOverlay) and
 * the inline mount on the policy detail Content tab.
 *
 * The modal layout reuses ModalOverlay's canonical structure:
 *   .modal-overlay.policy-preview-overlay > .modal-content >
 *     .modal-header (title + close)
 *     .modal-body   (iframe / card)
 *     .modal-footer (Download button — only when present)
 *
 * We override the modal-body height/padding so the iframe can fill it.
 */

/* Make the modal body fill the available height for iframe rendering. */
.policy-preview-overlay .modal-content {
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.policy-preview-overlay .modal-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
}

/* PDF iframe — fill the modal body. The browser PDF viewer provides its
   own toolbar (zoom, page nav, print, download) so we don't add ours. */
.policy-preview-iframe {
    flex: 1;
    width: 100%;
    border: none;
    background: var(--bg-primary);
    min-height: 60vh;
}

.policy-preview-image-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.policy-preview-image {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: var(--radius-md, 6px);
    background: var(--bg-primary);
}

/* Download card — non-renderable types (DOC/DOCX/XLSX/PPTX) and the
   error / no-file fallbacks. Centered card with icon, filename, file
   metadata, and a prominent action button. */
.policy-preview-card {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin: auto;
    padding: 32px;
    max-width: 560px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 12px);
}

.policy-preview-card-icon {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md, 6px);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
}

.policy-preview-card-icon .material-icons {
    font-size: 36px;
}

.policy-preview-card-body {
    flex: 1;
    min-width: 0;
}

.policy-preview-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    overflow-wrap: anywhere;
}

.policy-preview-card-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.policy-preview-card-note {
    font-size: 12px;
    color: var(--text-muted, var(--text-secondary));
    margin-bottom: 16px;
}

.policy-preview-card-error {
    font-size: 13px;
    color: var(--color-danger);
    margin-top: 8px;
}

/* Inline mount on the policy detail page — same card / iframe styles
   re-used inside the Content tab's panel. */
.content-uploaded-artifact {
    display: flex;
    flex-direction: column;
    min-height: 60vh;
    margin-top: 12px;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

.content-uploaded-artifact .policy-preview-iframe {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md, 6px);
}

.content-uploaded-artifact .policy-preview-card {
    margin: 24px auto;
}

@media (max-width: 768px) {
    .policy-preview-overlay .modal-content {
        max-height: 100vh;
        height: 100%;
    }
    .policy-preview-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
        margin: 16px;
        padding: 24px;
    }
}
