/* ---------- Variables globales ---------- */
/* Duplicadas fuera de .lg-shell para poder reutilizar .lg-input, .lg-field, .lg-submit,
   .lg-card, etc. en páginas normales de la app (perfil, email, contraseña) que no están
   dentro de la pantalla de login a pantalla completa. */
:root {
    --cobalt: #1f5eff;
    --ink: #0a1a33;
    --mist: #eaf1fb;
    --steel: #8fa9d1;
}

/* ---------- Estructura general ---------- */
/* La página ocupa toda la ventana, así que no depende de cómo esté hecho LoginLayout. */
.lg-shell {
    --abyss: #071a3b;
    --deep: #0d2a5c;
    --cobalt: #1f5eff;
    --sky: #5cc8ff;
    --beam: #2aa8ff;
    --steel: #8fa9d1;
    --mist: #eaf1fb;
    --ink: #0a1a33;
    --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;

    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(360px, 1fr);
    background: var(--abyss);
    font-family: Bahnschrift, "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
}

/* ---------- Escena de lectura ---------- */
.lg-wall {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    padding: 2.5rem;
    overflow: hidden;
    background:
        radial-gradient(60% 55% at 40% 45%, rgba(31, 94, 255, .38), transparent 70%),
        radial-gradient(rgba(92, 200, 255, .17) 1px, transparent 1.6px) 0 0 / 26px 26px,
        linear-gradient(160deg, var(--deep), var(--abyss) 65%);
}

.lg-scanner {
    display: flex;
    align-items: center;
    gap: clamp(1.25rem, 3vw, 3rem);
    width: 100%;
    max-width: 760px;
}

/* Marco de enfoque: se "engancha" al código cada ciclo */
.lg-lock {
    position: relative;
    flex: 0 0 auto;
    padding: 20px;
}

.lg-lock::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(var(--sky), var(--sky)) top left / 28px 3px no-repeat,
        linear-gradient(var(--sky), var(--sky)) top left / 3px 28px no-repeat,
        linear-gradient(var(--sky), var(--sky)) top right / 28px 3px no-repeat,
        linear-gradient(var(--sky), var(--sky)) top right / 3px 28px no-repeat,
        linear-gradient(var(--sky), var(--sky)) bottom left / 28px 3px no-repeat,
        linear-gradient(var(--sky), var(--sky)) bottom left / 3px 28px no-repeat,
        linear-gradient(var(--sky), var(--sky)) bottom right / 28px 3px no-repeat,
        linear-gradient(var(--sky), var(--sky)) bottom right / 3px 28px no-repeat;
    animation: lg-lockon 8s ease-out infinite;
}

/* El código, impreso sobre una superficie clara */
.lg-specimen {
    position: relative;
    overflow: hidden;
    width: clamp(190px, 21vw, 300px);
    aspect-ratio: 1;
    border-radius: 4px;
    background: #f2f7ff;
    color: #0a2250;
    box-shadow: 0 24px 60px rgba(2, 10, 30, .55);
}

.lg-dm {
    display: block;
    width: 100%;
    height: 100%;
}

/* Haz de lectura: estela clara y línea brillante en el borde inferior */
.lg-laser {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 45%;
    background: linear-gradient(180deg, transparent, rgba(42, 168, 255, .3));
    transform: translateY(-100%);
    opacity: 0;
    animation: lg-scan 8s linear infinite;
}

.lg-laser::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: var(--beam);
    box-shadow: 0 0 12px 3px rgba(42, 168, 255, .7);
}

/* Datos decodificados (identificadores GS1) */
.lg-readout {
    flex: 1;
    min-width: 0;
    max-width: 340px;
    color: #fff;
}

.lg-status {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1rem;
    color: var(--sky);
    font-size: .95rem;
    font-weight: 600;
    opacity: .4;
    animation: lg-read 8s ease-out 1.2s infinite;
}

.lg-status svg {
    width: 18px;
    height: 18px;
    flex: none;
}

.lg-row {
    display: grid;
    grid-template-columns: 2.7rem 1fr;
    gap: .5rem;
    padding: .8rem 0;
    border-top: 1px solid rgba(92, 200, 255, .22);
    opacity: .4;
    animation: lg-read 8s ease-out infinite;
}

.lg-row:nth-child(3) { animation-delay: .3s; }
.lg-row:nth-child(4) { animation-delay: .6s; }
.lg-row:nth-child(5) { animation-delay: .9s; }

.lg-ai {
    padding-top: .12rem;
    color: var(--sky);
    font-family: var(--mono);
    font-size: .85rem;
}

.lg-key {
    display: block;
    color: var(--steel);
    font-size: .8rem;
}

.lg-val {
    display: block;
    margin-top: .15rem;
    font-family: var(--mono);
    font-size: 1.05rem;
    letter-spacing: .02em;
    overflow-wrap: anywhere;
}

