/* ── DocumentViewer — KB-15.7 ────────────────────────────────────────────── */

/* Hidden state — backdrop not yet mounted/visible */
.dv-modal-hidden {
    display: none !important;
}

/* Medium content modal — .adm-modal specificity override to beat max-width:520px base rule */
.adm-modal.dv-modal-content {
    max-width: 860px;
    width: min(95vw, 860px);
    height: 82vh;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
}

/* Full-window mode — stretches to fill the entire viewport */
.adm-modal.dv-modal-content--fullscreen {
    max-width: 100%;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
}

/* Remove backdrop padding when going fullscreen so the modal edge-to-edge */
.adm-modal-backdrop:has(.dv-modal-content--fullscreen) {
    padding: 0;
}

/* Small ghost-button variant used in the viewer header */
.dv-btn-sm {
    font-size: 12px;
    padding: 4px 10px;
    line-height: 1.4;
}

/* ── Body area ───────────────────────────────────────────────────────────── */

.dv-body {
    display: flex;
    flex-direction: column;
    background: var(--adm-bg-card, #fff);
}

/* ── Spinner wrap ────────────────────────────────────────────────────────── */

.dv-spinner-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 160px;
    flex: 1;
}

/* ── Error alert ─────────────────────────────────────────────────────────── */

.dv-error-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 20px;
    background: var(--adm-error-bg, #fef2f2);
    border: 1px solid var(--adm-error-border, #fca5a5);
    border-radius: var(--adm-radius-md, 6px);
    margin: 16px;
    font-size: 14px;
    color: var(--adm-error-text, #991b1b);
}

.dv-error-msg {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

/* Transient download-failure toast floated above body content */
.dv-error-toast {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    z-index: 10;
    margin: 0;
    animation: dv-fade-in 0.15s ease;
}

/* ── Image / media wrappers ──────────────────────────────────────────────── */

.dv-img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    padding: 16px;
    background: var(--adm-surface, #f8fafc);
    overflow: auto;
}

.dv-media-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    padding: 16px;
    background: #000;
}

/* ── Text preview ────────────────────────────────────────────────────────── */

.dv-text-pre {
    margin: 0;
    padding: 20px 24px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--adm-text-primary, #111827);
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'Courier New', Courier, monospace;
    overflow: auto;
    flex: 1;
}

/* ── Info / download-only / blocked card ─────────────────────────────────── */

.dv-info-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 100%;
    min-height: 200px;
    padding: 32px;
    text-align: center;
}

.dv-info-icon {
    font-size: 48px;
    line-height: 1;
}

.dv-info-filename {
    font-size: 16px;
    font-weight: 600;
    color: var(--adm-text-primary, #111827);
    word-break: break-all;
    max-width: 500px;
}

.dv-info-size {
    font-size: 13px;
    color: var(--adm-text-muted, #9ca3af);
}

.dv-info-msg {
    font-size: 14px;
    color: var(--adm-text-secondary, #4b5563);
    max-width: 420px;
    line-height: 1.5;
}

.dv-blocked .dv-info-msg {
    color: var(--adm-error-text, #991b1b);
}

.dv-cta-btn {
    min-width: 140px;
}

/* ── Meta footer ─────────────────────────────────────────────────────────── */

.dv-meta {
    justify-content: flex-start !important;
    gap: 16px !important;
    flex-wrap: wrap;
}

/* ── Audit panel ─────────────────────────────────────────────────────────── */

.dv-audit-panel {
    border-bottom: 1px solid var(--adm-border, #e5e7eb);
    background: var(--adm-surface, #f8fafc);
    flex-shrink: 0;
    max-height: 280px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dv-audit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--adm-text-secondary, #4b5563);
    border-bottom: 1px solid var(--adm-border, #e5e7eb);
    flex-shrink: 0;
}

.dv-audit-close {
    font-size: 14px;
    padding: 2px 6px;
}

.dv-audit-body {
    overflow: auto;
    flex: 1;
    position: relative;
}

.dv-audit-empty {
    padding: 20px;
    font-size: 13px;
    color: var(--adm-text-muted, #9ca3af);
    text-align: center;
}

.dv-audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    color: var(--adm-text-primary, #111827);
}

.dv-audit-table th {
    padding: 6px 12px;
    background: var(--adm-bg-card, #fff);
    font-weight: 600;
    text-align: left;
    border-bottom: 1px solid var(--adm-border, #e5e7eb);
    position: sticky;
    top: 0;
    z-index: 1;
    white-space: nowrap;
}

.dv-audit-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--adm-border-light, #f3f4f6);
    vertical-align: middle;
}

.dv-audit-table tr:last-child td {
    border-bottom: none;
}

/* Login-ID shown below the display name in the audit table User cell */
.dv-audit-login-id {
    display: block;
    font-size: 11px;
    color: var(--adm-text-muted, #9ca3af);
    font-weight: 400;
}

/* IP-masking hint shown to non-super-admins in the audit table header */
.dv-audit-ip-hint {
    font-style: normal;
    font-size: 11px;
    color: var(--adm-text-muted, #9ca3af);
    cursor: help;
    vertical-align: middle;
}

.dv-audit-pager {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    padding: 8px 16px;
    font-size: 12px;
    color: var(--adm-text-muted, #9ca3af);
    border-top: 1px solid var(--adm-border-light, #f3f4f6);
    flex-shrink: 0;
}

/* ── Animations ──────────────────────────────────────────────────────────── */

@keyframes dv-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Responsive: narrow screens ──────────────────────────────────────────── */

@media (max-width: 640px) {
    .dv-modal-content {
        height: 100vh;
        max-height: 100vh;
        width: 100%;
        border-radius: 0;
    }

    .dv-audit-panel {
        max-height: 200px;
    }

    .dv-audit-table {
        font-size: 11px;
    }

    .dv-audit-table th,
    .dv-audit-table td {
        padding: 4px 8px;
    }
}
