/* ==========================================================================
   css/sesion.css  ·  Iniciar sesión y Registro (iniciarsesion.php / registro.php)
   Se carga después de styles.css y reutiliza sus variables.

   ÍNDICE
   1. Variables y caja   2. Panel lateral   3. Formulario y campos
   4. Tipo de cuenta, términos y contraseña   5. Botón y mensajes   6. Celular
   ========================================================================== */


/* ---------- 1. Variables y caja ---------- */
:root {
    --sesion-brillo: rgba(255, 255, 255, 0.12);   /* círculos decorativos del panel */
    --sesion-error: #d93a4a;
    --sesion-ok: #1f9d55;
    --sesion-error-suave: rgba(217, 58, 74, 0.14);
}

.sesion {
    display: grid;
    place-items: start center;
    padding: 40px 0 50px;
}

.sesion-caja {
    display: grid;
    grid-template-columns: 5fr 6fr;
    width: var(--portada-ancho);            /* 90% */
    max-width: 1050px;
    overflow: hidden;
    border-radius: 28px;
    background: var(--white);
    box-shadow: 0 20px 60px var(--card-sombra-hover);
    animation: paginaEntrada 0.7s ease backwards;   /* keyframe de styles.css */
}


/* ---------- 2. Panel lateral ---------- */
.sesion-lateral {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
    padding: 48px 40px;
    overflow: hidden;
    color: var(--white);
    background: linear-gradient(145deg, var(--primary-blue), var(--primary-dark-orange));
}

.sesion-lateral::before,
.sesion-lateral::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: var(--sesion-brillo);
    pointer-events: none;
}

.sesion-lateral::before { width: 300px; height: 300px; top: -110px; right: -110px; }
.sesion-lateral::after  { width: 220px; height: 220px; bottom: -80px; left: -70px; }

.sesion-lateral > * {
    position: relative;                     /* por encima de los círculos */
    z-index: 1;
}

.sesion-lateral img {
    display: block;
    width: 100%;
    max-width: 230px;
    height: auto;
}

.sesion-lateral h2 {
    font-size: 1.8rem;
    line-height: 1.2;
}

.sesion-lateral p {
    line-height: 1.6;
}

.sesion-lateral ul {
    display: grid;
    gap: 14px;
    margin-top: 6px;
}

.sesion-lateral li {
    display: flex;
    align-items: center;
    gap: 14px;
    font-weight: 600;
}

.sesion-lateral li span {
    flex: none;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--sesion-brillo);
}


/* ---------- 3. Formulario y campos ---------- */
.sesion-formulario {
    padding: 48px 44px;
}

.sesion-formulario h1 {
    font-size: 2rem;
    color: var(--text-dark);
}

.sesion-subtitulo {
    margin: 6px 0 26px;
    color: var(--texto-suave);
}

.campo {
    margin-bottom: 18px;
    padding: 0;
    border: 0;
}

.campo label,
.campo legend {
    display: block;
    margin-bottom: 6px;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-dark);
}

.campo-caja {
    position: relative;
}

.campo-icono {
    position: absolute;
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    color: var(--texto-suave);
    pointer-events: none;
}

.campo-caja input {
    width: 100%;
    height: 50px;
    padding: 0 48px 0 46px;
    font: inherit;
    color: var(--text-dark);
    border: 1px solid var(--gray-line);
    border-radius: 14px;
    background: var(--white);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.campo-caja input:focus {
    outline: none;
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 3px var(--card-sombra);
}

.campo-ver {
    position: absolute;
    top: 50%;
    right: 8px;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    color: var(--texto-suave);
    background: none;
    transform: translateY(-50%);
}

.campo-ver:hover {
    color: var(--primary-dark-orange);
}

.campo-ayuda {
    display: block;
    margin-top: 6px;
    font-size: 0.82rem;
    color: var(--texto-suave);
}

.fila-doble {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}


/* ---------- 4. Tipo de cuenta, términos y contraseña ---------- */
.tipos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.tipos legend {
    grid-column: 1 / -1;
}

.tipo {
    position: relative;
    margin: 0;
    cursor: pointer;
}

.tipo input {
    position: absolute;
    opacity: 0;
}

.tipo-caja {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    height: 100%;
    padding: 16px 10px;
    text-align: center;
    border: 2px solid var(--gray-line);
    border-radius: 14px;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.tipo-caja i {
    font-size: 1.5rem;
    color: var(--primary-dark-orange);
}

.tipo-caja small {
    font-size: 0.8rem;
    color: var(--texto-suave);
}

.tipo:hover .tipo-caja {
    transform: translateY(-2px);
}

.tipo input:checked + .tipo-caja {
    border-color: var(--primary-dark-orange);
    background: var(--fondo);
}

.tipo input:focus-visible + .tipo-caja {
    outline: 3px solid var(--primary-orange);
    outline-offset: 2px;
}

.terminos {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 0.92rem;
    cursor: pointer;
}

.terminos input {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--primary-dark-orange);
}

.terminos a {
    font-weight: 600;
    color: var(--primary-dark-orange);
}

/* Medidor de la contraseña */
.fuerza {
    height: 6px;
    margin-top: 10px;
    overflow: hidden;
    border-radius: 6px;
    background: var(--gray-line);
}

.fuerza span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: 6px;
    transition: width 0.3s ease, background 0.3s ease;
}

