/* =================== RESET Y FUENTE =================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* =================== CONTENEDOR PRINCIPAL =================== */
.container {
    width: 100%;
    max-width: 900px;
    position: relative;
    z-index: 10;
}

/* =================== CARD (VOLTEABLE) =================== */
/* Se usa opacity/visibility en lugar de preserve-3d para que los iframes
   (reCAPTCHA) sean interactivos en todos los navegadores */
.card {
    width: 100%;
    position: relative;
    min-height: 500px;
    overflow: visible;
}

/* =================== CARAS =================== */
.card-face {
    width: 100%;
    padding: 2rem 1.6rem;
    border-radius: 40px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    color: #f8f8f8;
    overflow: visible;
    transition: opacity 0.35s ease, transform 0.35s ease;
    opacity: 1;
    transform: scale(1);
}

/* La cara trasera se oculta por defecto */
.card-back {
    display: none;
    opacity: 0;
    transform: scale(0.97);
}

/* Cuando la tarjeta está girada: ocultar frente, mostrar reverso */
.card.flipped .card-face:not(.card-back) {
    display: none;
    opacity: 0;
}

.card.flipped .card-back {
    display: block;
    opacity: 1;
    transform: scale(1);
}


/* =================== FORMULARIO - LAYOUT PRINCIPAL =================== */
.form-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* =================== LOGO Y TÍTULOS =================== */
.logo-contenedor {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 0 35px 0;
}

.logo-col img {
    width: 60px;
}

.texto-col {
    display: flex;
    flex-direction: column;
    padding: 0 20px 0 20px;
}

.titulo-login, .logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, #f0e7ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.3rem;
}

.subtitulo {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.9);
}

/* =================== MENSAJES =================== */
.messages-container {
    margin-bottom: 1rem;
}

.alert {
    padding: 0.8rem 1rem;
    border-radius: 60px;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    background: rgba(255,255,255,0.25);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
}

/* =================== CAPTCHA =================== */
.captcha-box {
    margin-bottom: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: visible;
}

/* El popup de verificación del recaptcha no debe quedar cortado */
.g-recaptcha,
#captcha-container > div,
#captcha-container > div > div {
    overflow: visible !important;
}

.captcha-error-msg {
    display: flex;
    width: 100%;
    margin-top: 6px;
    padding: 6px 12px;
    background: rgba(248,113,113,0.5);
    border-radius: 60px;
    color: white;
    font-size: 0.8rem;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.captcha-error-msg.d-none { display: none !important; }

/* =================== INPUTS =================== */
.input-group {
    position: relative;
    margin-bottom: 1.2rem;
}

/* ICONO: centrado real respecto al input completo */
.input-group i {
    position: absolute;
    left: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    color: #ffffff;
    z-index: 2;
    pointer-events: none;
    /* Compensar el padding asimétrico del input (top 1.2rem, bottom 0.7rem → offset 0.25rem hacia arriba) */
    margin-top: -0.25rem;
}

/* Botón para mostrar/ocultar contraseña */
.toggle-password {
    position: absolute;
    right: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    margin-top: -0.25rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.45);
    z-index: 10;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}

/* Cuando el input tiene texto → botón más visible */
.input-group:has(.input:not(:placeholder-shown)) .toggle-password {
    background: rgba(102, 126, 234, 0.35);
    border-color: rgba(102, 126, 234, 0.7);
    color: #ffffff;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.25);
}

/* Cuando el input está enfocado → igual de visible */
.input-group:has(.input:focus) .toggle-password {
    background: rgba(102, 126, 234, 0.35);
    border-color: rgba(102, 126, 234, 0.7);
    color: #ffffff;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.25);
}

.toggle-password:hover,
.toggle-password:focus {
    background: rgba(102, 126, 234, 0.55);
    border-color: #667eea;
    color: #ffffff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
    outline: none;
}

.toggle-password i {
    position: static;
    top: auto;
    left: auto;
    transform: none;
    margin-top: 0;
    pointer-events: none;
    font-size: 0.85rem;
}

/* Input con botón ojo: añadir padding derecho extra */
.input-group:has(.toggle-password) .input {
    padding-right: 3.2rem;
}

.input {
    width: 100%;
    padding: 1.2rem 1rem 0.7rem 3rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 60px;
    font-size: 1rem;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(5px);
    color: white;
    outline: none;
    /* Quitado transform: translateY(-5%) que desplazaba el contenido */
}

.input:focus {
    border-color: #667eea;
    background: rgba(255,255,255,0.25);
}

.placeholder {
    position: absolute;
    left: 3rem;
    top: 50%;
    transform: translateY(-50%);
    /* Compensar padding asimétrico igual que el icono */
    margin-top: -0.25rem;
    color: rgba(255,255,255,0.8);
    pointer-events: none;
    transition: all 0.2s;
    font-size: 0.95rem;
    white-space: nowrap;
}

