/* --------------------------------------------------- */
/* ESTILOS MODERNOS E VIBRANTES - CARRINHO */
/* --------------------------------------------------- */

/* CORREÇÃO MOBILE: Garante que a página não deslize */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

body {
    background-color: #f4f7f6; /* Fundo suave */
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

h1 { 
    text-align: center; 
    color: #172b4d; 
    padding-bottom: 15px; 
    margin-bottom: 15px; 
    font-size: 2.2em;
    font-weight: 800;
}

/* NOVO: Contêiner centralizador para todo o conteúdo principal do carrinho */
.cart-main-content {
    max-width: 1000px; 
    margin: 0 auto; /* Centraliza */
    padding: 0 15px; /* Adiciona padding para telas menores (mantém margem lateral) */
}

/* Estilo de Tabela Moderna */
.cart-table-container {
    /* REMOVIDO: max-width: 1000px; e margin: 0 auto; - Agora é responsabilidade do .cart-main-content */
    margin-bottom: 25px;
    padding: 0; 
}
table { 
    width: 100%;
    border-collapse: separate; 
    border-spacing: 0;
    border: none;
    border-radius: 16px; 
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1); 
    background-color: #ffffff;
}
th {
    background-color: #007bff; 
    color: white;
    padding: 18px 15px; 
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
td {
    border-bottom: none; 
    padding: 15px;
    vertical-align: middle;
    background-color: white;
    color: #333;
}

/* Borda de separação por Produto (Linha tr) */
table tbody tr {
    border: 1px solid #dcdcdc; 
    margin-bottom: 10px; 
    display: table-row; 
}

tr:nth-child(even) td {
    background-color: #fcfcfc; 
}
tr:hover td {
    background-color: #f0f8ff; 
}

/* ESTILOS PARA CONTROLE DE QUANTIDADE (+/-) */
.quantity-control {
    display: flex;
    align-items: center;
    justify-content: center; 
    width: 100%;
    /* AJUSTE APLICADO: Aumentando max-width para acomodar inputs maiores */
    max-width: 150px; 
    margin: 0 auto;
}

/* ESTILOS PARA OCULTAR BOTÕES DE SPIN (SETAS) NOS INPUTS DE QUANTIDADE */
.quantity-input::-webkit-outer-spin-button,
.quantity-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Linha 96 atual */
.quantity-input {
  /* Adicione appearance: none; para compatibilidade geral */
  appearance: none; 
  -moz-appearance: textfield; /* Firefox */
}

.quantity-control button {
    background-color: #f8f9fa; 
    border: 1px solid #ced4da;
    color: #495057;
    font-size: 1.2em;
    font-weight: 700;
    padding: 5px 10px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1; 
    width: 35px; 
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.quantity-control button:hover {
    background-color: #e2e6ea;
    border-color: #b8c4ce;
}

/* Input de Quantidade (dentro do controle) */
.quantity-control input[type="number"] { 
    /* AJUSTE APLICADO: Aumentando width de 40px para 60px */
    width: 60px; 
    padding: 5px 2px; 
    text-align: center; 
    border-top: 1px solid #ced4da; 
    border-bottom: 1px solid #ced4da;
    border-left: none;
    border-right: none;
    font-weight: 600;
    height: 35px;
    box-sizing: border-box;
}
.quantity-control input[type="number"]:focus {
    border-color: #007bff;
    outline: none;
    z-index: 1; 
}

/* Arredonda as pontas dos botões */
.btn-qty-minus {
    border-top-left-radius: 8px; 
    border-bottom-left-radius: 8px;
}
.btn-qty-plus {
    border-top-right-radius: 8px; 
    border-bottom-right-radius: 8px;
}

.actions-bottom { 
    display: flex; 
    flex-direction: row; 
    /* AJUSTE: Permite espaço para o botão "Limpar Carrinho" */
    justify-content: space-between; 
    align-items: center;
    margin-top: 30px; 
    /* REMOVIDO: max-width: 1000px; e margens - Agora é responsabilidade do .cart-main-content */
    margin-bottom: 20px;
    padding: 0;
}
/* NOVO ESTILO: Container de botões à direita (Checkout) */
.actions-right-group {
    display: flex;
    align-items: center;
    gap: 15px; /* Espaço entre os botões */
}

/* Botão Continuar Comprando/Atualizar */
.continue-shopping-top {
    text-align: center;
    /* AJUSTE APLICADO AQUI: Adicionando margem superior para espaçamento extra */
    margin-top: 20px; 
    margin-bottom: 20px;
}
.btn-continue-shopping {
    color: white; 
    background-color: #007bff; 
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    font-weight: 600;
    display: inline-block;
    transition: all 0.3s;
    cursor: pointer;
    text-decoration: none; 
}
/* NOVO: Estilo para o botão Limpar Carrinho (Desktop) */
.btn-clear-cart-desktop {
    background-color: #dc3545; /* Vermelho/Danger */
    color: white;
    border: none;
    padding: 14px 30px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 1.05em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s;
    box-shadow: 0 6px 15px rgba(220, 53, 69, 0.3);
    cursor: pointer;
}
.btn-clear-cart-desktop:hover {
    background-color: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(220, 53, 69, 0.5);
}

/* Estado de alerta/pendente de atualização */
.btn-continue-shopping.pending {
    background-color: #ffc107; 
    color: #333;
    font-weight: 700;
    box-shadow: 0 4px 8px rgba(255, 193, 7, 0.5);
}

/* Estado desabilitado */
.btn-continue-shopping:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #007bff;
    color: white;
    box-shadow: none;
}

.action-link { 
    color: #dc3545; 
    text-decoration: none; 
    font-weight: 600;
    transition: color 0.3s; 
}
.action-link:hover { color: #a71d2a; text-decoration: underline; }

/* NOVO: Linha do Subtotal dos Produtos (Rodapé) - DESKTOP */
.subtotal-produtos-row td { 
    font-weight: 700; 
    background-color: #e6f7ff !important; /* COR DE FUNDO UNIFICADA */
    color: #007bff; 
    font-size: 1.1em; 
    padding: 15px;
    border-top: 1px solid #007bff;
}

/* NOVO: Linha do Custo de Entrega - DESKTOP */
.custo-entrega-row td {
    font-weight: 700; 
    background-color: #e6f7ff !important; /* COR DE FUNDO UNIFICADA */
    color: #007bff; 
    font-size: 1.1em; 
    padding: 15px;
    border-top: 1px dashed #b8daff;
}

/* NOVO: Linha do Total Geral do Pedido (Rodapé) - DESKTOP */
.total-pedido-row td { 
    font-weight: 800; 
    background-color: #e6f7ff !important; /* COR DE FUNDO UNIFICADA */
    color: #28a745; /* Cor verde para o total final */ 
    font-size: 1.5em; 
    padding: 20px 15px;
    border-top: 3px solid #007bff;
}
/* AJUSTE: Centraliza o texto nas colunas de total */
.total-value-desktop {
    text-align: right;
}

/* Botões Modernos */
.btn-checkout { 
    padding: 14px 30px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 1.05em;
    transition: all 0.3s;
    text-decoration: none;
    text-align: center;
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: linear-gradient(45deg, #28a745, #1e7e34); 
    color: white;
    box-shadow: 0 6px 15px rgba(40, 167, 69, 0.5);
    /* ADICIONADO: Garante que o botão no rodapé fixo ocupe 100% da largura */
    width: 100%;
    box-sizing: border-box; 
}
.btn-checkout:hover { 
    background: linear-gradient(45deg, #1e7e34, #28a745);
    transform: translateY(-2px);
}

.empty-cart { text-align: center; margin-top: 50px; padding: 40px; background: #fff; border-radius: 12px; max-width: 600px; margin: 50px auto; box-shadow: 0 4px 10px rgba(0,0,0,0.05); }
.empty-cart p:first-of-type { font-size: 1.2em; font-weight: 600; color: #555; }
.message { 
    margin-bottom: 25px; 
    padding: 15px; 
    border-radius: 8px; 
    background-color: #d4edda; 
    color: #155724; 
    border: 1px solid #c3e6cb;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    font-weight: 600;
    text-align: center;
}
.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
/* NOVO: Estilo para a mensagem de erro injetada pelo JS */
#checkout-error-message {
    display: none; /* Inicia oculto */
    max-width: 1000px;
    margin: 0 auto 20px auto; /* Adiciona margem abaixo e centraliza */
    padding: 15px;
    font-size: 1.1em;
    font-weight: 700;
}


/* Imagem do Produto */
.product-thumb {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin-right: 15px;
    border-radius: 8px;
    border: 1px solid #eee;
}

/* --- NOVO ESTILO: INFORMAÇÕES DE FRETE/RETIRADA --- */
.shipping-info-box {
    /* REMOVIDO: max-width: 1000px; e margens - Agora é responsabilidade do .cart-main-content */
    margin-top: 20px; 
    margin-bottom: 30px;
    padding: 20px 15px; 
    background-color: #ffffff;
    border: 1px solid #b8daff;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.05);
    color: #004085;
}
.shipping-info-box h2 {
    font-size: 1.2em;
    color: #007bff;
    margin-top: 0;
    margin-bottom: 10px;
    border-bottom: 1px dashed #e6f7ff;
    padding-bottom: 5px;
}
.shipping-info-box p {
    margin: 8px 0;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.shipping-info-box strong {
    font-weight: 700;
    color: #155724; /* Verde para frete grátis/retirada */
}
.shipping-info-box .frete-pago {
    color: #dc3545; /* Vermelho para frete pago */
}

/* *** CORREÇÃO APLICADA AQUI: GARANTE ESPAÇAMENTO UNIFORME *** */
.delivery-option {
    margin-bottom: 10px; /* Aplica o espaçamento uniforme a todas as opções */
    padding: 5px 0; /* Ajuda a dar um respiro visual */
}
.delivery-option:last-of-type {
    margin-bottom: 0; /* Remove a margem da última opção */
}
/* *** FIM DA CORREÇÃO APLICADA *** */

/* NOVO: Estilo para os radio buttons de entrega */
.delivery-option input[type="radio"] {
    width: auto;
    padding: 0;
    margin: 0;
    vertical-align: middle;
    height: 18px; 
    width: 18px; 
    border-radius: 50%;
}
.delivery-option label {
    display: inline-block !important; 
    margin-left: 10px;
    font-weight: 400 !important;
    font-size: 1.0em !important;
    color: #172b4d !important;
}
.delivery-option strong {
    font-weight: 700;
    color: #28a745;
}
.delivery-option .frete-pago {
    color: #dc3545;
}
/* --------------------------------------------------- */

/* NOVOS ESTILOS PARA FOOTER FIXO NO MOBILE */
.cart-sticky-footer {
    display: none; 
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #fff; 
    border-top: 1px solid #ddd;
    padding: 15px 15px; /* AJUSTE NO PADDING LATERAL */
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000; 
    box-sizing: border-box;
}
/* NOVO: Estilo para o bloco de totais no footer (para mobile) */
.total-info-mobile {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}
.total-info-mobile p {
    font-size: 0.9em; 
    margin: 0; 
    display: flex; 
    justify-content: space-between; 
    font-weight: 500; 
    color: #555;
    line-height: 1.6;
}
.total-info-mobile p:last-child {
    font-size: 1.2em;
    font-weight: 700;
    color: #28a745;
    padding-top: 5px;
}
.total-info-mobile strong {
    font-weight: 700;
}

/* NOVO: Agrupamento de botões no footer para mobile */
.cart-sticky-footer-actions {
    display: flex;
    gap: 10px; /* Espaço entre os botões */
}
/* NOVO: Botão Limpar Carrinho no footer mobile */
.btn-clear-cart-mobile {
    background-color: #dc3545; 
    color: white;
    border: none;
    /* ALTERADO AQUI: Reduzido de 14px para 10px */
    padding: 10px 15px;
    border-radius: 10px;
    font-weight: 700;
    /* ALTERADO AQUI: Reduzido de 1.05em para 0.9em */
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s;
    box-shadow: 0 6px 15px rgba(220, 53, 69, 0.3);
    width: 100%; /* Ocupa a largura total */
    /* ALTERADO AQUI: Reduzido de 35% para 25% */
    flex: 0 0 25%; 
    box-sizing: border-box; 
}
.btn-clear-cart-mobile i {
    /* ALTERADO AQUI: Reduzido de 1.2em para 1em */
    font-size: 1em; 
}
.btn-clear-cart-mobile:hover {
    background-color: #c82333;
    transform: translateY(-2px);
}
/* NOVO: O botão de checkout no mobile agora ocupa o espaço restante */
.cart-sticky-footer .btn-checkout {
    /* ALTERADO AQUI: Reduzido de 14px para 10px */
    padding: 10px 30px;
    /* ALTERADO AQUI: Reduzido de 1.05em para 0.9em */
    font-size: 0.9em;
    flex: 1; /* Ocupa o espaço restante */
    width: auto; /* Remove o width: 100% que estava forçando o preenchimento total */
}


/* REMOVIDO: Blocos de info do rodapé fixo, pois devem ficar apenas na parte rolante. */
.cart-sticky-footer .total-info,
.cart-sticky-footer .shipping-info-mobile {
    display: none;
}

/* Responsividade */
@media (max-width: 768px) {
    
    /* CORREÇÃO CRÍTICA: Remove o padding lateral do container principal no mobile */
    .cart-main-content {
        padding: 0;
    }

    .cart-table-container {
        padding: 0; 
        overflow-x: hidden; 
    }
    table {
        border-radius: 0; 
        box-shadow: none; 
    }
    
    body {
        /* Aumentado o padding para o rodapé fixo ter espaço */
        /* AJUSTADO AQUI: padding-bottom reduzido para 100px */
        padding-bottom: 100px; 
    }
    
    /* ** CORREÇÃO CRÍTICA: REMOVE A DUPLICAÇÃO DO TFOOT NO MOBILE ** */
    /* Oculta as linhas totais do desktop, que estavam visíveis no mobile */
    .cart-table-container table tfoot {
        display: none !important; 
    }
    
    .cart-sticky-footer {
        display: block; 
        /* AJUSTE NO PADDING LATERAL: Agora é feito na regra principal acima (15px 15px) */
    }

    .actions-bottom { 
        display: none; /* Oculta o rodapé do desktop */
    }

    table thead { display: none; }
    
    /* ========================================================== */
    /* == INÍCIO DA CORREÇÃO DE CENTRALIZAÇÃO == */
    /* ========================================================== */
    
    /* 1. REMOVEMOS DESTA LINHA:
       A regra genérica estava forçando width: 100% e
       impedindo a centralização do card de produto.
    */
    table tbody, td { display: block; width: 100%; box-sizing: border-box; }
    
    
    /* 2. APLICAMOS A REGRA DE CARD CENTRALIZADO APENAS AO:
       Isso aplica o estilo de "card" (borda, sombra)
       APENAS aos produtos no corpo (tbody)
       e NÃO às linhas de resumo no rodapé (tfoot).
    */
    table tbody tr {
        /* Propriedades de estilo que já existiam (borda, sombra, etc.) */
        border-radius: 10px;
        border: 1px solid #dcdcdc; 
        box-shadow: 0 4px 12px rgba(0,0,0,0.1); 

        /* --- INÍCIO DA CENTRALIZAÇÃO --- */
        
        /* 2a. (movido da regra genérica acima) */
        display: block; 
        
        /* 2b. (para ter margens laterais) */
        width: 95%; 
        
        /* 2c. (para centralizar o bloco de 95%)
           (Margem Topo: 0, Lados: auto, Fundo: 20px) */
        margin: 0 auto 20px auto; 
        
        /* --- FIM DA CENTRALIZAÇÃO --- */
    }
    /* ========================================================== */
    /* == FIM DA CORREÇÃO DE CENTRALIZAÇÃO == */
    /* ========================================================== */
    
    
    td {
        border-bottom: none; 
        padding: 10px 15px; 
        font-size: 0.9em; 
        display: flex; 
        justify-content: space-between;
        align-items: center;
    }
    
    /* Mantém bordas visíveis para separar as informações do produto */
    /* A coluna 1 é o produto, a 2 é a quantidade, a 3 é o subtotal, a 4 é a ação */
    .cart-table-container table tbody tr td:nth-child(2) { /* Quantidade */
        border-bottom: 1px solid #f0f0f0;
    }

    /* Ajuste do Produto (coluna 1) para Mobile: Foto + Nome + Preço Unitário */
    td:nth-child(1) {
        display: block; /* Ocupa a largura toda para o agrupamento */
        padding-bottom: 5px;
        /* NOVO: Borda inferior para separar o cabeçalho do item das demais infos */
        border-bottom: 1px solid #f0f0f0; 
    }
    .product-info-mobile {
        display: flex;
        align-items: center;
        justify-content: flex-start; /* Alinha a foto e o texto */
        gap: 10px; /* Espaço entre a imagem e os textos */
    }
    .product-details-text {
        display: flex;
        flex-direction: column;
        text-align: left;
    }
    .product-name-mobile {
        font-size: 1.2em; /* AJUSTADO: Maior e mais fácil de ler */
        font-weight: 700;
        color: #172b4d;
    }
    .unit-price-mobile {
        font-size: 0.95em; 
        font-weight: 500;
        color: #555;
        margin-top: 2px;
        /* NOVO: Adiciona a label "Preço Unitário" aqui para ser mais direto */
    }
    
    /* Ajusta a coluna de Quantidade (coluna 2) */
    /* MUDANÇA: Especificando o tbody */
    .cart-table-container table tbody td:nth-child(2) {
        padding-top: 15px;
        padding-bottom: 15px;
    }
    /* ALTERADO: Label de "Quantidade" para "Valor" */
    /* MUDANÇA: Especificando o tbody */
    .cart-table-container table tbody td:nth-child(2)::before {
        content: "Quantidade:"; /* CORRIGIDO AQUI */
        font-weight: 600;
        color: #555;
    }
    
    /* ****************************************************** */
    /* *** AJUSTE CRÍTICO: Removendo Fundo e Destacando Subtotal *** */
    /* ****************************************************** */
    /* Ajusta a coluna de Subtotal (coluna 3) */
    /* MUDANÇA: Especificando o tbody */
    .cart-table-container table tbody td:nth-child(3) {
        /* ** REMOVIDO: Fundo Cinza Claro - Deixando branco como padrão ** */
        background-color: white !important;
        padding-top: 15px;
        padding-bottom: 15px;
        font-size: 1.1em;
        font-weight: 700;
        color: #007bff;
        border-bottom: 1px solid #f0f0f0; /* Borda inferior para separação */
    }
    /* MUDANÇA: Especificando o tbody */
    .cart-table-container table tbody td:nth-child(3)::before {
        content: "Subtotal:";
        font-weight: 600;
        color: #555;
    }
    /* ****************************************************** */


    /* ****************************************************** */
    /* *** AJUSTE CRÍTICO: Redução do Fundo da Linha Remover *** */
    /* ****************************************************** */
    /* O TD da Ação (Remover) - coluna 4 */
    td:nth-child(4) {
        /* Fundo Vermelho **MUITO** Claro - Tom mais suave que o anterior */
        background-color: #fceceb !important; 
        /* Centraliza o link (que agora é o único elemento flexível) */
        justify-content: center; 
        padding-top: 8px; /* Redução de Padding Vertical */
        padding-bottom: 8px; /* Redução de Padding Vertical */
        border-top: 1px dashed #f0f0f0;
        /* Remove a borda inferior para maior espaçamento até o resumo */
        border-bottom: none !important;
    }
    /* NOVO: Espaçamento entre a tabela de produtos (tbody) e o resumo (tfoot) */
 .cart-table-container table tfoot {
 display: block; /* Garante que a margem funcione */

 /* --- CORREÇÃO CRÍTICA: LARGURA 100% E MARGEM 0 LATERAL --- */
 width: 100%;
 /* Define margens (Topo=25, L/R=0, Fundo=0) */
 margin: 25px 0 0 0; 
}
    
    /* Ajusta o Link Remover */
    td:nth-child(4) .action-link {
        font-size: 1.1em;
        display: flex; /* Permite alinhar o ícone e o texto */
        align-items: center;
        gap: 5px; /* Espaço entre o ícone e o texto */
        color: #dc3545; /* Garante a cor vermelha do texto/ícone */
    }
    /* ****************************************************** */
    
    /* Oculta o link de remover que estava duplicado na coluna 1 */
    .action-link-bottom-mobile {
        display: none !important;
    }
    
    .quantity-control {
        margin: 0;
        width: auto; 
        max-width: none;
        /* Alinha o controle de quantidade à direita, dentro do flex */
        justify-content: flex-end; 
    }
    
    .continue-shopping-top {
        margin: 0 15px 20px 15px; 
    }
    
  .shipping-info-box {
    /* CORREÇÃO CRÍTICA: AGORA É 100% DA LARGURA E MARGEM 0 LATERAL */
    width: 100%;
    margin: 10px 0 20px 0; /* Top=10, L/R=0, Bottom=20 */

    padding: 10px 15px; /* Mantém o padding interno para o conteúdo */

    /* Adicionado para o padding não quebrar a largura de 95% */
    box-sizing: border-box; 
}
    
    /* Estilo para a nova linha de frete no sticky footer */
    .shipping-info-mobile {
        display: none;
    }

    /* NOVO: Garante que o rótulo do frete não quebre o texto de forma estranha */
    .frete-label-mobile {
        display: flex; 
        align-items: center; /* Alinha o ícone e o texto */
        gap: 5px; 
        /* NOVO: Ajuda o texto a caber ao não forçar quebra de linha (removendo flex-wrap) */
        font-weight: 700; 
        color: #555; 
        min-width: 0; 
    }
    
    /* NOVO: Estilos para Iconografia no rodapé mobile */
    .tfoot-icon-mobile {
         font-size: 1.1em;
         margin-right: 5px;
    }
    .total-value-frete {
        font-weight: 700;
    }
    
    /* NOVO: Ajusta a mensagem de erro injetada */
    #checkout-error-message {
        margin: 10px 15px 20px 15px; 
        max-width: none;
    }
}