/**
 * checkout.css — Estilos da página de Checkout (carrinho-finalizar.php)
 *
 * Mobile-first. Touch targets mínimos de 44px.
 * Extraído dos inline styles do template + melhorias de UX.
 *
 * Seções:
 *   1. Layout geral
 *   2. Steps de progresso
 *   3. Seções do formulário
 *   4. Tabs de endereço
 *   5. Frete
 *   6. Pagamento — WebCheckout Getnet
 *   7. Pagamento — PIX
 *   8. Pagamento — Boleto
 *   9. Pagamento — Cartão
 *  10. Resumo do pedido (sidebar)
 *  11. Botões de ação
 *  12. Selos de confiança
 *  13. Área de login/cadastro (não logado)
 *  14. Utilitários de feedback (loading, erros, alerts)
 *  15. Media queries
 */

/* =========================================================
   1. LAYOUT GERAL
   ========================================================= */

.checkout-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.checkout-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

@media (min-width: 992px) {
    .checkout-layout {
        flex-direction: row;
        align-items: flex-start;
    }

    .checkout-main {
        flex: 1 1 auto;
        min-width: 0;
    }

    .checkout-sidebar {
        flex: 0 0 340px;
        width: 340px;
        position: sticky;
        top: 20px;
    }
}

/* =========================================================
   2. STEPS DE PROGRESSO
   ========================================================= */

.checkout-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 32px;
    padding: 16px 0;
}

.checkout-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: .82em;
    color: #aaa;
    min-width: 60px;
}

.checkout-step.active {
    color: #0066cc;
    font-weight: 600;
}

.checkout-step.done {
    color: #28a745;
}

.checkout-step .step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e9ecef;
    color: #aaa;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .9em;
    font-weight: 700;
}

/* Ícone de check: reduzido para caber no círculo */
.checkout-step.done .step-num .icon-check {
    font-size: .7em;
}

.checkout-step.active .step-num {
    background: #0066cc;
    color: #fff;
}

.checkout-step.done .step-num {
    background: #28a745;
    color: #fff;
}

.checkout-step-divider {
    flex: 1 0 20px;
    max-width: 60px;
    height: 2px;
    background: #e9ecef;
    margin-bottom: 20px;
}

/* =========================================================
   3. SEÇÕES DO FORMULÁRIO
   ========================================================= */

.checkout-section {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

.checkout-section-title {
    font-size: 1.05em;
    font-weight: 700;
    margin-bottom: 18px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #0066cc;
    color: #fff;
    font-size: .78em;
    font-weight: 700;
    flex-shrink: 0;
}

.customer-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
}

.customer-info-item .ci-label {
    font-size: .75em;
    color: #999;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.customer-info-item .ci-value {
    font-weight: 600;
    color: #333;
    font-size: .95em;
}

/* =========================================================
   4. TABS DE ENDEREÇO
   ========================================================= */

.address-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    border-bottom: 2px solid #e8e8e8;
}

.address-tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: #666;
    font-size: .9em;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .2s, border-color .2s;
    min-height: 44px;
}

/* Ícone da tab: tamanho reduzido */
.address-tab-btn .icon-truck-light,
.address-tab-btn .icon-doc {
    font-size: .85em;
}

.address-tab-btn.active,
.address-tab-btn:hover {
    color: #0066cc;
    border-bottom-color: #0066cc;
}

/* Link "Não sei meu CEP" */
.input-group .cep-nao-sei {
    text-decoration: none;
    font-size: .75em;
    color: #666;
    transition: color .2s;
}

.input-group .cep-nao-sei:hover {
    color: #0066cc;
}

/* =========================================================
   5. FRETE
   ========================================================= */

.shipping-placeholder {
    text-align: center;
    color: #aaa;
    padding: 28px 16px;
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    font-size: .95em;
}

.shipping-placeholder .icon-truck-light {
    display: block;
    font-size: 2em;
    margin-bottom: 8px;
    opacity: .4;
}

/* =========================================================
   6. PAGAMENTO — WEBCHECKOUT GETNET
   ========================================================= */

.webcheckout-info {
    padding: 24px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
    text-align: center;
}

.webcheckout-lock-icon {
    font-size: 2.2em;
    color: #28a745;
    margin-bottom: 14px;
    display: block;
}

