/*
 * Comparador Vida v2 — Entry form styles.
 *
 * Mismo lenguaje visual que el formulario de tvhm-v2: tokens compartidos,
 * labels 15/600, inputs 17px radius 10, submit centrado con spinner
 * integrado, checkbox de privacidad centrado. Sin font-family propias
 * (la tipografía la pone el theme). El color de marca se inyecta inline
 * vía --cv2-primary desde PHP.
 */

/* ── Design tokens ─────────────────────────────────────────────────── */

.cv2-form-wrap {
    --cv2-primary:       #2EA64C;
    --cv2-primary-dark:  #1f7836;
    --cv2-dark:          #00038C;
    --cv2-text:          #14171f;
    --cv2-text-muted:    #5b6470;
    --cv2-bg:            #ffffff;
    --cv2-bg-soft:       #f7f8f9;
    --cv2-border:        #e6e8ec;
    --cv2-border-strong: #c8ccd2;
    --cv2-error:         #7a2c1f;
    --cv2-radius:        10px;
    --cv2-radius-lg:     16px;

    position: relative;
    max-width: 640px;
    margin: 0 auto;
    color: var(--cv2-text);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    /* Columna flex para poder reordenar el banner de recuperación:
       arriba en móvil (orden DOM), debajo de todo en escritorio. */
    display: flex;
    flex-direction: column;
}
.cv2-scope.cv2-form-wrap > * { width: 100%; }
.cv2-form-wrap *,
.cv2-form-wrap *::before,
.cv2-form-wrap *::after { box-sizing: border-box; }

.cv2-test-banner {
    background: #d63638;
    color: #fff;
    text-align: center;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: var(--cv2-radius);
    margin-bottom: 14px;
}

/* ── Fields ────────────────────────────────────────────────────────── */

.cv2-form .cv2-field { margin: 0 0 16px; }

.cv2-form .cv2-label,
.cv2-label {
    display: block;
    margin-bottom: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--cv2-text);
    line-height: 1.3;
}
.cv2-label.cv2-label-opcional strong { font-weight: 700; }
.cv2-label.cv2-label-opcional span { font-weight: 400; }
/* ── Inputs ─────────────────────────────────────────────────────────
 * Prefijo con el wrapper (.cv2-scope.cv2-form-wrap / .cv2-scope.cv2-results,
 * el input de recalcular capital vive en resultados) para ganar en
 * especificidad al reset.css del tema (input[type=text], …) y a los estilos
 * de kit de Elementor (.elementor-kit-N input[type=…]).
 * ──────────────────────────────────────────────────────────────────── */

.cv2-scope.cv2-form-wrap .cv2-input,
.cv2-scope.cv2-results .cv2-input {
    display: block;
    width: 100%;
    padding: 14px 16px;
    font: inherit;
    font-size: 17px;
    color: var(--cv2-text);
    background: var(--cv2-bg);
    border: 1px solid var(--cv2-border-strong);
    border-radius: var(--cv2-radius);
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.cv2-scope.cv2-form-wrap .cv2-input:focus,
.cv2-scope.cv2-results .cv2-input:focus {
    outline: none;
    border-color: var(--cv2-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cv2-primary) 20%, transparent);
}
.cv2-scope.cv2-form-wrap .cv2-input::placeholder,
.cv2-scope.cv2-results .cv2-input::placeholder { color: var(--cv2-text-muted); font-weight: 400; }

/* ── Fechas: titular + pareja ──────────────────────────────────────────
 * Las dos fechas siempre visibles (la de la pareja es opcional: vacía =
 * tarificación individual). Dos columnas en escritorio, stacked en móvil.
 * El texto de ayuda de la pareja tiene DOS copias en el markup (feedback
 * cliente 2026-09-08, 3ª vuelta): -inline entre el label y el campo de la
 * pareja (solo móvil) y -bottom bajo los dos campos (solo escritorio).
 * ──────────────────────────────────────────────────────────────────── */