.fuerza span.nivel-1 { width: 25%;  background: var(--sesion-error); }
.fuerza span.nivel-2 { width: 50%;  background: var(--primary-orange); }
.fuerza span.nivel-3 { width: 75%;  background: var(--gold); }
.fuerza span.nivel-4 { width: 100%; background: var(--sesion-ok); }


/* ---------- 5. Botón y mensajes ---------- */
.sesion-boton {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 52px;
    border: 0;
    border-radius: 14px;
    font: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--white);
    background: var(--primary-dark-orange);
    box-shadow: 0 8px 20px var(--card-sombra);
    transition: transform 0.2s ease, background 0.2s ease;
}

.sesion-boton:hover {
    background: var(--primary-blue);
    transform: translateY(-2px);
}

.sesion-boton:disabled {
    opacity: 0.65;
    cursor: wait;
    transform: none;
}

.sesion-mensaje {
    min-height: 1.4em;
    margin-top: 14px;
    text-align: center;
    font-size: 0.94rem;
}

.sesion-mensaje.error { color: var(--sesion-error); }
.sesion-mensaje.ok    { color: var(--sesion-ok); }

.sesion-cambio {
    margin-top: 22px;
    text-align: center;
    color: var(--texto-suave);
}

.sesion-cambio a {
    font-weight: 700;
    color: var(--primary-blue);
}

.sesion-cambio a:hover {
    color: var(--primary-dark-orange);
}

/* "¿Olvidaste tu contraseña?" debajo del campo de contraseña, a la derecha */
.sesion-olvide {
    display: block;
    margin-top: 8px;
    text-align: right;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--primary-blue);
}

.sesion-olvide:hover {
    color: var(--primary-dark-orange);
    text-decoration: underline;
}

/* Registro: ventana de términos y condiciones */
.terminos-modal {
    margin: auto;
    width: min(820px, calc(100vw - 32px));
    height: min(760px, calc(100dvh - 32px));
    padding: 0;
    border: 0;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.terminos-modal[open] {
    display: flex;
    flex-direction: column;
}

.terminos-modal::backdrop {
    background: rgba(17, 24, 39, 0.6);
}

.terminos-modal > header,
.terminos-modal > footer {
    display: flex;
    flex: none;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
}

.terminos-modal > header {
    justify-content: space-between;
    color: #fff;
    background: linear-gradient(90deg, #111827, #5b3a26 70%, var(--primary-dark-orange));
}

.terminos-modal > header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
}

.terminos-cerrar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}

.terminos-cerrar:hover {
    background: rgba(255, 255, 255, 0.3);
}

.terminos-cuerpo {
    flex: 1;
    overflow-y: auto;
    padding: 6px 24px 18px;
    overscroll-behavior: contain;
}

.terminos-modal > footer {
    justify-content: flex-end;
    border-top: 1px solid #eee;
}

.terminos-modal > footer .boton-cancelar {
    height: auto;
    align-self: stretch;
}

.terminos-modal > footer .sesion-boton {
    width: auto;
    margin: 0;
    padding-left: 28px;
    padding-right: 28px;
}