.webcheckout-title {
    margin-bottom: 10px;
    color: #333;
    font-size: 1em;
    font-weight: 600;
}

.webcheckout-desc {
    color: #666;
    font-size: .95em;
    margin-bottom: 14px;
}

.webcheckout-metodos {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.webcheckout-metodo-badge {
    padding: 5px 15px;
    background: #fff;
    border-radius: 20px;
    border: 1px solid #ddd;
    font-size: .85em;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 32px;
}

.webcheckout-metodo-badge img {
    vertical-align: middle;
    display: inline-block;
}

.webcheckout-security-note {
    color: #999;
    font-size: .8em;
}

/* =========================================================
   7. PAGAMENTO — PIX (card exibido após gerar o código)
   ========================================================= */

.pix-payment-card {
    display: none;
    margin-top: 20px;
}

.pix-payment-card.ativo {
    display: block;
}

#pix-qr {
    max-width: 200px;
    border-radius: 8px;
}

#pix-code-input {
    min-height: 12em;
    font-size: .8em;
    resize: none;
}

.btn-copy-pix {
    width: 100%;
    text-align: center;
    margin-top: 8px;
    min-height: 44px;
}

/* =========================================================
   8. PAGAMENTO — BOLETO (card exibido após gerar)
   ========================================================= */

.boleto-info-card {
    display: none;
    margin-top: 20px;
}

.boleto-info-card.ativo {
    display: block;
}

.boleto-card-header {
    background: #ff6600;
    color: #fff;
    border-radius: 8px 8px 0 0;
}

.boleto-print-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 8px 20px;
}

/* =========================================================
   9. PAGAMENTO — MÉTODOS (radio + labels)
   ========================================================= */

.payment-methods {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.payment-option {
    flex: 1 0 120px;
    max-width: 160px;
}

.payment-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.payment-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    font-size: .88em;
    text-align: center;
    transition: border-color .2s, box-shadow .2s, background .2s;
    min-height: 76px;
}

.payment-label:hover {
    border-color: #0066cc;
}

.payment-option.active .payment-label,
.payment-option input:checked + .payment-label {
    border-color: #0066cc;
    background: #eef5ff;
    box-shadow: 0 0 0 3px rgba(0,102,204,.12);
}

.payment-label .card-logos {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}

.payment-label .card-logos img {
    width: 28px;
    height: auto;
}

.checkout-unavailable {
    text-align: center;
    color: #aaa;
    padding: 32px;
}

.checkout-unavailable .icon-cancel {
    font-size: 2.5em;
    display: block;
    margin-bottom: 12px;
}

/* Alerta informativo Getnet sem WebCheckout */
.getnet-dpm-alert {
    font-size: .88em;
}

/* =========================================================
   10. RESUMO DO PEDIDO (SIDEBAR)
   ========================================================= */

.order-summary-box {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    padding: 22px 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.order-summary-box h3 {
    font-size: 1.05em;
    font-weight: 700;
    margin-bottom: 16px;
    color: #333;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 12px;
}

.order-summary-items {
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 0;
}

/* Tabela totais: sem margem superior (continua após os itens) */
.order-summary-totals {
    margin-top: 0;
}

/* Linha de frete no resumo */
.shipping-total {
    font-size: .85em;
    color: #999;
}

.shipping-total th {
    font-weight: 400;
}

.shipping-total td {
    text-align: right;
    font-weight: 400;
}

/* Total final */
.order-total td {
    text-align: right;
}

/* =========================================================
   11. BOTÕES DE AÇÃO
   ========================================================= */

.btn-finalizar {
    width: 100%;
    text-align: center;
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
    font-size: 1em;
    font-weight: 600;
    border-radius: 8px;
    transition: opacity .2s;
}

/* Ícone de cadeado no botão finalizar */
.btn-finalizar .icon-lock {
    font-size: .85em;
}

.btn-finalizar:disabled,
.btn-finalizar.loading {
    opacity: .7;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-finalizar .spinner-border {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.btn-voltar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin-top: 10px;
    text-align: center;
    padding: 10px;
    min-height: 44px;
    font-size: .9em;
    color: #666;
    text-decoration: none;
    border-radius: 6px;
    transition: background .2s, color .2s;
}

/* Ícone da seta no botão voltar */
.btn-voltar .icon-left-open {
    font-size: .8em;
}

.btn-voltar:hover {
    background: #f0f0f0;
    color: #333;
}

/* =========================================================
   12. SELOS DE CONFIANÇA
   ========================================================= */

.checkout-trust {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid #f0f0f0;
    padding-top: 14px;
}

.checkout-trust-item {
    font-size: .8em;
    color: #888;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* =========================================================
   13. ÁREA DE LOGIN/CADASTRO (USUÁRIO NÃO LOGADO)
   ========================================================= */

.auth-page {
    padding: 0;
}

.auth-card {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    padding: 28px 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,.05);
}

.auth-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}

.auth-card-icon {
    font-size: 2em;
    color: #0066cc;
}

.auth-card-header h3 {
    margin: 0 0 2px;
    font-size: 1.05em;
    font-weight: 700;
}

.auth-card-header p {
    margin: 0;
    color: #888;
    font-size: .88em;
}

.auth-field {
    margin-bottom: 16px;
}

.auth-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input-icon {
    position: absolute;
    left: 12px;
    color: #aaa;
    font-size: .9em;
    pointer-events: none;
}

.auth-input {
    width: 100%;
    padding: 11px 40px 11px 36px;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: .95em;
    transition: border-color .2s, box-shadow .2s;
    min-height: 44px;
}

.auth-input:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0,102,204,.1);
}