/* ---------- Panel del formulario ---------- */
.lg-panel {
    display: flex;
    padding: 2rem;
    overflow-y: auto;
    background: var(--mist);
}

/* margin:auto centra sin cortar el contenido cuando la pantalla es baja */
.lg-form-wrap {
    width: 100%;
    max-width: 380px;
    margin: auto;
}

.lg-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-bottom: 2.5rem;
    color: var(--ink);
    font-size: 1.15rem;
    font-weight: 700;
}

.lg-brand svg {
    width: 34px;
    height: 34px;
}

.lg-form-wrap h1 {
    margin: 0 0 .5rem;
    color: var(--ink);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}

.lg-lead {
    margin: 0 0 2rem;
    color: #4a628a;
}

.lg-error {
    margin-bottom: 1.25rem;
    padding: .75rem 1rem;
    border-left: 4px solid #d64550;
    border-radius: 4px;
    background: #fdecee;
    color: #7a1d26;
    font-size: .92rem;
}

.lg-field {
    margin-bottom: 1.15rem;
}

.lg-field label {
    display: block;
    margin-bottom: .4rem;
    color: var(--ink);
    font-size: .9rem;
    font-weight: 600;
}

.lg-input {
    width: 100%;
    height: 3rem;
    padding: 0 .9rem;
    border: 1.5px solid #b9c9e2;
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    transition: border-color .15s, box-shadow .15s;
}

.lg-input:focus {
    outline: none;
    border-color: var(--cobalt);
    box-shadow: 0 0 0 3px rgba(31, 94, 255, .28);
}

.lg-submit {
    width: 100%;
    height: 3rem;
    margin-top: .5rem;
    border: 0;
    border-radius: 6px;
    background: var(--cobalt);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, transform .05s;
}

.lg-submit:hover {
    background: #3a71ff;
}

.lg-submit:active {
    transform: translateY(1px);
}

.lg-submit:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 2px;
}

.lg-help {
    margin: 1.75rem 0 0;
    color: #4a628a;
    font-size: .85rem;
}

/* ---------- Animaciones (un solo ciclo de 8 s) ---------- */
/* 0-10 %: el marco se engancha; 14-52 %: barrido; 52-92 %: se muestran los datos */
@keyframes lg-lockon {
    0%   { transform: scale(1.1); opacity: .3; }
    10%, 92% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.1); opacity: .3; }
}

@keyframes lg-scan {
    0%, 10% { transform: translateY(-100%); opacity: 0; }
    14%     { opacity: 1; }
    52%     { transform: translateY(122%); opacity: 1; }
    56%, 100% { transform: translateY(122%); opacity: 0; }
}

@keyframes lg-read {
    0%, 52%  { opacity: .4; }
    58%, 92% { opacity: 1; }
    100%     { opacity: .4; }
}

@media (prefers-reduced-motion: reduce) {
    .lg-lock::before {
        animation: none;
    }

    .lg-laser {
        display: none;
    }

    .lg-status,
    .lg-row {
        animation: none;
        opacity: 1;
    }
}

/* ---------- Tarjeta de formulario embebida ---------- */
/* Para usar el mismo estilo de campos (lg-field / lg-input / lg-submit) dentro del
   layout normal de la app, p. ej. en Perfil, Email y Cambiar contraseña. */
.lg-card {
    max-width: 480px;
    padding: 1.75rem;
    border-radius: 10px;
    background: var(--mist);
    box-shadow: 0 8px 28px rgba(10, 26, 51, .1);
}

.lg-success {
    margin-bottom: 1.25rem;
    padding: .75rem 1rem;
    border-left: 4px solid #1f8a4c;
    border-radius: 4px;
    background: #e9f8ee;
    color: #155c33;
    font-size: .92rem;
}

.lg-confirmed {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    margin-top: .35rem;
    color: #1f8a4c;
    font-size: .85rem;
    font-weight: 600;
}

.lg-link-btn {
    margin-top: .35rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--cobalt);
    font: inherit;
    font-weight: 600;
    font-size: .85rem;
    cursor: pointer;
}

.lg-link-btn:hover {
    text-decoration: underline;
}

/* ---------- Móvil y pantallas estrechas ---------- */
@media (max-width: 900px) {
    .lg-shell {
        grid-template-columns: 1fr;
        grid-template-rows: 32vh 1fr;
    }

    .lg-wall {
        padding: 1rem;
    }

    .lg-lock {
        padding: 12px;
    }

    .lg-specimen {
        width: clamp(100px, calc(32vh - 3.5rem), 220px);
    }

    .lg-readout {
        display: none;
    }

    .lg-brand {
        margin-bottom: 1.5rem;
    }

    .lg-form-wrap h1 {
        font-size: 1.6rem;
    }
}
