/**
 * Нижняя панель магазина (JoomShopping).
 *
 * @version      1.2.3 03.09.2026
 * @author       Claude (Anthropic)
 * @package      mod_jsbottombar
 * @license      GNU/GPL
 */

.jsbb {
    --jsbb-bg: #333333;
    --jsbb-fg: #cccccc;
    --jsbb-accent: #ef0a41;
    --jsbb-btn-fg: #ffffff;
    --jsbb-z: 1030;
    --jsbb-h: 48px;

    position: fixed;
    left: 0;
    right: 0;
    z-index: var(--jsbb-z);
    box-sizing: border-box;
    background: var(--jsbb-bg);
    color: var(--jsbb-fg);
    font-size: 14px;
    line-height: 1.2;
    /* Шаблоны любят выравнивать содержимое своих позиций по центру или по
       правому краю — панель и окно задают выравнивание сами. */
    text-align: left;
    box-shadow: 0 -1px 6px rgba(0, 0, 0, .18);
}

.jsbb--bottom {
    bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.jsbb--top {
    top: 0;
    box-shadow: 0 1px 6px rgba(0, 0, 0, .18);
}

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

.jsbb__inner {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 8px;
    min-height: var(--jsbb-h);
    margin: 0 auto;
    padding: 0 10px;
    max-width: 1400px;
}

.jsbb__left {
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
}

.jsbb__left > * {
    margin: 0;
}

.jsbb__right {
    display: flex;
    align-items: stretch;
    justify-content: flex-end;
    margin-left: auto;
    gap: 2px;
}

/* Вкладки: закладки и корзина */

.jsbb__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    color: var(--jsbb-fg);
    text-decoration: none;
    border-left: 1px solid rgba(255, 255, 255, .12);
    transition: background-color .15s ease, color .15s ease;
}

.jsbb__item:hover,
.jsbb__item:focus-visible {
    color: #ffffff;
    text-decoration: none;
    background: rgba(0, 0, 0, .22);
}

.jsbb__icon {
    display: inline-flex;
    align-items: center;
    color: var(--jsbb-accent);
}

.jsbb__icon svg {
    display: block;
}

.jsbb-is-empty .jsbb__icon {
    color: currentColor;
    opacity: .65;
}

.jsbb__label {
    white-space: nowrap;
}

.jsbb__badge {
    display: inline-block;
    min-width: 26px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--jsbb-accent);
    color: var(--jsbb-btn-fg);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.jsbb-is-empty .jsbb__badge {
    background: rgba(255, 255, 255, .16);
    color: inherit;
    font-weight: 400;
}

.jsbb__sum {
    white-space: nowrap;
    font-weight: 600;
    color: #ffffff;
}

.jsbb-is-empty .jsbb__sum {
    display: none;
}

/* Кнопка «Оформить заказ» */

.jsbb__checkout {
    display: flex;
    align-items: center;
    margin: 6px 0 6px 10px;
    padding: 0 18px;
    border-radius: 4px;
    background: var(--jsbb-accent);
    color: var(--jsbb-btn-fg);
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    transition: filter .15s ease;
}

.jsbb__checkout:hover,
.jsbb__checkout:focus-visible {
    color: var(--jsbb-btn-fg);
    text-decoration: none;
    filter: brightness(1.12);
}

.jsbb__checkout.jsbb-is-empty {
    background: rgba(255, 255, 255, .14);
    color: var(--jsbb-fg);
    filter: none;
    cursor: default;
}

/* Модуль в левом слоте («Задать вопрос» и подобные) не должен тащить
   собственные рамки и отступы внутрь панели. */

.jsbb__left .moduletable,
.jsbb__left .module,
.jsbb__left .card {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
}

.jsbb__left a {
    color: var(--jsbb-fg);
}

.jsbb__left a:hover {
    color: #ffffff;
}

@media (max-width: 900px) {
    .jsbb__item {
        padding: 6px 10px;
        gap: 6px;
    }

    .jsbb__checkout {
        padding: 0 12px;
        margin-left: 6px;
    }
}

