/* ═══════════════════════════════════════════
   QPT Cart Widget — v1.0.0
   ═══════════════════════════════════════════ */

/* Блокировка скролла при открытом ящике */
body.qpt-cw-no-scroll {
    overflow: hidden;
}

/* ══════════════════════════════════════════
   Кнопка мини-корзины (fixed bottom-right)
   ══════════════════════════════════════════ */

.qpt-cw-btn {
    position: fixed;
    top: 140px;
    bottom: auto;
    right: 24px;
    width: 62px;
    height: 62px;
    background: #20B8AD;
    color: #fff;
    border-radius: 50%;
    display: -webkit-flex;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9990;
    box-shadow: 0 4px 22px rgba(32, 184, 173, 0.45);
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
    -webkit-user-select: none;
    user-select: none;
}

.qpt-cw-btn:hover {
    background: #1a9b92;
    transform: scale(1.07);
    box-shadow: 0 6px 30px rgba(32, 184, 173, 0.55);
}

.qpt-cw-btn:active {
    transform: scale(0.94);
}

/* Переключение иконок корзина ↔ сердце */

.qpt-cw-icon--heart {
    display: none;
}

.qpt-cw-btn--heart .qpt-cw-icon--cart {
    display: none;
}

.qpt-cw-btn--heart .qpt-cw-icon--heart {
    display: block;
}

/* Анимация bounce при добавлении товара */
@keyframes qptcw-bounce {
    0%   { transform: scale(1); }
    25%  { transform: scale(1.28); }
    50%  { transform: scale(0.91); }
    75%  { transform: scale(1.10); }
    100% { transform: scale(1); }
}

.qpt-cw-btn.qpt-cw-btn--added {
    animation: qptcw-bounce 0.65s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* ── Счётчик позиций ── */

.qpt-cw-count {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    background: #fff;
    color: #20B8AD;
    font-size: 11px;
    font-weight: 800;
    border-radius: 11px;
    display: -webkit-flex;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 1px 5px rgba(0,0,0,0.22);
    box-sizing: border-box;
}

/* ══════════════════════════════════════════
   Пузырёк уведомления
   ══════════════════════════════════════════ */

.qpt-cw-bubble {
    position: fixed;
    top: 216px;
    bottom: auto;
    right: 24px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.14);
    padding: 11px 14px;
    max-width: 290px;
    z-index: 9991;
    opacity: 0;
    transform: translateY(10px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.28s ease;
}

.qpt-cw-bubble.qpt-cw-bubble--visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.qpt-cw-bubble__inner {
    display: -webkit-flex;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: #1a1a1a;
}

.qpt-cw-bubble__inner svg {
    flex-shrink: 0;
    color: #2e7d32;
    margin-top: 1px;
}

.qpt-cw-bubble__text {
    font-size: 13px;
    line-height: 1.45;
    font-weight: 500;
}

/* ══════════════════════════════════════════
   Оверлей
   ══════════════════════════════════════════ */

.qpt-cw-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.42);
    z-index: 9992;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.32s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.qpt-cw-overlay.qpt-cw-overlay--active {
    opacity: 1;
    pointer-events: auto;
}

/* ══════════════════════════════════════════
   Боковой ящик (drawer)
   ══════════════════════════════════════════ */

.qpt-cw-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 390px;
    max-width: 95vw;
    height: 100vh;
    height: 100dvh; /* точная высота без адресной строки */
    background: #fff;
    z-index: 9993;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    box-shadow: -6px 0 40px rgba(0, 0, 0, 0.11);
    transform: translateX(100%);
    -webkit-transform: translateX(100%);
    transition: transform 0.36s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-transition: -webkit-transform 0.36s cubic-bezier(0.4, 0, 0.2, 1);
}

.qpt-cw-drawer.qpt-cw-drawer--open {
    transform: translateX(0);
    -webkit-transform: translateX(0);
}

/* ── Шапка ── */

