/* ─── Cart Page ─── */

.em-cart {
    padding-top: 32px;
    padding-bottom: 80px;
    min-height: 100vh;
    /* Предотвращаем горизонтальный скролл на мобильных */
    overflow-x: hidden;
}

.em-cart__title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 900;
    color: var(--white);
    letter-spacing: -0.03em;
    margin-bottom: 32px;
}
.em-cart__title i { color: var(--neon); }
.em-cart__count {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--silver-3);
    margin-left: 4px;
}

/* Layout: items + sidebar */
.em-cart__layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
    /* Гарантируем что дочерние элементы не выходят за 100% */
    min-width: 0;
}
@media (min-width: 900px) {
    .em-cart__layout {
        grid-template-columns: 1fr 380px;
        gap: 40px;
    }
}

/* ─── Cart Item ─── */
.em-cart__item {
    display: flex;
    gap: 16px;
    padding: 20px;
    background: var(--black-2);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: var(--r-md);
    margin-bottom: 12px;
    transition: border-color 0.2s var(--ease);
}
.em-cart__item:hover { border-color: rgba(255,255,255,0.08); }

.em-cart__item-img {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
    border-radius: var(--r-sm);
    overflow: hidden;
    background: var(--black-3);
}
.em-cart__item-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.em-cart__item-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.em-cart__item-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.em-cart__item-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--white);
    line-height: 1.4;
}
.em-cart__item-name a { color: inherit; transition: color 0.2s; }
.em-cart__item-name a:hover { color: var(--neon); }

.em-cart__item-sku {
    display: block;
    font-size: 0.75rem;
    color: var(--silver-3);
    margin-top: 2px;
}

.em-cart__item-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--r-sm);
    color: var(--silver-3);
    transition: all 0.2s var(--ease);
    flex-shrink: 0;
    background: transparent;
    cursor: pointer;
    border: none;
}
@media (max-width: 599px) {
    .em-cart__item-remove { width: 44px; height: 44px; }
}
.em-cart__item-remove:hover {
    background: rgba(255,107,44,0.1);
    color: var(--orange);
}

.em-cart__item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    gap: 16px;
}

.em-cart__qty-wrap .quantity {
    display: flex;
    align-items: center;
}
.em-cart__qty-wrap .qty {
    width: 56px;
    height: 40px;
    background: var(--black-3);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--r-sm);
    color: var(--white);
    font-family: var(--font);
    font-size: 0.9375rem;
    font-weight: 600;
    text-align: center;
    padding: 0;
}
.em-cart__qty-wrap .qty:focus {
    outline: none;
    border-color: var(--neon);
}

.em-cart__item-price {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--white);
    white-space: nowrap;
}
.em-cart__item-price del {
    font-size: 0.8125rem;
    color: var(--silver-3);
    font-weight: 400;
}
.em-cart__item-price ins {
    text-decoration: none;
    color: var(--neon);
}

/* ─── Cart Actions ─── */
.em-cart__actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.em-cart__coupon {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}
.em-cart__coupon .input-text {
    background: var(--black-2);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--r-md);
    color: var(--white);
    font-family: var(--font);
    font-size: 0.875rem;
    padding: 10px 16px;
    width: 180px;
    min-width: 0;
    flex: 1;
}
.em-cart__coupon .input-text::placeholder { color: var(--silver-3); }
.em-cart__coupon .input-text:focus {
    outline: none;
    border-color: var(--neon);
}
.em-cart__coupon-btn {
    background: var(--black-3);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--r-md);
    color: var(--silver);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}
.em-cart__coupon-btn:hover {
    border-color: var(--neon);
    color: var(--neon);
}

.em-cart__update-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--r-md);
    color: var(--silver-3);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}
.em-cart__update-btn:hover {
    border-color: var(--silver);
    color: var(--silver);
}

/* ─── Sidebar / Totals ─── */
.em-cart__totals {
    background: var(--black-2);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: var(--r-lg);
    padding: 24px;
    position: sticky;
    top: calc(var(--header-h) + 24px);
    max-width: 100%;
    overflow-x: hidden;
}
@media (max-width: 899px) {
    .em-cart__totals { position: static; }
}

.em-cart__totals-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--white);
    margin-bottom: 20px;
}

.em-cart__totals-rows {
    margin-bottom: 20px;
}
.em-cart__totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 0.9375rem;
    color: var(--silver-2);
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.em-cart__totals-row:last-child { border-bottom: none; }
.em-cart__totals-row--discount span:last-child {
    color: var(--neon);
    font-weight: 600;
}

/* ─── Блок доставки (заменяет стандартную totals-row для shipping) ─── */
.em-cart__totals-shipping {
    padding: 12px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.em-cart__totals-shipping-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--silver-2);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
}
.em-cart__totals-shipping .woocommerce-shipping-methods {
    list-style: none;
    margin: 0 0 8px;
    padding: 0;
}
.em-cart__totals-shipping .woocommerce-shipping-methods li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
}
.em-cart__totals-shipping .woocommerce-shipping-methods input[type="radio"] {
    accent-color: var(--neon);
    width: 16px;
    height: 16px;
    min-width: 16px;
    cursor: pointer;
    margin: 0;
}
.em-cart__totals-shipping .woocommerce-shipping-methods label {
    font-size: 0.875rem;
    color: var(--silver);
    cursor: pointer;
    margin: 0;
    line-height: 1.4;
}
/* Скрываем цену ($0.00) в способах доставки - она посчитается в "К оплате" */
.em-cart__totals-shipping .woocommerce-Price-amount {
    font-size: 0.8125rem;
    color: var(--silver-3);
}
.em-cart__totals-shipping .woocommerce-shipping-destination {
    font-size: 0.75rem;
    color: var(--silver-3);
    line-height: 1.5;
    margin: 6px 0 0;
}
.em-cart__totals-shipping p {
    font-size: 0.75rem;
    color: var(--silver-3);
    margin: 4px 0 0;
}
/* Заголовок пакета (если несколько пакетов) */
.em-cart__totals-shipping .woocommerce-shipping-package {
    margin-bottom: 8px;
}

