/* Estilos do Carrinho (mobile-first) */

.cart-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--it-space-6) var(--it-space-4);
}

.cart-header {
    text-align: center;
    margin-bottom: var(--it-space-8);
}

.cart-header h1 {
    margin-bottom: var(--it-space-2);
}

.cart-subtitle {
    color: var(--it-color-text-muted);
}

/* Carrinho vazio */
.empty-cart {
    text-align: center;
    padding: var(--it-space-9) var(--it-space-5);
    background: var(--it-color-glass);
    border: 1px solid var(--it-color-border);
    border-radius: var(--it-radius-lg);
}

.empty-cart-icon {
    font-size: var(--it-text-3xl);
    color: var(--it-color-text-faint);
    margin-bottom: var(--it-space-5);
}

.empty-cart h2 {
    margin-bottom: var(--it-space-3);
}

.empty-cart p {
    margin-bottom: var(--it-space-6);
}

/* Grid do carrinho — mobile: 1 coluna; desktop: 2fr/1fr */
.cart-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--it-space-6);
}

@media (min-width: 992px) {
    .cart-grid {
        grid-template-columns: 2fr 1fr;
    }
}

.cart-items {
    background: var(--it-color-glass);
    border: 1px solid var(--it-color-border);
    border-radius: var(--it-radius-lg);
    padding: var(--it-space-5);
}

/* Mobile-first: cabeçalho de coluna escondido, cada item vira um "card" */
.cart-items-header {
    display: none;
}

.cart-item {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--it-space-2);
    padding: var(--it-space-5);
    border: 1px solid var(--it-color-border);
    border-radius: var(--it-radius-md);
    margin-bottom: var(--it-space-4);
}

.cart-item .product-info {
    flex-direction: column;
    text-align: center;
}

.cart-item .product-thumbnail {
    width: 120px;
    height: 120px;
    margin: 0 auto var(--it-space-3);
}

.cart-item .product-price,
.cart-item .product-quantity,
.cart-item .product-subtotal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--it-space-2) 0;
    border-top: 1px solid var(--it-color-border);
}

.cart-item .product-price::before {
    content: "Preço:";
    font-weight: var(--it-weight-semibold);
    color: var(--it-color-text-muted);
}

.cart-item .product-quantity::before {
    content: "Quantidade:";
    font-weight: var(--it-weight-semibold);
    color: var(--it-color-text-muted);
}

.cart-item .product-subtotal::before {
    content: "Subtotal:";
    font-weight: var(--it-weight-semibold);
    color: var(--it-color-text-muted);
}

.cart-item .product-remove {
    padding-top: var(--it-space-3);
    border-top: 1px solid var(--it-color-border);
}

.product-info {
    display: flex;
    gap: var(--it-space-4);
    align-items: center;
}

.product-thumbnail {
    width: 100px;
    height: 100px;
    overflow: hidden;
    border-radius: var(--it-radius-sm);
}

.product-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-details {
    flex: 1;
}

.product-title {
    font-size: var(--it-text-sm);
    margin-bottom: var(--it-space-2);
}

.product-title a {
    color: var(--it-color-text);
}

.product-title a:hover {
    color: var(--it-color-primary);
}

.product-price,
.product-subtotal {
    font-weight: var(--it-weight-medium);
    color: var(--it-color-text);
}

.product-quantity {
    display: flex;
    align-items: center;
    justify-content: center;
}

.quantity-wrapper {
    display: inline-flex;
    align-items: center;
    gap: var(--it-space-2);
}

.qty-btn {
    background: var(--it-color-primary);
    color: var(--it-color-text);
    width: 26px;
    height: 26px;
    font-size: var(--it-text-md);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--it-transition);
}

.qty-btn:hover {
    background: var(--it-color-primary-hover);
}

.qty-input {
    width: 40px;
    text-align: center;
    border: none;
    background: transparent;
    color: var(--it-color-text);
    font-size: var(--it-text-md);
}

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

.qty-input[type=number] {
    appearance: textfield;
}

/* Remover item: no mobile, botão com ícone e texto em largura total (o
   "×" solto de 14px era difícil de achar e de acertar no toque). Seletor
   específico e cor com !important porque o woocommerce.css estiliza
   ".woocommerce a.remove" com width/height 1em e cor !important. */
.cart-item .product-remove a.remove {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--it-space-2);
    width: 100%;
    height: auto;
    min-height: 44px;
    padding: var(--it-space-2) var(--it-space-4);
    border: 1px solid var(--it-color-error);
    border-radius: var(--it-radius-md);
    background: transparent;
    color: var(--it-color-error) !important;
    font-size: var(--it-text-sm);
    font-weight: var(--it-weight-semibold);
    line-height: 1.2;
}

.cart-item .product-remove a.remove:hover,
.cart-item .product-remove a.remove:focus-visible {
    background: rgba(231, 76, 60, .12);
    color: var(--it-color-error) !important;
}

.cart-item .product-remove a.remove i {
    font-size: var(--it-text-md);
}

.cart-actions {
    margin-top: var(--it-space-4);
}