.qpt-cw-drawer__header {
    display: -webkit-flex;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
    -webkit-flex-shrink: 0;
}

/* ── Вкладки (Корзина / Избранное) ── */

.qpt-cw-tabs {
    display: -webkit-flex;
    display: flex;
    flex: 1 1 auto;
    gap: 6px;
    background: #f5f5f5;
    border-radius: 10px;
    padding: 4px;
}

.qpt-cw-tab {
    -webkit-flex: 1;
    flex: 1;
    height: 32px;
    padding: 0 10px;
    border: none;
    background: transparent;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    display: -webkit-inline-flex;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: background 0.18s, color 0.18s;
    white-space: nowrap;
}

.qpt-cw-tab:hover:not(.qpt-cw-tab--active) {
    color: #444;
    background: rgba(0, 0, 0, 0.05);
}

.qpt-cw-tab--active {
    background: #fff;
    color: #1a1a1a;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.10);
}

.qpt-cw-tab__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #20B8AD;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 9px;
    line-height: 1;
    box-sizing: border-box;
}

.qpt-cw-tab:not(.qpt-cw-tab--active) .qpt-cw-tab__count {
    background: #d1d5db;
    color: #555;
}

/* .qpt-cw-drawer__title — заменён на .qpt-cw-tabs */

.qpt-cw-close {
    width: 34px;
    height: 34px;
    border: none;
    background: #f5f5f5;
    border-radius: 50%;
    cursor: pointer;
    color: #777;
    font-size: 14px;
    display: -webkit-flex;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    padding: 0;
    line-height: 1;
}

.qpt-cw-close:hover {
    background: #ececec;
    color: #222;
}

/* ── Тело (прокручиваемая область) ── */

.qpt-cw-drawer__body {
    flex: 1 1 0%;       /* 0% basis: растёт от 0, не пытается влезть в контент */
    -webkit-flex: 1 1 0%;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Пустая корзина ── */

.qpt-cw-empty {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    color: #bbb;
    gap: 14px;
    padding: 40px 20px;
}

.qpt-cw-empty p {
    font-size: 15px;
    margin: 0;
    color: #aaa;
}

/* ── Список позиций ── */

.qpt-cw-items {
    list-style: none;
    margin: 0;
    padding: 0;
}

.qpt-cw-item {
    display: -webkit-flex;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid #f4f4f4;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.qpt-cw-item.qpt-cw-item--removing {
    opacity: 0;
    transform: translateX(18px);
}

.qpt-cw-item__img {
    flex-shrink: 0;
    -webkit-flex-shrink: 0;
    width: 68px;
    height: auto;
    aspect-ratio: 3 / 4;
    border-radius: 8px;
    overflow: hidden;
    background: #f7f7f7;
}

.qpt-cw-item__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.qpt-cw-item__info {
    flex: 1 1 auto;
    -webkit-flex: 1 1 auto;
    min-width: 0;
}

.qpt-cw-item__name-row {
    display: -webkit-flex;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 3px;
    flex-wrap: wrap;
}

.qpt-cw-item__name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    text-decoration: none;
    line-height: 1.35;
    min-width: 0;
}

.qpt-cw-item__name:hover {
    color: #20B8AD;
}

/* Плашка предзаказа в виджете корзины */
.qpt-cw-item__name-row .qpt-preorder-badge {
    flex-shrink: 0;
    margin-top: 2px;
    margin-left: 0;
}

.qpt-cw-item__var {
    display: block;
    font-size: 12px;
    color: #999;
    margin-bottom: 6px;
    line-height: 1.3;
}

