/* ============================================
   Modal Forms — Zdorovie Custom Theme
   Design: Concept B — Split Layout
   Green sidebar (clinics) + White form panel

   Brand: #195F40 (dark green), #FF6633 (orange),
          #B4CD8E (olive), Montserrat
   ============================================ */

/* ── Overlay ────────────────────────────────── */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    pointer-events: none;
    /* iOS safe area */
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

.modal-overlay.is-active {
    visibility: visible;
    pointer-events: auto;
}

/* BVI («Версия для слабовидящих») оборачивает body в .bvi-body и через
   img.bvi-img / .bvi-body[data-bvi-theme] форсит visibility:visible на потомках,
   пробивая мягкое visibility:hidden закрытого оверлея → содержимое модалок «вылезает».
   В BVI-режиме убираем закрытые оверлеи из дерева целиком (display:none побеждает
   любой visibility-сброс). Открытый модал (.is-active) не трогаем. */
body.bvi-active .modal-overlay:not(.is-active) {
    display: none !important;
}

.modal-overlay__backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.23, 1, 0.32, 1), background 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

.modal-overlay.is-active .modal-overlay__backdrop {
    opacity: 1;
    background: rgba(0, 0, 0, 0.45);
}

/* ── Modal Window — Split ───────────────────── */

.modal-window--split {
    position: relative;
    display: flex;
    flex-direction: row;
    max-width: 820px;
    width: 92%;
    max-height: 92vh;
    max-height: 92dvh; /* iOS dynamic viewport */
    border-radius: 20px;
    overflow: hidden;
    box-shadow:
        0 25px 80px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(25, 95, 64, 0.06);
    transform: translateY(24px) scale(0.97);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1;
}

.modal-overlay.is-active .modal-window--split {
    transform: translateY(0) scale(1);
}

/* ── Close Button ───────────────────────────── */

.modal-window__close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: #FF6633;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 5;
    padding: 0;
}

.modal-window__close:hover {
    background: #e55a2b;
    transform: scale(1.08);
}

.modal-window__close:active {
    transform: scale(0.94);
}

.modal-window__close svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ── LEFT: Sidebar ──────────────────────────── */

.modal-sidebar {
    width: 260px;
    min-width: 260px;
    background: linear-gradient(170deg, #1a6b47 0%, #195F40 50%, #134a33 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px 28px;
    position: relative;
    overflow: hidden;
}

/* Subtle decorative element  */
.modal-sidebar::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 140px;
    height: 140px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 50%;
}

.modal-sidebar::after {
    content: '';
    position: absolute;
    bottom: -30px;
    left: -30px;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 50%;
}

.modal-sidebar__inner {
    position: relative;
    z-index: 1;
}

/* Logo */
.modal-sidebar__logo {
    margin-bottom: 32px;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    padding: 8px 12px;
    border-radius: 14px;
    text-align: center;
}

.modal-sidebar__logo img {
    max-width: 100%;
    /* width: auto обязателен: FlyingPress дописывает тегу width="939" (CLS).
       Без него на брейкпоинтах с фиксированной height (48px/36px) ширина
       зажимается max-width:100% до ширины блока → логотип растягивается. */
    width: auto;
    height: auto;
    display: block;
}

