/* ============================================================
   КОРЗИНА. Своя разметка (cart.php / cart-totals.php).
   ============================================================ */

/* --- Контейнер --- */
body.woocommerce-cart .tdps-entry-content > .woocommerce {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
    min-width: 0;
}

/* Один блок — одна колонка, полная ширина. Гасим float/width WC. */
body.woocommerce-cart .tdps-entry-content > .woocommerce > *,
body.woocommerce-cart .cart-collaterals,
body.woocommerce-cart .cart-collaterals .cart_totals,
body.woocommerce-cart .tdps-cart-totals {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    float: none !important;
    clear: both !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box;
}

/* ============================================================
   ФОРМА ТОВАРОВ
   ============================================================ */
.tdps-cart {
    background: var(--tdps-color-bg-surface);
    border: 1px solid var(--tdps-color-border);
    border-radius: var(--tdps-radius-lg);
    box-shadow: var(--tdps-shadow-sm);
    overflow: hidden;
}

/* --- Строка товара --- */
.tdps-cart-item {
    display: grid;
    grid-template-columns: 80px minmax(0, 1fr) 110px 130px 110px 40px;
    grid-template-areas: "thumb body price qty subtotal remove";
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--tdps-color-border);
    align-items: center;
    min-width: 0;
}
.tdps-cart-item:last-child { border-bottom: none; }

.tdps-cart-item__label { display: none; }

/* Фото */
.tdps-cart-item__thumb { grid-area: thumb; width: 80px; height: 80px; }
.tdps-cart-item__thumb a { display: block; width: 100%; height: 100%; }
.tdps-cart-item__thumb img {
    display: block;
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--tdps-radius-md);
    border: 1px solid var(--tdps-color-border);
    background: var(--tdps-color-bg-subtle);
}

/* Название + варианты */
.tdps-cart-item__body { grid-area: body; min-width: 0; }
.tdps-cart-item__name {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--tdps-color-text-main);
}
.tdps-cart-item__name a { color: inherit; text-decoration: none; transition: color .15s ease; }
.tdps-cart-item__name a:hover { color: var(--tdps-color-primary); }

.tdps-cart-item .variation {
    margin: 6px 0 0;
    font-size: 0.8125rem;
    color: var(--tdps-color-text-muted);
    line-height: 1.5;
}
.tdps-cart-item .variation dt,
.tdps-cart-item .variation dd { display: inline; margin: 0; padding: 0; }
.tdps-cart-item .variation dt::after { content: ': '; }
.tdps-cart-item .variation dd { margin-right: 8px; color: var(--tdps-color-text-main); }
.tdps-cart-item .variation p { display: inline; margin: 0; }

.tdps-cart-item .backorder_notification {
    margin: 6px 0 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--tdps-color-warning);
}

/* Цена */
.tdps-cart-item__price {
    grid-area: price;
    text-align: right;
    white-space: nowrap;
    font-size: 0.9375rem;
    color: var(--tdps-color-text-muted);
    font-weight: 500;
}
.tdps-cart-item__price del {
    color: #adb5bd;
    text-decoration: line-through;
    font-weight: 400;
    font-size: 0.85em;
    margin-right: 4px;
}
.tdps-cart-item__price ins {
    text-decoration: none;
    color: var(--tdps-color-sale);
    font-weight: 700;
    background: transparent;
}

/* Кол-во */
.tdps-cart-item__qty { grid-area: qty; text-align: center; }
.tdps-cart-item__qty .quantity { display: inline-block; }
.tdps-cart-item__qty input.qty {
    width: 64px;
    height: 38px;
    padding: 0 6px;
    border: 1px solid var(--tdps-color-border);
    border-radius: var(--tdps-radius-md);
    text-align: center;
    font-weight: 600;
    font-family: inherit;
    font-size: 0.9375rem;
    background: #fff;
    box-sizing: border-box;
}
.tdps-cart-item__qty input.qty:focus {
    border-color: var(--tdps-color-primary);
    outline: none;
}
.tdps-cart-item__qty .screen-reader-text { display: none; }

/* Сумма */
.tdps-cart-item__subtotal {
    grid-area: subtotal;
    text-align: right;
    white-space: nowrap;
    font-size: 1rem;
    font-weight: 700;
    color: var(--tdps-color-primary);
}
.tdps-cart-item__subtotal del {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: #adb5bd;
    text-decoration: line-through;
    margin-bottom: 2px;
}
.tdps-cart-item__subtotal ins {
    text-decoration: none;
    color: var(--tdps-color-sale);
    background: transparent;
}

