/**
 * Блок «Вопросы и ответы» в карточке товара.
 *
 * Все селекторы под префиксом .qna — конфликтов со стилями Битрикса
 * и шаблона нет. Шрифт наследуется от body.
 *
 * Файл общий для десктопного и мобильного шаблонов, поэтому цвета заданы
 * своими переменными, а не взяты из --bs-*: в alleya_2026 переменная
 * --bs-green — это фирменный #559723, а в alleya_mob_2026 — сток Bootstrap
 * #198754 (там фирменный цвет живёт в классе .bg-main-green). Опираться
 * на одноимённые токены с разным смыслом нельзя.
 */

:root {
    --qna-green: #559723;
    --qna-green-dark: #427E15;
    --qna-green-bg: #E9F1E2;
    --qna-text: #363636;
    --qna-muted: #797D83;
    --qna-line: #DFE0E5;
    --qna-fill: #F0F1F4;
    --qna-white: #fff;
    --qna-danger: #CF003A;
}

.qna {
    color: var(--qna-text);
    line-height: 1.4;
}

/* Атрибут hidden задаёт display:none только в UA-стилях, поэтому его
   перебивает любое авторское правило: у .count это display:inline-block
   (site.css:2613), у .qna-more-wrap — display:flex ниже в этом файле.
   Без этой страховки «скрытые» заготовки списка были бы видны. */
.qna [hidden],
.qna-count[hidden] {
    display: none !important;
}

/* ------------------------------------------------------------------ кнопки

   Блок не опирается на кнопочные классы шаблона (.btn-custom, .switch-btn,
   .duch-more-button, .link-feedback-inside): в alleya_mob_2026 самостоятельных
   правил для них нет — только контекстные, — и кнопки остались бы голым
   текстом, потому что глобальный сброс `button` снимает фон и рамку.
   Поэтому всё описано здесь и выглядит одинаково в обоих шаблонах. */

.qna-btn,
.qna-more,
.qna-sort__btn {
    -webkit-appearance: none;
    appearance: none;
    font-family: inherit;
    cursor: pointer;
    transition: .2s;
}

/* Основное действие: зелёная пилюля. */
.qna-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 47px;
    padding: 12px 22px;
    border: none;
    border-radius: 100px;
    background-color: var(--qna-green);
    color: var(--qna-white);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    margin: 0;
}

.qna-btn:hover {
    background-color: var(--qna-green-dark);
}

/* «Показать ещё»: второстепенное действие, поэтому контурная. */
.qna-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 24px;
    border: 1px solid var(--qna-line);
    border-radius: 100px;
    background: var(--qna-white);
    color: var(--qna-text);
    font-size: 15px;
}

.qna-more:hover {
    border-color: var(--qna-green);
    color: var(--qna-green-dark);
}

/* ------------------------------------------------------------ верхняя строка */

.qna-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
}

.qna-toolbar__note {
    font-size: 16px;
    color: var(--qna-muted);
}

/* -------------------------------------------------------------------- форма */

.qna-form-wrap {
    margin-top: 24px;
}

.qna-form {
    padding: 24px;
    border: 1px solid var(--qna-line);
    border-radius: 16px;
    background: var(--qna-white);
}

.qna-form__title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
}

.qna-form__grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.qna-form__grid .qna-field {
    flex: 1 1 240px;
    min-width: 0;
}

.qna-field {
    margin-bottom: 16px;
}

.qna-field--full {
    width: 100%;
}

.qna-field__label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--qna-text);
}

.qna-req {
    color: var(--qna-danger);
}

.qna-field__optional {
    font-weight: 400;
    color: var(--qna-muted);
}

.qna-captcha {
    min-height: 100px;
}

/* Поля описываем полностью и намеренно НЕ используем штатный класс .input:
   его базовое правило (css/site.css:5183) — наследие тёмной темы,
   color: #f1f1f1 на прозрачном фоне. Читаемым его делает только
   `.modal-content .input`, а наша форма живёт во вкладке, а не в модалке,
   поэтому текст был бы белым по белому.
   Шрифт и размер приходят от сброса `input, select, textarea` (site.css:5171). */