/* Contacts */
.modal-sidebar__contacts {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-sidebar__contact {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-sidebar__contact-name {
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.65);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-sidebar__contact-phone {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Montserrat', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    transition: color 0.2s ease;
}

.modal-sidebar__contact-phone:hover {
    color: #B4CD8E;
}

.modal-sidebar__contact-phone svg {
    flex-shrink: 0;
    opacity: 0.7;
}

/* Schedule */
.modal-sidebar__schedule {
    margin-top: 28px;
    font-family: 'Montserrat', sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 0.3px;
}

/* ── RIGHT: Form Body ───────────────────────── */

.modal-body {
    flex: 1;
    background: #fff;
    padding: 36px 40px;
    overflow-y: auto;
}

/* Scrollbar */
.modal-body::-webkit-scrollbar {
    width: 5px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #B4CD8E;
    border-radius: 3px;
}

/* Title */
.modal-body__title {
    font-family: 'Montserrat', sans-serif;
    font-size: 24px;
    font-weight: 700;
    color: #195F40;
    margin: 0 0 4px;
    line-height: 1.2;
    text-align: center;
}

.modal-body__subtitle {
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: #888;
    margin: 0 0 24px;
    text-align: center;
}

/* ── Form ───────────────────────────────────── */

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Honeypot */
.modal-form__honeypot {
    position: absolute;
    left: -9999px;
    top: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
}

/* Field */
.modal-form__field {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.modal-form__row {
    display: flex;
    gap: 12px;
}

.modal-form__row .modal-form__field {
    flex: 1;
    min-width: 0;
}

/* ── Input / Select / Textarea ──────────────── */

.modal-form__input,
.modal-form__select,
.modal-form__textarea {
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: #195F40;
    background: #f7f9f5;
    border: 2px solid #a8b89e;
    border-radius: 12px;
    padding: 14px 18px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    width: 100%;
    box-sizing: border-box;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04);
}

.modal-form__input::placeholder,
.modal-form__textarea::placeholder {
    color: #195F40;
    font-weight: 400;
}

/* Override browser autofill background — preserve icons */
.modal-form__input:-webkit-autofill,
.modal-form__input:-webkit-autofill:hover,
.modal-form__input:-webkit-autofill:focus,
.modal-form__textarea:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px #f7f9f5 inset !important;
    -webkit-text-fill-color: #195F40 !important;
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 500;
    transition: background-color 5000s ease-in-out 0s;
    background-color: #f7f9f5 !important;
}


.modal-form__input:focus,
.modal-form__select:focus,
.modal-form__textarea:focus {
    border-color: #195F40;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(25, 95, 64, 0.1), inset 0 1px 3px rgba(0, 0, 0, 0.02);
}

/* Select */
.modal-form__select {
    appearance: none;
    -webkit-appearance: none;
    background-color: #f7f9f5;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a6b55' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 7px;
    padding-right: 36px;
    cursor: pointer;
    color: #195F40;
}

.modal-form__select:focus {
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23195F40' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px 7px;
}

.modal-form__select option {
    color: #333;
}

/* ── Custom Select Dropdown ───────────────── */

.custom-select {
    position: relative;
    width: 100%;
}

.custom-select__trigger {
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: #195F40;
    background: #f7f9f5;
    border: 2px solid #a8b89e;
    border-radius: 12px;
    padding: 14px 40px 14px 18px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    width: 100%;
    box-sizing: border-box;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    -webkit-user-select: none;
}

.custom-select__trigger.icon-clinic,
.custom-select__trigger.icon-doctor {
    padding-left: 44px;
    background-repeat: no-repeat;
    background-position: 14px center;
    background-size: 18px 18px;
}

.custom-select__trigger.icon-clinic {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23195F40' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 21h18'/%3E%3Cpath d='M5 21V7l8-4v18'/%3E%3Cpath d='M19 21V11l-6-4'/%3E%3Cpath d='M9 9h1'/%3E%3Cpath d='M9 13h1'/%3E%3Cpath d='M9 17h1'/%3E%3C/svg%3E");
}

.custom-select__trigger.icon-doctor {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23195F40' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.8 2.3A.3.3 0 105 2H4a2 2 0 00-2 2v5a6 6 0 006 6 6 6 0 006-6V4a2 2 0 00-2-2h-1a.2.2 0 10.3.3'/%3E%3Cpath d='M8 15v1a6 6 0 006 6 6 6 0 006-6v-4'/%3E%3Ccircle cx='20' cy='10' r='2'/%3E%3C/svg%3E");
}

.custom-select__text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.custom-select__arrow {
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.custom-select.is-open .custom-select__arrow {
    transform: rotate(180deg);
}

.custom-select.is-open .custom-select__trigger {
    border-color: #195F40;
    background-color: #fff;
    box-shadow: 0 0 0 4px rgba(25, 95, 64, 0.1);
    border-radius: 12px 12px 0 0;
}

/* Dropdown panel */
.custom-select__dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 2px solid #195F40;
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 100;
    display: none;
    overflow: hidden;
}

.custom-select.is-open .custom-select__dropdown {
    display: block;
    animation: customSelectSlide 0.2s ease;
}

@keyframes customSelectSlide {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Search */
.custom-select__search-wrap {
    padding: 8px 10px;
    border-bottom: 1px solid #e8ede5;
}

.custom-select__search {
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 400;
    color: #195F40;
    background: #f7f9f5;
    border: 1px solid #c5d4be;
    border-radius: 8px;
    padding: 8px 12px;
    width: 100%;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s ease;
}

.custom-select__search:focus {
    border-color: #195F40;
    background: #fff;
}

.custom-select__search::placeholder {
    color: #8a9e85;
}

/* Options list */
.custom-select__options {
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #c5d4be transparent;
}

.custom-select__options::-webkit-scrollbar {
    width: 5px;
}

.custom-select__options::-webkit-scrollbar-track {
    background: transparent;
}

.custom-select__options::-webkit-scrollbar-thumb {
    background: #c5d4be;
    border-radius: 3px;
}

/* Option items */
.custom-select__option {
    padding: 10px 18px;
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: #195F40;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-select__option:hover {
    background: var(--color-cta-orange);
    color: #fff;
}

.custom-select__option.is-selected {
    background: rgba(25, 95, 64, 0.08);
    font-weight: 600;
}

.custom-select__option.is-selected:hover {
    background: var(--color-cta-orange);
    color: #fff;
}

.custom-select__option.is-hidden {
    display: none;
}

/* First option (placeholder) lighter */
.custom-select__option[data-value=""] {
    color: #8a9e85;
    font-weight: 400;
}

.custom-select__no-results {
    padding: 12px 18px;
    font-size: 13px;
    color: #999;
    text-align: center;
    font-style: italic;
}

/* "Не знаю" option — accent */
.custom-select__option[data-value="__custom__"] {
    color: var(--color-cta-orange);
    font-weight: 600;
    font-style: italic;
    border-bottom: 1px solid #f0f0f0;
}

.custom-select__option[data-value="__custom__"]:hover {
    background: var(--color-cta-orange);
    color: var(--color-primary-green);
}

/* Textarea */
.modal-form__textarea {
    resize: vertical;
    min-height: 80px;
}

/* Date input native text color */
.modal-form__input[type="date"] {
    color: #195F40;
}

.modal-form__input[type="date"]::-webkit-datetime-edit-fields-wrapper {
    color: #195F40;
}

.modal-form__input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0.6;
    cursor: pointer;
}

/* ── Field Icons (via ::before on wrapper — autofill-safe) ───────── */

.modal-form__field {
    position: relative;
}

/* Inputs with icons get left padding */
.modal-form__input.has-icon,
.modal-form__select.has-icon {
    padding-left: 44px;
}

/* Icon pseudo-element on the field wrapper */
.modal-form__field.icon-name::before,
.modal-form__field.icon-phone::before,
.modal-form__field.icon-date::before,
.modal-form__field.icon-email::before,
.modal-form__field.icon-doctor::before {
    content: '';
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background-repeat: no-repeat;
    background-size: contain;
    z-index: 1;
    pointer-events: none;
}

/* Name — person icon */
.modal-form__field.icon-name::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23195F40' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E");
}