/* Удалить */
.tdps-cart-item__remove { grid-area: remove; justify-self: end; }
.tdps-cart-item__remove .remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--tdps-color-bg-subtle);
    color: var(--tdps-color-text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    line-height: 1;
    transition: background .15s ease, color .15s ease;
}
.tdps-cart-item__remove .remove:hover {
    background: var(--tdps-color-error-bg);
    color: var(--tdps-color-error);
}

/* ============================================================
   ACTIONS: купон слева, кнопка справа
   ============================================================ */
.tdps-cart__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    background: var(--tdps-color-bg-subtle);
    border-top: 1px solid var(--tdps-color-border);
}
.tdps-cart__actions .coupon {
    display: flex;
    gap: 8px;
    align-items: stretch;
    min-width: 0;
}
.tdps-cart__actions .coupon label { display: none; }
.tdps-cart__actions .coupon input[type="text"] {
    width: 220px;
    height: 40px;
    padding: 0 14px;
    border: 2px solid var(--tdps-color-border);
    border-radius: var(--tdps-radius-md);
    font-size: 0.9375rem;
    background: #fff;
    color: var(--tdps-color-text-main);
    box-sizing: border-box;
}
.tdps-cart__actions .coupon input[type="text"]:focus {
    border-color: var(--tdps-color-primary);
    outline: none;
}
.tdps-cart__actions .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 18px;
    background: #fff;
    color: var(--tdps-color-text-main);
    border: 2px solid var(--tdps-color-border);
    border-radius: var(--tdps-radius-md);
    font-weight: 600;
    font-size: 0.8125rem;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease;
    box-sizing: border-box;
}
.tdps-cart__actions .button:hover:not(:disabled) {
    border-color: var(--tdps-color-primary);
    color: var(--tdps-color-primary);
}
.tdps-cart__actions .button:disabled {
    opacity: .5;
    cursor: not-allowed;
}
.tdps-cart__actions .tdps-cart__update {
    margin-left: auto;
}

/* ============================================================
   БЛОК «СУММА КОРЗИНЫ»
   ============================================================ */
.tdps-cart-totals {
    background: var(--tdps-color-bg-surface);
    border: 1px solid var(--tdps-color-border);
    border-radius: var(--tdps-radius-lg);
    padding: 24px;
    box-shadow: var(--tdps-shadow-sm);
    box-sizing: border-box;
    width: 100%;
}
.tdps-cart-totals__title {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--tdps-color-border);
    color: var(--tdps-color-text-main);
}
.tdps-cart-totals__rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}
.tdps-cart-totals__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.9375rem;
    min-width: 0;
}
.tdps-cart-totals__label {
    color: var(--tdps-color-text-muted);
    font-weight: 500;
    min-width: 0;
    overflow-wrap: anywhere;
}
.tdps-cart-totals__value {
    font-weight: 600;
    color: var(--tdps-color-text-main);
    text-align: right;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.tdps-cart-totals__value--shipping {
    font-weight: 400;
    font-style: italic;
    color: var(--tdps-color-text-muted);
    font-size: 0.875rem;
    white-space: normal;
}

/* Купон: label сверху, значение под ним — не вылезает на узких */
.tdps-cart-totals__row.cart-discount {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
}
.tdps-cart-totals__row.cart-discount .tdps-cart-totals__label {
    color: var(--tdps-color-sale);
    font-weight: 600;
    font-size: 0.875rem;
}
.tdps-cart-totals__row.cart-discount .tdps-cart-totals__value {
    text-align: left;
    color: var(--tdps-color-sale);
    font-size: 0.875rem;
    white-space: normal;
}
.tdps-cart-totals__row.cart-discount a {
    color: inherit;
    text-decoration: underline;
    margin-left: 4px;
    white-space: nowrap;
}

.tdps-cart-totals__value del {
    color: #adb5bd;
    text-decoration: line-through;
    font-weight: 400;
    margin-right: 6px;
}
.tdps-cart-totals__value ins {
    text-decoration: none;
    color: var(--tdps-color-sale);
    font-weight: 700;
    background: transparent;
}

.tdps-cart-totals__row.order-total {
    margin-top: 8px;
    padding-top: 14px;
    border-top: 1px solid var(--tdps-color-border);
}
.tdps-cart-totals__row.order-total .tdps-cart-totals__label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--tdps-color-text-main);
}
.tdps-cart-totals__row.order-total .tdps-cart-totals__value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--tdps-color-primary);
    white-space: nowrap;
}

