/* === PRELOADER === */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(37, 68, 141, 1) 0%, rgba(0, 37, 122, 1) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.preloader.hidden {
    opacity: 0;
    visibility: hidden;
}

.preloader-content {
    text-align: center;
    max-width: 400px;
    padding: 2rem;
}

.preloader-logo {
    margin-bottom: 3rem;
    animation: fadeInDown 0.6s ease-out;
}

.preloader-logo img {
    width: 120px;
    height: auto;
}

.pulse-logo {
    animation: pulseLogo 2s ease-in-out infinite;
}

@keyframes pulseLogo {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.progress-container {
    margin-bottom: 2rem;
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffffff 0%, #e0e7ff 50%, #ffffff 100%);
    background-size: 200% 100%;
    border-radius: 20px;
    width: 0%;
    transition: width 0.3s ease;
    animation: shimmer 1.5s infinite;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.progress-percentage {
    font-size: 2.5rem;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.05em;
}

.preloader-text {
    animation: fadeIn 0.6s ease-out 0.4s both;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.loading-dots {
    font-size: 1.2rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.05em;
}

.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {

    0%,
    20% {
        content: '';
    }

    40% {
        content: '.';
    }

    60% {
        content: '..';
    }

    80%,
    100% {
        content: '...';
    }
}

/* Responsive para preloader */
@media (max-width: 576px) {
    .preloader-logo img {
        width: 90px;
    }

    .progress-percentage {
        font-size: 2rem;
    }

    .loading-dots {
        font-size: 1rem;
    }
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #00257A;
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* === ESTRUCTURA PRINCIPAL === */
.main-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-height: 100vh;
    height: 100vh;
    background: radial-gradient(circle at center top, rgba(37, 68, 141, 1) 0%, rgba(0, 37, 122, 1) 100%);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

.main-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 300px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
}

/* === HEADER AZUL === */
#top-header-content {
    width: 100%;
    max-width: 500px;
    text-align: center;
    height: 230px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#top-header-content img {
    width: 96px;
    transition: transform 0.3s ease;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
    flex-shrink: 0;
}

#top-header-content img:hover {
    transform: scale(1.05);
}

#header-title {
    transition: all 0.3s ease;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    margin: 0;
    flex-shrink: 0;
}

#header-subtitle {
    transition: all 0.3s ease;
    opacity: 0.9;
    margin: 0;
    flex-shrink: 0;
}

/* === CONTENEDOR BLANCO PRINCIPAL === */
#form-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    background: #ffffff;
    border-top-left-radius: 1.5rem;
    border-top-right-radius: 1.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex !important;
    flex-direction: column !important;
    height: calc(100vh - 230px);
    overflow: hidden !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}

#form-container>main {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    min-height: 0 !important;
    position: relative !important;
}

#form-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(to right, #00257A, #25448D, #00257A);
    border-top-left-radius: 1.5rem;
    border-top-right-radius: 1.5rem;
}

/* Media query para tablets */
@media (max-width: 768px) and (min-width: 577px) {
    #form-container {
        height: calc(100vh - 150px);
        max-height: none;
    }

    #top-header-content {
        height: 150px !important;
        padding: 1rem 1.5rem !important;
    }

    #header-title {
        font-size: 1.65rem !important;
        line-height: 1.2 !important;
    }

    #header-subtitle {
        font-size: 0.95rem !important;
        line-height: 1.35 !important;
    }

    .form-scroll-area {
        padding-bottom: 1.5rem;
    }
}

/* === ÁREA SCROLL INTERNA === */
.form-scroll-area {
    padding: 1.5rem 1.5rem 6rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    position: relative;
    height: 100%;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

#form-steps-container .form-scroll-area {
    padding-bottom: 20rem;
}

/* Asegurar que el formulario use todo el espacio disponible */
#main-form {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    min-height: 0 !important;
}

/* El header del formulario no se encoge */
#form-steps-container>div:first-child {
    flex-shrink: 0 !important;
}

/* El form crece y se encoge según sea necesario */
#form-steps-container>form {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

/* Área de scroll dentro del form */
#main-form>.form-scroll-area {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    min-height: 0 !important;
}

/* Botón siempre visible */
#main-form>div:last-child {
    flex-shrink: 0 !important;
}

/* Scroll estético mejorado */
.form-scroll-area::-webkit-scrollbar {
    width: 6px;
}

.form-scroll-area::-webkit-scrollbar-track {
    background: transparent;
}

