/* ==============================================
   FONDO PREMIUM Y TÍTULOS
   ============================================== */
body {
    background-color: var(--bg-secondary); 
    background-image: none;
}

.page-header-title {
    text-align: center;
    color: #ffffff;
    margin-bottom: 10px;
    margin-top: calc(var(--header-height, 105px) + 20px); 
    padding: 0 15px;
}

.page-header-title h1 {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    font-weight: 900;
    text-transform: uppercase;
    margin-bottom: 10px;
    letter-spacing: 1px;
    color: #ffffff;
}

.page-header-title p {
    color: #d1d5db;
    font-size: 1.05rem;
}

.app-wrapper {
    overflow: visible !important;
    clip-path: none !important;
}

/* =========================================================================
   ESTRUCTURA PRINCIPAL DEL CHECKOUT (RESPONSIVE + STICKY EN PC)
   ========================================================================= */

/* 1. Base para Celulares (< 992px): 1 Columna, Resumen Primero, Formulario Segundo */
.checkout-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px 40px 15px;
    box-sizing: border-box;
    width: 100%;
}

.checkout-summary-col {
    order: 1; /* En celular el resumen va arriba */
}

.checkout-form-col {
    order: 2; /* En celular el formulario va abajo */
}

/* 2. Computadora (>= 992px): 2 Columnas Paralelas + Resumen Sticky que te persigue */
@media (min-width: 992px) {
    .checkout-wrapper {
        display: grid;
        grid-template-columns: 1fr 380px;
        gap: 30px;
        align-items: start;
    }

    .checkout-form-col {
        order: initial;
    }

    .checkout-summary-col {
        order: initial;
        position: sticky;
        top: calc(var(--header-height, 105px) + 20px);
        align-self: start;
    }
}

/* ==============================================
   CAJAS DE SECCIONES (Datos Personales, etc)
   ============================================== */
.checkout-section {
    background-color: var(--bg-surface);
    padding: 20px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow-lg); 
    margin-bottom: 25px;
    border: 1px solid rgba(255,255,255,0.05);
}

@media (min-width: 768px) {
    .checkout-section {
        padding: 30px;
    }
}

.checkout-section h3 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    margin-top: 0;
    font-weight: 800;
    color: #111;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 12px;
    text-transform: uppercase;
}

/* ==============================================
   CAMPOS DEL FORMULARIO
   ============================================== */
.input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 18px;
    width: 100%;
    position: relative;
}

.input-group label {
    font-size: 13px;
    font-weight: 700;
    color: #444;
    margin-bottom: 8px;
}

.checkout-input, 
.checkout-select {
    width: 100%;
    padding: 14px;
    background-color: #fdfdfd;
    border: 1px solid var(--border-input);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    box-sizing: border-box;
    transition: all 0.3s;
    font-family: inherit;
}

.checkout-input:focus, 
.checkout-select:focus {
    border-color: var(--border-input-focus);
    outline: none;
    box-shadow: 0 0 0 3px var(--bg-input-focus);
}

/* Validación (Borde rojo) */
.checkout-input.error, 
.checkout-select.error {
    border-color: var(--color-error);
    background-color: var(--bg-error-soft);
}

.error-text {
    color: var(--color-error);
    font-size: 11px;
    font-weight: bold;
    margin-top: 4px;
    display: none;
}

.input-group.has-error .error-text {
    display: block;
}

/* ==============================================
   MAPA, BOTONES Y ACCIONES DEL FORMULARIO
   ============================================== */
.map-container {
    width: 100%;
    height: 250px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-input);
    margin-bottom: 15px;
    z-index: 1; 
}

@media (min-width: 768px) {
    .map-container {
        height: 350px;
    }
}

.search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.search-row input {
    margin-bottom: 0;
}

.btn-buscar {
    background-color: #333;
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    padding: 0 20px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}

.btn-buscar:hover {
    background-color: #555;
}

.btn-gps {
    width: 100%;
    background-color: var(--bg-btn-primary); 
    color: var(--text-btn-primary);
    border: none;
    padding: 12px;
    font-size: 14px;
    font-weight: bold;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    margin-bottom: 20px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.3s, transform 0.2s;
}

.btn-gps:hover {
    background-color: var(--bg-btn-primary-hover);
    transform: translateY(-2px);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
    cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--bg-btn-primary);
}

.checkbox-row label {
    font-size: 14px;
    font-weight: bold;
    color: #444;
    cursor: pointer;
}

.checkout-textarea {
    resize: none; 
    min-height: 90px;
    max-height: 200px; 
    overflow-y: auto;
}

/* Base (Móvil): Botones de acción apilados */
.checkout-actions {
    display: flex;
    flex-direction: column-reverse;
    gap: 20px;
    align-items: center;
    margin-top: 10px;
}

.btn-submit {
    background-color: var(--bg-btn-whatsapp);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 15px;
    font-weight: bold;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 8px;
    transition: background 0.3s, transform 0.2s;
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.3);
    text-transform: uppercase;
}

.btn-submit:hover {
    background-color: var(--bg-btn-whatsapp-hover);
    transform: scale(1.02);
}

.btn-back {
    color: #d1d5db;
    text-decoration: none;
    font-weight: bold;
    font-size: 14px;
    transition: color 0.3s;
}

.btn-back:hover {
    color: var(--bg-surface);
    text-decoration: underline;
}