/* Legacy - остаем для обратной совместимости если WC рендерит в старом месте */
.em-cart__totals-row .woocommerce-shipping-methods {
    list-style: none;
    text-align: right;
}
.em-cart__totals-row .woocommerce-shipping-methods label {
    font-size: 0.875rem;
    color: var(--silver);
}

.em-cart__totals-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 1.125rem;
    font-weight: 800;
    color: var(--white);
}
.em-cart__totals-total .woocommerce-Price-amount {
    font-size: 1.375rem;
    font-weight: 900;
    color: var(--neon);
}

/* Checkout button */
.em-cart__checkout-btn-wrap {
    margin-top: 20px;
}
.em-cart__checkout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    background: var(--neon);
    color: var(--black);
    font-family: var(--font);
    font-size: 1.0625rem;
    font-weight: 700;
    padding: 16px 24px;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: all 0.2s var(--ease);
    border: none;
}
.em-cart__checkout-btn:hover {
    background: #4dff33;
    box-shadow: 0 0 24px rgba(57,255,20,0.3);
    transform: translateY(-1px);
    color: var(--black);
}

/* Sidebar trust */
.em-cart__sidebar-trust {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.04);
}
.em-cart__sidebar-trust div {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    color: var(--silver-3);
}
.em-cart__sidebar-trust i {
    color: var(--neon);
    width: 16px;
    text-align: center;
}

/* ─── Continue shopping ─── */
.em-cart__continue {
    margin-top: 32px;
}
.em-cart__continue-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--silver-3);
    font-size: 0.9375rem;
    font-weight: 500;
    transition: color 0.2s var(--ease);
}
.em-cart__continue-link:hover { color: var(--neon); }

/* ─── Empty cart ─── */
.woocommerce-cart .cart-empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--silver-2);
    font-size: 1.125rem;
}
.woocommerce-cart .cart-empty::before {
    content: "\f07a";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    display: block;
    font-size: 3rem;
    color: var(--silver-3);
    margin-bottom: 16px;
}
.woocommerce-cart .return-to-shop {
    text-align: center;
    margin-top: 24px;
}

/* ─── Mobile ─── */
@media (max-width: 599px) {
    /* Корзина - исправляем перенос товаров */
    .em-cart__item { flex-direction: column; padding: 16px; }
    .em-cart__item-img { width: 100%; height: 200px; }
    .em-cart__item-name { font-size: 0.9375rem; }

    /* Промокод - растягиваем на всю ширину, ничего не выходит за край */
    .em-cart__actions {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .em-cart__coupon {
        width: 100%;
    }
    .em-cart__coupon .input-text {
        width: 100%;
        flex: 1;
        font-size: 16px;
        min-height: 44px;
        padding: 12px 16px;
    }
    .em-cart__coupon-btn,
    .em-cart__update-btn {
        width: 100%;
        justify-content: center;
        min-height: 44px;
        font-size: 0.9375rem;
    }

    /* Блок Итого - убрать лишние отступы */
    .em-cart__totals {
        padding: 20px 16px;
    }
    .em-cart__title { font-size: 1.375rem; margin-bottom: 20px; }
    .em-cart__count { display: block; margin-left: 0; margin-top: 4px; }
    .em-cart__checkout-btn { font-size: 1rem; padding: 14px 20px; }
}

/* ── Empty cart ── */
.em-cart__empty {
    text-align: center;
    padding: 80px 24px;
}
.em-cart__empty-icon {
    font-size: 3rem;
    color: var(--silver-3);
    margin-bottom: 20px;
}
.em-cart__empty h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 8px;
}
.em-cart__empty p {
    font-size: 0.9375rem;
    color: var(--silver-2);
    margin-bottom: 24px;
}

/* ── Предзаказ в строке корзины (см. inc/preorder.php) ──
   Базовые .em-preorder-badge / .em-preorder-notice лежат в wc-common.css,
   тут только раскладка внутри карточки товара корзины. */
.em-cart__item-preorder {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}
.em-cart__item-preorder .em-preorder-badge { margin-top: 0; }
.em-cart__item-preorder-note {
    font-size: 0.75rem;
    color: var(--warning);
    opacity: 0.85;
    line-height: 1.35;
}

@media (max-width: 599px) {
    .em-cart__item-preorder { gap: 6px; }
    .em-cart__item-preorder-note { flex-basis: 100%; }
}
/* Active price mode, shared renderer with checkout. */
.em-cart__totals .em-checkout__pricing-mode {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 0 0 14px;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--r-md);
    background: rgba(255,255,255,0.025);
    color: var(--silver-2);
    font-size: 0.78rem;
    line-height: 1.45;
}
.em-cart__totals .em-checkout__pricing-mode[data-pricing-mode="delivery"] {
    border-color: rgba(57,255,20,0.24);
    background: rgba(57,255,20,0.045);
}
.em-cart__totals .em-checkout__pricing-mode i { color: var(--neon); margin-top: 2px; }
