﻿/* ============================================================
   МОДАЛЬНОЕ ОКНО – ЦВЕТОВАЯ ГАММА (обновлена)
   Единый стиль с основным site.css
   Размеры, отступы, анимации – без изменений
   ============================================================ */

/* Базовые стили модального окна */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1055;
    display: none;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    outline: 0;
}

    .modal.show {
        display: block !important;
    }

/* Диалог - ограничение высоты */
.modal-dialog {
    position: relative;
    width: auto;
    margin: 0.5rem;
    pointer-events: none;
    max-height: calc(100vh - 1rem);
    display: flex;
    flex-direction: column;
}

/* Анимация */
.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
    transform: translate(0, -30px);
    opacity: 0;
}

.modal.show .modal-dialog {
    transform: translate(0, 0);
    opacity: 1;
}

/* Центрирование */
.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - 1rem);
}

    .modal-dialog-centered .modal-content {
        width: 100%;
    }

/* Скроллабельный режим */
.modal-dialog-scrollable {
    height: calc(100% - 1rem);
}

    .modal-dialog-scrollable .modal-content {
        max-height: 100%;
        overflow: hidden;
    }

    .modal-dialog-scrollable .modal-body {
        overflow-y: auto;
    }

/* ===== ОСНОВНОЙ КОНТЕЙНЕР (светлая тема) ===== */
.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    background: var(--color-card-bg, #ffffff);
    border: 1px solid var(--color-card-border, #e2dcd3);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(90, 123, 156, 0.08);
    outline: 0;
    max-height: calc(100vh - 1rem);
    overflow: hidden;
    transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

/* ===== ЗАГОЛОВОК ===== */
.modal-header {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid var(--color-card-border, #e2dcd3);
    border-top-left-radius: 23px;
    border-top-right-radius: 23px;
    background: rgba(90, 123, 156, 0.03);
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-title {
    margin-bottom: 0;
    line-height: 1.4;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-header, #2d2a24);
    letter-spacing: -0.3px;
}

/* ===== КНОПКА ЗАКРЫТИЯ ===== */
.btn-close {
    box-sizing: content-box;
    width: 1.2em;
    height: 1.2em;
    padding: 0.25em;
    color: var(--color-text, #2d2a24);
    background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%235a7b9c'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
    border: 0;
    border-radius: 50%;
    opacity: 0.5;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

    .btn-close:hover {
        opacity: 1;
        transform: rotate(90deg);
        background-color: rgba(90, 123, 156, 0.1);
    }

/* ===== ТЕЛО МОДАЛКИ ===== */
.modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 1.75rem;
    color: var(--color-text, #2d2a24);
    font-size: 0.95rem;
    line-height: 1.6;
    overflow-y: auto;
    max-height: calc(100vh - 140px);
}

    .modal-body::-webkit-scrollbar {
        width: 6px;
    }

    .modal-body::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.04);
        border-radius: 10px;
        margin: 10px 0;
    }

    .modal-body::-webkit-scrollbar-thumb {
        background: var(--color-link, #6b655a);
        border-radius: 10px;
    }

        .modal-body::-webkit-scrollbar-thumb:hover {
            background: var(--color-primary, #5a7b9c);
        }

/* ===== ФУТЕР ===== */
.modal-footer {
    display: flex;
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 1rem 1.75rem;
    border-top: 1px solid var(--color-card-border, #e2dcd3);
    border-bottom-right-radius: 23px;
    border-bottom-left-radius: 23px;
    background: rgba(0, 0, 0, 0.02);
    position: sticky;
    bottom: 0;
    z-index: 10;
}

    .modal-footer > * {
        margin: 0;
    }

    /* ===== КНОПКИ В ФУТЕРЕ (адаптация под общий стиль) ===== */
    .modal-footer .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 10px 24px;
        font-size: 0.9rem;
        font-weight: 600;
        border-radius: 40px;
        transition: all 0.2s ease;
        cursor: pointer;
        border: none;
        text-decoration: none;
    }

    .modal-footer .btn-primary {
        background: var(--color-primary, #5a7b9c);
        color: #ffffff;
    }

        .modal-footer .btn-primary:hover {
            background: var(--color-primary-hover, #4b6b8a);
            transform: translateY(-2px);
        }

    .modal-footer .btn-secondary {
        background: transparent;
        color: var(--color-link, #6b655a);
        border: 1px solid var(--color-card-border, #e2dcd3);
    }

        .modal-footer .btn-secondary:hover {
            background: rgba(90, 123, 156, 0.08);
            border-color: var(--color-primary, #5a7b9c);
            color: var(--color-primary, #5a7b9c);
        }

/* ===== ЗАТЕМНЕНИЕ ФОНА ===== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

    .modal-backdrop.fade {
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .modal-backdrop.show {
        opacity: 1;
    }

/* Блокировка скролла body */
.modal-open {
    overflow: hidden;
}

/* ============================================================
   РАЗМЕРЫ МОДАЛЬНЫХ ОКОН (без изменений)
   ============================================================ */
.modal-xs {
    max-width: 300px;
}

.modal-sm {
    max-width: 400px;
}

.modal-md {
    max-width: 550px;
}

.modal-lg {
    max-width: 700px;
}

.modal-xl {
    max-width: 1000px;
}

.modal-xxl {
    max-width: 1200px;
}

.modal-fullscreen {
    width: 100vw;
    max-width: none;
    height: 100%;
    margin: 0;
}

    .modal-fullscreen .modal-content {
        height: 100%;
        border-radius: 0;
        max-height: 100vh;
    }

    .modal-fullscreen .modal-body {
        max-height: calc(100vh - 100px);
    }

/* ============================================================
   АДАПТИВНОСТЬ (без изменений)
   ============================================================ */
@media (min-width: 576px) {
    .modal-dialog {
        max-width: 550px;
        margin: 1.75rem auto;
        max-height: calc(100vh - 3.5rem);
    }

    .modal-dialog-centered {
        min-height: calc(100% - 3.5rem);
    }

    .modal-content {
        max-height: calc(100vh - 3.5rem);
    }

    .modal-xs {
        max-width: 300px;
    }

    .modal-sm {
        max-width: 400px;
    }
}

@media (min-width: 768px) {
    .modal-md {
        max-width: 600px;
    }
}

@media (min-width: 992px) {
    .modal-lg {
        max-width: 750px;
    }

    .modal-xl {
        max-width: 950px;
    }
}

@media (min-width: 1200px) {
    .modal-xl {
        max-width: 1100px;
    }

    .modal-xxl {
        max-width: 1300px;
    }
}

/* ============================================================
   АДАПТАЦИЯ ПОД МАЛЕНЬКУЮ ВЫСОТУ (без изменений)
   ============================================================ */
@media (max-height: 700px) {
    .modal-header {
        padding: 1rem 1.5rem;
    }

    .modal-body {
        max-height: calc(100vh - 120px);
        padding: 1.25rem 1.5rem;
    }

    .modal-footer {
        padding: 0.75rem 1.5rem;
    }
}

@media (max-height: 550px) {
    .modal-header {
        padding: 0.75rem 1.25rem;
    }

    .modal-body {
        max-height: calc(100vh - 100px);
        padding: 1rem 1.25rem;
    }

    .modal-footer {
        padding: 0.6rem 1.25rem;
    }

        .modal-footer .btn {
            padding: 6px 16px;
            font-size: 0.85rem;
        }
}

@media (max-height: 450px) {
    .modal-dialog {
        margin: 0.25rem auto;
    }

    .modal-header {
        padding: 0.5rem 1rem;
    }

    .modal-body {
        max-height: calc(100vh - 85px);
        padding: 0.75rem 1rem;
    }

    .modal-footer {
        padding: 0.5rem 1rem;
    }

    .modal-title {
        font-size: 1.1rem;
    }
}

/* ============================================================
   АНИМАЦИИ (без изменений)
   ============================================================ */
.fade {
    transition: opacity 0.2s linear;
}

    .fade:not(.show) {
        opacity: 0;
    }

/* ============================================================
   СПИННЕР ЗАГРУЗКИ
   ============================================================ */
.spinner-border {
    display: inline-block;
    width: 2.5rem;
    height: 2.5rem;
    vertical-align: text-bottom;
    border: 0.25em solid rgba(90, 123, 156, 0.2);
    border-right-color: var(--color-primary, #5a7b9c);
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
}

@keyframes spinner-border {
    to {
        transform: rotate(360deg);
    }
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================
   ФОРМЫ ВНУТРИ МОДАЛКИ (адаптировано под общий стиль)
   ============================================================ */
.modal-body input,
.modal-body textarea,
.modal-body select {
    background: var(--color-input-bg, #ffffff);
    border: 1px solid var(--color-input-border, #d5cec4);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--color-input-text, #2d2a24);
    font-size: 0.9rem;
    width: 100%;
    transition: all 0.2s ease;
}

    .modal-body input:focus,
    .modal-body textarea:focus,
    .modal-body select:focus {
        outline: none;
        border-color: var(--color-focus-border, #5a7b9c);
        box-shadow: 0 0 0 3px rgba(90, 123, 156, 0.15);
    }

.modal-body label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-label, #3d3831);
    margin-bottom: 6px;
    display: block;
}

/* ============================================================
   ALERT СООБЩЕНИЯ (адаптировано под общий стиль)
   ============================================================ */
.modal-body .alert {
    padding: 16px;
    border-radius: 16px;
    margin-bottom: 0;
}

.modal-body .alert-success {
    background: #e8f5ee;
    border: 1px solid #b8d9c8;
    color: #2d6a4f;
}

.modal-body .alert-danger {
    background: #fce8e8;
    border: 1px solid #f0c8c8;
    color: #8a3a3a;
}

.modal-body .alert-warning {
    background: #fef7e8;
    border: 1px solid #f0dfc8;
    color: #8a6a2a;
}

.modal-body .alert-info {
    background: #e8f0f8;
    border: 1px solid #c8d8e8;
    color: #2a5a7a;
}

/* ============================================================
   ТЁМНАЯ ТЕМА ДЛЯ МОДАЛЬНОГО ОКНА
   ============================================================ */
[data-bs-theme="dark"] .modal-content {
    background: var(--color-card-bg, #27292d);
    border-color: var(--color-card-border, #3d4045);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(90, 123, 156, 0.15);
}

[data-bs-theme="dark"] .modal-header {
    border-bottom-color: var(--color-card-border, #3d4045);
    background: rgba(255, 255, 255, 0.03);
}

[data-bs-theme="dark"] .modal-title {
    color: var(--color-header, #e8eaed);
}

[data-bs-theme="dark"] .modal-body {
    color: var(--color-text, #e8eaed);
}

[data-bs-theme="dark"] .modal-footer {
    border-top-color: var(--color-card-border, #3d4045);
    background: rgba(0, 0, 0, 0.15);
}

[data-bs-theme="dark"] .btn-close {
    filter: invert(1) brightness(1.5);
    opacity: 0.6;
}

    [data-bs-theme="dark"] .btn-close:hover {
        opacity: 1;
        background-color: rgba(90, 123, 156, 0.2);
    }

[data-bs-theme="dark"] .modal-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
}

[data-bs-theme="dark"] .modal-body::-webkit-scrollbar-thumb {
    background: #5e646c;
}

    [data-bs-theme="dark"] .modal-body::-webkit-scrollbar-thumb:hover {
        background: var(--color-primary, #5a7b9c);
    }

[data-bs-theme="dark"] .modal-footer .btn-secondary {
    color: #9aa0a8;
    border-color: #4a4d52;
}

    [data-bs-theme="dark"] .modal-footer .btn-secondary:hover {
        background: rgba(90, 123, 156, 0.15);
        border-color: var(--color-primary, #5a7b9c);
        color: #6d8db0;
    }

[data-bs-theme="dark"] .modal-backdrop {
    background: rgba(0, 0, 0, 0.8);
}

[data-bs-theme="dark"] .modal-body input,
[data-bs-theme="dark"] .modal-body textarea,
[data-bs-theme="dark"] .modal-body select {
    background: var(--color-input-bg, #2d2f33);
    border-color: var(--color-input-border, #4a4d52);
    color: var(--color-input-text, #dde0e3);
}

    [data-bs-theme="dark"] .modal-body input:focus,
    [data-bs-theme="dark"] .modal-body textarea:focus,
    [data-bs-theme="dark"] .modal-body select:focus {
        border-color: var(--color-focus-border, #6d8db0);
        box-shadow: 0 0 0 3px rgba(90, 123, 156, 0.2);
    }

[data-bs-theme="dark"] .modal-body label {
    color: #9aa0a8;
}

[data-bs-theme="dark"] .modal-body .alert-success {
    background: rgba(46, 125, 50, 0.15);
    border-color: rgba(46, 125, 50, 0.3);
    color: #81c784;
}

[data-bs-theme="dark"] .modal-body .alert-danger {
    background: rgba(211, 47, 47, 0.15);
    border-color: rgba(211, 47, 47, 0.3);
    color: #ef9a9a;
}

[data-bs-theme="dark"] .modal-body .alert-warning {
    background: rgba(255, 160, 0, 0.15);
    border-color: rgba(255, 160, 0, 0.3);
    color: #ffcc80;
}

[data-bs-theme="dark"] .modal-body .alert-info {
    background: rgba(30, 136, 229, 0.15);
    border-color: rgba(30, 136, 229, 0.3);
    color: #64b5f6;
}
