/* ============================================================================
 * ОБЩИЕ СТИЛИ ФОРМ — Contact Form 7 базовый «скин» темы.
 *
 * Подключается глобально через dk-forms enqueue, поэтому любая CF7-форма
 * на сайте (в модалке, в шорткоде на странице, на новой странице без
 * page-specific CSS) сразу выглядит в фирменной стилистике.
 *
 * Все правила scoped под `.wpcf7-form` — это родитель CF7-формы, который
 * WP ставит автоматически. Внутри page-specific вёрстки (.contact-form-card
 * .wpcf7-form …) более высокая специфичность переопределит эти базовые.
 * ========================================================================== */

/* ---- CF7 оборачивает каждое поле в <p> — убираем лишние отступы ---- */
.wpcf7-form p {
    margin: 0 0 12px;
}

.wpcf7-form label {
    display: block;
    font-family: var(--font-primary);
    font-size: var(--font-size-14);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-main);
    margin-bottom: 6px;
    line-height: 1.4;
}

.wpcf7-form-control-wrap {
    display: block;
    width: 100%;
}

/* ---- Поля ввода ---- */
.wpcf7-form input[type="text"],
.wpcf7-form input[type="email"],
.wpcf7-form input[type="tel"],
.wpcf7-form input[type="url"],
.wpcf7-form input[type="number"],
.wpcf7-form input[type="date"],
.wpcf7-form input[type="password"],
.wpcf7-form select,
.wpcf7-form textarea {
    display: block;
    width: 100%;
    box-sizing: border-box;
    background: var(--color-white);
    border: 1px solid var(--color-border-light, #e6e6e6);
    border-radius: 40px;
    padding: 20px 32px;
    font-family: var(--font-primary);
    font-size: var(--font-size-16);
    line-height: 1.4;
    color: var(--color-text-main);
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
    -webkit-appearance: none;
       -moz-appearance: none;
            appearance: none;
}

.wpcf7-form input[type="text"]:hover,
.wpcf7-form input[type="email"]:hover,
.wpcf7-form input[type="tel"]:hover,
.wpcf7-form input[type="url"]:hover,
.wpcf7-form input[type="number"]:hover,
.wpcf7-form input[type="date"]:hover,
.wpcf7-form input[type="password"]:hover,
.wpcf7-form select:hover,
.wpcf7-form textarea:hover {
    border-color: var(--color-border, #cfcfcf);
}

.wpcf7-form input[type="text"]:focus,
.wpcf7-form input[type="email"]:focus,
.wpcf7-form input[type="tel"]:focus,
.wpcf7-form input[type="url"]:focus,
.wpcf7-form input[type="number"]:focus,
.wpcf7-form input[type="date"]:focus,
.wpcf7-form input[type="password"]:focus,
.wpcf7-form select:focus,
.wpcf7-form textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--focus-green, rgba(50,119,10,.15));
}

.wpcf7-form input::placeholder,
.wpcf7-form textarea::placeholder {
    color: var(--color-text-gray);
    opacity: 1;
}

.wpcf7-form textarea {
    /* height перебивает атрибут rows="..." у CF7-textarea; halves старый размер. */
    height: 80px;
    min-height: 50px;
    max-height: 160px;
    resize: vertical;
}

.wpcf7-form select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%23656565' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 18px center;
    padding-right: 44px;
}

/* ---- Чекбоксы / acceptance ----
 * Глобальный стиль чекбокса вынесен ниже (см. блок «Кастомный чекбокс согласия»),
 * здесь — только обвязка для wpcf7-list-item и стиль radio. */
.wpcf7-form .wpcf7-list-item {
    display: block;
    margin: 0 0 8px;
}

.wpcf7-form .wpcf7-list-item label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    font-weight: var(--font-weight-regular);
    font-size: var(--font-size-14);
    color: var(--color-text-main);
    cursor: pointer;
    line-height: 1.4;
}

.wpcf7-form input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    flex-shrink: 0;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.wpcf7-form .wpcf7-list-item-label {
    flex: 1;
    line-height: 1.4;
}

/* ---- Submit ---- */
.wpcf7-form input[type="submit"],
.wpcf7-form button[type="submit"],
.wpcf7-form .wpcf7-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    background: var(--color-primary);
    color: var(--color-white);
    border: none;
    border-radius: 30px;
    font-family: var(--font-primary);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-18);
    line-height: 1.2;
    cursor: pointer;
    transition: background .2s ease, transform .15s ease, box-shadow .2s ease;
    -webkit-appearance: none;
            appearance: none;
}