.cv2-fechas {
    display: grid;
    gap: 0 16px;
    grid-template-columns: 1fr;
    grid-template-areas:
        "titular"
        "pareja";
    margin-bottom: 16px;
}
.cv2-fechas .cv2-field-titular { grid-area: titular; margin-bottom: 10px; }
.cv2-fechas .cv2-field-pareja  { grid-area: pareja; margin: 0; }
.cv2-fechas .cv2-pareja-help-inline { margin: -2px 0 8px; }
.cv2-fechas .cv2-pareja-help-bottom { display: none; }

@media (min-width: 521px) {
    .cv2-fechas {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "titular pareja"
            "ayuda   ayuda";
    }
    .cv2-fechas .cv2-field-titular { margin-bottom: 0; }
    /* Labels de distinta altura ("Opcional: …" parte en 2 líneas en tablet):
       los inputs se anclan abajo para quedar a la misma altura. */
    .cv2-fechas .cv2-field-titular,
    .cv2-fechas .cv2-field-pareja { display: flex; flex-direction: column; }
    .cv2-fechas .cv2-field-titular .cv2-input,
    .cv2-fechas .cv2-field-pareja .cv2-input { margin-top: auto; }
    .cv2-fechas .cv2-pareja-help-inline { display: none; }
    .cv2-fechas .cv2-pareja-help-bottom { display: block; grid-area: ayuda; margin: 8px 0 0 !important; }
}

/* ── Textos de ayuda bajo los labels (capital y pareja) ────────────── */
.cv2-scope .cv2-field-help {
    margin: -2px 0 10px;
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--cv2-text-muted);
}

/* ── Email + móvil en la misma línea (stacked en móvil) ────────────── */
.cv2-contact-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 480px) {
    .cv2-contact-row { grid-template-columns: 1fr; }
}

/* ── Botonera de capitales (?capitales=1) ──────────────────────────── */
.cv2-capital-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.cv2-scope .cv2-capital-btn {
    flex: 1 1 calc(33% - 8px);
    min-width: 110px;
    padding: 12px 8px;
    border: 2px solid var(--cv2-primary);
    background: #fff;
    color: var(--cv2-primary);
    font: inherit;
    font-weight: 700;
    font-size: 15px;
    border-radius: var(--cv2-radius);
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}
.cv2-scope .cv2-capital-btn:hover {
    background: color-mix(in srgb, var(--cv2-primary) 8%, white);
}
.cv2-scope .cv2-capital-btn.is-active {
    background: var(--cv2-primary);
    color: #fff;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--cv2-primary) 28%, transparent);
}
.cv2-capital-otra { margin-top: 10px; }

/* ── Checkboxes ────────────────────────────────────────────────────── */
.cv2-check {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
}
.cv2-check input[type="checkbox"] { flex-shrink: 0; }

/* ── Errores ───────────────────────────────────────────────────────── */
.cv2-field-error {
    display: block;
    margin-top: 6px;
    color: var(--cv2-error);
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.35;
}
.cv2-scope.cv2-form-wrap .cv2-input.cv2-error-input,
.cv2-scope.cv2-results .cv2-input.cv2-error-input {
    border-color: var(--cv2-error);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cv2-error) 18%, transparent);
}

.cv2-errors {
    margin: 16px 0;
    padding: 16px;
    background: color-mix(in srgb, var(--cv2-error) 10%, white);
    border-left: 4px solid var(--cv2-error);
    border-radius: var(--cv2-radius);
    color: var(--cv2-error);
    font-weight: 500;
    font-size: 14px;
}
.cv2-errors ul { margin: 4px 0 0 18px; padding: 0; }

/* ── Banner de recuperación de presupuesto (patrón ctii2) ──────────── */
/* OJO: un display de autor anula el atributo [hidden] del navegador —
   sin esta regla el banner salía siempre, vacío, aunque no hubiese cookie. */
