/**
 * Estilos para el frontend del plugin de formularios
 */

/* Contenedor principal */
.formulario-avanzado-container {
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.formulario-descripcion {
    margin-bottom: 20px;
    font-size: 16px;
    line-height: 1.5;
}

/* Estilos del formulario */
.formulario-avanzado-form {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

/* Posición de etiquetas */
.formulario-avanzado-form.labels-top label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.formulario-avanzado-form.labels-left {
    display: grid;
    grid-template-columns: 30% 70%;
    gap: 15px;
    align-items: start;
}

.formulario-avanzado-form.labels-left .campo-wrapper {
    display: contents;
}

.formulario-avanzado-form.labels-left label {
    font-weight: 600;
    padding-top: 10px;
}

.formulario-avanzado-form.labels-left .campo-error {
    grid-column: 2;
}

.formulario-avanzado-form.labels-left .formulario-submit {
    grid-column: 2;
}

/* Estilos de los campos */
.campo-wrapper {
    margin-bottom: 20px;
}

.formulario-avanzado-form input[type="text"],
.formulario-avanzado-form input[type="email"],
.formulario-avanzado-form input[type="number"],
.formulario-avanzado-form input[type="date"],
.formulario-avanzado-form select,
.formulario-avanzado-form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    font-size: 16px;
    line-height: 1.5;
    transition: border-color 0.3s ease;
}

.formulario-avanzado-form input[type="text"]:focus,
.formulario-avanzado-form input[type="email"]:focus,
.formulario-avanzado-form input[type="number"]:focus,
.formulario-avanzado-form input[type="date"]:focus,
.formulario-avanzado-form select:focus,
.formulario-avanzado-form textarea:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

.formulario-avanzado-form textarea {
    min-height: 120px;
    resize: vertical;
}

/* Opciones de radio y checkboxes */
.formulario-avanzado-form .radio-group,
.formulario-avanzado-form .checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.formulario-avanzado-form .radio-option,
.formulario-avanzado-form .checkbox-option {
    display: flex;
    align-items: center;
    gap: 10px;
}

.formulario-avanzado-form .radio-option label,
.formulario-avanzado-form .checkbox-option label {
    margin-bottom: 0;
    font-weight: normal;
    cursor: pointer;
}

/* Mensajes de error */
.campo-error {
    color: #d63638;
    font-size: 14px;
    margin-top: 5px;
    min-height: 20px;
}

.has-error {
    border-color: #d63638 !important;
}

.radio-group.has-error,
.checkbox-group.has-error {
    padding: 5px;
    border: 1px dashed #d63638;
    border-radius: 4px;
}

/* Botón de envío */
.formulario-submit {
    margin-top: 25px;
    display: flex;
    align-items: center;
}

.submit-button {
    padding: 10px 20px;
    background-color: #2271b1;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.submit-button:hover {
    background-color: #135e96;
}

.submit-button:disabled {
    background-color: #c3c4c7;
    cursor: not-allowed;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-left: 15px;
    visibility: hidden;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner.is-active {
    visibility: visible;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mensajes de respuesta */
.formulario-mensaje {
    margin-top: 20px;
    padding: 15px;
    border-radius: 4px;
    font-size: 16px;
    line-height: 1.5;
}

.formulario-mensaje.success {
    background-color: #ecf8ed;
    color: #1d6d30;
    border: 1px solid #c3e6cb;
}

.formulario-mensaje.error {
    background-color: #f8d7da;
    color: #842029;
    border: 1px solid #f5c2c7;
}

/* Campo requerido */
.requerido {
    color: #d63638;
    margin-left: 3px;
}

/* Estilos para dispositivos móviles */
@media (max-width: 768px) {
    .formulario-avanzado-form.labels-left {
        display: block;
    }
    
    .formulario-avanzado-form.labels-left label {
        display: block;
        margin-bottom: 8px;
    }
    
    .formulario-submit {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .spinner {
        margin-left: 0;
        margin-top: 10px;
    }
}

/* reCAPTCHA */
.g-recaptcha {
    margin-top: 20px;
    margin-bottom: 20px;
}

/* ========================================
   MODAL DE ÉXITO
   ======================================== */

/* Overlay del modal */
.formulario-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 999999 !important;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    padding: 20px;
    box-sizing: border-box;
}

/* Modal visible */
.formulario-modal-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* Contenido del modal */
.formulario-modal-content {
    background: #ffffff;
    border-radius: 20px;
    padding: 48px 40px;
    max-width: 540px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.25),
                0 10px 30px rgba(0, 0, 0, 0.15);
    transform: scale(0.8);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.35s ease;
    text-align: center;
    margin: auto;
    box-sizing: border-box;
}

/* Modal visible con animación */
.formulario-modal-overlay.is-visible .formulario-modal-content {
    transform: scale(1);
    opacity: 1;
}

/* Botón cerrar (X) */
.formulario-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6c757d;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
    padding: 0;
}

.formulario-modal-close:hover {
    background-color: #f8f9fa;
    color: #212529;
    transform: rotate(90deg);
}

.formulario-modal-close:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* Icono de éxito (checkmark) */
.formulario-modal-icon {
    margin: 0 auto 28px;
    width: 88px;
    height: 88px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.3);
}

