/* assets/css/login.css */

html,
body {
    height: 100%;
    overflow: hidden;
}

/* --- Material Body --- */
.material-login-body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    background:
        radial-gradient(circle at 15% 18%, rgba(175, 233, 148, 0.20), transparent 28%),
        radial-gradient(circle at 82% 12%, rgba(94, 204, 47, 0.16), transparent 24%),
        radial-gradient(circle at 80% 82%, rgba(35, 103, 139, 0.28), transparent 30%),
        linear-gradient(135deg, #194962 0%, #23678b 54%, #7dd856 140%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: none;
    position: relative;
    font-family: var(--font-family-base);
    box-sizing: border-box;
    background-size: 175% 175%, 190% 190%, 175% 175%, 200% 200%;
    animation: login-gradient-drift 18s ease-in-out infinite alternate;
}

.material-login-body::before,
.material-login-body::after {
    content: '';
    position: absolute;
    border-radius: 999px;
    pointer-events: none;
    filter: blur(6px);
}

.material-login-body::before {
    width: 320px;
    height: 320px;
    left: -90px;
    top: 8%;
    background: rgba(175, 233, 148, 0.10);
    animation: login-particle-float-a 11s ease-in-out infinite;
}

.material-login-body::after {
    width: 280px;
    height: 280px;
    right: -90px;
    bottom: 12%;
    background: rgba(242, 244, 232, 0.08);
    animation: login-particle-float-b 13s ease-in-out infinite;
}

@keyframes login-gradient-drift {
    0% {
        background-position: 0% 0%, 100% 0%, 100% 100%, 0% 0%;
    }

    100% {
        background-position: 16% 10%, 88% 12%, 84% 88%, 24% 26%;
    }
}

