/* The overlay is always laid out and hidden with visibility, not display:none, so the
   opacity transition can run: the dark layer fades in and out instead of appearing in a
   single frame. Visibility flips only after the fade-out, and a hidden overlay takes no
   clicks or focus. */
.ms-pdf-overlay { display: flex; visibility: hidden; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 99999; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s ease-out, visibility 0s linear 0.2s; }
.ms-pdf-overlay.is-open { visibility: visible; opacity: 1; transition: opacity 0.2s ease-out, visibility 0s; }
.ms-pdf-content { background: var(--color-surface-card, #fff); width: 90%; height: 90%; max-width: 1400px; position: relative; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.5); transform: scale(0.98); transition: transform 0.2s ease-out; }
.ms-pdf-overlay.is-open .ms-pdf-content { transform: none; }
.ms-pdf-close { position: absolute; top: 40px; right: 40px; background: none; border: none; color: #fff; cursor: pointer; padding: 5px; transition: transform 0.2s; z-index: 100000; }
.ms-pdf-close:hover { transform: scale(1.1); }
#ms-doc-container { flex-grow: 1; width: 100%; height: 100%; background: var(--color-bg-tertiary, #f4f4f4); position: relative; }
.ms-pdf-footer { padding: 15px; background: var(--color-surface-card, #fff); border-top: 1px solid var(--color-border, #eee); display: flex; justify-content: flex-end; }
.ms-pdf-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; background: #003366; color: #fff; text-decoration: none; font-weight: 500; font-size: 14px; transition: background 0.2s; }
.ms-pdf-btn:hover { background: #002244; color: #fff; }
.ms-pdf-iframe { width: 100%; height: 100%; border: none; display: block; }

@media (max-width: 768px) {
    .ms-pdf-overlay {
        height: 100dvh;
        align-items: stretch;
        justify-content: stretch;
    }
    .ms-pdf-content {
        width: 100%;
        height: 100%;
        max-height: none;
        max-width: none;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }
    .ms-pdf-close {
        position: absolute;
        top: 10px;
        left: 6px;
        margin: 0;
        padding: 4px;
        width: 36px;
        height: 36px;
        background: rgba(0, 0, 0, 0.4);
        border-radius: 0;
        z-index: 100001;
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .ms-pdf-close svg {
        width: 24px;
        height: 24px;
    }
    .ms-pdf-footer {
        display: none; /* Ховаємо футер, щоб документ був на всю висоту */
    }
}

@media (prefers-reduced-motion: reduce) {
    .ms-pdf-content { transform: none; }
}
