/* wantdiscount: кнопка, модалка (десктоп) и шторка (мобайл) — по макету */

.wd-root {
    --wd-accent: #005bff;
    --wd-btn-text-color: var(--wd-accent);
    --wd-text: #1a1a1a;
    --wd-muted: #8f8f8f;
    --wd-border: #e3e3e8;
    --wd-bg-soft: #f5f5f7;
    --wd-green: #0c9b54;
    --wd-green-bg: #e7f7ef;
    --wd-red: #d3453c;
    --wd-note-bg: #fff8e1;
    --wd-note-text: #6b5b1e;
    --wd-radius: 14px;
    --wd-title-size: 20px;
    --wd-field-height: 48px;
    --wd-preset-height: 46px;
    --wd-submit-height: 40px;
    font-family: inherit;
    box-sizing: border-box;
}

.wd-root *, .wd-root *::before, .wd-root *::after { box-sizing: border-box; }

/* шрифты — строго от темы магазина */
.wd-root button,
.wd-root input,
.wd-root textarea,
.wd-root select {
    font-family: inherit;
}

/* автозаполнение браузера: не заливать поля серым, не менять цвет текста */
.wd-root input:-webkit-autofill,
.wd-root input:-webkit-autofill:hover,
.wd-root input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px #fff inset !important;
    -webkit-text-fill-color: var(--wd-text) !important;
    caret-color: var(--wd-text);
    transition: background-color 99999999s ease-out;
}

/* --- кнопка под ценой --- */

.wd-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    /* паттерн couponcard: фикс. высота 40px, шрифт 13px/600, line-height 1;
       паддинги 7/5 при фикс. высоте смещают центрированный текст на 1px вниз */
    min-height: 40px;
    padding: 7px 10px 5px;
    border: 1px solid var(--wd-btn-text-color);
    border-radius: 10px;
    background: transparent;
    color: var(--wd-btn-text-color);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.wd-btn:hover { background: var(--wd-btn-text-color); color: #fff; }

.wd-btn__icon { width: 25px; height: 25px; flex: 0 0 auto; }
.wd-btn__img  { width: 25px; height: 25px; flex: 0 0 auto; display: block; object-fit: contain; }
/* загруженная цветная иконка на акцентном ховере становится белой
   (стандартный SVG красится через currentColor и белеет сам) */
.wd-btn:hover .wd-btn__img { filter: brightness(0) invert(1); }

/* --- модалка / шторка --- */

.wd-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.wd-modal[hidden] { display: none; }

.wd-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    opacity: 0;
    transition: opacity .28s ease-out;
}

.wd-modal__sheet {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 440px;
    max-height: min(90vh, 90dvh);
    background: #fff;
    border-radius: var(--wd-radius);
    box-shadow: 0 12px 48px rgba(0, 0, 0, .22);
    transform: translateY(28px) scale(.96);
    opacity: 0;
    transition: transform .32s cubic-bezier(.16, 1, .3, 1), opacity .24s ease-out;
    will-change: transform, opacity;
}

.wd-modal.wd-open .wd-modal__overlay { opacity: 1; }
.wd-modal.wd-open .wd-modal__sheet { transform: translateY(0) scale(1); opacity: 1; }

.wd-modal__grabber { display: none; }

/* --- шаблон «шторка справа» (только десктоп; на мобиле — обычная нижняя шторка) --- */

.wd-modal--panel { align-items: stretch; justify-content: flex-end; padding: 0; }

.wd-modal--panel .wd-modal__sheet {
    /* отступы 15px сверху, снизу и справа */
    margin: 15px 15px 15px 0;
    max-height: none;
    transform: translateX(calc(100% + 15px));
}

.wd-modal--panel.wd-open .wd-modal__sheet { transform: translateX(0); }

.wd-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    flex: 0 0 auto;
}

.wd-modal__title {
    flex: 1;
    min-width: 0;
    text-align: left;
    font-size: var(--wd-title-size);
    font-weight: 700;
    color: var(--wd-text);
}

/* на экране успеха заголовок скрыт (по макету), крестик остаётся */
.wd-root.wd-has-request .wd-modal__title { visibility: hidden; }

.wd-modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50% !important;
    background: #f0f2f5;
    color: #5a5a5a;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.wd-modal__close:hover { background: #e4e7ec; color: #1a1a1a; }
.wd-modal__close svg { width: 16px; height: 16px; display: block; }

.wd-modal__body {
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 16px 16px;
    scrollbar-width: thin;
    scrollbar-color: #c9cdd6 transparent;
}