.qna-field__input,
.qna-field__textarea {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 5px 14px;
    border: 1px solid var(--qna-line);
    /* 12px — тот же радиус, что у контейнеров шаблона (утилита .br-3,
       site.css:4977). Поля шаблона (.modal-content .input, .lk-input)
       сами по себе квадратные — скругление здесь сделано по просьбе. */
    border-radius: 12px;
    color: var(--qna-text);
    background-color: var(--qna-white);
    font-weight: 400;
    line-height: 1.4;
    transition: .2s;
}

.qna-field__input {
    height: 44px;
}

.qna-field__textarea {
    min-height: 110px;
    padding: 12px 14px;
    resize: vertical;
}

.qna-field__input:focus,
.qna-field__textarea:focus {
    border-color: var(--qna-green);
}

.qna-field__input::placeholder,
.qna-field__textarea::placeholder {
    color: var(--qna-muted);
}

.qna-field--invalid .qna-field__input,
.qna-field--invalid .qna-field__textarea {
    border-color: var(--qna-danger);
}

.qna-field__note {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: var(--qna-muted);
}

.qna-error {
    display: none;
    margin-top: 6px;
    font-size: 13px;
    color: var(--qna-danger);
}

.qna-error--visible {
    display: block;
}

/* Ханипот: невидим для людей, но доступен ботам, читающим разметку. */
.qna-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.qna-consent {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    color: var(--qna-muted);
    cursor: pointer;
}

/* Глобальный сброс `input, select, textarea { -webkit-appearance: none }`
   (site.css:5171) убивает и нативный чекбокс — без своей отрисовки он
   схлопнулся бы в невидимую точку. Рисуем так же, как [type=checkbox].type
   в site.css:4868, теми же SVG. */
.qna-consent input[type="checkbox"] {
    flex: 0 0 auto;
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    margin: 0;
    background: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='0.5' y='0.5' width='19' height='19' rx='3.5' stroke='%23559723'/%3E%3C/svg%3E%0A") no-repeat center/contain;
    cursor: pointer;
}

.qna-consent input[type="checkbox"]:checked {
    background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='0.5' y='0.5' width='19' height='19' rx='3.5' stroke='%23559723'/%3E%3Cpath d='M14.697 6.66667L8.0303 13.3333L5 10.303' stroke='%23559723' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E%0A");
}

.qna-consent input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--qna-green);
    outline-offset: 2px;
}

.qna-field--invalid .qna-consent input[type="checkbox"] {
    background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='0.5' y='0.5' width='19' height='19' rx='3.5' stroke='%23CF003A'/%3E%3C/svg%3E%0A");
}

.qna-consent a {
    color: var(--qna-green);
    text-decoration: underline;
}

.qna-consent a:hover {
    color: var(--qna-green-dark);
}

.qna-form__footer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 8px;
}

/* Страховка на случай, если класс .submit вернут в разметку:
   его margin-top ломает выравнивание кнопки с подписью. */
.qna-submit {
    margin-top: 0;
}

.qna-submit--loading {
    opacity: .6;
    pointer-events: none;
}

.qna-form__hint {
    font-size: 13px;
    color: var(--qna-muted);
}

.qna-alert {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
}

.qna-alert--error {
    background: #FDECEF;
    color: var(--qna-danger);
}

.qna-thanks {
    padding: 20px 24px;
    border-radius: 16px;
    background: var(--qna-green-bg);
    color: var(--qna-green-dark);
    font-size: 16px;
    font-weight: 600;
}

/* ------------------------------------------------------------------- список */

.qna-item {
    padding-top: 32px;
    margin-top: 32px;
    border-top: 1px solid var(--qna-line);
}

.qna-list .qna-item:first-child {
    margin-top: 0;
}