.cv2-scope .cv2-recuperar[hidden] { display: none; }
.cv2-scope .cv2-recuperar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    background: color-mix(in srgb, var(--cv2-primary) 7%, white);
    border: 1px solid color-mix(in srgb, var(--cv2-primary) 30%, white);
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 20px;
}
.cv2-scope .cv2-recuperar p { margin: 0; }
.cv2-scope .cv2-recuperar-texto { font-size: 14.5px; }
.cv2-scope .cv2-recuperar-acciones {
    display: flex;
    gap: 10px;
    align-items: stretch;
    flex-wrap: wrap;
}
/* Dos opciones al mismo nivel, las dos con forma de botón (patrón ctii2,
   petición del cliente 2026-09-04). */
.cv2-scope .cv2-recuperar-btn,
.cv2-scope a.cv2-recuperar-btn,
.cv2-scope button.cv2-recuperar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--cv2-primary);
    border: 1px solid var(--cv2-primary);
    border-radius: 10px;
    padding: 10px 18px;
    color: #fff !important;
    font-family: inherit;
    font-size: 0.92em;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none !important;
    white-space: nowrap;
    cursor: pointer;
}
.cv2-scope .cv2-recuperar-btn-sec,
.cv2-scope button.cv2-recuperar-btn-sec {
    background: #fff;
    color: var(--cv2-primary) !important;
}
.cv2-scope .cv2-recuperar-btn:hover { filter: brightness(1.05); }
.cv2-scope .cv2-recuperar-btn-sec:hover { background: color-mix(in srgb, var(--cv2-primary) 8%, white); }
/* El banner va arriba del todo del formulario en todos los tamaños (2026-09-04;
   antes en escritorio se mandaba abajo con `order: 2`). */

/* ── Privacidad + submit ───────────────────────────────────────────── */
.cv2-actions {
    margin-top: 28px;
    text-align: center;
}
.cv2-privacy {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    max-width: 380px;
    margin: 0 auto 6px;
    text-align: left;
    font-size: 0.88rem;
    line-height: 1.45;
}
.cv2-privacy input[type="checkbox"] { flex-shrink: 0; }
.cv2-privacy label { cursor: pointer; margin: 0; }
.cv2-privacy a { color: var(--cv2-primary); text-decoration: underline; }
.cv2-privacy-note {
    color: var(--cv2-text-muted);
    font-size: 12px;
    max-width: 380px;
    margin: 0 auto 16px;
}

.cv2-scope.cv2-form-wrap .cv2-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 380px;
    padding: 18px 32px;
    font: inherit;
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    background: var(--cv2-primary);
    border: 0;
    border-radius: var(--cv2-radius);
    cursor: pointer;
    white-space: normal;
    box-shadow: 0 4px 16px color-mix(in srgb, var(--cv2-primary) 28%, transparent);
    transition: background 120ms ease, transform 80ms ease, box-shadow 200ms ease;
}
.cv2-scope.cv2-form-wrap .cv2-submit:hover,
.cv2-scope.cv2-form-wrap .cv2-submit:focus-visible {
    background: var(--cv2-primary-dark);
    color: #fff;
    box-shadow: 0 6px 20px color-mix(in srgb, var(--cv2-primary) 38%, transparent);
    outline: none;
}
.cv2-scope.cv2-form-wrap .cv2-submit:active { transform: translateY(1px); }
.cv2-scope.cv2-form-wrap .cv2-submit:disabled {
    cursor: not-allowed;
    opacity: 0.65;
    transform: none;
}

.cv2-submit-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cv2-spin 700ms linear infinite;
}
.cv2-submit-spinner[hidden] { display: none; }

@keyframes cv2-spin { to { transform: rotate(360deg); } }

/* ── Logos de compañías (shortcode cv2-companias) ──────────────────── */
.cv2-logos-comps { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 18px; }
.cv2-logos-comps .cv2-logo img { max-height: 34px; width: auto; }
/* Variante [cv2-companias class="fila"]: los PNG (319x205) llevan ~1/3 de
   margen transparente y a 34 px de alto el logo visible se quedaba en 10-20 px
   (queja de Carlos, 2026-10-05). Escritorio: hasta 160 px por logo y se reparten
   en las filas que hagan falta (sin nowrap, que los encogía); móvil 3 por fila.
   Sin gris ni opacidad (Pedro: «se ven feos y opacos»). Es opt-in porque hay páginas con CSS propio sobre la
   tira por defecto (globalfinanz.es /seguros-de-vida/: max-height 70px !important). */