/* аккуратный тонкий скроллбар формы запроса */
.wd-modal__body::-webkit-scrollbar { width: 6px; }
.wd-modal__body::-webkit-scrollbar-track { background: transparent; }
.wd-modal__body::-webkit-scrollbar-thumb { background: #c9cdd6; border-radius: 6px; }
.wd-modal__body::-webkit-scrollbar-thumb:hover { background: #aeb3bf; }
.wd-modal__body { -webkit-overflow-scrolling: touch; }

/* --- экран успеха (после отправки) --- */

.wd-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 8px 12px;
}

.wd-success[hidden] { display: none; }
.wd-form[hidden] { display: none; }

.wd-success__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--wd-green-bg);
    color: var(--wd-green);
}

.wd-success__icon svg { width: 32px; height: 32px; display: block; }

.wd-success__title { margin-top: 14px; font-size: 18px; font-weight: 700; color: var(--wd-text); }
.wd-success__text { margin-top: 6px; font-size: 14px; color: var(--wd-muted); }
.wd-success__note { margin-top: 12px; padding: 10px 12px; font-size: 13px; line-height: 1.45; color: var(--wd-note-text, #6b5b1e); background: var(--wd-note-bg, #fff8e1); border-radius: 8px; text-align: left; }

/* экран входа для гостей («Только для авторизованных») */
.wd-auth { padding: 20px 8px 8px; text-align: center; }
.wd-auth__icon { width: 48px; height: 48px; margin: 0 auto; border-radius: 50%; background: var(--wd-bg-soft, #f5f5f7); color: var(--wd-muted, #8f8f8f); display: flex; align-items: center; justify-content: center; }
.wd-auth__icon svg { width: 26px; height: 26px; display: block; }
.wd-auth__text { margin-top: 14px; font-size: 14px; line-height: 1.5; color: var(--wd-text); }
.wd-auth .wd-submit { display: inline-flex; margin-top: 20px; text-decoration: none; }

.wd-edit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    margin-top: 20px;
    padding: 0 24px;
    border: 1px solid var(--wd-edit-btn-border, var(--wd-border));
    border-radius: 10px;
    background: var(--wd-edit-btn-bg, #fff);
    color: var(--wd-edit-btn-text, var(--wd-text));
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease, background .15s ease;
}

.wd-edit-btn:hover {
    border-color: var(--wd-edit-btn-hover-border, var(--wd-accent));
    color: var(--wd-edit-btn-hover-text, var(--wd-accent));
}

/* display:inline-flex выше перебивает атрибут hidden (UA-стили слабее класса) */
.wd-edit-btn[hidden] { display: none; }

/* --- карточка товара --- */

.wd-product {
    display: flex;
    gap: 12px;
    padding: 10px;
    background: var(--wd-bg-soft);
    border-radius: 12px;
}

.wd-product__img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 10px;
    flex: 0 0 auto;
}

.wd-product__info { min-width: 0; }

.wd-product__name {
    color: var(--wd-text);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wd-product__name:hover { text-decoration: underline; }

.wd-product__price { margin-top: 4px; font-size: 16px; font-weight: 700; color: var(--wd-text); }
.wd-product__price-old { margin-left: 6px; font-size: 13px; font-weight: 400; color: var(--wd-muted); }
.wd-product__counter { margin-top: 2px; font-size: 12px; color: var(--wd-muted); }

/* --- пресеты --- */

.wd-label { margin: 16px 0 8px; font-size: 14px; font-weight: 600; color: var(--wd-text); }

.wd-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.wd-presets__btn {
    height: var(--wd-preset-height);
    border: 1px solid var(--wd-border);
    border-radius: 10px;
    background: #fff;
    color: var(--wd-text);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.wd-presets__btn:hover { border-color: var(--wd-accent); color: var(--wd-accent); }

.wd-presets__btn.is-active {
    background: var(--wd-accent);
    border-color: var(--wd-accent);
    color: #fff;
}

/* --- поля --- */

.wd-fields { display: flex; gap: 8px; margin-top: 12px; }
.wd-field { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.wd-field--qty { flex: 0 0 150px; }

.wd-field__label { font-size: 12px; color: var(--wd-muted); }

/* Инпуты — с префиксом .wd-root: селекторы вида input[type="text"] у старых
   тем (default SS7) специфичнее одиночного класса и ломали высоту/паддинги */
.wd-root .wd-field__input {
    width: 100%;
    height: var(--wd-field-height);
    padding: 0 14px;
    border: 1px solid var(--wd-border);
    border-radius: 10px;
    background: #fff;
    color: var(--wd-text);
    font-size: 16px;
    line-height: normal;
    box-sizing: border-box;
    outline: none;
    transition: border-color .15s ease;
}

.wd-root .wd-field__input:focus { border-color: var(--wd-accent); }

/* степпер количества: [−] 1 [+] */
.wd-qty {
    display: flex;
    align-items: stretch;
    width: 100%;
    height: var(--wd-field-height);
    border: 1px solid var(--wd-border);
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}

.wd-qty__btn {
    flex: 0 0 40px;
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    height: 100%;
    padding: 0;
    border: 0;
    background: #fff;
    color: var(--wd-text);
    font-size: 20px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.wd-qty__btn:hover { background: #f0f2f5; color: var(--wd-accent); }
.wd-qty__btn:active { background: #e4e7ec; }

.wd-root .wd-qty__input {
    flex: 1 1 0%;
    width: 100%;
    min-width: 0;
    height: 100%;
    padding: 0;
    border: 0;
    text-align: center;
    font-size: 16px;
    line-height: normal;
    color: var(--wd-text);
    outline: none;
    background: transparent;
    -moz-appearance: textfield;
    box-sizing: border-box;
}

.wd-root .wd-qty__input::-webkit-outer-spin-button,
.wd-root .wd-qty__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.wd-guest { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.wd-guest .wd-field { flex: none; }

/* --- заметка, кнопка, faq, ошибка --- */

.wd-note {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--wd-note-bg);
    color: var(--wd-note-text);
    font-size: 13px;
    line-height: 1.45;
}

.wd-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: var(--wd-submit-height);
    margin-top: 14px;
    /* 2px сверху при фикс. высоте сдвигают центрированный текст на 1px вниз */
    padding: 2px 6px 0;
    border: 0;
    border-radius: 12px;
    background: var(--wd-accent);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: filter .15s ease;
}

.wd-submit:hover { filter: brightness(1.08); }
.wd-submit:disabled { opacity: .6; cursor: default; }

.wd-faq { margin-top: 12px; text-align: center; }

.wd-faq__toggle {
    border: 0;
    background: none;
    padding: 0;
    color: var(--wd-muted);
    font-size: 13px;
    text-decoration: underline;
    cursor: pointer;
}

.wd-faq__toggle:hover { color: var(--wd-text); }

.wd-faq__text {
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--wd-text);
    background: var(--wd-bg-soft);
    border-radius: 10px;
    padding: 10px 12px;
    text-align: left;
}

.wd-error { margin-top: 10px; }
.wd-error[hidden] { display: none; }
.wd-error:not([hidden]) {
    padding: 10px 12px;
    border-radius: 10px;
    background: #fdecea;
    color: var(--wd-red);
    font-size: 13px;
    line-height: 1.4;
}
.wd-error a { color: var(--wd-red); font-weight: 600; }

.wd-lock, .wd-lock body { overflow: hidden !important; }

/* --- мобильная шторка --- */

@media (max-width: 767px) {

    .wd-modal {
        align-items: flex-end;
        justify-content: stretch;
        padding: 0;
    }

    .wd-modal__sheet {
        max-width: none;
        max-height: 92dvh;
        border-radius: 16px 16px 0 0;
        border-bottom: 0;
        transform: translateY(100%);
        opacity: 1;
        touch-action: pan-y;
    }

    .wd-modal.wd-open .wd-modal__sheet { transform: translateY(0); }

    /* панель на мобиле — обычная нижняя шторка */
    .wd-modal--panel { align-items: flex-end; justify-content: stretch; }
    .wd-modal--panel .wd-modal__sheet { margin: 0; max-height: 92dvh; transform: translateY(100%); }
    .wd-modal--panel.wd-open .wd-modal__sheet { transform: translateY(0); }

    .wd-modal__grabber {
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 22px;
        cursor: grab;
        touch-action: none;
    }

    .wd-modal__grabber span {
        display: block;
        width: 44px;
        height: 4px;
        margin: 9px auto 0;
        border-radius: 2px;
        background: #d9d9de;
    }

    .wd-modal__head { padding-top: 26px; }
    .wd-modal__body { padding: 0 16px max(16px, env(safe-area-inset-bottom)); }

    /* по макету: пресеты 2×2, поля друг под другом */
    .wd-presets { grid-template-columns: repeat(2, 1fr); }
    .wd-fields { flex-direction: column; }
    .wd-field--qty { flex: none; }
}