@media (max-width: 640px) {
    .terminos-modal {
        width: 100vw;
        height: 100dvh;
        max-width: none;
        max-height: none;
        border-radius: 0;
    }

    .terminos-cuerpo {
        padding: 4px 16px 16px;
    }

    .terminos-modal > footer .sesion-boton,
    .terminos-modal > footer .boton-cancelar {
        flex: 1 1 0;
        min-width: 0;
    }
}

/* Aviso verde: la contraseña ya se cambió */
.sesion-aviso-ok {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 18px;
    padding: 12px 14px;
    border-radius: 12px;
    font-weight: 600;
    color: #15803d;
    background: #dcfce7;
}


/* ---------- 6. Celular y tablet ---------- */
@media (max-width: 900px) {
    .sesion-caja {
        grid-template-columns: 1fr;
        max-width: 560px;
    }

    .sesion-lateral {
        display: none;      /* en pantallas chicas solo se ve el formulario */
    }

    .sesion-formulario {
        padding: 36px 28px;
    }
}

@media (max-width: 480px) {
    .sesion {
        padding-top: 20px;
    }

    .sesion-formulario {
        padding: 28px 20px;
    }

    .fila-doble,
    .tipos {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sesion-caja {
        animation: none;
    }
}

/* ---------- 7. Campo con problema (resaltado en rojo) ---------- */
.campo.invalido .campo-caja input,
.campo.invalido .codigo-caja {
    border-color: var(--sesion-error);
    background: var(--sesion-error-suave);
    box-shadow: 0 0 0 3px var(--sesion-error-suave);
}

.campo.invalido > label,
.campo.invalido > legend,
.campo.invalido .campo-icono {
    color: var(--sesion-error);
}

.campo.invalido .campo-caja,
.campo.invalido .codigo-cajas,
.terminos.invalido {
    animation: sesionSacudir 0.35s ease;
}

.terminos.invalido span {
    color: var(--sesion-error);
}

.terminos.invalido input {
    outline: 2px solid var(--sesion-error);
    outline-offset: 2px;
}

@keyframes sesionSacudir {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-6px); }
    75%      { transform: translateX(6px); }
}


/* ---------- 8. Verificar correo ---------- */
.verificar-icono {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    border-radius: 18px;
    font-size: 1.8rem;
    color: var(--white);
    background: linear-gradient(135deg, var(--primary-orange), var(--primary-dark-orange));
    box-shadow: 0 8px 20px var(--card-sombra);
}

.codigo-cajas {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

.codigo-caja {
    width: 100%;
    height: 60px;
    padding: 0;
    text-align: center;
    font: inherit;
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text-dark);
    border: 1px solid var(--gray-line);
    border-radius: 14px;
    background: var(--white);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.codigo-caja:focus {
    outline: none;
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 3px var(--card-sombra);
}

.enlace-boton {
    padding: 0;
    border: 0;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    color: var(--primary-blue);
    background: none;
}

.enlace-boton:hover:not(:disabled) {
    color: var(--primary-dark-orange);
    text-decoration: underline;
}

.enlace-boton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Verificar: recuadro "¿No encuentras tu código?" con el botón para pedir uno nuevo */
.verificar-reenvio {
    margin: 22px 0 8px;
    padding: 14px 16px;
    border: 1px dashed #e0b77d;
    border-radius: 14px;
    background: #fff8ef;
    font-size: .88rem;
    line-height: 1.5;
    color: #5b4630;
    text-align: left;
}
.verificar-reenvio p { margin: 0 0 8px; }
.verificar-reenvio p i { color: var(--primary-orange, #d27d2d); }
.verificar-reenvio-boton {
    display: inline-flex; align-items: center; gap: 8px;
    width: 100%; justify-content: center;
    margin-top: 4px; padding: 10px 16px;
    border: 1px solid var(--primary-orange, #d27d2d); border-radius: 10px;
    font: inherit; font-weight: 700; cursor: pointer;
    color: var(--primary-orange, #d27d2d); background: #fff;
}
.verificar-reenvio-boton:hover:not(:disabled) { color: #fff; background: var(--primary-orange, #d27d2d); }
.verificar-reenvio-boton:disabled { opacity: .6; cursor: not-allowed; }

@media (max-width: 480px) {
    .codigo-cajas { gap: 6px; }
    .codigo-caja  { height: 52px; font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
    .campo.invalido .campo-caja,
    .campo.invalido .codigo-cajas,
    .terminos.invalido {
        animation: none;
    }
}