.qna-item__question {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.qna-item__avatar {
    flex: 0 0 auto;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--qna-fill);
    color: var(--qna-muted);
    font-size: 24px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

.qna-item__body {
    min-width: 0;
    flex: 1 1 auto;
}

.qna-item__meta {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 8px;
}

.qna-item__author {
    font-size: 16px;
    font-weight: 700;
}

.qna-item__author--anon {
    font-weight: 400;
    color: var(--qna-muted);
}

.qna-item__avatar--anon {
    color: var(--qna-muted);
}

.qna-item__avatar--anon svg {
    display: block;
}

.qna-item__date {
    font-size: 14px;
    color: var(--qna-muted);
}

.qna-item__text {
    font-size: 16px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

/* ------------------------------------------------------- лайк вопроса */

/* Шаблон объявляет `button { -webkit-appearance: button }` (site.css:433),
   из-за чего iOS Safari подмешивает нативную отрисовку поверх наших фонов
   и радиусов. Гасим явно на обеих кнопках голосования. */
.qna-like,
.qna-helpful__btn {
    -webkit-appearance: none;
    appearance: none;
    font-family: inherit;
}

.qna-item__actions {
    margin-top: 12px;
}

.qna-like {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 14px;
    border: 1px solid var(--qna-line);
    border-radius: 100px;
    background: var(--qna-white);
    color: var(--qna-muted);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: .2s;
}

.qna-like:hover {
    border-color: var(--qna-green);
    color: var(--qna-green);
}

.qna-like--on {
    border-color: var(--qna-green);
    background: var(--qna-green-bg);
    color: var(--qna-green-dark);
}

/* Иконка — PNG-маска, а не картинка: так она окрашивается через currentColor
   и меняет цвет вместе с кнопкой при наведении и после голоса.
   Приём взят из faq_alleya/faq/faq.css. */
.qna-like__icon {
    display: block;
    flex: 0 0 auto;
    /* 20px, а не 16-18: у иконки тонкий контур (9.7% закрашенных пикселей
       против 19.2% у варианта с плюсом), на меньшем размере она бледнит. */
    width: 20px;
    height: 20px;
    background-color: currentColor;
    -webkit-mask-image: url("../img/qna-like.png?v=2");
    mask-image: url("../img/qna-like.png?v=2");
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-size: contain;
    mask-size: contain;
}

/* Браузеры без mask-image: показываем сам PNG. Он чёрный, поэтому
   состояние «проголосовано» будет видно только по фону и рамке. */
@supports not ((-webkit-mask-image: url("../img/qna-like.png")) or (mask-image: url("../img/qna-like.png"))) {
    .qna-like__icon {
        background-color: transparent;
        background-image: url("../img/qna-like.png?v=2");
        background-position: center;
        background-repeat: no-repeat;
        background-size: contain;
    }
}

.qna-like__count {
    font-weight: 600;
}

/* ---------------------------------------------------------- ответ и оценка */

.qna-item__answer {
    margin: 16px 0 0 78px; /* 62px аватар + 16px зазор */
    padding: 16px 20px;
    border-radius: 12px;
    background: var(--qna-fill);
}

.qna-helpful {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.qna-helpful__label {
    font-size: 14px;
    color: var(--qna-muted);
    margin-right: 4px;
}

.qna-helpful__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 14px;
    border: 1px solid var(--qna-line);
    border-radius: 100px;
    background: var(--qna-white);
    color: var(--qna-text);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: .2s;
}

.qna-helpful__btn:hover {
    border-color: var(--qna-green);
}

.qna-helpful__btn--on {
    border-color: var(--qna-green);
    background: var(--qna-green-bg);
    color: var(--qna-green-dark);
}

.qna-helpful__count {
    color: var(--qna-muted);
}

.qna-helpful__btn--on .qna-helpful__count {
    color: var(--qna-green-dark);
}

/* Кнопка остаётся кликабельной на вид, но запрос уже летит. */
.qna-vote--busy {
    opacity: .55;
    pointer-events: none;
}

.qna-item__answer-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--qna-green-dark);
    margin-bottom: 6px;
}

/* ---------------------------------------------------------- лучший ответ */

.qna-item__answer--best {
    background: var(--qna-green-bg);
    box-shadow: inset 0 0 0 1px var(--qna-green);
}

.qna-best {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 10px;
    padding: 5px 12px;
    border-radius: 100px;
    background: var(--qna-green);
    color: var(--qna-white);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
}

/* Тот же PNG, что у кнопки лайка: бейдж и кнопка про одно и то же —
   про пользу ответа, и общая иконка это связывает. */
.qna-best__icon {
    display: block;
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    background-color: currentColor;
    -webkit-mask-image: url("../img/qna-like.png?v=2");
    mask-image: url("../img/qna-like.png?v=2");
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-size: contain;
    mask-size: contain;
}

/* --------------------------------------------------- состояние «отправлено» */

/* Прячем именно панель и пустую плашку целиком, а не .qna-open-form:
   этот класс висит ещё и на ссылке ВНУТРИ предложения в пустой плашке,
   и её скрытие оставило бы висящее тире с запятой. */
