/* ==========================================
   ESTILOS DE PÁGINA DE CHECKOUT (JUGADA) - REDISEÑO V2
   ========================================== */

:root {
    --checkout-bg: #f1f5f9;  /* Un poco más oscuro para que resalte el blanco de las cajas */
    --checkout-card-bg: #ffffff;
    --checkout-primary: #1e293b; /* Color profundo para textos muy importantes */
    --checkout-accent: #059669;  /* Verde de acción más oscuro y notorio */
    --checkout-border: #cbd5e1;  /* Borde más notorio */
    --checkout-text-main: #0f172a; /* Texto casi negro para mejor contraste */
    --checkout-text-muted: #334155; /* Texto secundario más oscuro */
    --checkout-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
    --checkout-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
}

/* Reset de box-sizing para evitar desbordamientos */
.checkout-page *,
.checkout-page *::before,
.checkout-page *::after {
    box-sizing: border-box;
}

.checkout-page {
    background-color: var(--checkout-bg);
    min-height: 100vh;
    color: var(--checkout-text-main);
    font-family: 'Poppins', sans-serif;
    overflow-x: hidden; /* DEFINITIVO: Sin desplazamiento horizontal */
}

.checkout-page .navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--checkout-border);
}

.checkout-page .nav-links a {
    color: var(--checkout-text-main);
    font-weight: 500;
}

.checkout-main {
    padding-top: 20px;
    padding-bottom: 60px;
    background: linear-gradient(180deg, #e0e7ff 0%, var(--checkout-bg) 200px);
    overflow-x: hidden;
    width: 100%;
}

/* Enlace Volver al Inicio */
.checkout-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    margin: 0 20px 20px;
    color: var(--checkout-primary);
    background: white;
    border-radius: 12px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: var(--checkout-shadow);
    transition: all 0.2s;
    border: 1px solid var(--checkout-border);
}

.checkout-back-link:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.2);
}

.checkout-header-section {
    text-align: center;
    margin-bottom: 30px;
    padding: 0 20px;
}

/* STEPS MEJORADO */
.checkout-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
    font-size: 0.95rem;
    font-weight: 700;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #94a3b8;
    transition: all 0.3s;
}

.step-item.active {
    color: var(--color-primary);
}

.step-item.active .step-circle {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

.step-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: white;
    border: 2px solid #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    transition: all 0.3s;
}

.step-line {
    height: 3px;
    width: 40px;
    background: #e2e8f0;
    border-radius: 2px;
}

.checkout-title {
    font-size: 3rem;
    font-weight: 900;
    color: var(--checkout-primary);
    margin-bottom: 10px;
    letter-spacing: -1px;
}

.checkout-subtitle {
    font-size: 1.2rem;
    color: var(--checkout-text-muted);
    font-weight: 500;
    max-width: 600px;
    margin: 0 auto;
}

/* LAYOUT 2 COLUMNAS (Flujo Lineal y Ordenado) */
.checkout-grid-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px; /* 2 Columnas */
    gap: 30px;
    max-width: 1200px; /* Ancho optimizado para legibilidad */
    margin: 0 auto;
    padding: 0 20px;
    align-items: start;
}

/* Columna Izquierda (Todos los pasos) */
.checkout-left-column {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.checkout-card {
    background: var(--checkout-card-bg);
    border-radius: 20px;
    padding: 30px;
    border: 1px solid var(--checkout-border);
    box-shadow: var(--checkout-shadow);
}

.checkout-section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 25px;
    color: var(--checkout-primary);
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 12px;
}

.checkout-section-title i {
    color: white;
    background: var(--color-primary);
    padding: 8px;
    border-radius: 10px;
    font-size: 1.1rem;
}

/* Grilla de Animales Integrada */
.checkout-animals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
    gap: 10px;
    margin-top: 15px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 5px;
}

.checkout-animals-grid::-webkit-scrollbar {
    width: 6px;
}
.checkout-animals-grid::-webkit-scrollbar-thumb {
    background-color: var(--checkout-border);
    border-radius: 10px;
}

.checkout-animal-cell {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    position: relative;
}

.checkout-animal-cell:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.2);
}

.checkout-animal-cell img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 6px;
    transition: opacity 0.2s;
}

.checkout-animal-cell .num {
    font-weight: bold;
    font-size: 0.85rem;
    margin-top: 4px;
    color: var(--checkout-text-main);
}

/* ESTADO SELECCIONADO EN GRILLA */
.checkout-animal-cell.selected-in-grid {
    border-color: var(--checkout-accent);
    background-color: #ecfdf5; /* Verde muy claro */
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.checkout-animal-cell.selected-in-grid::after {
    content: '\f00c'; /* Check de FontAwesome */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--checkout-accent);
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: 2px solid white;
}


/* Campos de Formulario */
.checkout-page input[type="text"],
.checkout-page input[type="tel"],
.checkout-page input[type="number"] {
    background: #ffffff;
    border: 2px solid #94a3b8;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 1.05rem;
    color: var(--checkout-text-main);
    font-weight: 500;
    width: 100%;
}

