/* ============================================
   AUTOFIN - Modal de Crédito desde Ficha de Auto (Caso 3)
   Colores Dukal: fondo #0b0b0b, accent #00A9DE, letras blancas
   ============================================ */

/* === Modal Overlay === */
.autofin-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.autofin-modal__backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
}

.autofin-modal__container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 720px;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    background: #1a1a1a;
    border-radius: 16px;
    border: 1px solid #2a2a2a;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    animation: autofin-modal-in 0.3s ease-out;
}

@keyframes autofin-modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Ocultamos la X original que no funciona */
.autofin-modal__close {
    display: none !important;
}

/* Header del modal con botón cerrar */
.autofin-modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #111;
    border-bottom: 1px solid #333;
    border-radius: 16px 16px 0 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.autofin-modal__header-title {
    color: #00A9DE;
    font-size: 16px;
    font-weight: 700;
    margin: 0;
}

.autofin-modal__close-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.autofin-modal__close-btn:hover {
    background: #c0392b;
    transform: scale(1.02);
}

.autofin-modal__close-btn:active {
    transform: scale(0.98);
}

/* === Wizard dentro del modal === */
.credito-wizard--modal {
    margin: 0;
    border: none;
    box-shadow: none;
    border-radius: 0;
    background: transparent;
    padding: 25px 30px 35px 30px;
}

/* === Inputs readonly (datos precargados) === */
.credito-wizard__input--readonly {
    padding: 12px 14px;
    font-size: 14px;
    background: #111 !important;
    color: #00A9DE !important;
    border: 1px solid #00A9DE33 !important;
    border-radius: 8px;
    cursor: default;
    font-weight: 600;
}

/* === Subtítulo === */
.credito-wizard__subtitle {
    font-size: 13px;
    color: #666;
    margin: -15px 0 20px;
}

/* === Botón trigger en la ficha === */
.autofin-btn-credito-wrapper {
    margin: 15px 0;
    padding: 0;
}

.autofin-btn-credito-listing {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 24px;
    font-size: 14px;
    font-weight: 700;
    font-family: 'Montserrat', sans-serif, Arial;
    background: linear-gradient(135deg, #00A9DE 0%, #0090bd 100%);
    color: #fff !important;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0, 169, 222, 0.3);
    text-decoration: none !important;
}

.autofin-btn-credito-listing:hover {
    background: linear-gradient(135deg, #0090bd 0%, #007aa0 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 169, 222, 0.4);
    color: #fff !important;
}

.autofin-btn-credito-listing:active {
    transform: translateY(0);
}

.autofin-btn-credito-listing__icon {
    font-size: 18px;
}

/* === Fallback: botón fijo si no se encuentra contenedor === */
.autofin-btn-credito-wrapper--fixed {
    position: fixed;
    bottom: 20px;
    left: 20px;
    top: auto;
    z-index: 9998;
    margin: 0;
}

.autofin-btn-credito-wrapper--fixed .autofin-btn-credito-listing {
    box-shadow: 0 4px 20px rgba(0, 169, 222, 0.5);
    padding: 14px 24px;
    font-size: 14px;
    animation: autofin-btn-pulse 2s infinite;
}

@keyframes autofin-btn-pulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(0, 169, 222, 0.4);
    }
    50% {
        box-shadow: 0 4px 30px rgba(0, 169, 222, 0.7);
    }
}

/* === Scrollbar del modal === */
.autofin-modal__container::-webkit-scrollbar {
    width: 6px;
}
.autofin-modal__container::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 0 16px 16px 0;
}
.autofin-modal__container::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

/* === Responsive === */
@media (max-width: 768px) {
    .autofin-modal {
        padding: 10px;
    }

    .autofin-modal__container {
        max-height: 95vh;
        border-radius: 12px;
    }

    .credito-wizard--modal {
        padding: 25px 18px;
    }

    .credito-wizard--modal .credito-wizard__row {
        grid-template-columns: 1fr;
    }

    .credito-wizard--modal .credito-wizard__progress {
        gap: 5px;
    }

    .credito-wizard--modal .credito-wizard__step-label {
        font-size: 9px;
    }

    .credito-wizard--modal .credito-wizard__actions {
        flex-direction: column;
    }

    .credito-wizard--modal .credito-wizard__btn--next,
    .credito-wizard--modal .credito-wizard__btn--submit {
        margin-left: 0;
    }

    .autofin-btn-credito-listing {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
    }
    
    .autofin-btn-credito-wrapper--fixed {
        bottom: 15px;
        left: 10px;
        right: auto;
        top: auto;
    }
    
    .autofin-btn-credito-wrapper--fixed .autofin-btn-credito-listing {
        width: 100%;
        justify-content: center;
    }
}

/* === Body scroll lock cuando modal está abierto === */
body.autofin-modal-open {
    overflow: hidden;
}

/* === Integración con tema Motors === */
.single-listing-sidebar .autofin-btn-credito-wrapper,
.stm-single-listing-sidebar .autofin-btn-credito-wrapper {
    margin-bottom: 20px;
    padding: 15px;
    background: #1a1a1a;
    border-radius: 8px;
    border: 1px solid #2a2a2a;
}

.single-listing-sidebar .autofin-btn-credito-listing,
.stm-single-listing-sidebar .autofin-btn-credito-listing {
    width: 100%;
    justify-content: center;
}

/* Si aparece dentro del precio */
.listing-price-box .autofin-btn-credito-wrapper,
.stm-car-price-box .autofin-btn-credito-wrapper {
    margin-top: 15px;
}

/* Para layouts donde va al lado del título */
.single-listing-title .autofin-btn-credito-wrapper,
.stm-single-listing-title .autofin-btn-credito-wrapper,
.listing-title-wrap .autofin-btn-credito-wrapper {
    display: inline-block;
    margin-left: 15px;
    vertical-align: middle;
}