/* Phone — phone icon */
.modal-form__field.icon-phone::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23195F40' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07 19.5 19.5 0 01-6-6 19.79 19.79 0 01-3.07-8.67A2 2 0 014.11 2h3a2 2 0 012 1.72c.127.96.361 1.903.7 2.81a2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45c.907.339 1.85.573 2.81.7A2 2 0 0122 16.92z'/%3E%3C/svg%3E");
}

/* Clinic — building icon (on select, Chrome doesn't autofill selects) */
.modal-form__select.icon-clinic {
    padding-left: 44px;
    background-repeat: no-repeat;
    background-position: 14px center, right 14px center;
    background-size: 18px 18px, 12px 7px;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23195F40' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 21h18'/%3E%3Cpath d='M5 21V7l8-4v18'/%3E%3Cpath d='M19 21V11l-6-4'/%3E%3Cpath d='M9 9h1'/%3E%3Cpath d='M9 13h1'/%3E%3Cpath d='M9 17h1'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a6b55' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Doctor — stethoscope icon (on select, Chrome doesn't autofill selects) */
.modal-form__select.icon-doctor {
    padding-left: 44px;
    background-repeat: no-repeat;
    background-position: 14px center, right 14px center;
    background-size: 18px 18px, 12px 7px;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23195F40' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.8 2.3A.3.3 0 105 2H4a2 2 0 00-2 2v5a6 6 0 006 6 6 6 0 006-6V4a2 2 0 00-2-2h-1a.2.2 0 10.3.3'/%3E%3Cpath d='M8 15v1a6 6 0 006 6 6 6 0 006-6v-4'/%3E%3Ccircle cx='20' cy='10' r='2'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a6b55' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Doctor icon on input (custom doctor field) */
.modal-form__field.icon-doctor::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23195F40' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.8 2.3A.3.3 0 105 2H4a2 2 0 00-2 2v5a6 6 0 006 6 6 6 0 006-6V4a2 2 0 00-2-2h-1a.2.2 0 10.3.3'/%3E%3Cpath d='M8 15v1a6 6 0 006 6 6 6 0 006-6v-4'/%3E%3Ccircle cx='20' cy='10' r='2'/%3E%3C/svg%3E");
}