.qpt-cw-item__meta {
    display: -webkit-flex;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Контрол количества ── */

.qpt-cw-qty-ctrl {
    display: -webkit-inline-flex;
    display: inline-flex;
    align-items: center;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    height: 32px;
}

.qpt-cw-qty-btn {
    width: 30px;
    height: 100%;
    border: none;
    background: #f8f9fa;
    color: #374151;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: -webkit-flex;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    -webkit-flex-shrink: 0;
}

.qpt-cw-qty-btn:hover:not(:disabled) {
    background: #e5e7eb;
    color: #1a1a1a;
}

.qpt-cw-qty-btn:disabled {
    color: #d1d5db;
    cursor: default;
}

.qpt-cw-qty-input {
    width: 38px;
    height: 100%;
    border: none;
    border-left: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    padding: 0;
    background: #fff;
    -moz-appearance: textfield;
    outline: none;
}

.qpt-cw-qty-input::-webkit-outer-spin-button,
.qpt-cw-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Состояние "обновляется" */
.qpt-cw-item--updating {
    pointer-events: none;
}

.qpt-cw-item--updating .qpt-cw-qty-ctrl {
    opacity: 0.5;
}

.qpt-cw-item--updating .qpt-cw-item__total {
    opacity: 0.4;
}

.qpt-cw-item__total-wrap {
    display: -webkit-flex;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.qpt-cw-item__total {
    font-size: 14px;
    font-weight: 700;
    color: #20B8AD;
}

.qpt-cw-item__total .woocommerce-Price-amount {
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
}

.qpt-cw-item__unit-price {
    font-size: 11px;
    color: #999;
    white-space: nowrap;
}

.qpt-cw-item__unit-price .woocommerce-Price-amount {
    font-size: inherit;
    color: inherit;
}

.qpt-cw-item__remove {
    flex-shrink: 0;
    -webkit-flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #ccc;
    cursor: pointer;
    font-size: 12px;
    display: -webkit-flex;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
    padding: 0;
    margin-top: -2px;
}

.qpt-cw-item__remove:hover {
    background: #fff0f0;
    color: #c0392b;
}

/* ── Итог ── */

.qpt-cw-totals {
    padding: 14px 20px;
    border-top: 2px solid #f0f0f0;
    background: #fafafa;
}

.qpt-cw-totals__row {
    display: -webkit-flex;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 15px;
}

.qpt-cw-totals__row span {
    color: #666;
}

.qpt-cw-totals__row strong {
    font-size: 22px;
    color: #1a1a1a;
    font-weight: 700;
}

.qpt-cw-totals__row strong .woocommerce-Price-amount {
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
}

/* ── Ссылка «Войти» в гостевой панели избранного ── */

.qpt-cw-wl-login-link {
    display: inline-block;
    margin-top: 14px;
    background: #1a1a1a;
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 22px;
    border-radius: 8px;
    transition: background .18s;
}

.qpt-cw-wl-login-link:hover {
    background: #333;
}

/* ── Подвал (кнопка оформления) ── */

.qpt-cw-drawer__footer {
    padding: 16px 20px 24px;
    flex-shrink: 0;
    -webkit-flex-shrink: 0;
    border-top: 1px solid #f0f0f0;
}

.qpt-cw-checkout-btn {
    display: block;
    width: 100%;
    padding: 14px 20px;
    background: #20B8AD;
    color: #fff;
    text-align: center;
    font-size: 15px;
    font-weight: 700;
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
    box-sizing: border-box;
}

.qpt-cw-checkout-btn:hover,
.qpt-cw-checkout-btn:focus {
    background: #1a9b92;
    color: #fff;
    text-decoration: none;
}

.qpt-cw-checkout-btn:active {
    transform: scale(0.98);
}

/* ══════════════════════════════════════════
   Адаптив
   ══════════════════════════════════════════ */

@media (max-width: 768px) {
    .qpt-cw-btn {
        top: auto;
        bottom: 86px;
        right: 26px;
        width: 54px;
        height: 54px;
    }

    .qpt-cw-bubble {
        top: auto;
        bottom: 154px;
        right: 26px;
        max-width: calc(100vw - 32px);
    }

    .qpt-cw-drawer {
        width: 100vw;
        max-width: 100vw;
    }
}