@media (min-width: 768px) {
    .checkout-actions {
        flex-direction: row;
        justify-content: space-between;
        gap: 0;
    }
    .btn-submit {
        width: auto;
    }
}

/* ==============================================
   COLUMNA DERECHA: RESUMEN Y PRECIOS
   ============================================== */
.checkout-summary-col {
    background-color: var(--bg-surface); 
    padding: 20px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow-lg);
    border: 1px solid rgba(0,0,0,0.05);
}

@media (min-width: 768px) {
    .checkout-summary-col {
        padding: 30px;
    }
}

#resumen-productos-lista button {
    display: none !important;
}

#resumen-productos-lista .quantity-controls, 
#resumen-productos-lista .qty-btn {
    pointer-events: none;
}

.summary-totals {
    border-top: 2px solid #eee;
    margin-top: 10px;
    padding-top: 20px;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    color: #666;
    font-size: 14px;
}

/* CORRECCIÓN UX: Todo el total en una sola línea fluida */
.summary-total-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: clamp(1rem, 3.5vw, 1.25rem);
    font-weight: bold;
    margin-top: 15px;
    color: #000;
    gap: 10px;
    flex-wrap: nowrap; /* Impide saltos de línea bruscos */
}

.total-price-highlight {
    color: var(--bg-btn-primary);
    font-size: clamp(1.2rem, 4vw, 1.6rem);
    font-weight: 900;
    white-space: nowrap; /* Mantiene la cifra y el texto de envío unidos */
    text-align: right;
}

.btn-editar-cantidades {
    font-size: 0.8rem;
    color: var(--border-input-focus);
    background-color: #eef4ff;
    padding: 8px 14px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: bold;
    border: 1px solid #cce0ff;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-transform: uppercase;
}

.btn-editar-cantidades:hover {
    background-color: #dbe8ff;
    transform: translateY(-2px);
}

/* --- Monto Mínimo de Compra: etiqueta permanente (informativa) + aviso (cuando falta) --- */
.checkout-minimo-tag {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #e8f9ee;
    color: #1a7f37;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 7px 12px;
    border-radius: 20px;
    margin-top: 15px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border: 1px solid #b8ecc9;
}

.checkout-minimo-aviso {
    display: none;
    background-color: #fff8e1;
    color: #856404;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 15px;
    text-align: center;
    line-height: 1.4;
    border: 1px solid #ffe088;
}

.warning-box {
    background-color: #fff8e1;
    border-left: 4px solid #ffc107;
    color: #856404;
    padding: 15px;
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
    font-size: 12px;
    margin-top: 30px;
    display: flex;
    gap: 10px;
    align-items: center;
}

/* =========================================================================
   PANTALLA DE CONFIRMACIÓN (100% CENTRADA EN PC Y RESPONSIVA EN MÓVIL)
   ========================================================================= */

.checkout-wrapper.modo-confirmacion {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    min-height: 45vh !important;
    width: 100% !important;
    margin-top: calc(var(--header-height, 105px) + 20px) !important;
    margin-bottom: 50px !important;
    padding: 0 15px !important;
    grid-template-columns: none !important; /* Desactiva la grilla de 2 columnas */
}

.checkout-wrapper.modo-confirmacion #contenedor-resumen {
    width: 100% !important;
    max-width: 580px !important;
    margin: 0 auto !important;
}

.confirmation-card {
    grid-column: 1 / -1 !important; 
    margin: 0 auto !important;
    max-width: 580px;
    width: 100%;
    text-align: center;
    padding: 25px 20px;
    background-color: #ffffff;
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
    border: 1px solid #e5e7eb;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .confirmation-card {
        padding: 40px 35px;
    }
}

.confirmation-card h3 {
    color: #111827 !important;
    font-size: clamp(1.3rem, 4vw, 1.65rem);
    font-weight: 800;
    margin-top: 0;
    margin-bottom: 12px;
}

.confirmation-card p {
    color: #374151 !important;
    font-size: 0.98rem;
    margin-bottom: 6px;
    line-height: 1.4;
}

.confirmation-card .subtext {
    color: #6b7280 !important;
    font-size: 0.88rem;
    margin-bottom: 24px;
}

.confirmation-actions {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 340px;
    margin: 0 auto;
}

/* Botón WhatsApp */
.confirmation-actions a.btn-whatsapp-manual {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-decoration: none;
    box-sizing: border-box;
}

.confirmation-actions .wa-icon {
    flex-shrink: 0;
}

/* Botón Volver al Catálogo */
.btn-volver-catalogo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 13px 20px;
    background-color: transparent;
    color: #1f2937 !important;
    border: 2px solid #374151;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.25s ease;
    box-sizing: border-box;
}

.btn-volver-catalogo:hover {
    background-color: #1f2937;
    color: #ffffff !important;
    border-color: #1f2937;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
/* ==========================================================================
   [FASE 6 - CHECKOUT FIX] PROTECCIÓN DE OVERFLOW: SELECT DE ZONA DE ENVÍO
   Si el nombre de una ZonaEnvio es largo, evita que rompa el ancho del
   select truncándolo con "...". No toca la regla compartida
   .checkout-input, .checkout-select — es un bloque nuevo, aparte, que
   solo agrega estas 3 propiedades encima de las que ya existen.
   Con nombres cortos de zona (como ahora) no cambia nada visualmente.
   ========================================================================== */
.checkout-select {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}