/* Date — calendar icon */
.modal-form__field.icon-date::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23195F40' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
}

/* Email — mail icon */
.modal-form__field.icon-email::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23195F40' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z'/%3E%3Cpolyline points='22,6 12,13 2,6'/%3E%3C/svg%3E");
}

/* Comment — message icon (textarea, not autofilled) */
.modal-form__textarea.icon-comment {
    padding-left: 44px;
    background-repeat: no-repeat;
    background-position: 14px 14px;
    background-size: 18px 18px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23195F40' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z'/%3E%3C/svg%3E");
}

/* ── Validation ─────────────────────────────── */

.modal-form__error {
    font-size: 11px;
    color: #e53935;
    margin-top: 3px;
    min-height: 0;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal-form__error.is-visible {
    opacity: 1;
}

.modal-form__input.is-invalid,
.modal-form__select.is-invalid,
.modal-form__textarea.is-invalid {
    border-color: #e53935;
    box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.08);
}

/* ── Star Rating ────────────────────────────── */

.modal-form__label {
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #195F40;
    margin-bottom: 6px;
    display: block;
}

.modal-form__required {
    color: #FF6633;
}

.modal-form__stars {
    display: flex;
    gap: 5px;
}

.modal-form__star {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.modal-form__star:hover {
    transform: scale(1.15);
}

.modal-form__star:active {
    transform: scale(0.95);
}

.modal-form__star svg {
    width: 100%;
    height: 100%;
    fill: #ddd;
    transition: fill 0.2s ease;
}

.modal-form__star.is-hover svg,
.modal-form__star.is-active svg {
    fill: #FF6633;
}

/* ── Low Rating Notice ─────────────────────── */

.review-rating-notice {
    display: none;
    margin-top: 12px;
}

.review-rating-notice.is-visible {
    display: block;
    animation: noticeSlideIn 0.35s ease;
}

@keyframes noticeSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
        max-height: 0;
    }

    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 200px;
    }
}