@media (max-width: 700px) {
    .jsbb__item .jsbb__label {
        display: none;
    }

    .jsbb__sum {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .jsbb__left {
        display: none;
    }

    .jsbb__inner {
        padding: 0 6px;
    }

    .jsbb__item {
        border-left: 0;
        padding: 6px 8px;
    }

    .jsbb__right {
        width: 100%;
        justify-content: space-between;
    }

    .jsbb__checkout {
        flex: 1 1 auto;
        justify-content: center;
        margin-left: 4px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .jsbb__item,
    .jsbb__checkout {
        transition: none;
    }
}

/* Кнопка «Задать вопрос» в левой части панели */

.jsbb__ask {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 6px 12px;
    border: 0;
    background: none;
    color: var(--jsbb-fg);
    font: inherit;
    line-height: 1.2;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color .15s ease, color .15s ease;
}

.jsbb__ask:hover,
.jsbb__ask:focus-visible {
    color: #ffffff;
    background: rgba(0, 0, 0, .22);
}

.jsbb__ask .jsbb__icon {
    color: var(--jsbb-accent);
}

/* Окно с формой вопроса */

.jsbb-modal {
    width: min(460px, calc(100vw - 24px));
    max-height: calc(100vh - 40px);
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: #ffffff;
    color: #222222;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
    overflow: visible;
}

.jsbb-modal::backdrop {
    background: rgba(0, 0, 0, .55);
}

.jsbb-modal__box {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: calc(100vh - 40px);
    padding: 24px 24px 20px;
    overflow-y: auto;
    font-size: 15px;
    line-height: 1.4;
    text-align: left;
}

.jsbb-modal__close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    background: none;
    color: #888888;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
}

.jsbb-modal__close:hover,
.jsbb-modal__close:focus-visible {
    color: #222222;
    background: #f1f1f1;
}

.jsbb-modal__title {
    margin: 0 30px 0 0;
    font-size: 20px;
    line-height: 1.25;
    color: inherit;
}

.jsbb-modal__intro {
    margin: 0;
    color: #666666;
    font-size: 14px;
}

.jsbb-modal__field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.jsbb-modal__label {
    font-size: 13px;
    color: #555555;
}

.jsbb-modal__hint {
    color: #999999;
}

.jsbb-modal__field input,
.jsbb-modal__field textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    border: 1px solid #d5d5d5;
    border-radius: 6px;
    background: #ffffff;
    color: #222222;
    font: inherit;
    resize: vertical;
}

.jsbb-modal__field input:focus,
.jsbb-modal__field textarea:focus {
    outline: none;
    border-color: var(--jsbb-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--jsbb-accent) 22%, transparent);
}

.jsbb-modal__field.jsbb-has-error input,
.jsbb-modal__field.jsbb-has-error textarea {
    border-color: #d93025;
}

.jsbb-modal__error {
    display: none;
    color: #d93025;
    font-size: 13px;
}

.jsbb-has-error .jsbb-modal__error {
    display: block;
}

.jsbb-modal__consent {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 8px;
    align-items: start;
    font-size: 13px;
    color: #666666;
}

.jsbb-modal__consent input {
    margin: 3px 0 0;
}

.jsbb-modal__consent .jsbb-modal__error {
    grid-column: 2;
}

.jsbb-modal__consent a {
    color: var(--jsbb-accent);
}

.jsbb-modal__trap {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.jsbb-modal__msg {
    display: none;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 14px;
}

.jsbb-modal__msg.jsbb-is-ok {
    display: block;
    background: #e8f5e9;
    color: #1b5e20;
}

.jsbb-modal__msg.jsbb-is-error {
    display: block;
    background: #fdecea;
    color: #b3261e;
}

.jsbb-modal__submit {
    margin-top: 4px;
    padding: 11px 18px;
    border: 0;
    border-radius: 6px;
    background: var(--jsbb-accent);
    color: var(--jsbb-btn-fg);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.jsbb-modal__submit:hover:not(:disabled),
.jsbb-modal__submit:focus-visible:not(:disabled) {
    filter: brightness(1.1);
}

.jsbb-modal__submit:disabled {
    opacity: .6;
    cursor: default;
}

/* Запасной вариант для браузеров без <dialog>.showModal() */

.jsbb-modal.jsbb-modal--fallback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: calc(var(--jsbb-z) + 10);
}

.jsbb-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: calc(var(--jsbb-z, 1030) + 9);
    background: rgba(0, 0, 0, .55);
}

@media (max-width: 480px) {
    /* Слева на телефоне остаётся только кнопка вопроса, значком: чужие модули
       туда не помещаются. */
    .jsbb__left {
        display: flex;
    }

    .jsbb__left > *:not(.jsbb__ask) {
        display: none;
    }

    .jsbb__ask .jsbb__label {
        display: none;
    }

    .jsbb__ask {
        padding: 6px 8px;
    }

    .jsbb-modal__box {
        padding: 20px 16px 16px;
    }
}

/* Обёртка модуля остаётся в потоке пустой: сама панель фиксирована.
   В позиции внутри подвала это давало заметную дыру.

   Было `:has(> .jsbb)` — только прямой потомок, и правило не срабатывало
   вовсе: Helix Ultimate заворачивает вывод модуля ещё в один слой,
   `.sp-module > .sp-module-content > .jsbb`. В подвале из-за этого висела
   пустая коробка на 138 px. Теперь ищем панель на любой глубине и убираем
   сам блок обёртки через `display: contents`: её содержимое (панель и окно
   «Задать вопрос») зафиксировано и места в потоке не занимает, а заголовок
   модуля, если владелец его оставил, продолжает выводиться как раньше. */

.sp-module:has(.jsbb),
.sp-module-content:has(.jsbb),
.moduletable:has(.jsbb),
.module:has(.jsbb),
.card:has(.jsbb) {
    display: contents;
}

#jsbb-spacer {
    width: 100%;
}