.cv2-logos-comps-fila { gap: 0 4px; }
.cv2-logos-comps-fila .cv2-logo { min-width: 0; max-width: 160px; line-height: 0; }
.cv2-logos-comps-fila .cv2-logo img { width: 100%; max-height: none; height: auto; }
@media (max-width: 767px) {
    .cv2-logos-comps-fila { flex-wrap: wrap; gap: 0; }
    .cv2-logos-comps-fila .cv2-logo { flex: 0 0 33.333%; max-width: 110px; }
}
.cv2-logos-comps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }

/* Móvil: rejilla de 2 columnas para que todos los botones midan lo mismo
   (feedback cliente 2026-09-04); "Otra cantidad" ocupa la fila entera. */
@media (max-width: 520px) {
    .cv2-capital-buttons { display: grid; grid-template-columns: 1fr 1fr; }
    .cv2-scope .cv2-capital-btn { min-width: 0; padding: 12px 6px; }
    .cv2-scope .cv2-capital-btn-otra { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
    .cv2-form-wrap *,
    .cv2-form-wrap *::before,
    .cv2-form-wrap *::after {
        transition: none !important;
        animation: none !important;
    }
}

/* ── Pantalla de carga (patrón ctii2) ──────────────────────────────── */
.cv2-scope .cv2-carga {
    position: fixed;
    inset: 0;
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity 0.25s ease-out;
}
.cv2-scope .cv2-carga.cv2-carga-visible { opacity: 1; }
.cv2-scope .cv2-carga[hidden] { display: none; }
.cv2-scope .cv2-carga-box {
    text-align: center;
    max-width: 520px;
    padding: 24px;
}
.cv2-scope .cv2-carga-marca img {
    max-height: 58px;
    max-width: 230px;
    object-fit: contain;
    animation: cv2-carga-pulso 2s ease-in-out infinite;
}
.cv2-scope .cv2-carga-icono {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 92px;
    height: 92px;
    color: var(--cv2-primary);
    animation: cv2-carga-pulso 2s ease-in-out infinite;
}
.cv2-scope .cv2-carga-anillo {
    position: absolute;
    inset: 0;
    border: 3px solid color-mix(in srgb, var(--cv2-primary) 18%, white);
    border-top-color: var(--cv2-primary);
    border-radius: 50%;
    animation: cv2-spin 1.1s linear infinite;
}
@keyframes cv2-carga-pulso {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}
.cv2-scope .cv2-carga-titulo {
    font-size: 1.25em;
    font-weight: 800;
    margin: 18px 0 6px;
}
.cv2-scope .cv2-carga-msg {
    color: var(--cv2-text-muted);
    min-height: 4.5em;
    margin: 0 0 16px;
}
.cv2-scope .cv2-carga-frase { margin: 0; animation: cv2-frase-in 350ms ease-out both; }
@keyframes cv2-frase-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}
.cv2-scope .cv2-carga-bar {
    height: 6px;
    background: color-mix(in srgb, var(--cv2-primary) 12%, white);
    border-radius: 999px;
    overflow: hidden;
}
.cv2-scope .cv2-carga-bar span {
    display: block;
    height: 100%;
    width: 8%;
    background: var(--cv2-primary);
    border-radius: 999px;
    animation: cv2-carga-avance 9s cubic-bezier(0.2, 0.6, 0.3, 1) forwards;
}
@keyframes cv2-carga-avance {
    0%   { width: 8%; }
    30%  { width: 45%; }
    60%  { width: 72%; }
    100% { width: 94%; }
}
/* Escenario de aseguradoras: un logo cada vez + contador 0→100% (JS). */
.cv2-scope .cv2-carga-aseg {
    margin-top: 18px;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 240ms ease, transform 240ms ease;
}
.cv2-scope .cv2-carga-aseg.cv2-carga-aseg-in { opacity: 1; transform: none; }
.cv2-scope .cv2-carga-aseg.cv2-carga-aseg-out { opacity: 0; transform: translateY(-6px); }
.cv2-scope .cv2-carga-aseg-logo {
    max-height: 34px;
    max-width: 130px;
    object-fit: contain;
}
.cv2-scope .cv2-carga-aseg-pct {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 0.95em;
    color: var(--cv2-primary);
    min-width: 44px;
    text-align: left;
}
.cv2-scope .cv2-carga-nota {
    color: var(--cv2-text-muted);
    font-size: 0.82em;
    margin: 10px 0 0;
}
@media (prefers-reduced-motion: reduce) {
    .cv2-scope .cv2-carga-icono,
    .cv2-scope .cv2-carga-anillo,
    .cv2-scope .cv2-carga-marca img,
    .cv2-scope .cv2-carga-frase,
    .cv2-scope .cv2-carga-bar span { animation: none !important; }
    .cv2-scope .cv2-carga-aseg { transition: none !important; }
}