.checkout-page input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    outline: none;
}

.checkout-page label {
    font-weight: 700;
    color: var(--checkout-text-main);
    margin-bottom: 6px;
    display: block;
}

/* Errores visuales UX */
.input-error {
    border-color: #ef4444 !important;
    background-color: #fef2f2 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}

.error-msg {
    color: #ef4444;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 5px;
    display: none;
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-3px); }
}

/* Grillas Internas */
.checkout-page .schedule-grid,
.checkout-page .currency-grid,
.checkout-page .payment-grid {
    display: grid;
    gap: 10px;
    margin-top: 10px;
    width: 100%;
}
.checkout-page .schedule-grid {
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
}
.checkout-page .currency-grid {
    grid-template-columns: repeat(3, 1fr); /* Bs, USD, COP en fila */
}
.checkout-page .payment-grid {
    grid-template-columns: repeat(2, 1fr);
}

.checkout-page .schedule-btn,
.checkout-page .currency-card,
.checkout-page .payment-card {
    background: #f8fafc;
    border: 2px solid #cbd5e1;
    border-radius: 12px;
    padding: 12px;
    font-weight: 600;
    color: #1e293b !important; /* Negro garantizado para que siempre se lea */
    cursor: pointer;
    text-align: center;
    width: 100%;
    transition: all 0.2s;
}

/* Tarjetas de método de pago: icono + texto centrado */
.checkout-page .payment-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 70px;
}
.checkout-page .payment-card i {
    font-size: 1.3rem;
    color: #1e293b !important;
}
.checkout-page .payment-card span {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    color: #1e293b !important;
}

/* Moneda: solo texto, centrado */
.checkout-page .currency-card {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    font-size: 1rem;
    letter-spacing: 0.5px;
    color: #1e293b !important;
}

.checkout-page .schedule-btn:hover,
.checkout-page .currency-option:hover .currency-card,
.checkout-page .payment-option:hover .payment-card {
    border-color: var(--color-primary);
    background: #eff6ff;
    color: var(--checkout-text-main);
}

/* Estado activo/seleccionado: verde esmeralda (igual que Validar Ticket) */
.checkout-page .schedule-btn.active {
    border-color: #047857;
    background: #059669;
    color: white !important;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35);
    font-weight: 700;
}

.checkout-page input:checked + .currency-card,
.checkout-page input:checked + .payment-card {
    border-color: #047857;
    background: #059669;
    color: white !important;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35);
}

.checkout-page input:checked + .currency-card i,
.checkout-page input:checked + .payment-card i,
.checkout-page input:checked + .currency-card span,
.checkout-page input:checked + .payment-card span {
    color: white !important;
}

/* Jugada Sidebar */
.checkout-sticky-side {
    position: sticky;
    top: 100px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Inputs de Montos individuales */
.selected-animal-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
    border: 1px solid var(--checkout-border);
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 8px;
    animation: slideIn 0.3s ease-out forwards;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.selected-animal-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.selected-animal-info span {
    color: var(--checkout-text-main);
}

.selected-animal-img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
}

.animal-amount-input {
    width: 70px !important;
    padding: 6px 8px !important;
    text-align: right;
    font-weight: bold;
    color: var(--checkout-accent) !important;
    margin-right: 10px;
    border-color: var(--checkout-border) !important;
}

.animal-amount-input:focus {
    border-color: var(--checkout-accent) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2) !important;
}

.remove-animal {
    color: #ef4444;
    cursor: pointer;
    padding: 5px;
    transition: transform 0.2s;
}

.remove-animal:hover {
    transform: scale(1.2);
}

/* Botón Final / Total */
.checkout-total-box {
    background: #f1f5f9;
    border: 2px dashed #94a3b8;
    border-radius: 12px;
    padding: 15px;
    margin: 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.2rem;
    font-weight: 800;
}

.checkout-submit {
    height: 60px;
    font-size: 1.2rem;
    font-weight: 800;
    border-radius: 14px;
    background: var(--checkout-accent);
    color: white;
    width: 100%;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(5, 150, 105, 0.3);
    transition: all 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.checkout-submit:hover {
    background: #047857;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(5, 150, 105, 0.4);
}

.summary-mascot {
    width: 120px;
    margin: -40px auto 10px;
    display: block;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.15));
    animation: float 4s ease-in-out infinite;
}

