/* ==================== СТИЛЬНЫЕ ДИАЛОГОВЫЕ ОКНА ==================== */
/* Замена стандартным alert(), confirm(), prompt() */

.dialog-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10010;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    padding: 20px;
}

.dialog-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

body.light-theme .dialog-modal-overlay {
    background-color: rgba(255, 255, 255, 0.7);
}

body.modal-open-dialog {
    overflow: hidden !important;
}

.dialog-modal {
    width: 100%;
    max-width: 480px;
    background-color: #0a0a0a;
    border: 1px solid #333;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    transform: translateY(30px) scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    background-color 0.5s ease,
    border-color 0.5s ease;
}

.dialog-modal-overlay.active .dialog-modal {
    transform: translateY(0) scale(1);
}

body.light-theme .dialog-modal {
    background-color: #ffffff;
    border: 1px solid #ddd;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* ===== Заголовок ===== */
.dialog-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
    transition: border-color 0.5s ease;
}

body.light-theme .dialog-modal-header {
    border-bottom: 1px solid #ddd;
}

.dialog-modal-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background-color 0.5s ease, color 0.5s ease;
}

.dialog-modal-icon svg {
    width: 20px;
    height: 20px;
}

/* Типы иконок */
.dialog-modal-icon.info {
    background-color: rgba(123, 215, 221, 0.15);
    color: #7BD7DD;
}

.dialog-modal-icon.success {
    background-color: rgba(183, 255, 105, 0.15);
    color: #B7FF69;
}

.dialog-modal-icon.warning {
    background-color: rgba(255, 165, 0, 0.15);
    color: #FFA500;
}

.dialog-modal-icon.error {
    background-color: rgba(255, 80, 80, 0.15);
    color: #ff8080;
}

.dialog-modal-icon.question {
    background-color: rgba(183, 148, 246, 0.15);
    color: #B794F6;
}

body.light-theme .dialog-modal-icon.info {
    background-color: rgba(47, 111, 122, 0.1);
    color: #2F6F7A;
}

body.light-theme .dialog-modal-icon.success {
    background-color: rgba(72, 0, 150, 0.1);
    color: #480096;
}

body.light-theme .dialog-modal-icon.warning {
    background-color: rgba(200, 120, 0, 0.1);
    color: #B45F06;
}

body.light-theme .dialog-modal-icon.error {
    background-color: rgba(200, 0, 0, 0.1);
    color: #c00;
}

body.light-theme .dialog-modal-icon.question {
    background-color: rgba(100, 50, 200, 0.1);
    color: #6B46C1;
}

.dialog-modal-title {
    flex: 1;
    font-size: 1.1rem;
    font-weight: 600;
    color: #FFFFFF;
    margin: 0;
    transition: color 0.5s ease;
}

body.light-theme .dialog-modal-title {
    color: #000000;
}

/* ===== Тело ===== */
.dialog-modal-body {
    padding: 20px 22px;
    color: #e0e0e0;
    font-size: 0.95rem;
    line-height: 1.5;
    transition: color 0.5s ease;
    overflow-y: auto;
    max-height: 50vh;
}

body.light-theme .dialog-modal-body {
    color: #1a1a1a;
}

.dialog-modal-message {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Поле ввода для prompt */
.dialog-modal-input {
    width: 100%;
    margin-top: 14px;
    padding: 12px 14px;
    background-color: #151515;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    color: #FFFFFF;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    box-sizing: border-box;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.5s ease;
}

.dialog-modal-input:focus {
    border-color: #B7FF69;
    box-shadow: 0 0 0 3px rgba(183, 255, 105, 0.1);
}

body.light-theme .dialog-modal-input {
    background-color: #f5f5f5;
    border: 1px solid #e0e0e0;
    color: #000000;
}

body.light-theme .dialog-modal-input:focus {
    border-color: #480096;
    box-shadow: 0 0 0 3px rgba(72, 0, 150, 0.1);
}

/* ===== Кнопки ===== */
.dialog-modal-footer {
    display: flex;
    gap: 10px;
    padding: 16px 22px;
    border-top: 1px solid #333;
    background-color: #0a0a0a;
    flex-shrink: 0;
    justify-content: flex-end;
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

body.light-theme .dialog-modal-footer {
    background-color: #fafafa;
    border-top: 1px solid #ddd;
}

.dialog-modal-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    min-width: 90px;
}

.dialog-modal-btn:active {
    transform: scale(0.97);
}

/* Primary — основная (OK, Да, Сохранить) */
.dialog-modal-btn.primary {
    background-color: rgba(183, 255, 105, 0.15);
    border-color: rgba(183, 255, 105, 0.35);
    color: #B7FF69;
}

.dialog-modal-btn.primary:hover {
    background-color: rgba(183, 255, 105, 0.25);
    border-color: rgba(183, 255, 105, 0.55);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(183, 255, 105, 0.15);
}

body.light-theme .dialog-modal-btn.primary {
    background-color: rgba(72, 0, 150, 0.08);
    border-color: rgba(72, 0, 150, 0.25);
    color: #480096;
}

body.light-theme .dialog-modal-btn.primary:hover {
    background-color: rgba(72, 0, 150, 0.15);
    border-color: rgba(72, 0, 150, 0.45);
    box-shadow: 0 4px 15px rgba(72, 0, 150, 0.12);
}

/* Secondary — второстепенная (Отмена, Нет) */
.dialog-modal-btn.secondary {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
}

.dialog-modal-btn.secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

body.light-theme .dialog-modal-btn.secondary {
    background-color: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.1);
    color: #000000;
}