.wpcf7-form input[type="submit"]:hover,
.wpcf7-form button[type="submit"]:hover,
.wpcf7-form .wpcf7-submit:hover {
    background: var(--color-primary-hover, #245807);
}

.wpcf7-form input[type="submit"]:active,
.wpcf7-form button[type="submit"]:active,
.wpcf7-form .wpcf7-submit:active {
    transform: translateY(1px);
}

.wpcf7-form input[type="submit"]:disabled,
.wpcf7-form .wpcf7-submit:disabled {
    opacity: 1; /* disabled-сабмит непрозрачный (по просьбе); признак неактивности — курсор */
    cursor: not-allowed;
}

/* ---- Сообщения CF7 (success / error / validation) ---- */
.wpcf7-form .wpcf7-response-output {
    margin: 16px 0 0;
    padding: 12px 16px;
    border: none;
    border-radius: 12px;
    font-size: var(--font-size-14);
    line-height: 1.4;
    background: var(--color-bg-plashka, #f4f5f7);
    color: var(--color-text-main);
}

.wpcf7 form.sent .wpcf7-response-output,
.wpcf7-form.sent .wpcf7-response-output {
    background: rgba(50,119,10,.08);
    color: var(--color-primary);
}

.wpcf7 form.failed .wpcf7-response-output,
.wpcf7 form.aborted .wpcf7-response-output,
.wpcf7 form.invalid .wpcf7-response-output,
.wpcf7-form.failed .wpcf7-response-output,
.wpcf7-form.invalid .wpcf7-response-output {
    background: rgba(176, 30, 30, .07);
    color: #b01e1e;
}

/* Подсказка-ошибка под полем (иконка ⚠ + красный текст) — единый стиль всех форм */
.wpcf7-form .wpcf7-not-valid-tip {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 7px;
    color: #d0342c;
    font-size: var(--font-size-12, 12px);
    font-weight: 600;
    line-height: 1.35;
}
.wpcf7-form .wpcf7-not-valid-tip::before {
    content: "";
    flex: 0 0 auto;
    width: 15px;
    height: 15px;
    margin-top: 1px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d0342c' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* Невалидное поле: красная рамка + светлый фон + «встряхивание» */
@keyframes dk-shake {
    10%, 90%      { transform: translateX(-1px); }
    20%, 80%      { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-4px); }
    40%, 60%      { transform: translateX(4px); }
}
.wpcf7-form input.wpcf7-not-valid,
.wpcf7-form textarea.wpcf7-not-valid,
.wpcf7-form select.wpcf7-not-valid {
    border-color: #d0342c !important;
    background: #fdf3f2;
    box-shadow: 0 0 0 3px rgba(208, 52, 44, .12);
    animation: dk-shake .4s ease both;
}
.wpcf7-form .wpcf7-not-valid:focus {
    box-shadow: 0 0 0 3px rgba(208, 52, 44, .18) !important;
}
/* Невалидный чекбокс согласия */
.wpcf7-form .wpcf7-acceptance input[type="checkbox"].wpcf7-not-valid {
    outline: 2px solid #d0342c;
    outline-offset: 2px;
}

/* --- Спиннер отправки (все формы): CF7 6.x ставит форме data-status="submitting".
   Текст кнопки прячем, поверх крутится спиннер (элемент .dk-cf7-spinner вставляет
   forms.js в обёртку кнопки .dk-cf7-submit-wrap; у <input> нет псевдоэлементов). --- */
@keyframes dk-cf7-spin { to { transform: rotate(360deg); } }
.wpcf7-form .dk-cf7-submit-wrap { position: relative; }
.wpcf7-form[data-status="submitting"] input.wpcf7-submit {
    color: transparent !important;
    pointer-events: none;
    cursor: progress;
}
.wpcf7-form .dk-cf7-spinner { display: none; }
.wpcf7-form[data-status="submitting"] .dk-cf7-spinner {
    display: block;
    position: absolute;
    left: 50%;
    top: 50%;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    border: 2.5px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: dk-cf7-spin .7s linear infinite;
    pointer-events: none;
}
/* Нативный спиннер CF7 не нужен — у нас свой в кнопке. */
.wpcf7-form .wpcf7-spinner { display: none !important; }

/* ---- Скрытое поле hidden-fields-container (CF7 6.x) ---- */
.wpcf7-form .hidden-fields-container {
    border: 0;
    padding: 0;
    margin: 0;
    height: 0;
    overflow: hidden;
}

/* ============================================================================
 * Модалка: финальные мелкие правки для формы внутри `.dk-modal-form`.
 * Внешний контейнер задаёт padding/радиус, тут только корректируем CF7.
 * ========================================================================== */

.dk-modal-form .wpcf7 {
    width: 100%;
}

.dk-modal-form .wpcf7-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dk-modal-form .wpcf7-form p {
    margin: 0 0 10px;
}

.dk-modal-form .wpcf7-form p:has(input[type="submit"]),
.dk-modal-form .wpcf7-form p:has(.wpcf7-submit) {
    margin-top: 8px;
    margin-bottom: 0;
}

/* Хелпер на случай старых браузеров без :has() — последний <p> обычно submit */
.dk-modal-form .wpcf7-form > p:last-of-type {
    margin-bottom: 0;
}


/* ============================================================================
 * Глобальный кастомный чекбокс (донорский вид со страницы «О нас»).
 *
 * Один стиль для ВСЕХ чекбоксов сайта: 20×20 с зелёной рамкой 2px,
 * checked-состояние рисует внутренний квадрат 12×12 через ::after.
 * Цель — любой добавленный input[type=checkbox] (CF7, фильтры, формы)
 * автоматически получает этот вид без дополнительных классов.
 *
 * Контекстные override'ы:
 *  - бордовый вариант (.agreement-burgundy / .contact-form-card.theme-burgundy)
 *    — в modular-contact-form.css;
 *  - .calculator-section .dropdown-option (фиолетовый secondary акцент в
 *    калькуляторе подписки) — в subscriptions.css.
 * ========================================================================== */
input[type=checkbox],
.agreement-option input[type=checkbox],
.wpcf7-form input[type=checkbox] {
    margin: 0;
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 2px solid var(--color-primary);
    border-radius: 4px;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    position: relative;
    transition: 0.3s;
    background: var(--color-white);
    padding: 0;
    box-sizing: border-box;
    flex-shrink: 0;
}

input[type=checkbox]:checked,
.agreement-option input[type=checkbox]:checked,
.wpcf7-form input[type=checkbox]:checked {
    background: var(--color-white);
    border: 2px solid var(--color-primary);
}

input[type=checkbox]:checked::after,
.agreement-option input[type=checkbox]:checked::after,
.wpcf7-form input[type=checkbox]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    background: var(--color-primary);
    border-radius: 0;
    transform: translate(-50%, -50%);
}

/* ----------------------------------------------------------------------------
 * Пилюля-обёртка для acceptance-чекбокса CF7.
 * <p class="agreement-field"> > .wpcf7-acceptance > .wpcf7-list-item > label
 * рендерится единообразно во всех формах сайта.
 * -------------------------------------------------------------------------- */
.agreement-field { margin-bottom: 24px; }
.agreement-field > p { margin: 0; padding: 0; }
.wpcf7-acceptance { display: block; }
.wpcf7-acceptance .wpcf7-list-item { margin: 0; display: block; }

.wpcf7-acceptance .wpcf7-list-item label,
.agreement-field .wpcf7-list-item label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 16px 20px;
    border-radius: 30px;
    background: var(--color-white);
    transition: 0.3s;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    line-height: 1.5;
}