.review-rating-notice__inner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: #fff7f3;
    border: 2px solid var(--color-cta-orange);
    border-radius: 12px;
    position: relative;
}

.review-rating-notice__icon {
    flex-shrink: 0;
    color: var(--color-cta-orange);
    margin-top: 1px;
}

.review-rating-notice__text {
    font-size: 13px;
    line-height: 1.5;
    color: var(--color-primary-green);
    margin: 0;
    padding-right: 20px;
}

.review-rating-notice__text strong {
    font-weight: 700;
}

.review-rating-notice__close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-green);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease, transform 0.2s ease;
}

.review-rating-notice__close:hover {
    background: var(--color-cta-orange);
    transform: scale(1.1);
}

/* ── Consent ────────────────────────────────── */

.modal-form__consent {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    padding: 2px 0;
}

.modal-form__checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.modal-form__checkmark {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 1.5px solid #dce4d7;
    border-radius: 4px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease;
    margin-top: 1px;
}

.modal-form__checkmark::after {
    content: '';
    display: none;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

.modal-form__checkbox:checked+.modal-form__checkmark {
    background: #195F40;
    border-color: #195F40;
}

.modal-form__checkbox:checked+.modal-form__checkmark::after {
    display: block;
}

.modal-form__checkbox:focus-visible+.modal-form__checkmark {
    box-shadow: 0 0 0 3px rgba(25, 95, 64, 0.15);
}

.modal-form__consent-text {
    font-size: 14px;
    font-weight: 500;
    color: rgba(25, 95, 64, 0.6);
    line-height: 1.5;
}

.modal-form__consent-text a {
    color: #195F40;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.modal-form__consent-text a:hover {
    color: #FF6633;
}

/* ── Consent Group (152-ФЗ: two checkboxes) ─── */

.modal-form__consent-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modal-form__error--consent-policy,
.modal-form__error--consent-processing {
    margin-left: 28px;
}

/* ── Submit Button ──────────────────────────── */

.modal-form__submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 6px;
    padding: 13px 32px;
    background: #FF6633;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-family: 'Montserrat', sans-serif;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.modal-form__submit:hover {
    background: #e55a2b;
    box-shadow: 0 8px 24px rgba(255, 102, 51, 0.3);
    transform: translateY(-1px);
}

.modal-form__submit:active {
    transform: translateY(0) scale(0.97);
}

/* Loading */
.modal-form__submit-spinner,
.modal-form__submit-check {
    display: none;
}

.modal-form__submit.is-loading .modal-form__submit-text {
    opacity: 0;
    position: absolute;
}

.modal-form__submit.is-loading .modal-form__submit-spinner {
    display: block;
    animation: modalSpin 1s linear infinite;
}

.modal-form__submit.is-loading {
    pointer-events: none;
    opacity: 0.8;
}

/* Success */
.modal-form__submit.is-success .modal-form__submit-text {
    display: none;
}

.modal-form__submit.is-success .modal-form__submit-check {
    display: block;
    font-size: 20px;
}

.modal-form__submit.is-success {
    background: #195F40;
    pointer-events: none;
}

@keyframes modalSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ── Status ─────────────────────────────────── */

