/*
 * SWEB Market — выдвижные панели (мобильное меню, корзина, фильтр)
 * и общая модалка (быстрый просмотр, быстрый заказ).
 */

.sw-drawer {
    position: fixed;
    inset: 0;
    z-index: var(--sw-z-drawer);
}

.sw-drawer[hidden] {
    display: none;
}

.sw-drawer__backdrop {
    position: absolute;
    inset: 0;
    background: var(--sw-backdrop);
    animation: sw-fade-in .15s ease-out;
}

.sw-drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    width: min(420px, 100vw);
    height: 100%;
    background: var(--sw-surface);
    box-shadow: var(--sw-shadow-lg);
    animation: sw-slide-right .2s ease-out;
}

.sw-drawer--left .sw-drawer__panel {
    right: auto;
    left: 0;
    animation-name: sw-slide-left;
}

.sw-drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--sw-border);
}

.sw-drawer__title {
    font-size: 1.0625rem;
    font-weight: 600;
}

.sw-drawer__body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.sw-drawer__foot {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    border-top: 1px solid var(--sw-border);
}

@keyframes sw-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes sw-slide-right {
    from { transform: translateX(100%); }
    to   { transform: none; }
}

@keyframes sw-slide-left {
    from { transform: translateX(-100%); }
    to   { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .sw-drawer__backdrop,
    .sw-drawer__panel {
        animation: none;
    }
}

/* ------------------------------------------------------- Корзина в шторке -- */

.sw-cart {
    position: relative;
}

.sw-cart__list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sw-cart__item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.sw-cart__thumb {
    flex: none;
    width: 64px;
    height: 64px;
    border: 1px solid var(--sw-border);
    border-radius: var(--sw-radius);
    overflow: hidden;
}

.sw-cart__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sw-cart__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.sw-cart__name {
    color: var(--sw-ink);
    font-size: .875rem;
    font-weight: 500;
}

.sw-cart__name:hover {
    color: var(--sw-primary);
}

.sw-cart__options,
.sw-cart__recurring {
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--sw-text-muted);
    font-size: .75rem;
}

.sw-cart__meta {
    color: var(--sw-text-dim);
    font-size: .8125rem;
}

.sw-cart__remove {
    flex: none;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: var(--sw-radius-sm);
    background: none;
    color: var(--sw-text-muted);
    cursor: pointer;
}

.sw-cart__remove:hover {
    color: var(--sw-danger);
}

.sw-cart__empty {
    padding: 32px 0;
    color: var(--sw-text-muted);
    text-align: center;
}

.sw-cart__totals {
    margin: 0 0 8px;
}

.sw-cart__total {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    font-size: .875rem;
}

.sw-cart__total dt,
.sw-cart__total dd {
    margin: 0;
}

.sw-cart__total:last-child {
    font-size: 1rem;
    font-weight: 700;
}

/* Ссылка «Перейти до кошика» под кнопками: третье действие рядом с двумя
   кнопками читалось бы как ещё одна кнопка и растащило бы внимание. */
.sw-cart__link {
    align-self: center;
    color: var(--sw-text-dim);
    font-size: .8125rem;
    text-decoration: underline;
}

.sw-cart__link:hover {
    color: var(--sw-primary);
}

/*
 * Только что добавленный товар. Подсветка гаснет сама через две секунды:
 * шторка после этого остаётся обычным списком корзины, и при добавлении
 * второго товара покупатель видит новую подсветку, а не две сразу.
 */
.sw-cart__item.is-added {
    animation: sw-cart-added 2s ease-out;
}

@keyframes sw-cart-added {
    from { background: rgba(var(--sw-primary-rgb), .14); }
    to   { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
    .sw-cart__item.is-added {
        animation: none;
    }
}

/* ------------------------------------------------------------- Модалка -- */

/*
 * Одна модалка на весь магазин: быстрый просмотр и быстрый заказ кладут в
 * неё готовый HTML со своих контроллеров. Разметку создаёт sw-common.js —
 * держать её в шаблоне шапки значило бы отдавать пустой диалог на каждой
 * странице, включая те, где ни одной кнопки-открывателя нет.
 */
.sw-modal {
    position: fixed;
    inset: 0;
    z-index: var(--sw-z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

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

.sw-modal__backdrop {
    position: absolute;
    inset: 0;
    background: var(--sw-backdrop);
    animation: sw-fade-in .15s ease-out;
}

.sw-modal__dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(980px, 100%);
    max-height: min(92vh, 100%);
    border-radius: var(--sw-radius-lg);
    background: var(--sw-surface);
    box-shadow: var(--sw-shadow-lg);
    animation: sw-modal-in .2s ease-out;
}

.sw-modal--narrow .sw-modal__dialog {
    width: min(460px, 100%);
}

.sw-modal__close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 1;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: var(--sw-radius);
    background: var(--sw-surface);
    color: var(--sw-text-dim);
    cursor: pointer;
}

.sw-modal__close:hover,
.sw-modal__close:focus-visible {
    color: var(--sw-primary);
}

.sw-modal__body {
    padding: 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Пока ответ контроллера не пришёл, диалог уже открыт и держит фокус —
   иначе кнопка «Швидкий перегляд» отвечала бы задержкой без признаков
   жизни, и покупатель нажимал бы её второй раз. */
.sw-modal__loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    color: var(--sw-text-muted);
}

@keyframes sw-modal-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .sw-modal__backdrop,
    .sw-modal__dialog {
        animation: none;
    }
}