/* RESPONSIVE MÓVIL (DEFINITIVO) */
@media (max-width: 992px) {
    .checkout-main {
        padding-top: 10px;
    }
    .checkout-title {
        font-size: 1.7rem;
        letter-spacing: -0.5px;
    }
    .checkout-subtitle {
        font-size: 0.9rem;
        padding: 0 10px;
    }
    .checkout-steps {
        font-size: 0.78rem;
        gap: 6px;
        flex-wrap: nowrap;
    }
    .step-circle {
        width: 24px;
        height: 24px;
        font-size: 0.8rem;
        flex-shrink: 0;
    }
    .step-line {
        width: 15px;
        flex-shrink: 0;
    }
    .step-item span:last-child {
        white-space: nowrap;
    }
    .checkout-back-link {
        margin: 0 15px 15px;
        padding: 8px 15px;
        font-size: 0.85rem;
    }
    .checkout-grid-layout {
        grid-template-columns: 1fr;
        padding: 0 12px;
        gap: 18px;
        width: 100%;
    }
    .checkout-left-column {
        order: 1;
        width: 100%;
        min-width: 0;
    }
    .checkout-sticky-side {
        position: static !important;
        order: 2;
        margin-top: 10px;
        width: 100%;
        min-width: 0;
    }
    .checkout-card {
        padding: 18px 15px;
        border-radius: 15px;
    }
    .checkout-section-title {
        font-size: 1.1rem;
        margin-bottom: 15px;
    }
    /* Forzar que grillas de moneda/pago quepan en móvil */
    .checkout-page .currency-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    .checkout-page .payment-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .checkout-page .currency-card,
    .checkout-page .payment-card {
        padding: 10px 5px;
        font-size: 0.85rem;
    }
    .checkout-page .payment-card span {
        font-size: 0.8rem;
    }
    /* Campos de texto 100% sin overflow */
    .checkout-page input[type="text"],
    .checkout-page input[type="tel"],
    .checkout-page input[type="number"] {
        width: 100%;
        max-width: 100%;
        font-size: 0.95rem;
    }
    .checkout-animals-grid {
        grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
        gap: 6px;
        max-height: 350px;
    }
    .summary-mascot {
        width: 90px;
    }
}

/* Fix iPhone pequeño */
@media (max-width: 375px) {
    .checkout-title { font-size: 1.5rem; }
    .step-item span:last-child { display: none; }
    .checkout-page .currency-card,
    .checkout-page .payment-card { padding: 8px 3px; font-size: 0.75rem; }
    .schedule-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ESTILIZACIÓN DEL TUTORIAL (Driver.js) */
.driver-popover {
    border-radius: 16px !important;
    padding: 20px !important;
    border: none !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1) !important;
    font-family: 'Poppins', sans-serif !important;
}
.driver-popover-title {
    font-size: 1.25rem !important;
    font-weight: 800 !important;
    color: var(--checkout-primary) !important;
    margin-bottom: 10px !important;
}
.driver-popover-description {
    font-size: 0.95rem !important;
    color: var(--checkout-text-muted) !important;
    line-height: 1.5 !important;
}
.driver-popover-footer button {
    border-radius: 10px !important;
    font-weight: 600 !important;
    padding: 8px 16px !important;
    text-shadow: none !important;
    border: none !important;
    transition: all 0.2s;
}
.driver-popover-next-btn, .driver-popover-done-btn {
    background-color: var(--color-primary) !important;
    color: white !important;
}
.driver-popover-next-btn:hover, .driver-popover-done-btn:hover {
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3) !important;
}
.driver-popover-prev-btn {
    background-color: #f1f5f9 !important;
    color: var(--checkout-primary) !important;
}
.driver-popover-close-btn {
    color: #94a3b8 !important;
}
.driver-popover-close-btn:hover {
    color: #ef4444 !important;
}
/* Fix driver.js en móvil */
@media (max-width: 992px) {
    .driver-popover {
        max-width: 90vw !important;
        min-width: 260px !important;
    }
    .driver-popover-title {
        font-size: 1.1rem !important;
    }
    .driver-popover-description {
        font-size: 0.88rem !important;
    }

    /* Grilla más grande y táctil para mayor facilidad */
    .checkout-animals-grid {
        grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
        gap: 8px;
    }
    .checkout-animal-cell {
        padding: 8px 5px;
    }
    .checkout-animal-cell .num {
        font-size: 1rem;
        font-weight: 800;
    }
}

/* Botón secundario para expandir/colapsar búsqueda por texto */
.toggle-grid-btn {
    width: 100%;
    padding: 10px 14px;
    background: #f8fafc;
    border: 2px solid #cbd5e1;
    border-radius: 12px;
    color: #475569;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    margin-top: 10px;
    transition: all 0.2s;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.toggle-grid-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #1e293b;
}
.collapsed-grid {
    display: none;
}
.animal-search-panel.collapsed-grid {
    display: none;
}

/* Desglose informativo del total (Multi-horario) */
.schedule-breakdown-container {
    margin-top: 15px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 15px;
}

.schedule-breakdown-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: #475569;
    font-weight: 500;
}

.schedule-breakdown-row .schedule-label {
    display: flex;
    align-items: center;
    gap: 6px;
}

.schedule-breakdown-row .schedule-label i {
    color: #3b82f6;
}

.schedule-breakdown-row .schedule-amount {
    font-weight: 700;
    color: #1e293b;
}

.total-info-helper {
    font-size: 0.8rem;
    color: #64748b;
    text-align: right;
    margin-top: -12px;
    margin-bottom: 12px;
    font-weight: 600;
    font-style: italic;
    display: block;
    width: 100%;
}

.total-info-helper i {
    color: #059669;
    margin-right: 4px;
}