.modal-form__status {
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-form__status.is-visible {
    opacity: 1;
    padding: 4px 0;
}

.modal-form__status.is-success {
    color: #195F40;
}

.modal-form__status.is-error {
    color: #e53935;
}

/* ── Scroll Lock ────────────────────────────── */

body.modal-open {
    overflow: hidden;
}

/* ============================================
   Responsive
   ============================================ */

/* ≤ 1279px — shrink sidebar */
@media (max-width: 1279.98px) {
    .modal-window--split {
        max-width: 760px;
    }

    .modal-sidebar {
        width: 230px;
        min-width: 230px;
        padding: 32px 22px;
    }

    .modal-body {
        padding: 32px 32px;
    }
}

/* ≤ 1023px — narrower */
@media (max-width: 1023.98px) {
    .modal-window--split {
        max-width: 680px;
    }

    .modal-sidebar {
        width: 210px;
        min-width: 210px;
        padding: 28px 20px;
    }

    .modal-sidebar__logo img {
        height: 48px;
    }

    .modal-sidebar__contact-phone {
        font-size: 14px;
    }

    .modal-sidebar__contact-name {
        font-size: 12px;
    }

    .modal-body {
        padding: 28px 28px;
    }

    .modal-body__title {
        font-size: 22px;
    }

    .modal-form__input,
    .modal-form__select,
    .modal-form__textarea {
        padding: 11px 14px;
        font-size: 16px;
    }
}

/* < 768px — stack vertical (mobile) */
@media (max-width: 767.98px) {
    .modal-overlay {
        align-items: flex-start;
        padding-top: env(safe-area-inset-top, 8px);
    }

    .modal-window--split {
        flex-direction: column;
        width: 95%;
        max-width: none;
        max-height: 90vh;
        max-height: 90dvh; /* iOS dynamic viewport */
        margin-top: auto;
        margin-bottom: auto;
        border-radius: 16px;
    }

    .modal-sidebar {
        width: 100%;
        min-width: 100%;
        padding: 20px 24px 14px;
        flex-direction: row;
        flex-shrink: 0;
        overflow: visible;
    }

    .modal-sidebar__inner {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        width: 100%;
    }

    .modal-sidebar__logo {
        margin-bottom: 0;
        text-align: center;
    }

    .modal-sidebar__logo img {
        height: 36px;
    }

    /* Contacts in horizontal row on mobile */
    .modal-sidebar__contacts {
        flex-direction: row;
        gap: 6px 10px;
        flex-wrap: wrap;
    }

    .modal-sidebar__contact {
        gap: 1px;
    }

    .modal-sidebar__contact-name {
        font-size: 8px;
        letter-spacing: 0.2px;
    }

    .modal-sidebar__contact-phone {
        font-size: 10.5px;
        gap: 3px;
    }

    .modal-sidebar__contact-phone svg {
        width: 10px;
        height: 10px;
    }

    .modal-sidebar__schedule {
        margin-top: 6px;
        font-size: 10px;
        font-weight: 600;
        color: rgba(255, 255, 255, 0.95);
    }

    /* Decorative circles: hide on mobile */
    .modal-sidebar::before,
    .modal-sidebar::after {
        display: none;
    }

    .modal-body {
        padding: 24px 20px;
    }

    .modal-body__title {
        font-size: 20px;
    }

    .modal-body__subtitle {
        font-size: 13px;
        margin-bottom: 18px;
    }

    .modal-form {
        gap: 10px;
    }

    .modal-form__row {
        flex-direction: column;
        gap: 10px;
    }

    .modal-form__input,
    .modal-form__select,
    .modal-form__textarea {
        padding: 11px 14px;
        font-size: 16px;
        border-radius: 10px;
    }

    .modal-form__input.has-icon,
    .modal-form__select.has-icon {
        padding-left: 38px;
    }

    /* Custom select mobile sizes */
    .custom-select__trigger {
        font-size: 14px;
        padding: 11px 36px 11px 14px;
    }

    .custom-select__option {
        font-size: 14px;
        padding: 9px 14px;
    }

    .custom-select__search {
        font-size: 14px;
    }

    /* Smaller icons on mobile */
    .modal-form__field.icon-name::before,
    .modal-form__field.icon-phone::before,
    .modal-form__field.icon-date::before,
    .modal-form__field.icon-email::before,
    .modal-form__field.icon-doctor::before {
        left: 12px;
        width: 16px;
        height: 16px;
    }

    .modal-form__submit {
        padding: 13px 20px;
        font-size: 14px;
        border-radius: 10px;
    }

    .modal-form__star {
        width: 28px;
        height: 28px;
    }

    .modal-window__close {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
    }

    .modal-window__close svg {
        width: 15px;
        height: 15px;
    }
}

/* Very small screens (< 400px) */
@media (max-width: 399.98px) {
    .modal-sidebar__contacts {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 5px 8px;
    }

    .modal-sidebar__contact-name {
        font-size: 7.5px;
    }

    .modal-sidebar__contact-phone {
        font-size: 9.5px;
    }

    .modal-sidebar__contact-phone svg {
        width: 9px;
        height: 9px;
    }

    .modal-sidebar__schedule {
        font-size: 8.5px;
    }
}

/* ── Reduced Motion ────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .modal-overlay__backdrop {
        transition: none;
    }

    .modal-window--split {
        transition: none;
    }

    .modal-form__input,
    .modal-form__select,
    .modal-form__textarea,
    .modal-form__checkmark,
    .modal-form__submit,
    .modal-window__close,
    .custom-select__trigger,
    .custom-select__arrow,
    .modal-form__star,
    .modal-form__star svg,
    .modal-form__error,
    .modal-form__status {
        transition: none;
    }

    .zdorovie-flatpickr .flatpickr-day {
        transition: none;
    }
}

/* ============================================
   Flatpickr — Custom Zdorovie Theme
   ============================================ */

.zdorovie-flatpickr {
    font-family: 'Montserrat', sans-serif;
    border: 2px solid #a8b89e;
    border-radius: 14px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    background: #fff;
}

.zdorovie-flatpickr .flatpickr-months {
    background: #195F40;
    border-radius: 0;
    padding: 4px 0;
}

.zdorovie-flatpickr .flatpickr-months .flatpickr-month {
    color: #fff;
    fill: #fff;
}

.zdorovie-flatpickr .flatpickr-current-month {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.zdorovie-flatpickr .flatpickr-current-month .flatpickr-monthDropdown-months {
    background: #195F40;
    color: #fff;
    font-weight: 600;
}

.zdorovie-flatpickr .flatpickr-months .flatpickr-prev-month,
.zdorovie-flatpickr .flatpickr-months .flatpickr-next-month {
    fill: #fff;
    color: #fff;
}

.zdorovie-flatpickr .flatpickr-months .flatpickr-prev-month:hover,
.zdorovie-flatpickr .flatpickr-months .flatpickr-next-month:hover {
    fill: #B4CD8E;
    color: #B4CD8E;
}

.zdorovie-flatpickr .flatpickr-months .flatpickr-prev-month svg,
.zdorovie-flatpickr .flatpickr-months .flatpickr-next-month svg {
    fill: inherit;
}

.zdorovie-flatpickr .flatpickr-weekdays {
    background: #195F40;
}

.zdorovie-flatpickr .flatpickr-weekday {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-weight: 600;
}

.zdorovie-flatpickr .flatpickr-day {
    color: #195F40;
    font-weight: 500;
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.zdorovie-flatpickr .flatpickr-day:hover {
    background: var(--color-cta-orange);
    border-color: var(--color-cta-orange);
    color: #fff;
}

.zdorovie-flatpickr .flatpickr-day.today {
    border-color: #195F40;
    background: transparent;
    color: #195F40;
    font-weight: 700;
}

.zdorovie-flatpickr .flatpickr-day.today:hover {
    background: #195F40;
    color: #fff;
}

.zdorovie-flatpickr .flatpickr-day.selected,
.zdorovie-flatpickr .flatpickr-day.selected:hover {
    background: #FF6633;
    border-color: #FF6633;
    color: #fff;
    font-weight: 700;
}

.zdorovie-flatpickr .flatpickr-day.flatpickr-disabled {
    color: #ccc;
}

.zdorovie-flatpickr .flatpickr-day.prevMonthDay,
.zdorovie-flatpickr .flatpickr-day.nextMonthDay {
    color: #bbb;
}

/* Readonly input cursor */
.flatpickr-date[readonly] {
    cursor: pointer;
}