.qna--submitted .qna-toolbar,
.qna--submitted .qna-empty {
    display: none;
}

/* ---------------------------------------------------------- сортировка */

.qna-sort {
    margin-top: 20px;
}

.qna-sort__row {
    display: inline-flex;
    border: 1px solid var(--qna-line);
    border-radius: 12px;
    overflow: hidden;
}

.qna-sort__btn {
    padding: 9px 18px;
    background: var(--qna-white);
    color: var(--qna-muted);
    font-size: 14px;
    border: none;
}

.qna-sort__btn + .qna-sort__btn {
    border-left: 1px solid var(--qna-line);
}

.qna-sort__btn.active {
    background: var(--qna-green-bg);
    color: var(--qna-green-dark);
    font-weight: 600;
}

/* --------------------------------------------------- подсказки в форме */

.qna-suggest {
    margin-top: 14px;
    padding: 14px 16px;
    border: 1px solid var(--qna-line);
    border-radius: 12px;
    background: var(--qna-fill);
}

.qna-suggest__title {
    font-size: 13px;
    font-weight: 600;
    color: var(--qna-green-dark);
    margin-bottom: 10px;
}

.qna-suggest__item + .qna-suggest__item {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--qna-line);
}

.qna-suggest__q {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.qna-suggest__a {
    font-size: 14px;
    color: var(--qna-muted);
}

/* --------------------------------------------------- пометка варианта */

.qna-item__variant {
    font-size: 12px;
    padding: 2px 9px;
    border-radius: 100px;
    background: var(--qna-fill);
    color: var(--qna-muted);
    white-space: nowrap;
}

/* ------------------------------------------------------ загрузка и ошибка */

.qna-loading {
    margin-top: 28px;
    font-size: 16px;
    color: var(--qna-muted);
}

.qna-list {
    margin-top: 28px;
}

.qna-load-error {
    margin-top: 24px;
    padding: 12px 16px;
    border-radius: 12px;
    background: #FDECEF;
    color: var(--qna-danger);
    font-size: 14px;
}

/* -------------------------------------------------------------- пустой блок */

.qna-empty {
    margin-top: 32px;
    padding: 32px;
    border: 1px dashed var(--qna-line);
    border-radius: 16px;
    text-align: center;
}

.qna-empty__title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.qna-empty__text {
    font-size: 16px;
    color: var(--qna-muted);
}

.qna-empty__link {
    color: var(--qna-green);
    text-decoration: underline;
    cursor: pointer;
}

.qna-empty__link:hover {
    color: var(--qna-green-dark);
}

/* Счётчик у заголовка вкладки и аккордеона. На десктопе рядом есть класс
   .count из шаблона, в мобильном такого правила нет — описываем сами. */
.qna-count {
    display: inline-block;
    margin-left: 6px;
    color: #A0B88D;
    font-weight: 600;
}

/* ------------------------------------------------------------- показать ещё */

.qna-more-wrap {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.qna-more {
    cursor: pointer;
}

.qna-more--loading {
    opacity: .6;
    pointer-events: none;
}

/* ------------------------------------------------------------------ мобилка */

@media (max-width: 800px) {
    .qna-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .qna-toolbar__note {
        font-size: 14px;
    }

    /* На 375 точках две подписи в строку не помещаются — растягиваем
       переключатель на всю ширину и ужимаем отступы. */
    .qna-sort__row {
        display: flex;
        width: 100%;
    }

    .qna-sort__btn {
        flex: 1 1 50%;
        padding: 9px 6px;
        font-size: 13px;
        text-align: center;
    }

    .qna-form {
        padding: 16px;
    }

    .qna-form__grid {
        gap: 0;
    }

    .qna-form__grid .qna-field {
        flex: 1 1 100%;
    }

    .qna-item__avatar {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    .qna-item__answer {
        margin-left: 0;
        padding: 12px 16px;
    }

    .qna-helpful {
        gap: 6px;
    }

    .qna-helpful__label {
        flex: 1 1 100%;
        margin-right: 0;
        font-size: 13px;
    }

    .qna-item {
        padding-top: 24px;
        margin-top: 24px;
    }

    .qna-empty {
        padding: 24px 16px;
    }
}
