/* Модальное окно консультации — стиль сайта */

:root {
    --cm-accent: #e63b2e;
    --cm-accent-hover: #cc2f23;
    --cm-dark: #1a1a1a;
    --cm-text: #4a4a4a;
    --cm-text-light: #6c757d;
    --cm-bg: #ffffff;
    --cm-bg-light: #f5f5f5;
    --cm-border: #e0e0e0;
    --cm-bar: #2d2d2d;
    --cm-overlay: rgba(0, 0, 0, 0.55);
    --cm-font: 'Montserrat', 'Roboto', 'Open Sans', sans-serif;
}

/* Overlay — скрыто по умолчанию (даже если CSS подгрузится с задержкой) */
.cm-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: var(--cm-overlay);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.cm-modal-overlay.is-open {
    display: flex;
    opacity: 1;
    visibility: visible;
}

.cm-modal-overlay[hidden] {
    display: none !important;
}

body.cm-modal-open {
    overflow: hidden;
}

/* Dialog */
.cm-modal {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    background: var(--cm-bg);
    border-radius: 0;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    transform: translateY(16px);
    transition: transform 0.25s ease;
}

.cm-modal-overlay.is-open .cm-modal {
    transform: translateY(0);
}

/* Левая акцентная полоса как на карточках сайта */
.cm-modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background: var(--cm-bar);
}

.cm-modal__inner {
    padding: 36px 40px 32px 46px;
}

/* Кнопка закрытия */
.cm-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--cm-dark);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s ease;
}

.cm-modal__close:hover,
.cm-modal__close:focus {
    color: var(--cm-accent);
    outline: none;
}

/* Текст */
.cm-modal__title {
    margin: 0 0 12px;
    padding-right: 28px;
    color: var(--cm-dark);
    font-family: var(--cm-font);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
    text-transform: none;
}

.cm-modal__text {
    margin: 0 0 24px;
    color: var(--cm-text);
    font-family: var(--cm-font);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.6;
}

/* Форма */
.cm-modal__form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.cm-modal__field label {
    display: block;
    margin-bottom: 6px;
    color: var(--cm-dark);
    font-family: var(--cm-font);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cm-modal__field input[type='tel'] {
    width: 100%;
    padding: 12px 14px;
    border: none;
    border-bottom: 2px solid var(--cm-border);
    border-radius: 0;
    background: var(--cm-bg-light);
    color: var(--cm-dark);
    font-family: var(--cm-font);
    font-size: 16px;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.cm-modal__field input[type='tel']:focus {
    outline: none;
    border-bottom-color: var(--cm-accent);
    background: var(--cm-bg);
}

.cm-modal__field input.is-invalid {
    border-bottom-color: #dc3545;
}

.cm-modal__error {
    display: none;
    margin-top: 6px;
    color: #dc3545;
    font-size: 13px;
}

.cm-modal__error.is-visible {
    display: block;
}

/* Чекбоксы */
.cm-modal__checkboxes {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cm-modal__checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-family: var(--cm-font);
    font-size: 13px;
    line-height: 1.45;
    color: var(--cm-text-light);
}

.cm-modal__checkbox input[type='checkbox'] {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    accent-color: var(--cm-accent);
    cursor: pointer;
}

.cm-modal__checkbox a {
    color: var(--cm-accent);
    text-decoration: underline;
}

.cm-modal__checkbox a:hover {
    text-decoration: none;
}

/* Кнопка отправки */
.cm-modal__submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-top: 4px;
    padding: 14px 24px;
    border: none;
    border-radius: 0;
    background: var(--cm-accent);
    color: #ffffff;
    font-family: var(--cm-font);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s ease;
}

.cm-modal__submit:hover:not(:disabled) {
    background: var(--cm-accent-hover);
}

.cm-modal__submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.cm-modal__submit-arrow {
    font-size: 16px;
    line-height: 1;
}

/* Состояние успеха */
.cm-modal__success {
    display: none;
    padding: 20px 0 8px;
    text-align: center;
}

.cm-modal__success.is-visible {
    display: block;
}

.cm-modal__success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
    background: var(--cm-bg-light);
    color: var(--cm-accent);
    font-size: 28px;
    font-weight: 700;
}

.cm-modal__success-text {
    margin: 0;
    color: var(--cm-dark);
    font-family: var(--cm-font);
    font-size: 18px;
    font-weight: 600;
    line-height: 1.5;
}

.cm-modal--success .cm-modal__form-wrap {
    display: none;
}

/* Honeypot — скрытое поле */
.cm-modal__hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

/* Мобильная адаптация */
@media (max-width: 575.98px) {
    .cm-modal-overlay {
        padding: 12px;
        align-items: flex-end;
    }

    .cm-modal {
        max-height: calc(100vh - 24px);
    }

    .cm-modal__inner {
        padding: 28px 20px 24px 28px;
    }

    .cm-modal__title {
        font-size: 18px;
        padding-right: 24px;
    }

    .cm-modal__text {
        font-size: 14px;
        margin-bottom: 20px;
    }

    .cm-modal__field input[type='tel'] {
        font-size: 16px; /* предотвращает zoom на iOS */
    }

    .cm-modal__submit {
        padding: 13px 20px;
        font-size: 13px;
    }
}