.input:focus + .placeholder,
.input:not(:placeholder-shown) + .placeholder {
    top: -0.1rem;
    left: 1rem;
    font-size: 0.8rem;
    margin-top: 0; /* sin offset cuando está flotado */
    z-index: 4;
    color: #ffffff;
    font-family: 'Inter', sans-serif;
    background: #667eea;
    padding: 0 1rem;
    border-radius: 2rem;
    /* resetear transform para posición flotada */
    transform: translateY(-50%) 
}

.input-hint {
    margin-top: 0.2rem;
    margin-left: 1rem;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.6);
}

.terms-container .link-primary {
    color: rgba(135, 201, 255, 0.9);
    text-decoration: none;
    font-weight: 600;
}



/* =================== BOTONES Y ENLACES =================== */
.forgot-password {
    justify-content: end;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 0.85rem;
}

.btn {
    width: 100%;
    padding: 1.0rem;
    border-radius: 60px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(255,255,255,0.25);
    backdrop-filter: blur(10px);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    transition: 0.2s;
    cursor: pointer;
    margin: 15px 0 10px 0;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -8px rgba(0,0,0,0.3);
}

.divider {
    display: flex;
    align-items: center;
    margin: 0.3rem 0;
    color: rgba(255,255,255,0.6);
    padding: 10px 0;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.divider span { padding: 0 0.8rem; font-size: 0.8rem; }

.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    width: 100%;
    border-radius: 60px;
    border: none;
    background: #ffffff;
    color: #3c4043;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    transition: box-shadow 0.2s, transform 0.2s;
    margin-bottom: 0.5rem;
}

.google-btn:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.35);
    transform: translateY(-1px);
    color: #3c4043;
    text-decoration: none;
}

.google-btn img { width: 20px; height: 20px; flex-shrink: 0; }

.register-link {
    text-align: center;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.register-link a {
    color: rgba(135, 201, 255, 0.9);
    text-decoration: none;
    font-weight: 600;
}

/* =================== LAYOUT DOS COLUMNAS (REGISTRO) =================== */
.card-back form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.5rem;
}

.card-back .input-group:nth-of-type(1) { grid-column: 1; grid-row: 1; }
.card-back .input-group:nth-of-type(2) { grid-column: 2; grid-row: 1; }
.card-back .input-group:nth-of-type(3) { grid-column: 1; grid-row: 2; }
.card-back .input-group:nth-of-type(4) { grid-column: 2; grid-row: 2; }
.card-back .terms-container { grid-column: 1 / span 2; grid-row: 3; }
.card-back .btn-primary     { grid-column: 1 / span 2; grid-row: 4; }
.card-back .divider         { grid-column: 1 / span 2; grid-row: 5; }
.card-back .google-btn      { grid-column: 1 / span 2; grid-row: 6; }
.card-back .register-link   { grid-column: 1 / span 2; grid-row: 7; }
.card-back .footer          { grid-column: 1 / span 2; grid-row: 8; }

.card-back .input-group   { margin-bottom: 0.8rem; }
.card-back .terms-container { margin-bottom: 0.8rem; }

.card-back .texto-col {
    display: flex;
    flex-direction: column;
    padding: 0 20px 0 20px;
    font-size: small;
}

/* En card-back los iconos e inputs ya tienen padding simétrico base → sin margin-top extra */
.card-back .input-group i {
    top: 50%;
    transform: translateY(-50%);
    margin-top: 0;
}

.card-back .placeholder {
    top: 50%;
    transform: translateY(-50%);
    margin-top: 0;
}

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

/* Extra Large Desktop (> 1200px) */
@media (max-width: 1200px) {
    .container       { max-width: 950px; }
    .logo-contenedor { padding-bottom: 40px; }
    .logo-col img    { width: 70px; }
    .titulo-login, .logo h1 { font-size: 1.8rem; }
    .subtitulo       { font-size: 1rem; }
}

/* Tablets Landscape (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .container { max-width: 700px; }
    body { padding: 0.8rem; }

    .card-face {
        background: none;
        padding: 1.8rem 1.5rem;
        border-radius: 35px;
        border: none;
    }

    .logo-contenedor { padding-bottom: 25px; }
    .logo-col img    { width: 55px; }
    .titulo-login, .logo h1 { font-size: 1.4rem; }
    .subtitulo       { font-size: 0.9rem; }
    .texto-col       { padding: 0 15px; }

    .card-face:not(.card-back) form,
    .card-back form  { gap: 0 1rem; }

    .input           { padding: 1rem 1rem 0.6rem 2.8rem; font-size: 0.95rem; }

    /* Recalcular offset para nuevo padding (top 1rem, bottom 0.6rem → offset 0.2rem) */
    .input-group i   { left: 1rem; font-size: 1rem; margin-top: -0.2rem; }
    .placeholder     { left: 2.8rem; font-size: 0.9rem; margin-top: -0.2rem; }
    .toggle-password { margin-top: -0.2rem; }

    .btn, .google-btn { padding: 0.9rem; font-size: 0.95rem; }
    .google-btn { color: #3c4043; }
}

