:root{
    --max-width: 1200px;
    --card-bg: #fff;
    --muted-bg: #f9f9f9;
    --accent: #ff8a00;
    --accent-hover: #0f766a;
    --danger: #e74c3c;
    --shadow-1: 0 6px 20px rgba(0,0,0,0.08);
    --shadow-2: 0 4px 10px rgba(0,0,0,0.05);
    --radius: 12px;
    --font: 'Montserrat', sans-serif;
}

/* ===========================
   Estilos Globais - Desktop
   =========================== */

/* Container geral do carrinho */
.woocommerce {
    max-width: 900px;
    margin: 40px auto;
    padding: 20px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    font-family: var(--font);
}

/* Tabela do carrinho (legacy .woocommerce) */
.woocommerce table.shop_table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 15px;
}
.woocommerce table.shop_table th,
.woocommerce table.shop_table td {
    padding: 12px 15px;
    text-align: center;
}
.woocommerce table.shop_table th {
    background: #f7f7f7;
    font-weight: 600;
    border-radius: 8px;
}

/* Imagem do produto (legacy) */
.woocommerce table.shop_table .product-thumbnail img {
    width: 80px;
    height: auto;
    border-radius: 8px;
}

/* Botão remover (legacy) */
.woocommerce table.shop_table .product-remove a {
    color: #ff4d4f;
    font-weight: bold;
    font-size: 18px;
    transition: color 0.3s;
}
.woocommerce table.shop_table .product-remove a:hover {
    color: #d9363e;
}

/* Quantidade (legacy) */
.woocommerce .quantity input {
    width: 60px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 6px;
}