@media (max-width: 575.98px) {
    .sw-modal {
        padding: 0;
        align-items: flex-end;
    }

    .sw-modal__dialog,
    .sw-modal--narrow .sw-modal__dialog {
        width: 100%;
        max-height: 94vh;
        border-radius: var(--sw-radius-lg) var(--sw-radius-lg) 0 0;
    }

    .sw-modal__body {
        padding: 20px 16px;
    }
}

/* ------------------------------------------------------ Быстрый просмотр -- */

.sw-qv {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
}

.sw-qv__gallery {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.sw-qv__stage {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    padding: 12px;
    border: 1px solid var(--sw-border);
    border-radius: var(--sw-radius);
    background: #fff;
}

.sw-qv__stage img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.sw-qv__thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

.sw-qv__thumb {
    flex: none;
    width: 56px;
    height: 56px;
    padding: 4px;
    border: 1px solid var(--sw-border-strong);
    border-radius: var(--sw-radius-sm);
    background: #fff;
    cursor: pointer;
}

.sw-qv__thumb.is-active {
    border-color: var(--sw-primary);
}

.sw-qv__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sw-qv__info {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.sw-qv__title {
    margin: 0;
    padding-right: 44px;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
}

.sw-qv__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    color: var(--sw-text-dim);
    font-size: .8125rem;
}

.sw-qv__price {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px;
}

.sw-qv__price-new {
    font-size: 1.5rem;
    font-weight: 700;
}

.sw-qv__price-new.is-special {
    color: var(--sw-danger);
}

.sw-qv__price-old {
    color: var(--sw-text-muted);
}

.sw-qv__specs {
    margin: 0;
}

.sw-qv__spec {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
    border-bottom: var(--sw-border-dashed);
    font-size: .8125rem;
}

.sw-qv__spec dt {
    color: var(--sw-text-dim);
    font-weight: 400;
}

.sw-qv__spec dd {
    margin: 0;
    text-align: right;
}

.sw-qv__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sw-qv__actions .sw-qty {
    flex: none;
}

.sw-qv__actions .sw-qv__buy {
    flex: 1;
    min-width: 140px;
}

.sw-qv__more {
    align-self: flex-start;
}

@media (max-width: 767.98px) {
    .sw-qv {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }

    .sw-qv__stage {
        aspect-ratio: 4 / 3;
    }
}

/* ------------------------------------------------- Форма в модалке ------- */

/*
 * Общая вёрстка коротких форм в диалоге: быстрый заказ, обратный звонок,
 * «сообщить о наличии». Блок один на всех, потому что и форма одна и та же —
 * заголовок, пояснение, товар, два поля и кнопка. Своя копия стилей на
 * каждую расходилась бы по мелочам, а чинить пришлось бы в трёх местах.
 */

.sw-popform__title {
    margin: 0 44px 4px 0;
    font-size: 1.125rem;
    font-weight: 700;
}

.sw-popform__lead {
    margin: 0 0 16px;
    color: var(--sw-text-dim);
    font-size: .875rem;
}

.sw-popform__product {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    padding: 12px;
    border-radius: var(--sw-radius);
    background: var(--sw-bg);
}

.sw-popform__thumb {
    flex: none;
    width: 56px;
    height: 56px;
    border-radius: var(--sw-radius-sm);
    background: #fff;
    object-fit: contain;
}

.sw-popform__name {
    display: block;
    color: var(--sw-ink);
    font-size: .875rem;
    font-weight: 500;
}

.sw-popform__sum {
    color: var(--sw-text-dim);
    font-size: .8125rem;
}

.sw-popform__fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sw-popform__note {
    margin: 0;
    color: var(--sw-text-muted);
    font-size: .75rem;
}

/*
 * Ловушка для ботов. Не `display: none` и не `hidden`: часть спам-скриптов
 * такие поля пропускает именно потому, что их не видно. Поле остаётся в
 * потоке для машины и уезжает за край экрана для человека.
 */
.sw-popform__trap {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.sw-popform__done {
    padding: 16px 0;
    text-align: center;
}

.sw-popform__done-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    color: var(--sw-success);
}

.sw-popform__done-title {
    margin: 0 0 8px;
    font-size: 1.125rem;
    font-weight: 700;
}

.sw-popform__done-text {
    margin: 0 0 16px;
    color: var(--sw-text-dim);
    font-size: .875rem;
}