/* Tablets Portrait (576px - 767px) */
@media (min-width: 576px) and (max-width: 767px) {
    .container { max-width: 500px; }
    body { padding: 0.8rem; }

    .card { min-height: 550px; }
    .card-face { padding: 1.5rem 1.3rem; border-radius: 30px; background: none; border: none;}

    .card-face:not(.card-back) form,
    .card-back form { display: flex !important; flex-direction: column; gap: 0; }


    .logo-contenedor { padding-bottom: 20px; }
    .logo-col img    { width: 55px; }
    .titulo-login, .logo h1 { font-size: 1.3rem; }
    .subtitulo       { font-size: 0.85rem; }
    .texto-col       { padding: 0 12px; }

    .input           { padding: 1rem 1rem 0.6rem 2.8rem; font-size: 0.9rem; }
    .input-group i   { left: 1rem; margin-top: -0.2rem; }
    .placeholder     { left: 2.8rem; font-size: 0.85rem; margin-top: -0.2rem; }
    .toggle-password { margin-top: -0.2rem; }

    .btn, .google-btn { padding: 0.85rem; }
    .google-btn { color: #3c4043; }
    .alert           { padding: 0.7rem 0.9rem; font-size: 0.8rem; }
}

/* Mobile (400px - 575px) */
@media (min-width: 400px) and (max-width: 575px) {
    .container { max-width: 100%; padding: 0.5rem; }
    body { padding: 0.5rem; }

    .card { min-height: 520px; }
    .card-face { padding: 1.3rem 1.2rem; border-radius: 25px; background: none; border: none; }

    .card-face:not(.card-back) form,
    .card-back form { display: flex !important; flex-direction: column; gap: 0; }

    .card-face:not(.card-back) .input-group,
    .card-face:not(.card-back) #captcha-container,
    .card-face:not(.card-back) .forgot-password,
    .card-face:not(.card-back) .btn-primary,
    .card-face:not(.card-back) .divider,
    .card-face:not(.card-back) .google-btn,
    .card-face:not(.card-back) .register-link,
    .card-back .input-group,
    .card-back .terms-container,
    .card-back .btn-primary,
    .card-back .divider,
    .card-back .google-btn,
    .card-back .register-link,
    .card-back .footer {
        grid-column: auto; grid-row: auto; width: 100%; margin-bottom: 0.9rem;
    }

    .card-face:not(.card-back) .forgot-password { text-align: right; }


    .logo-contenedor { padding-bottom: 18px; gap: 10px; }
    .logo-col img    { width: 50px; }
    .titulo-login, .logo h1 { font-size: 1.2rem; }
    .subtitulo       { font-size: 0.8rem; }
    .texto-col       { padding: 0 10px; }

    /* padding casi simétrico → offset mínimo 0.15rem */
    .input           { padding: 0.9rem 0.9rem 0.6rem 2.6rem; font-size: 0.9rem; border-radius: 50px; }
    .input-group     { margin-bottom: 0.9rem; }
    .input-group i   { left: 1rem; font-size: 0.95rem; margin-top: -0.15rem; }
    .placeholder     { left: 2.6rem; font-size: 0.85rem; margin-top: -0.15rem; }
    .toggle-password { right: 1rem; font-size: 1rem; margin-top: -0.15rem; }

    .btn, .google-btn { padding: 0.85rem; font-size: 0.9rem; border-radius: 50px; }
    .google-btn { color: #3c4043; }
    .btn             { margin: 10px 0 8px 0; }
    .divider         { margin: 0.2rem 0; padding: 8px 0; }
    .divider span    { font-size: 0.75rem; }
    .alert           { padding: 0.65rem 0.8rem; font-size: 0.75rem; border-radius: 50px; }
    .input-hint      { font-size: 0.65rem; }
    .forgot-password, .register-link { font-size: 0.8rem; }
}

/* Small Mobile (< 400px) */
@media (max-width: 399px) {
    .container { max-width: 100%; padding: 0.3rem; }
    body { padding: 0.3rem; }

    .card { min-height: 500px; }
    .card-face { border-radius: 20px; box-shadow: 0 15px 35px -8px rgba(0,0,0,0.3); background: none; border: none;}

    .card-face:not(.card-back) form,
    .card-back form { display: flex !important; flex-direction: column; gap: 0; }

    .card-face:not(.card-back) .input-group,
    .card-face:not(.card-back) #captcha-container,
    .card-face:not(.card-back) .forgot-password,
    .card-face:not(.card-back) .btn-primary,
    .card-face:not(.card-back) .divider,
    .card-face:not(.card-back) .google-btn,
    .card-face:not(.card-back) .register-link,
    .card-back .input-group,
    .card-back .terms-container,
    .card-back .btn-primary,
    .card-back .divider,
    .card-back .google-btn,
    .card-back .register-link,
    .card-back .footer {
        grid-column: auto; grid-row: auto; width: 100%; margin-bottom: 0.8rem;
    }

    .card-face:not(.card-back) .forgot-password { text-align: right; }
  

    .logo-contenedor { padding-bottom: 15px; gap: 8px; }
    .logo-col img    { width: 45px; }
    .titulo-login, .logo h1 { font-size: 1.1rem; }
    .subtitulo       { font-size: 0.75rem; }
    .texto-col       { padding: 0 8px; }

    /* padding casi simétrico → offset 0.15rem */
    .input           { padding: 0.85rem 0.8rem 0.55rem 2.5rem; font-size: 0.85rem; border-radius: 40px; }
    .input-group     { margin-bottom: 0.8rem; }
    .input-group i   { left: 0.9rem; font-size: 0.9rem; margin-top: -0.15rem; }
    .placeholder     { left: 2.5rem; font-size: 0.8rem; margin-top: -0.15rem; }
    .toggle-password { right: 0.9rem; font-size: 0.95rem; margin-top: -0.15rem; }

    .input:focus + .placeholder,
    .input:not(:placeholder-shown) + .placeholder {
        font-size: 0.7rem; padding: 0 0.8rem; margin-top: 0; transform: translateY(0);
    }

    .btn, .google-btn { padding: 0.8rem; font-size: 0.85rem; border-radius: 40px; }
    .google-btn { color: #3c4043; }
    .btn             { margin: 8px 0 6px 0; }
    .divider         { margin: 0.15rem 0; padding: 6px 0; }
    .divider span    { font-size: 0.7rem; padding: 0 0.6rem; }
    .alert           { padding: 0.6rem 0.7rem; font-size: 0.7rem; border-radius: 40px; }
    .input-hint      { font-size: 0.6rem; margin-left: 0.8rem; }
    .forgot-password, .register-link { font-size: 0.75rem; }
    .google-btn img  { width: 18px; height: 18px; }
    .footer p        { font-size: 0.7rem; }
}

/* Landscape móvil */
@media (max-height: 600px) and (orientation: landscape) {
    body { padding: 0.5rem; }
    .card { min-height: auto; }
    .card-face { padding: 1rem 1.5rem; }
    .logo-contenedor { padding-bottom: 10px; }
    .logo-col img    { width: 40px; }
    .titulo-login, .logo h1 { font-size: 1rem; }
    .subtitulo       { font-size: 0.75rem; }
    .input-group     { margin-bottom: 0.6rem; }

    /* padding (0.7rem top, 0.5rem bottom → offset 0.1rem) */
    .input           { padding: 0.7rem 0.8rem 0.5rem 2.4rem; font-size: 0.85rem; }
    .input-group i   { margin-top: -0.1rem; }
    .placeholder     { margin-top: -0.1rem; }
    .toggle-password { margin-top: -0.1rem; }

    .btn, .google-btn { padding: 0.7rem; font-size: 0.85rem; }
    .google-btn { color: #3c4043; }
    .btn             { margin: 6px 0 4px 0; }
    .divider         { padding: 4px 0; margin: 0.1rem 0; }
    .alert           { padding: 0.5rem 0.7rem; font-size: 0.7rem; }
}

/* Pantallas muy anchas (> 1400px) */
@media (min-width: 1400px) {
    .container { max-width: 1000px; }
    .card-face { padding: 3rem 2.5rem; }
    .logo-col img { width: 75px; }
    .titulo-login, .logo h1 { font-size: 2rem; }
    .subtitulo    { font-size: 1.1rem; }

    /* padding (1.3rem top, 0.8rem bottom → offset 0.25rem) */
    .input           { padding: 1.3rem 1.2rem 0.8rem 3.2rem; font-size: 1.05rem; }
    .input-group i   { left: 1.3rem; font-size: 1.2rem; margin-top: -0.25rem; }
    .placeholder     { left: 3.2rem; font-size: 1rem; margin-top: -0.25rem; }
    .toggle-password { margin-top: -0.25rem; }

    .btn, .google-btn { padding: 1.1rem; font-size: 1rem; }
    .google-btn { color: #3c4043; }
}

/* Reducción de movimiento */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
    .card { transition: none; }
    .btn-primary:hover { transform: none; }
}

/* =================== FOOTER =================== */
.footer p {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    text-align: center;
    margin-top: 1rem;
}