/* Модалка callback (Webform + Bootstrap) */

/* Токены: общие для статической (#callBackModal/.modal-cvetok-callback) и ajax (#drupal-bootstrap4-modal) */
.modal-cvetok-callback,
#drupal-bootstrap4-modal {
    --field-border: var(--c-accent);
    --field-radius: var(--r-md);
    --field-h: 45px;
    --field-fs: 16px;
    --field-lh: 21px;
    --cb-size: 26px;
    --cb-h: 27px;
}

/* — Контейнер / диалог / шапка / тело / футер — */
.modal-cvetok-callback .modal-content {
    border: none;
    background-clip: padding-box;
}

.modal-cvetok-callback .modal-header {
    display: grid !important;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 3px 0;
    width: 100%;
    padding: 0 !important;
    border-bottom: none !important;
}

.modal-cvetok-callback .modal-title { text-align: center !important; }

.modal-cvetok-callback .modal-body {
    padding: 0 !important;
    border: none;
}

.modal-cvetok-callback .modal-footer {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100%;
    margin: 0;
    padding: 0 !important;
    border-top: none !important;
    gap: 0;
}

.modal-cvetok-callback .modal-cvetok-callback__dialog,
#drupal-bootstrap4-modal .modal-dialog.modal-cvetok-callback__dialog {
    width: 100%;
    max-width: min(640px, calc(100vw - 32px));
    margin: .375rem auto;
}

.modal-cvetok-callback .modal-cvetok-callback__content {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 16px 18px 20px;
    font-family: var(--ff-base);
    color: var(--c-text);
    background: var(--c-bg);
    border: 1px solid #e8e4df;
    border-radius: 12px;
    box-shadow: 3px 2px 20px 4px rgba(140, 148, 162, .2);
}

#drupal-bootstrap4-modal .modal-dialog .modal-content {
    box-sizing: border-box;
    padding: 22px 26px 28px;
    border-radius: 12px;
    font-family: var(--ff-base);
    color: var(--c-text);
}
#drupal-bootstrap4-modal .modal-header {
    margin-bottom: 0;
    padding-bottom: 0 !important;
    border-bottom: none !important;
}
#drupal-bootstrap4-modal .modal-body { padding: 8px 2px 0; }
#drupal-bootstrap4-modal .modal-body > hr:first-child,
#drupal-bootstrap4-modal .modal-body > .form-item:first-child hr,
#drupal-bootstrap4-modal .webform-submission-form > hr:first-of-type { display: none; }

/* — Кнопка закрытия — */
.modal-cvetok-callback .modal-header .btn-close {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: start;
    width: 30px;
    height: 30px;
    margin: 0;
    padding: 0;
    opacity: 1;
    background-size: 14px;
    border-radius: 4px;
    transition: background-color .2s ease, opacity .2s ease;
}
.modal-cvetok-callback .modal-header .btn-close:hover,
.modal-cvetok-callback .modal-header .btn-close:focus-visible {
    background-color: var(--c-accent-soft);
    box-shadow: none;
}

/* — Заголовок — */
.modal-cvetok-callback .modal-title,
.modal-cvetok-callback .modal-header > :is(h1, h2, h3, h4, h5):not(.btn-close) {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
    width: 100%;
    max-width: 635px;
    margin: 0;
    text-align: center;
    font-weight: 700;
    font-size: clamp(20px, 2.6vw, 26px);
    line-height: 1.2;
    color: var(--c-text);
}
#drupal-bootstrap4-modal :is(.modal-title, .modal-header h2, .modal-body > h2:first-of-type, .modal-body .form-item--processed-text > h2, .webform-submission-form > .form-item:first-child h2) {
    width: 100%;
    margin: 0 0 8px;
    text-align: center;
    font-family: var(--ff-base);
    font-weight: 700;
    font-size: clamp(22px, 2.2vw + 12px, 34px);
    line-height: 1.25;
    color: var(--c-text);
}

/* — Тело — */
.modal-cvetok-callback .modal-body {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 100%;
    max-width: 591px;
    margin: 0;
}
.modal-cvetok-callback .modal-body > * { width: 100%; }

/* — Формы — */
.modal-cvetok-callback :is(.webform-submission-form, form.webform-submission-form, .modal-body > form),
#drupal-bootstrap4-modal .webform-submission-form {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    margin: 0;
}
#drupal-bootstrap4-modal .webform-submission-form { gap: 12px; }

.modal-cvetok-callback .webform-flexbox,
#drupal-bootstrap4-modal .webform-flexbox {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
}
#drupal-bootstrap4-modal .webform-flexbox { gap: 12px; }

.modal-cvetok-callback .webform-flexbox__item,
.modal-cvetok-callback .js-form-item { margin: 0; }

.modal-cvetok-callback :is(fieldset, .fieldset-wrapper) {
    margin: 0;
    padding: 0;
    border: none;
}