/* ── Variante compacta ([cv2_form compact="1"]) ─────────────────────────
 * Sustituta del form-vida-simple del comparador viejo: landings (SMS,
 * publicidad) y huecos estrechos. El template ya omite la pareja y el
 * banner de recuperación; aquí solo estrechamos y apilamos en una columna
 * con espaciados reducidos. Mismo flujo completo que el form estándar.
 * ──────────────────────────────────────────────────────────────────── */
.cv2-form-wrap.cv2-form-compact { max-width: 420px; }

@media (min-width: 521px) {
    /* Sin pareja no hay segunda columna ni fila de ayuda. */
    .cv2-form-compact .cv2-fechas {
        grid-template-columns: 1fr;
        grid-template-areas: "titular";
    }
}
.cv2-form-compact .cv2-fechas { margin-bottom: 0; }
.cv2-form-compact .cv2-fechas .cv2-field-titular { margin-bottom: 0; }

.cv2-form-compact .cv2-form .cv2-field { margin: 0 0 12px; }
.cv2-form-compact .cv2-contact-row { grid-template-columns: 1fr; gap: 0; }

.cv2-form-compact .cv2-form .cv2-label,
.cv2-form-compact .cv2-label { margin-bottom: 6px; font-size: 14px; }

.cv2-scope.cv2-form-wrap.cv2-form-compact .cv2-input { padding: 11px 13px; font-size: 16px; }

.cv2-form-compact .cv2-actions { margin-top: 18px; }

/* ── Modo pensión ([cv2_form pension="1"]) ─────────────────────────────
 * Fecha + ingresos + cónyuge + hijos en rejilla 2×2 (una columna en móvil);
 * inputs anclados abajo para alinear aunque los labels ocupen 1 o 2 líneas.
 * ──────────────────────────────────────────────────────────────────── */
.cv2-pension-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0 16px;
}
@media (min-width: 521px) {
    .cv2-pension-grid { grid-template-columns: 1fr 1fr; }
    .cv2-pension-grid .cv2-field { display: flex; flex-direction: column; }
    .cv2-pension-grid .cv2-field > .cv2-input,
    .cv2-pension-grid .cv2-field > .cv2-seg { margin-top: auto; }
}
.cv2-scope.cv2-form-wrap select.cv2-input {
    padding-right: 42px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 18px 18px;
}
.cv2-scope .cv2-seg {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.cv2-scope .cv2-seg-opt { position: relative; margin: 0; cursor: pointer; }
.cv2-scope .cv2-seg-opt input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}
.cv2-scope .cv2-seg-opt span {
    display: block;
    padding: 14px 16px;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    color: var(--cv2-text);
    background: var(--cv2-bg);
    border: 1px solid var(--cv2-border-strong);
    border-radius: var(--cv2-radius);
    transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}
.cv2-scope .cv2-seg-opt input:checked + span {
    color: #fff;
    background: var(--cv2-primary);
    border-color: var(--cv2-primary);
}
.cv2-scope .cv2-seg-opt input:focus-visible + span {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cv2-primary) 25%, transparent);
}