@keyframes login-particle-float-a {
    0% {
        transform: translate3d(0, 0, 0) scale(1);
        opacity: 0.88;
    }

    25% {
        transform: translate3d(34px, -26px, 0) scale(1.05);
        opacity: 0.98;
    }

    50% {
        transform: translate3d(64px, 8px, 0) scale(1.1);
        opacity: 1;
    }

    75% {
        transform: translate3d(28px, 30px, 0) scale(1.04);
        opacity: 0.96;
    }

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

@keyframes login-particle-float-b {
    0% {
        transform: translate3d(0, 0, 0) scale(1);
        opacity: 0.82;
    }

    25% {
        transform: translate3d(-30px, 18px, 0) scale(1.05);
        opacity: 0.95;
    }

    50% {
        transform: translate3d(-58px, -20px, 0) scale(1.1);
        opacity: 1;
    }

    75% {
        transform: translate3d(-24px, -34px, 0) scale(1.04);
        opacity: 0.94;
    }

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

@media (prefers-reduced-motion: reduce) {

    .material-login-body,
    .material-login-body::before,
    .material-login-body::after {
        animation: none !important;
    }
}

/* --- SVG Waves (Estáticas) --- */
.wave-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40vh;
    overflow: hidden;
    z-index: 1;
    opacity: 0.72;
}

.waves {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 100%;
    min-height: 100px;
    max-height: 400px;
    display: block;
    /* Elimina el gap de línea base que generan los elementos inline como SVG */
    margin-bottom: -1px;
    /* Evita cualquier pixel muerto al borde inferior de la ventana */
}

/* Eliminamos la animación de move-forever, dejamos los SVG como formas orgánicas sólidas */
.static-waves>use {
    transform: translate3d(0, 0, 0);
    /* Posición base bonita */
}

/* Distribuimos un poco las ondas manualmente usando translate para darle ese look escalonado */
.static-waves>use:nth-child(1) {
    transform: translate3d(-30px, 0, 0);
}

.static-waves>use:nth-child(2) {
    transform: translate3d(20px, 0, 0);
}

.static-waves>use:nth-child(3) {
    transform: translate3d(-10px, 0, 0);
}

.static-waves>use:nth-child(4) {
    transform: translate3d(50px, 0, 0);
}


/* --- Wrapper --- */
.login-wrapper {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    /* Por encima de las olas */
    padding: clamp(0.75rem, 2vw, 1.2rem);
    overflow: hidden;
    box-sizing: border-box;
}

/* --- Tarjeta Material Expressive --- */
.material-card {
    width: 100%;
    max-width: 440px;
    background: rgba(242, 244, 232, 0.92);
    border: none;
    border-radius: 28px;
    box-shadow:
        0 24px 60px -18px rgba(13, 39, 53, 0.42),
        0 6px 18px rgba(13, 39, 53, 0.18);
    padding: 1.1rem 2.25rem 2.25rem;
    display: flex;
    flex-direction: column;
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    position: relative;
    z-index: 2;
    max-height: none;
    overflow: hidden;
}

/* --- LOGO --- */
.logo-box {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 1.25rem;
    width: 90%;
    padding: 1.25rem 1.2rem;
    border-radius: 28px 28px 28px 28px;
    background: linear-gradient(135deg, #194962 0%, #23678b 100%);
    box-shadow: 0 14px 30px rgba(25, 73, 98, 0.28);
    border: none;
    min-height: 180px;
    margin-top: 15px;
}

.login-logo {
    width: min(340px, 100%);
    max-width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    opacity: 1;
    visibility: visible;
}

.login-logo-object {
    width: min(340px, 100%);
    max-width: 100%;
    height: 180px;
    display: block;
    line-height: 0;
    margin-bottom: -20px;
}

.logo-placeholder {
    width: 72px;
    height: 72px;
    /* "Primary Container" shape */
    background-color: #eef8e8;
    /* Soft green */
    border-radius: 20px;
    /* Squircle appearance */
    display: flex;
    align-items: center;
    justify-content: center;
    color: #23678b;
    /* Orion blue */
    font-weight: 800;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* --- Header --- */
.login-header {
    margin-bottom: 1.5rem;
    text-align: center;
}

.login-header h1 {
    font-size: clamp(1.35rem, 2.8vw, 1.75rem);
    color: #194962;
    font-weight: 500;
    /* Medium weight en títulos M3 */
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

.subtitle {
    font-size: clamp(0.88rem, 1.8vw, 1rem);
    color: #23678b;
}

/* --- Material "Filled" Textfields --- */
.form-group {
    margin-bottom: 1.25rem;
}

.material-input-group {
    position: relative;
}

/* El input toma el estilo de 'Surface Variant' */
.input-wrapper {
    position: relative;
    width: 100%;
    border-radius: 12px;
    background: rgba(242, 244, 232, 0.96);
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    overflow: hidden;
    border: 1px solid rgba(35, 103, 139, 0.14);
}

.input-wrapper:has(input:focus) {
    background-color: #eef8e8;
    box-shadow: 0 0 0 3px rgba(175, 233, 148, 0.16);
    transform: translateY(-1px);
}

/* Línea indicadora inferior animada clásica de Material */
.input-wrapper::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: #5ecc2f;
    transform: scaleX(0);
    transition: transform 0.2s cubic-bezier(0.0, 0, 0.2, 1);
    transform-origin: center;
}

.input-wrapper:has(input:focus)::after {
    transform: scaleX(1);
}

.input-wrapper input {
    width: 100%;
    /* Padding alto para dar espacio al Floating Label */
    padding: 1.75rem 1rem 0.75rem 1rem;
    background-color: transparent;
    border: none;
    font-size: 1rem;
    color: #194962;
    font-weight: 500;
}

.input-wrapper input:focus {
    outline: none;
}

/* Eliminar el fondo amarillo del autocompletado nativo usando internal shadow */
.input-wrapper input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 100px #f2f4e8 inset !important;
    -webkit-text-fill-color: #194962 !important;
    caret-color: #5ecc2f;
}

.input-wrapper:has(input:focus) input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 100px #eef8e8 inset !important;
}

/* --- Floating Labels --- */
.floating-label {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    color: #23678b;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.0, 0, 0.2, 1);
}

/* Cuando el input tiene el foco, O cuando no está vacío (hack con placeholder =" " y :not(:placeholder-shown)) */
.input-wrapper input:focus~.floating-label,
.input-wrapper input:not(:placeholder-shown)~.floating-label {
    top: 1rem;
    font-size: 0.75rem;
    color: #194962;
    font-weight: 500;
}

.input-wrapper input:not(:focus):not(:placeholder-shown)~.floating-label {
    color: #23678b;
}

/* --- Contraseña Eye Icon --- */
.btn-eye {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #23678b;
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 50%;
    /* Ripple effect rounded */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.btn-eye:hover {
    background-color: rgba(25, 73, 98, 0.1);
    color: #194962;
}

/* --- Submit Button (Pill Shape) --- */
.btn-material-submit {
    width: 100%;
    margin-top: 1.5rem;
    height: 3.35rem;
    border-radius: 12px;
    background: linear-gradient(135deg, #5ecc2f 0%, #afe994 100%);
    color: #f2f4e8;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.0, 0, 0.2, 1);
    box-shadow: 0 12px 24px -10px rgba(94, 204, 47, 0.55);
}

.btn-material-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 30px -14px rgba(25, 73, 98, 0.42);
}

.btn-material-submit:focus,
.btn-material-submit:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(94, 204, 47, 0.3);
}

.btn-material-submit:active {
    background-color: #23678b;
    box-shadow: 0 1px 2px rgba(25, 73, 98, 0.22);
    transform: translateY(0);
}

/* --- Android (Material Expressive) --- */
.is-android .btn-material-submit {
    border-radius: 100px;
    letter-spacing: 0.25px;
}

/* --- iOS (Native Apple Style) --- */
.is-ios .btn-material-submit {
    border-radius: 14px;
    background: #23678b;
    color: #ffffff;
    box-shadow: none;
    font-weight: 600;
    letter-spacing: -0.4px;
    height: 3.2rem;
}

.is-ios .btn-material-submit:active {
    background: #194962;
    transform: scale(0.97);
}

/* --- Responsive --- */
/* Login Settings Button */
.login-top-settings {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 100;
}

.login-top-settings .btn-icon {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: var(--shadow-sm);
}

.login-top-settings .btn-icon:hover {
    background: white;
}

/* ============================================
   Responsive — Tablet (max-width: 1024px)
   ============================================ */
@media (max-width: 1024px) {
    .material-card {
        max-width: 420px;
        padding: 1rem 1.8rem 1.8rem;
    }

    .logo-box {
        width: 94%;
        min-height: 160px;
        padding: 1rem;
    }

    .login-logo {
        width: min(300px, 100%);
    }

    .login-logo-object {
        width: min(300px, 100%);
        height: 150px;
    }
}

/* ============================================
   Responsive — Mobile First (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {

    /* --- Micro-animaciones de entrada para móvil --- */
    @keyframes mobileAppEntrance {
        from {
            opacity: 0;
            transform: translateY(30px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    @keyframes logoEntrance {
        from {
            opacity: 0;
            transform: scale(0.92);
        }
        to {
            opacity: 1;
            transform: scale(1);
        }
    }

    /* Contenedor principal: centrado absoluto */
    .material-login-body {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        min-height: 100dvh;
        height: 100vh;
        height: 100dvh;
        margin: 0;
        padding: 0;
        overflow: hidden;
    }

    /* Contenedor del login centrado en Bottom Sheet */
    .login-wrapper {
        flex: 1;
        min-height: 0;
        display: flex;
        align-items: stretch;
        justify-content: flex-end;
        flex-direction: column;
        width: 100%;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }

    /* Tarjeta de login pierde fondo y anchos máximos */
    .material-card {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        justify-content: flex-end;
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    /* Nuevo contenedor Bottom Sheet */
    .login-bottom-sheet {
        background: rgba(242, 244, 232, 0.98);
        -webkit-backdrop-filter: blur(24px);
        backdrop-filter: blur(24px);
        padding: 3rem 1.5rem calc(2.5rem + env(safe-area-inset-bottom));
        border-radius: 36px 36px 0 0;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
        width: 100%;
        flex-shrink: 0;
        box-sizing: border-box;
        opacity: 0;
        animation: mobileAppEntrance 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.18s forwards;
    }

    .login-logo {
        width: 100%;
    }

    .login-logo-object {
        width: 100%;
        height: 180px;
    }

    /* Caja del logo flota arriba libremente */
    .logo-box {
        margin-top: 3rem;
        width: 100%;
        max-width: 100%;
        background: transparent;
        box-shadow: none;
        height: 100%;
        border-radius: 0;
        padding: 0;
        min-height: auto;
        display: flex;
        justify-content: center;
        align-items: center;
        opacity: 0;
        animation: logoEntrance 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.05s forwards;
    }

    /* Títulos legibles */
    .login-header {
        margin-bottom: 1.5rem;
    }

    .login-header h1 {
        font-size: 1.32rem;
    }

    .subtitle {
        font-size: 0.86rem;
    }

    /* Inputs anti-zoom iOS */
    .input-wrapper input {
        font-size: 16px;
        padding: 1.5rem 1rem 0.75rem 1rem;
    }

    /* Floating labels ajustadas */
    .floating-label {
        font-size: 16px;
    }

    .input-wrapper input:focus~.floating-label,
    .input-wrapper input:not(:placeholder-shown)~.floating-label {
        font-size: 0.75rem;
    }

    /* Botón grande y cómodo */
    .btn-material-submit {
        height: 3.1rem;
        font-size: 0.96rem;
        margin-top: 1.1rem;
    }

    /* Reducir espaciado */
    .form-group {
        margin-bottom: 1rem;
    }

    /* Waves más sutiles */
    .wave-container {
        height: 24vh;
        opacity: 0.72;
    }
}

/* ============================================
   Responsive — Móvil pequeño (max-width: 480px)
   ============================================ */
@media (max-width: 480px) {
    .login-bottom-sheet {
        padding: 1.8rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
    }

    .login-header {
        margin-bottom: 1.2rem;
    }

    .login-header h1 {
        font-size: 1.2rem;
    }

    .subtitle {
        font-size: 0.82rem;
    }

    .input-wrapper input {
        padding: 1.35rem 0.9rem 0.7rem 0.9rem;
    }

    .floating-label {
        left: 0.9rem;
    }
}

/* ============================================
   Responsive — Móvil muy estrecho (max-width: 360px)
   ============================================ */
@media (max-width: 360px) {
    .login-bottom-sheet {
        padding: 1.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
    }

    .login-logo {
        width: min(195px, 100%);
    }

    .login-logo-object {
        width: min(195px, 100%);
        height: 100%;
    }

    .login-header h1 {
        font-size: 1.12rem;
    }
}