/* — Скрытые лейблы — */
:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) .form-item:not(.form-type-checkbox) label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* — Поля ввода — */
:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) :is(input[type="text"], input[type="tel"], input[type="email"], input[type="number"], input.form-text, input.form-email, input.form-tel, select) {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    height: var(--field-h);
    min-height: var(--field-h);
    padding: 5px 8px;
    font-family: var(--ff-base);
    font-weight: 400;
    font-size: var(--field-fs);
    line-height: var(--field-lh);
    color: var(--c-text);
    background: var(--c-bg);
    border: 1px solid var(--field-border);
    border-radius: var(--field-radius);
}

:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) textarea {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-height: 100px;
    padding: 7px 9px;
    font-family: var(--ff-base);
    font-weight: 400;
    font-size: var(--field-fs);
    line-height: var(--field-lh);
    color: var(--c-text);
    background: var(--c-bg);
    border: 1px solid var(--field-border);
    border-radius: var(--field-radius);
    resize: vertical;
}

:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) :is(input, textarea)::placeholder { color: #757575; }

:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) :is(input, textarea, select):focus {
    outline: none;
    border-color: var(--c-accent-hover);
    box-shadow: 0 0 0 1px var(--c-accent-ring);
}

:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) .form-item--error :is(input, textarea, select) {
    border-color: var(--c-accent);
    box-shadow: 0 0 0 1px rgba(200, 0, 0, .25);
}

/* Перебить Bootstrap .form-control */
:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) :is(input, textarea, select).form-control {
    border: 1px solid var(--field-border) !important;
    border-radius: var(--field-radius) !important;
    box-shadow: none !important;
}

/* — Ошибки — */
:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) :is(.form-item--error-message, strong.yh-error, .form-item--error div.error) {
    display: block;
    margin: 2px 0 0;
    padding: 0;
    font-family: var(--ff-base);
    font-weight: 400 !important;
    font-size: 12px !important;
    line-height: 1.33;
    color: var(--c-error) !important;
}
:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) .form-item--error-message strong {
    font-weight: 400 !important;
    font-size: inherit !important;
    color: inherit !important;
}

/* — Текст-описание над формой — */
:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) :is(.form-type-webform-markup, .webform-element--description, .form-item--markup) {
    width: 100%;
    margin: 0 0 4.5px;
    font-family: var(--ff-base);
    font-weight: 400;
    font-size: var(--field-fs);
    line-height: var(--field-lh);
    color: var(--c-text);
    text-align: left;
}
.modal-cvetok-callback :is(.form-type-webform-markup, .form-item--markup):last-child,
#drupal-bootstrap4-modal .form-type-webform-markup:last-of-type,
#drupal-bootstrap4-modal .form-item--markup p:last-child { margin-bottom: 0; }
.modal-cvetok-callback :is(.form-type-webform-markup, .form-item--markup, .webform-element--webform_markup) p { margin: 0 0 .33em; }
.modal-cvetok-callback :is(.form-type-webform-markup, .form-item--markup) p:last-child { margin-bottom: 0; }

.modal-cvetok-callback :is(.form-type-webform-markup, .form-item--markup) + * { margin-top: -4px; }
#drupal-bootstrap4-modal :is(.form-type-webform-markup, .form-item--markup) + * { margin-top: -6px; }

.modal-cvetok-callback .webform-flexbox > .webform-flexbox__item:first-child { margin-bottom: -4px; }
#drupal-bootstrap4-modal .webform-flexbox > .webform-flexbox__item:first-child { margin-bottom: -6px; }

/* — Description обычное — */
.modal-cvetok-callback :is(.description, .webform-element--description) {
    margin-top: 2px;
    font-size: 13px;
    line-height: 1.35;
    color: #555;
}
.modal-cvetok-callback .form-type-checkbox .description p { margin: 0; }

/* — HR — */
.modal-cvetok-callback :is(hr, .webform-element--horizontal_rule) {
    box-sizing: border-box;
    width: 100%;
    margin: 3px 0;
    border: 0;
    border-top: 1px solid var(--c-divider);
}

/* — Ссылки — */
.modal-cvetok-callback a {
    color: var(--c-accent);
    text-decoration: underline;
    cursor: pointer;
}
.modal-cvetok-callback a:hover,
.modal-cvetok-callback a:focus-visible { color: var(--c-accent-hover); }
.modal-cvetok-callback :is(a.btn, a.btn-primary),
.modal-cvetok-callback :is(a.btn, a.btn-primary):hover,
.modal-cvetok-callback :is(a.btn, a.btn-primary):focus-visible { color: var(--c-bg) !important; }

.modal-cvetok-callback .messages {
    box-sizing: border-box;
    width: 100%;
    max-width: 591px;
    margin: 0;
    border-radius: 4px;
}

/* — Чекбокс согласия — */
:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) .form-type-checkbox {
    display: grid !important;
    grid-template-columns: var(--cb-size) minmax(0, 1fr);
    column-gap: 6px;
    row-gap: 4px;
    align-items: start;
    width: 100%;
    max-width: 100%;
    text-align: left;
}
#drupal-bootstrap4-modal .form-type-checkbox { margin-top: 2px; }

:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) .form-type-checkbox input[type="checkbox"] {
    box-sizing: border-box;
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    width: var(--cb-size) !important;
    min-width: var(--cb-size) !important;
    max-width: var(--cb-size) !important;
    height: var(--cb-h);
    min-height: var(--cb-h);
    margin: 2px 0 0 !important;
    padding: 0;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: none;
    border-radius: var(--r-md);
    background-color: var(--c-bg);
    background-repeat: no-repeat;
    background-position: center;
    background-size: 14px 11px;
    box-shadow: inset 0 0 0 1px var(--c-accent);
    accent-color: transparent;
    cursor: pointer;
}

:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) .form-type-checkbox input[type="checkbox"]:checked {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='11' viewBox='0 0 14 11' fill='none'%3E%3Cpath d='M1 5.5L4.5 9L13 1' stroke='%239E2747' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.modal-cvetok-callback .form-type-checkbox input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--c-accent-hover);
    outline-offset: 2px;
}

:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) .form-type-checkbox :is(label, .option) {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    margin: 0;
    font-family: var(--ff-base);
    font-size: 14px;
    line-height: 18px;
    color: var(--c-text);
    text-align: left;
    cursor: pointer;
}

:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) .form-type-checkbox a {
    color: var(--c-accent);
    text-decoration: underline;
    cursor: pointer;
}
.modal-cvetok-callback .form-type-checkbox a:hover { color: var(--c-accent-hover); }

:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) .form-type-checkbox :is(.form-item--error-message, strong.yh-error, .form-item--error div.error) {
    display: block;
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    margin: 0 !important;
    font-weight: 400 !important;
    font-size: 12px !important;
    line-height: 1.33;
    color: var(--c-error) !important;
}

/* — Bootstrap .form-check вариант — */
.modal-cvetok-callback .form-check {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    gap: 6px;
    margin-bottom: 0;
    padding-left: 0 !important;
}
.modal-cvetok-callback .form-check-input {
    float: none !important;
    flex: 0 0 var(--cb-size) !important;
    width: var(--cb-size) !important;
    min-width: var(--cb-size) !important;
    max-width: var(--cb-size) !important;
    height: var(--cb-h) !important;
    margin: 2px 0 0 !important;
    appearance: none;
    -webkit-appearance: none;
    border: none;
    border-radius: var(--r-md);
    background-color: var(--c-bg);
    box-shadow: inset 0 0 0 1px var(--c-accent);
    cursor: pointer;
}
.modal-cvetok-callback .form-check-input:checked {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='11' viewBox='0 0 14 11' fill='none'%3E%3Cpath d='M1 5.5L4.5 9L13 1' stroke='%239E2747' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 14px 11px;
}
.modal-cvetok-callback .form-check-label {
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--ff-base);
    font-size: 14px;
    line-height: 18px;
    color: var(--c-text);
}

/* — Действия — */
:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) :is(.form-actions, .webform-actions) {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    margin: 2px 0 0;
    padding: 0;
}
#drupal-bootstrap4-modal :is(.form-actions, .webform-actions) {
    margin-top: 8px;
    padding-top: 3px;
}

/* — Кнопка submit (перебить Bootstrap/Webform) — */
:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) :is(input[type="submit"], button[type="submit"], .form-submit, .webform-button--submit, .btn, .btn-primary) {
    box-sizing: border-box;
    width: 100% !important;
    max-width: 100% !important;
    min-height: var(--field-h) !important;
    padding: 5px 10px !important;
    font-family: var(--ff-base) !important;
    font-weight: 700 !important;
    font-size: var(--field-fs) !important;
    line-height: var(--field-lh) !important;
    text-align: center !important;
    color: var(--c-bg) !important;
    background: var(--c-accent) !important;
    background-image: none !important;
    border: none !important;
    border-radius: var(--r-md) !important;
    box-shadow: none !important;
    cursor: pointer;
    transition: background .2s ease, color .2s ease;
}

:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) :is(input[type="submit"], button[type="submit"], .form-submit, .webform-button--submit, .btn, .btn-primary):hover,
:is(.modal-cvetok-callback, #drupal-bootstrap4-modal) :is(input[type="submit"], button[type="submit"], .form-submit, .webform-button--submit, .btn, .btn-primary):focus-visible {
    color: var(--c-bg) !important;
    background: var(--c-accent-hover) !important;
    background-image: none !important;
}

/* Bootstrap 5 btn-vars */
.modal-cvetok-callback .btn-primary {
    --bs-btn-bg: var(--c-accent);
    --bs-btn-border-color: var(--c-accent);
    --bs-btn-hover-bg: var(--c-accent-hover);
    --bs-btn-hover-border-color: var(--c-accent-hover);
    --bs-btn-active-bg: var(--c-accent-hover);
    --bs-btn-active-border-color: var(--c-accent-hover);
    --bs-btn-disabled-bg: var(--c-accent);
    --bs-btn-disabled-border-color: var(--c-accent);
}