.formulario-modal-icon svg {
    width: 52px;
    height: 52px;
    color: #ffffff;
}

/* Animación del checkmark */
.checkmark-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) 0.3s forwards;
}

.checkmark-check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes stroke {
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes scaleIn {
    0% {
        transform: scale(0);
    }
    100% {
        transform: scale(1);
    }
}

/* Título del modal */
.formulario-modal-titulo {
    margin: 0 0 20px;
    font-size: 32px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.2;
    letter-spacing: -0.5px;
    animation: fadeInUp 0.5s ease 0.4s both;
}

/* Mensaje del modal */
.formulario-modal-mensaje {
    margin: 0 0 36px;
    font-size: 17px;
    line-height: 1.7;
    color: #4a5568;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
    animation: fadeInUp 0.5s ease 0.5s both;
}

@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Botón del modal */
.formulario-modal-button {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #ffffff;
    border: none;
    padding: 16px 40px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
    animation: fadeInUp 0.5s ease 0.6s both;
    min-width: 140px;
}

.formulario-modal-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.45);
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.formulario-modal-button:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.formulario-modal-button:focus {
    outline: 3px solid rgba(59, 130, 246, 0.5);
    outline-offset: 2px;
}

/* Responsive - Móviles */
@media (max-width: 768px) {
    .formulario-modal-overlay {
        padding: 16px;
    }

    .formulario-modal-content {
        padding: 36px 28px;
        max-width: 100%;
        border-radius: 16px;
    }

    .formulario-modal-titulo {
        font-size: 26px;
        margin-bottom: 16px;
    }

    .formulario-modal-mensaje {
        font-size: 16px;
        margin-bottom: 28px;
    }

    .formulario-modal-icon {
        width: 72px;
        height: 72px;
        margin-bottom: 24px;
    }

    .formulario-modal-icon svg {
        width: 44px;
        height: 44px;
    }

    .formulario-modal-button {
        width: 100%;
        padding: 14px 32px;
    }

    .formulario-modal-close {
        width: 36px;
        height: 36px;
        top: 12px;
        right: 12px;
    }
}

/* Prevenir scroll del body cuando modal está abierto */
body.formulario-modal-open {
    overflow: hidden !important;
}

/* Prevenir que contenedores padre rompan el posicionamiento fixed */
.formulario-avanzado-container {
    /* NO usar transform, filter, perspective o will-change */
    /* Estos crean un nuevo stacking context que rompe position: fixed */
    transform: none !important;
    filter: none !important;
    perspective: none !important;
    will-change: auto !important;
}

/* Animación de pulse para el botón (opcional, para llamar más la atención) */
@keyframes pulse {
    0% {
        box-shadow: 0 4px 12px rgba(34, 113, 177, 0.3);
    }
    50% {
        box-shadow: 0 4px 20px rgba(34, 113, 177, 0.5);
    }
    100% {
        box-shadow: 0 4px 12px rgba(34, 113, 177, 0.3);
    }
}

.formulario-modal-button.pulse {
    animation: pulse 2s infinite;
}