body.light-theme .dialog-modal-btn.secondary:hover {
    background-color: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.2);
}

/* Danger — опасное действие (Удалить, Очистить) */
.dialog-modal-btn.danger {
    background-color: rgba(255, 80, 80, 0.12);
    border-color: rgba(255, 80, 80, 0.3);
    color: #ff8080;
}

.dialog-modal-btn.danger:hover {
    background-color: rgba(255, 80, 80, 0.2);
    border-color: rgba(255, 80, 80, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(255, 80, 80, 0.15);
}

body.light-theme .dialog-modal-btn.danger {
    background-color: rgba(200, 0, 0, 0.06);
    border-color: rgba(200, 0, 0, 0.2);
    color: #c00;
}

body.light-theme .dialog-modal-btn.danger:hover {
    background-color: rgba(200, 0, 0, 0.12);
    border-color: rgba(200, 0, 0, 0.4);
    box-shadow: 0 4px 15px rgba(200, 0, 0, 0.12);
}

/* ===== Адаптация ===== */
@media (max-width: 575px) {
    .dialog-modal-overlay {
        padding: 12px;
    }

    .dialog-modal {
        max-width: 100%;
        border-radius: 10px;
    }

    .dialog-modal-header {
        padding: 14px 18px;
    }

    .dialog-modal-title {
        font-size: 1rem;
    }

    .dialog-modal-icon {
        width: 32px;
        height: 32px;
    }

    .dialog-modal-icon svg {
        width: 18px;
        height: 18px;
    }

    .dialog-modal-body {
        padding: 16px 18px;
        font-size: 0.9rem;
    }

    .dialog-modal-footer {
        padding: 12px 18px;
        gap: 8px;
    }

    .dialog-modal-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
        min-width: 0;
        flex: 1;
    }
}

/* ===== Поддержка safe area ===== */
@supports (padding: max(0px)) {
    @media (max-width: 575px) {
        .dialog-modal-header {
            padding-top: max(14px, env(safe-area-inset-top));
        }
        .dialog-modal-footer {
            padding-bottom: max(12px, env(safe-area-inset-bottom));
        }
    }
}

/* ===== Кнопка "Открыть в новой вкладке" ===== */
.editor-modal-newtab {
    background: none;
    border: none;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.08);
    transition: all 0.3s ease;
    flex-shrink: 0;
    padding: 0;
    margin-right: 8px; /* Отступ от кнопки "Развернуть" */
}

.editor-modal-newtab:hover {
    background-color: rgba(255, 255, 255, 0.18);
    transform: scale(1.1);
}

.editor-modal-newtab svg {
    width: 18px;
    height: 18px;
    color: #FFFFFF;
    transition: color 0.5s ease;
}

body.light-theme .editor-modal-newtab {
    background-color: rgba(0, 0, 0, 0.05);
}

body.light-theme .editor-modal-newtab:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

body.light-theme .editor-modal-newtab svg {
    color: #000000;
}

/* ===== Стили для standalone-страницы редактора ===== */
.standalone-editor-body {
    padding: 0 !important; /* Убираем отступы, чтобы редактор занял весь экран */
    margin: 0 !important;
    background-color: #000; /* Фон, как у редактора */
}

.standalone-editor-body .editor-modal-overlay {
    padding: 0; /* Убираем отступы у оверлея */
}