/* Sidebar do carrinho */
.cart-sidebar {
    position: static;
}

.cart-collaterals {
    background: var(--it-color-glass);
    border: 1px solid var(--it-color-border);
    border-radius: var(--it-radius-lg);
    padding: var(--it-space-5);
}

/* O WooCommerce core dá float:right;width:48% para .cart_totals (layout
   classico de 2 colunas ao lado de .cross-sells) — como a sidebar deste
   tema ja e estreita por si so, isso espreme a tabela pela metade. O
   proprio WooCommerce corrige isso, mas so dentro de um media query de
   tela estreita; aqui deixamos sempre ativo. */
.woocommerce-page .cart-collaterals .cart_totals,
.woocommerce-page .cart-collaterals .shipping_calculator {
    float: none;
    width: 100%;
}

/* Venda cruzada: faixa de largura total abaixo de todo o carrinho (ver
   page-carrinho.php). O core também aplica float:left;width:48% aqui. */
.woocommerce-page .cart-content .cross-sells {
    float: none;
    width: 100%;
    margin-top: var(--it-space-8);
    padding-top: var(--it-space-6);
    border-top: 1px solid var(--it-color-border);
}

.cart-content .cross-sells > h2 {
    margin-bottom: var(--it-space-5);
}

.cart_totals h2 {
    margin-bottom: var(--it-space-5);
}

.shop_table {
    width: 100%;
    border-collapse: collapse;
}

.shop_table th,
.shop_table td {
    padding: var(--it-space-3) 0;
    border-bottom: 1px solid var(--it-color-border);
}

.shop_table th {
    text-align: left;
    color: var(--it-color-text-muted);
    font-weight: var(--it-weight-regular);
}

.shop_table td {
    text-align: right;
    font-weight: var(--it-weight-medium);
}

/* Célula de frete tem uma lista de métodos com texto longo, que quebra em
   várias linhas — alinhar à direita fica serrilhado/ilegível. */
.shop_table .woocommerce-shipping-totals td {
    text-align: left;
}

/* O WooCommerce core tem um reset genérico "ul[class]" que centraliza texto
   e aplica padding-left:35% (pensado pra coluna larga do layout clássico de
   2 colunas) — errado pra sidebar estreita deste tema. */
.cart-collaterals .woocommerce-shipping-methods {
    padding-left: 0;
    text-align: left;
}

.order-total th,
.order-total td {
    font-size: var(--it-text-md);
    border-bottom: none;
}

.wc-proceed-to-checkout {
    margin-top: var(--it-space-5);
}

.checkout-button {
    display: block;
    width: 100%;
}

/* Loading state (spinner único, sem injeção via JS) */
.cart-items.is-loading,
.woocommerce-cart-form.loading {
    position: relative;
    opacity: .6;
    pointer-events: none;
}

.cart-items.is-loading::after,
.woocommerce-cart-form.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid var(--it-color-border);
    border-top-color: var(--it-color-primary);
    border-radius: 50%;
    animation: it-spin 1s linear infinite;
}

@keyframes it-spin {
    to { transform: rotate(360deg); }
}

/* A partir de 768px, volta a layout de tabela com cabeçalho */
@media (min-width: 768px) {
    .cart-items-header {
        display: grid;
        grid-template-columns: 3fr 1fr 1fr 1fr .5fr;
        gap: var(--it-space-3);
        padding-bottom: var(--it-space-3);
        border-bottom: 1px solid var(--it-color-border);
        font-weight: var(--it-weight-semibold);
        color: var(--it-color-text-muted);
        font-size: var(--it-text-sm);
    }

    .cart-item {
        grid-template-columns: 3fr 1fr 1fr 1fr .5fr;
        gap: var(--it-space-3);
        padding: var(--it-space-4) 0;
        border: none;
        border-bottom: 1px solid var(--it-color-border);
        border-radius: 0;
        margin-bottom: 0;
        align-items: center;
    }

    .cart-item .product-info {
        flex-direction: row;
        text-align: left;
    }

    .cart-item .product-thumbnail {
        width: 80px;
        height: 80px;
        margin: 0;
    }

    .cart-item .product-price,
    .cart-item .product-quantity,
    .cart-item .product-subtotal {
        display: block;
        padding: 0;
        border-top: none;
        text-align: center;
    }

    .cart-item .product-price::before,
    .cart-item .product-quantity::before,
    .cart-item .product-subtotal::before {
        content: none;
    }

    /* Na tabela a coluna é estreita: só o ícone, em alvo de 44px. */
    .cart-item .product-remove {
        padding-top: 0;
        border-top: none;
    }

    .cart-item .product-remove a.remove {
        width: 44px;
        height: 44px;
        margin-inline: auto;
        padding: 0;
        border-color: transparent;
        border-radius: 50%;
    }

    .cart-item .product-remove a.remove .remove__label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(1px, 1px, 1px, 1px);
        white-space: nowrap;
    }
}

@media (min-width: 992px) {
    .cart-sidebar {
        position: sticky;
        top: 90px;
    }
}