.tdps-cart-totals .wc-proceed-to-checkout { padding: 0; margin: 0; }
.tdps-cart-totals .wc-proceed-to-checkout .checkout-button,
.tdps-cart-totals .wc-proceed-to-checkout .button,
.tdps-cart-totals .wc-proceed-to-checkout a.button,
.tdps-cart-totals .wc-proceed-to-checkout a.wc-forward {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 16px 24px;
    background: var(--tdps-color-primary);
    color: #fff;
    border: none;
    border-radius: var(--tdps-radius-md);
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.2;
    text-decoration: none;
    text-align: center;
    min-height: 54px;
    box-sizing: border-box;
    transition: background .15s ease;
}
.tdps-cart-totals .wc-proceed-to-checkout .checkout-button:hover,
.tdps-cart-totals .wc-proceed-to-checkout .button:hover {
    background: var(--tdps-color-primary-hover);
    color: #fff;
}

/* ============================================================
   ПУСТАЯ КОРЗИНА
   ============================================================ */
.tdps-cart-empty {
    max-width: 640px;
    margin: 24px auto 8px;
    padding: 56px 32px 48px;
    text-align: center;
    background: var(--tdps-color-bg-surface);
    border: 1px solid var(--tdps-color-border);
    border-radius: var(--tdps-radius-lg);
    box-shadow: var(--tdps-shadow-sm);
    box-sizing: border-box;
}

.tdps-cart-empty__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 104px;
    height: 104px;
    margin: 0 auto 24px;
    border-radius: 50%;
    background: var(--tdps-color-primary-subtle);
    color: var(--tdps-color-primary);
}
.tdps-cart-empty__icon svg {
    width: 52px;
    height: 52px;
    display: block;
}

.tdps-cart-empty__title {
    font-size: clamp(1.375rem, 2.5vw, 1.75rem);
    font-weight: 700;
    color: var(--tdps-color-text-main);
    margin: 0 0 12px;
    line-height: 1.3;
}

.tdps-cart-empty__text {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--tdps-color-text-muted);
    margin: 0 auto 28px;
    max-width: 480px;
}

.tdps-cart-empty__buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}
.tdps-cart-empty__buttons .tdps-btn {
    min-height: 48px;
    padding: 12px 24px;
    font-size: 0.9375rem;
    text-decoration: none;
}
.tdps-cart-empty__btn-icon {
    line-height: 1;
    margin-right: 2px;
}

/* ============================================================
   МОБИЛЬНЫЕ
   ============================================================ */
@media (max-width: 900px) {
    .tdps-cart-item {
        grid-template-columns: 80px minmax(0, 1fr) 36px;
        grid-template-areas:
            "thumb body     remove"
            "thumb price    price"
            "thumb qty      qty"
            "thumb subtotal subtotal";
        gap: 6px 12px;
        padding: 14px 16px;
        align-items: start;
    }

    .tdps-cart-item__thumb {
        align-self: start;
        width: 80px;
        height: 80px;
    }
    .tdps-cart-item__thumb img {
        width: 80px;
        height: 80px;
    }

    .tdps-cart-item__body { grid-area: body; }
    .tdps-cart-item__remove { grid-area: remove; align-self: start; }

    .tdps-cart-item__label {
        display: inline-block;
        font-size: 0.7rem;
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--tdps-color-text-muted);
        margin-right: 8px;
    }

    .tdps-cart-item__price,
    .tdps-cart-item__qty,
    .tdps-cart-item__subtotal {
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-align: right;
        white-space: normal;
        min-width: 0;
    }

    .tdps-cart-item__price { padding-top: 4px; }
    .tdps-cart-item__qty   { padding-top: 2px; }
    .tdps-cart-item__subtotal {
        padding-top: 10px;
        margin-top: 4px;
        border-top: 1px solid var(--tdps-color-border);
        font-size: 1.125rem;
    }
    .tdps-cart-item__qty .quantity { display: inline-block; }

    .tdps-cart__actions {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
    }
    .tdps-cart__actions .coupon {
        flex-direction: column;
        width: 100%;
    }
    .tdps-cart__actions .coupon input[type="text"] {
        width: 100%;
    }
    .tdps-cart__actions .button {
        width: 100%;
    }
    .tdps-cart__actions .tdps-cart__update {
        margin-left: 0;
    }

    /* Пустая корзина на мобильном */
    .tdps-cart-empty {
        margin: 12px 0 0;
        padding: 40px 20px 36px;
        border-radius: var(--tdps-radius-md);
    }
    .tdps-cart-empty__icon {
        width: 80px;
        height: 80px;
        margin-bottom: 20px;
    }
    .tdps-cart-empty__icon svg {
        width: 40px;
        height: 40px;
    }
    .tdps-cart-empty__buttons {
        flex-direction: column;
    }
    .tdps-cart-empty__buttons .tdps-btn {
        width: 100%;
    }
}