.wpcf7-acceptance .wpcf7-list-item-label,
.agreement-field .wpcf7-list-item-label {
    color: #111;
    flex: 1;
    font-size: var(--font-size-14);
    line-height: var(--line-height-auto);
    font-weight: var(--font-weight-regular);
    font-family: var(--font-primary);
    letter-spacing: var(--letter-spacing-0);
}

.wpcf7-acceptance a,
.agreement-field a {
    color: var(--color-primary);
    text-decoration: underline;
    transition: color 0.3s;
}
.wpcf7-acceptance a:hover,
.agreement-field a:hover {
    color: var(--color-primary-dark, #265a07);
}


/* ============================================================================
 * Глобальная валидация .contact-form (SSR inline + модальные).
 *
 * Используется submit-обработчиком из assets/js/forms.js (bindInlineFormSubmit)
 * и assets/js/webinar-package.js — оба ставят `.is-invalid` на поле + раскрывают
 * <span class="form-error"> под ним с русским текстом. Также добавляют
 * <div class="form-status"> для итогового сообщения после ответа сервера.
 *
 * Поведение: на пустых обязательных полях форма НЕ отправляется, поля
 * подсвечиваются красной рамкой, под ними появляется подсказка.
 * ========================================================================== */
.contact-form .form-error {
    display: block;
    color: var(--color-error, #c33);
    font-size: 13px;
    margin-top: 6px;
    margin-left: 22px;
}
.contact-form .form-error.sf-hidden {
    display: none;
}

.contact-form input.is-invalid,
.contact-form textarea.is-invalid {
    border-color: var(--color-error, #c33) !important;
}

.contact-form .agreement-option input[type=checkbox].is-invalid {
    border-color: var(--color-error, #c33);
    box-shadow: 0 0 0 2px rgba(204, 51, 51, 0.2);
}

.contact-form .form-status {
    margin-top: 14px;
    font-size: 14px;
    min-height: 1.2em;
}
.contact-form .form-status.is-success {
    color: var(--color-primary);
}
.contact-form .form-status.is-error {
    color: var(--color-error, #c33);
}