.auth-toggle-pw {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    padding: 4px;
    font-size: 1em;
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .2s;
}

.auth-toggle-pw:hover {
    color: #0066cc;
}

.auth-type-selector {
    display: flex;
    gap: 10px;
}

.auth-type-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    font-size: .9em;
    transition: border-color .2s, background .2s;
    min-height: 44px;
}

.auth-type-option:has(input:checked),
.auth-type-option.active {
    border-color: #0066cc;
    background: #eef5ff;
    color: #0066cc;
}

.auth-type-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Campo PJ oculto por padrão (JS alterna) */
#pj_fields {
    display: none;
}

.auth-divider-col {
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0;
}

.auth-divider-line {
    flex: 1;
    width: 1px;
    background: #e0e0e0;
}

.auth-divider-text {
    padding: 8px 4px;
    color: #aaa;
    font-size: .8em;
    font-weight: 600;
    white-space: nowrap;
}

.auth-divider-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
}

/* =========================================================
   14. FEEDBACK (LOADING, ERRO, VALIDAÇÃO)
   ========================================================= */

/* Estado de carregamento no botão principal */
.btn-finalizar .checkout-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: checkout-spin .7s linear infinite;
    flex-shrink: 0;
}

.btn-finalizar.loading .checkout-spinner {
    display: inline-block;
}

.btn-finalizar.loading .btn-finalizar-icon {
    display: none;
}

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

/* Banner de divergências de carrinho/frete */
.checkout-divergencias-alert {
    display: none;
    margin-bottom: 16px;
}

.checkout-divergencias-alert.ativo {
    display: block;
}

.checkout-divergencias-alert ul {
    margin: 8px 0 0;
    padding-left: 20px;
    font-size: .9em;
}

/* =========================================================
   15. MEDIA QUERIES
   ========================================================= */

@media (max-width: 575px) {
    .checkout-section {
        padding: 16px 14px;
    }

    .order-summary-box {
        padding: 16px 14px;
    }

    .checkout-steps {
        gap: 4px;
    }

    .checkout-step {
        font-size: .72em;
        min-width: 48px;
    }

    .checkout-step .step-num {
        width: 28px;
        height: 28px;
        font-size: .8em;
    }

    .payment-option {
        flex: 1 0 100px;
        max-width: 140px;
    }

    .auth-type-selector {
        flex-direction: column;
    }

    .auth-type-option {
        flex: none;
    }

    .webcheckout-info {
        padding: 16px;
    }
}

@media (max-width: 767px) {
    .checkout-layout {
        gap: 16px;
    }

    .customer-info-grid {
        grid-template-columns: 1fr 1fr;
    }

    .webcheckout-metodos {
        gap: 8px;
    }

    /* Sidebar vai para baixo do formulário em mobile */
    .checkout-sidebar {
        order: 2;
        width: 100%;
    }

    .checkout-main {
        order: 1;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .checkout-layout {
        gap: 20px;
    }
}
