/*
 * Публичные стили Simple Modal Manager.
 * Оформляют фон, диалог, содержимое, состояния загрузки/отправки и четыре варианта шаблона.
 * Отвечают за размеры, прокрутку, видимый фокус и поддержку уменьшенной анимации.
 */

/* Открытое окно блокирует прокрутку страницы за диалогом. */
body[data-smm-modal-open],
body.smm-modal-open {
    overflow: hidden;
}

/* Маска и индикатор отправки формы показываются только для состояния активного запроса. */
.smm-overlay[data-smm-submitting] .smm-modal,
.smm-overlay.smm-form-submitting .smm-modal {
    position: relative;
}

.smm-overlay[data-smm-submitting] .smm-modal::before,
.smm-overlay.smm-form-submitting .smm-modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.smm-overlay[data-smm-submitting] .smm-modal::after,
.smm-overlay.smm-form-submitting .smm-modal::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: smmSpin 1s linear infinite;
    z-index: 1001;
}

/* Блокировка закрытия модального окна во время отправки формы */
.smm-overlay[data-smm-prevent-close] .smm-close,
.smm-overlay.smm-form-prevent-close .smm-close {
    pointer-events: none;
    opacity: 0.5;
}

.smm-overlay[data-smm-prevent-close],
.smm-overlay.smm-form-prevent-close {
    pointer-events: auto;
}

.smm-overlay[data-smm-prevent-close] .smm-modal,
.smm-overlay.smm-form-prevent-close .smm-modal {
    pointer-events: auto;
}

/* Фиксированный затемненный фон и расположение диалога поверх страницы. */
.smm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 12px;
    align-items: center;
    justify-content: center;
}

.smm-overlay[data-smm-state="open"],
.smm-overlay.smm-active {
    display: flex;
    opacity: 1;
}

/* Контейнер диалога: ограниченные размеры и отдельная прокрутка содержимого. */
.smm-modal {
    position: relative;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 90vh;
    width: 600px;
    margin: auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Заголовок и зона кнопки закрытия не сжимаются вместе с содержимым. */
.smm-modal-header {
    display: flex;
    gap: 8px;
    padding: 16px 24px;
    border-bottom: 1px solid #F3F4F6;
    justify-content: space-between;
    flex-shrink: 0;
}

.smm-modal-title {
    font-size: 24px;
    font-weight: 600;
    line-height: 1.2;
}

/* Кнопка закрытия: область клика, состояния наведения и видимый клавиатурный фокус. */
.smm-close {
    cursor: pointer;
    outline: none;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 6px;
    background-color: transparent;
    border-radius: 8px;
    transition-property: color, background-color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.smm-close:hover {
    background-color: #F3F4F6;
}

.smm-close:hover > * {
    color: #1e2939;
    transition-property: color, background-color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.smm-close:focus,
.smm-close:focus-visible {
     outline: 2px solid #0073aa;
     outline-offset: 2px;
}

/* Внутренняя область содержимого со своей вертикальной прокруткой. */
.smm-modal-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.smm-modal-content p:first-child {
    margin-top: 0;
}

.smm-modal-content p:last-child {
    margin-bottom: 0;
}

/* Дополнительные классы появления и скрытия для совместимых шаблонов и интеграций. */
.smm-fade-in {
    animation: smmFadeIn 0.3s ease;
}

.smm-fade-out {
    animation: smmFadeOut 0.3s ease;
}

.smm-slide-in {
    animation: smmSlideIn 0.3s ease;
}

.smm-slide-out {
    animation: smmSlideOut 0.3s ease;
}

.smm-zoom-in {
    animation: smmZoomIn 0.3s ease;
}

.smm-zoom-out {
    animation: smmZoomOut 0.3s ease;
}

/* Кадры плавного появления, смещения и масштабирования окна. */
@keyframes smmFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes smmFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes smmSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes smmSlideOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-50px);
    }
}

@keyframes smmZoomIn {
    from {
        opacity: 0;
        transform: scale(0.3);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes smmZoomOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.3);
    }
}

/* Дополнительные классы положения окна по вертикали. */
.smm-position-center {
    align-items: center;
    justify-content: center;
}

.smm-position-top {
    align-items: flex-start;
    justify-content: center;
}

.smm-position-bottom {
    align-items: flex-end;
    justify-content: center;
}

/* Базовые размеры диалога на узком экране; inline-настройки и варианты шаблона уточняют их. */
@media (max-width: 480px) {
    .smm-modal {
        width: 100vw;
        height: 100vh;
        max-width: none;
        max-height: none;
    }
}

/* Служебные состояния фокуса и скрытого диалога. */
.smm-modal:focus {
    outline: none;
}

.smm-modal[aria-hidden="true"] {
    display: none;
}

/* Совместимое состояние загрузки контейнера и его индикатор. */
.smm-modal.smm-loading {
    pointer-events: none;
}

.smm-modal.smm-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: smmSpin 1s linear infinite;
}

@keyframes smmSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Заполнитель отложенного содержимого и минимальная высота во время AJAX-загрузки. */
.smm-lazy-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 40px;
}

.smm-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: smmSpin 1s linear infinite;
}

.smm-overlay[data-smm-loading] .smm-modal-body,
.smm-overlay.smm-lazy-loading .smm-modal-body {
    position: relative;
    min-height: 200px;
}

/* Совместимый атрибут шаблона полностью скрывает окно, отклоненное через cookie. */
.smm-overlay[data-cookie-dismissed="1"] {
    display: none !important;
}

/* Общие стили вариантов шаблона подключаются один раз независимо от количества окон. */
.smm-overlay, .smm-overlay * { box-sizing: border-box; }
/* Визуально скрытый текст остается доступным вспомогательным технологиям. */
.smm-sr-only { position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0; }
.smm-template-minimal .smm-modal { border-radius:12px; }
.smm-template-minimal .smm-minimal-header { border:0;padding:0; }
.smm-template-minimal .smm-close { position:absolute;top:12px;right:12px;z-index:1; }
.smm-template-minimal .smm-modal-content { padding:48px 32px 32px; }
/* Полноэкранный вариант занимает динамическую высоту области просмотра. */
.smm-template-fullscreen { padding:0; }
.smm-template-fullscreen .smm-modal { width:100vw!important;height:100dvh!important;max-width:none!important;max-height:none!important;border-radius:0; }
.smm-template-fullscreen .smm-modal-body { max-width:800px;margin:auto;padding:20px 12px; }
/* Выезжающий вариант располагает диалог у правого края на всю высоту. */
.smm-template-slide-in { justify-content:flex-end;padding:0; }
.smm-template-slide-in .smm-modal { margin:0;height:100dvh!important;max-height:none!important;border-radius:0; }
.smm-modal-title { margin:0; }
.smm-modal-body button:focus-visible, .smm-trigger:focus-visible { outline:2px solid #0073aa;outline-offset:3px; }
/* Уважаем системное предпочтение уменьшения движения для оболочки и диалога. */
@media (prefers-reduced-motion:reduce) { .smm-overlay,.smm-modal { transition:none;animation:none; } }