.form-scroll-area::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.form-scroll-area::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* === PASOS === */
.step {
    display: flex !important;
    flex-direction: column !important;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.step.hidden {
    opacity: 0;
    transform: translateY(20px);
    display: none !important;
    pointer-events: none;
}

/* Solo el form-steps-container necesita flex:1 para el scroll */
#form-steps-container {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

/* === SUBSTEPS === */
.substep {
    animation: slideIn 0.4s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.substep.hidden {
    display: none !important;
}

/* === INPUTS Y SELECTS === */
.form-control,
.form-select {
    border: 2px solid #e9ecef;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    transition: all 0.3s ease;
}

input:not([type='file']),
select {
    transition: all 0.15s ease-in-out;
    line-height: 1.5;
    font-size: 0.9375rem;
    color: #1f2937;
}

.form-control:focus,
.form-select:focus {
    border-color: #00257A;
    box-shadow: 0 0 0 3px rgba(0, 37, 122, 0.1);
    outline: none;
    transform: translateY(-1px);
}

.form-control:hover,
.form-select:hover {
    border-color: #25448D;
}

.form-control::placeholder {
    color: #adb5bd;
    opacity: 1;
}

/* Select custom */
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1em;
    padding-right: 2.5rem !important;
    transition: all 0.15s ease-in-out;
}

select::-ms-expand {
    display: none;
}

select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Inputs válidos */
.form-control:valid:not(:placeholder-shown),
.form-select:valid {
    border-color: #28a745;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2328a745' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

/* Labels mejorados */
.form-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    letter-spacing: 0.01em;
}

/* === BOTONES === */
.btn {
    border-radius: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, #00257A 0%, #25448D 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(0, 37, 122, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #25448D 0%, #00257A 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 37, 122, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 37, 122, 0.3);
}

.btn-primary:disabled {
    background: #C7D0E4;
    cursor: not-allowed;
    opacity: 0.7;
    transform: none;
    box-shadow: none;
}

.btn-outline-primary {
    border: 2px solid #00257A;
    color: #00257A;
    background: transparent;
}

.btn-outline-primary:hover {
    background: #00257A;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 37, 122, 0.3);
}

.btn-link {
    color: #6c757d;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-link:hover {
    color: #00257A;
    transform: translateX(-3px);
}

/* === BOTÓN SIGUIENTE === */
.next-btn {
    background: linear-gradient(to right, #00257A, #25448D);
}

.next-btn:hover:not(:disabled) {
    opacity: 0.9;
}

.next-btn:disabled {
    background: #C7D0E4;
    cursor: not-allowed;
    opacity: 1;
}

/* Botón flotante - SIEMPRE VISIBLE */
.text-center.pt-3 {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 1rem !important;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;
    flex-shrink: 0;
}

@media (max-width: 768px) and (min-width: 577px) {
    .text-center.pt-3 {
        padding: 1rem !important;
        margin: 0;
    }

    #top-header-content img {
        width: 70px;
        margin-bottom: 0.5rem !important;
    }
}

/* === ANIMACIONES DE CARGA === */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.btn-primary:disabled {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* === STEP SUCCESS === */
#step-success {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 2rem 1rem !important;
}

#step-success>div {
    width: 100%;
    max-width: 500px;
}

#step-success img {
    animation: bounceIn 0.6s ease-out;
    margin: 0 auto;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        transform: scale(1);
    }
}

/* === ICONOS Y ELEMENTOS VISUALES === */
.bi-arrow-left {
    transition: transform 0.2s ease;
}

.btn-link:hover .bi-arrow-left {
    transform: translateX(-3px);
}

/* === CARDS Y CONTENEDORES === */
.card {
    border: none;
    border-radius: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

/* === MEJORAS DE ACCESIBILIDAD === */
.form-control:focus-visible,
.form-select:focus-visible,
.btn:focus-visible {
    outline: 3px solid #00257A;
    outline-offset: 2px;
}

/* === LOADING SPINNER === */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* === MEJORA VISUAL PARA CAMPOS MANUALES === */
#manual-fields {
    animation: slideDown 0.3s ease-out;
    overflow: hidden;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        max-height: 500px;
        transform: translateY(0);
    }
}

#manual-fields.hidden {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 1;
        max-height: 500px;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        max-height: 0;
        transform: translateY(-10px);
    }
}

/* === DESKTOP ADJUSTMENTS === */
@media (min-width: 769px) {
    #form-container {
        height: calc(100vh - 230px);
        max-height: calc(100vh - 230px);
    }

    #top-header-content {
        height: 230px !important;
    }

    .form-scroll-area {
        overflow-y: auto !important;
        padding: 1rem 1.5rem 1rem 1.5rem;
    }

    /* Botón sticky en desktop */
    .text-center.pt-3 {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 1rem 1.5rem !important;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
        z-index: 100;
    }

    /* Mejorar scroll en desktop */
    .form-scroll-area::-webkit-scrollbar {
        width: 10px;
    }

    .form-scroll-area::-webkit-scrollbar-thumb {
        background: linear-gradient(180deg, #00257A, #25448D);
        border-radius: 10px;
    }

    .form-scroll-area::-webkit-scrollbar-thumb:hover {
        background: linear-gradient(180deg, #25448D, #00257A);
    }
}

/* === ALTAS RESOLUCIONES (Full HD, 2K, 4K) === */
@media (min-width: 1920px) {
    #form-container {
        height: calc(100vh - 230px);
        max-height: calc(100vh - 230px);
    }

    #top-header-content {
        height: 230px !important;
    }
}