/* Totais do carrinho (legacy) */
.cart-collaterals {
    margin-top: 30px;
    padding: 20px;
    background: var(--muted-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
}
.cart-collaterals h2 {
    font-size: 22px;
    margin-bottom: 15px;
    color: #333;
}
.cart-collaterals table th,
.cart-collaterals table td {
    padding: 10px 15px;
    text-align: right;
}
.cart-collaterals table th { font-weight: 500; }
.cart-collaterals table td { font-weight: 600; }

/* Botão checkout (legacy) */
.wc-proceed-to-checkout .checkout-button {
    display: inline-block;
    width: 100%;
    padding: 14px 0;
    background: var(--accent);
    color: #fff;
    text-transform: uppercase;
    font-weight: 600;
    border-radius: 12px;
    text-align: center;
    transition: background 0.3s;
}
.wc-proceed-to-checkout .checkout-button:hover {
    background: var(--accent-hover);
}

/* Botões de cupom / atualizar */
[name="apply_coupon"] {
    background-color: var(--accent);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}
[name="update_cart"] {
    padding: 20px;
    font-size: 16px;
    margin-top: 10px;
}

/* ===========================
   WC Block (layout moderno)
   =========================== */

/* Container Principal do bloco */
.wc-block-cart {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 20px;
}

.wc-block-cart {
    display: -webkit-box !important;
}
/* Layout em Colunas para Desktop (Sidebar à Direita) */
.wc-block-components-sidebar-layout {
    display: -webkit-box;
    gap: 30px;
    align-items: flex-start;
}
.wc-block-cart__main { flex-grow: 1; }

/* Sidebar resumo */
.wc-block-cart__sidebar {
    width: 300px;
    padding: 20px;
    border: 1px solid #eee;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    background-color: var(--card-bg);
    position: sticky;
    top: 30px;
}

/* Itens do cart (block/table híbrido) */
.wc-block-cart-items { width: 100%; border-collapse: collapse; }
.wc-block-cart-items thead { background-color: #f8f8f8; border-bottom: 2px solid #ddd; }
.wc-block-cart-items th, .wc-block-cart-items td { padding: 15px; text-align: left; border-bottom: 1px solid #eee; }

/* Imagem do produto (block) */
.wc-block-cart-item__image { width: 80px; }
.wc-block-cart-item__image img { width: 100%; height: auto; border-radius: 6px; }

/* Seletor de Quantidade (block) */
.wc-block-components-quantity-selector {
    display: flex;
    align-items: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: fit-content;
    overflow: hidden;
    margin-top: 10px;
}
.wc-block-components-quantity-selector__input {
    border: none !important;
    text-align: center;
    width: 50px;
    padding: 5px 0;
    margin: 0;
    box-shadow: none !important;
}
.wc-block-components-quantity-selector__button {
    background-color: #f0f0f0;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    font-weight: bold;
    line-height: 1;
    transition: background-color 0.2s;
}
.wc-block-components-quantity-selector__button:hover:not(:disabled) { background-color: #e0e0e0; }

/* Remover item (block) */
.wc-block-cart-item__remove-link {
    color: var(--danger);
    text-decoration: none;
    font-size: 0.9em;
    margin: 10px 0;
    transition: color 0.2s;
}
.wc-block-cart-item__remove-link:hover { color: #c0392b; }

/* Botão finalizar compra (block) */
.wc-block-cart__submit-button {
    width: 100%;
    text-align: center;
    padding: 15px 20px;
    background-color: #27ae60 !important;
    color: #ffffff !important;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    transition: background-color 0.3s;
    text-decoration: none;
    line-height: 1;
    display: block;
}
.wc-block-cart__submit-button:hover { background-color: #2ecc71 !important; }

/* ===========================
   Responsivo - Único @media
   =========================== */

@media (max-width: 768px) {

    /* Ajustes gerais do container */
    .woocommerce {
        margin: 20px auto;
        padding: 15px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    }

    /* Legacy table -> card layout */
    .woocommerce table.shop_table,
    .woocommerce table.shop_table thead,
    .woocommerce table.shop_table tbody,
    .woocommerce table.shop_table th,
    .woocommerce table.shop_table td,
    .woocommerce table.shop_table tr {
        display: block;
        width: 100%;
    }
    .woocommerce table.shop_table thead { display: none; }

    .woocommerce table.shop_table tr.cart_item {
        margin-bottom: 20px;
        padding: 15px;
        background: var(--card-bg);
        border-radius: 12px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.05);
        position: relative;
    }
    .woocommerce table.shop_table .product-thumbnail img {
        width: 80px;
        height: auto;
        border-radius: 8px;
        float: left;
        margin-right: 15px;
        margin-top: 37px;
    }
    .woocommerce table.shop_table .product-name,
    .woocommerce table.shop_table .product-price,
    .woocommerce table.shop_table .product-quantity,
    .woocommerce table.shop_table .product-subtotal {
        display: block;
        text-align: left;
        margin: 10px 0;
    }
    .woocommerce table.shop_table .product-remove { position: absolute; top: 10px; right: 10px; }

    .woocommerce .quantity input { width: 50px; padding: 6px; }

    .cart-collaterals { padding: 15px; }

    /* Botões em full width (legacy) */
    .wc-proceed-to-checkout .checkout-button,
    [name="apply_coupon"],
    [name="update_cart"] {
        width: 100%;
        padding: 12px 0;
        font-size: 16px;
        margin-top: 10px;
    }

    /* Cupom - layout coluna */
    .woocommerce-cart-form .coupon {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    .woocommerce-cart-form .coupon input[type="text"] {
        width: 100%;
        padding: 10px;
        border-radius: 8px;
        border: 1px solid #ddd;
    }

    /* WC Block - mobile adjustments */
    .wc-block-components-sidebar-layout { display: block; }
    .wc-block-cart__sidebar {
        width: 100%;
        position: static;
        order: -1; /* resumo acima da lista */
    }

    .wc-block-cart-items {
        display: block;
        overflow-x: auto;
        width: 100%;
    }
    .wc-block-cart-items thead { display: none; }
    .wc-block-cart-items tbody,
    .wc-block-cart-items tr { display: block; width: 100%; }

    .wc-block-cart-items__row {
        border: 1px solid #ddd;
        border-radius: 8px;
        margin-bottom: 15px;
        padding: 10px;
        display: grid;
        grid-template-columns: 80px 1fr;
        grid-template-areas:
            "image product-details"
            "image product-total";
    }

    .wc-block-cart-item__image { grid-area: image; padding: 0; width: 120px; }
    .wc-block-cart-item__product { grid-area: product-details; padding: 0 0 0 15px; }
    .wc-block-cart-item__total {
        grid-area: product-total;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-top: 1px solid #eee;
        margin-top: 10px;
        padding: 10px 0 0 15px;
    }
    .wc-block-cart-item__total:before { content: "Total do Produto:"; font-weight: bold; color: #555; }

    .wc-block-cart-item__wrap { display: flex; flex-direction: column; }

    .wc-block-cart-item__quantity {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-top: 15px;
    }
    .wc-block-cart-item__remove-link { margin-left: 0; }

}