/* === RESPONSIVE ADJUSTMENTS === */

/* Media query para móviles muy pequeños (menos de 400px) */
@media (max-width: 399px) {
    #top-header-content {
        height: 120px !important;
        padding: 0.6rem 0.75rem !important;
        gap: 0.2rem;
    }

    #top-header-content img {
        width: 50px;
        margin-bottom: 0.3rem !important;
    }

    #header-title {
        font-size: 1.3rem !important;
        line-height: 1.15 !important;
        margin-bottom: 0.2rem !important;
    }

    #header-subtitle {
        font-size: 0.75rem !important;
        line-height: 1.25 !important;
        margin-top: 0.2rem !important;
        padding: 0 0.5rem;
    }

    #form-container {
        height: calc(100vh - 120px);
    }
}

/* Media query específica para móviles entre 400px y 576px (ej: 412x869) */
@media (min-width: 400px) and (max-width: 576px) {
    #top-header-content {
        height: 140px !important;
        padding: 0.75rem 1rem !important;
        gap: 0.25rem;
    }

    #top-header-content img {
        width: 60px;
        margin-bottom: 0.35rem !important;
    }

    #header-title {
        font-size: 1.5rem !important;
        line-height: 1.2 !important;
        margin-bottom: 0.25rem !important;
    }

    #header-subtitle {
        font-size: 0.85rem !important;
        line-height: 1.3 !important;
        margin-top: 0.25rem !important;
        padding: 0 0.5rem;
    }

    #form-container {
        height: calc(100vh - 140px);
        border-top-left-radius: 1.5rem;
        border-top-right-radius: 1.5rem;
    }
}

@media (max-width: 576px) {

    /* Permitir scroll en body para móviles */
    body {
        overflow: auto !important;
    }

    /* Permitir scroll en main-wrapper para móviles */
    .main-wrapper {
        overflow: auto !important;
        position: relative !important;
    }

    #form-container {
        border-radius: 0;
        max-width: 100%;
        overflow: visible !important;
        position: relative !important;
    }

    #form-container>main {
        overflow: visible !important;
    }

    .form-control,
    .form-select {
        font-size: 16px;
        /* Previene zoom en iOS */
    }

    .btn {
        padding: 0.875rem 1.25rem;
        font-size: 1rem;
    }

    #top-header-content img {
        margin-bottom: 0.3rem !important;
    }

    /* Asegurar que el scroll funcione en mobile */
    .form-scroll-area {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        max-height: none !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        padding-bottom: 6rem !important;
        touch-action: pan-y !important;
    }

    /* Agregar margen inferior al último campo del formulario */
    .substep {
        padding-bottom: 1rem;
    }

    .substep .mb-3:last-child {
        margin-bottom: 3rem !important;
    }

    /* Asegurar que el botón esté siempre visible */
    .text-center.pt-3 {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 1rem !important;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
        z-index: 1000;
        margin-top: auto;
    }
}

/* === TRANSICIONES SUAVES === */
* {
    -webkit-tap-highlight-color: transparent;
}

input,
select,
button {
    -webkit-appearance: none;
    appearance: none;
}

/* === FILE INPUT === */
.file-input {
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    position: absolute;
    z-index: -1;
}

.file-input+label {
    cursor: pointer;
}

/* === POLICY BUTTONS === */
.policy-btn.active {
    background: linear-gradient(to right, #00257A, #25448D);
    color: white;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
}

.policy-btn.inactive {
    background: #f3f4f6;
    color: #6b7280;
    border-color: #e5e7eb;
}

/* === FLOATING BUTTONS === */
.floating-buttons {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem 1.5rem;
    background: linear-gradient(to top, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
    z-index: 10;
    pointer-events: none;
}

.floating-buttons>* {
    pointer-events: auto;
}

/* === RECAPTCHA INFO === */
.recaptcha-info {
    text-align: center;
}

.recaptcha-info a {
    color: #00257A;
    transition: color 0.2s ease;
}

.recaptcha-info a:hover {
    color: #25448D;
}

/* === GENERAL === */
.hidden {
    display: none !important;
}