/* =============================================================================
   ENCARGA 2.0 — Login de TENANT (login.php). Sólo presentación.
   La lógica (CSRF, Turnstile, sesión, auditoría, cambio obligatorio) vive en login.php y no depende de estos estilos.
   Layout: izquierda 40 % formulario real · derecha 60 % hero de producto (images/login2.0.*). Sin scroll en escritorio.
   ============================================================================= */
:root {
    --navy: #0B2A5B;
    --blue: #1E63D6;
    --blue-deep: #1553B9;
    --blue-soft: #E8F0FD;
    --ink: #1B2A41;
    --slate: #4A5A72;
    --muted: #6E7D92;
    --line: #D9E3F0;
    --ground: #F5F9FF;
    --white: #FFFFFF;
    --focus: rgba(30, 99, 214, .22);
    --danger: #B42318;
    --danger-bg: #FEF3F2;
    --danger-line: #FECDCA;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body.login-v2 {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

/* ---------- estructura ---------- */
.login-wrapper {
    display: grid;
    grid-template-columns: 40% 60%;
    min-height: 100vh;
    min-height: 100dvh;
}
.login-left {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    background: var(--white);
    border-right: 1px solid var(--line);
    padding: 32px 24px;
}
.login-container { width: 100%; max-width: 420px; min-width: 0; }
.login-container > * { min-width: 0; }
.field-input { min-width: 0; }

/* ---------- marca ---------- */
.brand-header { margin-bottom: 26px; }
.brand-logo-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--navy);
    border-radius: 8px;
}
.brand-logo-link:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.brand-logo-link img { width: 44px; height: 44px; object-fit: contain; display: block; }
.brand-name { font-size: 26px; font-weight: 700; letter-spacing: -.01em; line-height: 1; color: var(--navy); }
.brand-version {
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    color: var(--blue);
    background: var(--blue-soft);
    border-radius: 999px;
    padding: 6px 10px;
    margin-left: 4px;
    white-space: nowrap;
}
.login-title {
    margin: 26px 0 8px;
    font-size: clamp(28px, 2.6vw, 36px);
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--navy);
}
.login-title span { display: block; color: var(--blue); }
.login-subtitle { margin: 0; font-size: 16px; color: var(--slate); max-width: 38ch; }

/* ---------- formulario ---------- */
.field { position: relative; margin-bottom: 14px; }
.field-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: #8A9AB3;
    font-size: 15px;
    pointer-events: none;
}
.field-input {
    width: 100%;
    height: 56px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--white);
    padding: 0 16px 0 48px;
    font: inherit;
    font-size: 15.5px;
    color: var(--ink);
    transition: border-color .15s, box-shadow .15s;
}
.field-input::placeholder { color: #94A3B8; }
.field-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--focus); }
.field-input.has-toggle { padding-right: 56px; }
.toggle-password {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #8A9AB3;
    cursor: pointer;
}
.toggle-password:hover { color: var(--blue); background: var(--blue-soft); }
.toggle-password:focus-visible { outline: none; color: var(--blue); box-shadow: 0 0 0 3px var(--focus); }

.form-extras {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 2px 0 18px;
    font-size: 14px;
    color: var(--slate);
}
.remember { display: inline-flex; align-items: center; gap: 10px; margin: 0; cursor: pointer; }
.remember input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); }
.remember input:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); border-radius: 4px; }
/* SEC-APP-4 (16-oct-2026): «¿Olvidaste tu contraseña?» → recuperar.php */
.link-recuperar { color: var(--blue); font-weight: 600; text-decoration: none; border-radius: 6px; }
.link-recuperar:hover { text-decoration: underline; }
.link-recuperar:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }

/* Cloudflare Turnstile: el widget real, integrado en un marco sobrio (nunca se oculta ni se simula) */
.turnstile-slot {
    margin-bottom: 18px;
    min-height: 77px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #FBFCFE;
    padding: 6px;
}
.turnstile-slot .cf-turnstile { display: flex; justify-content: center; margin: 0; }

.btn-login {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 56px;
    border: 0;
    border-radius: 14px;
    background: linear-gradient(90deg, #1E63D6 0%, #1A5BC7 100%);
    color: #fff;
    font: inherit;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(30, 99, 214, .22);
    transition: background .15s, box-shadow .15s, transform .05s;
}
.btn-login:hover { background: linear-gradient(90deg, #1959C4 0%, #1550B0 100%); }
.btn-login:active { transform: translateY(1px); }
.btn-login:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--focus), 0 8px 20px rgba(30, 99, 214, .22); }
.btn-login .btn-chevron { position: absolute; right: 18px; font-size: 14px; opacity: .9; }
.btn-login .spinner-border { color: #fff; }

.alert-custom {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--danger-bg);
    border: 1px solid var(--danger-line);
    color: var(--danger);
    font-size: 14px;
}

/* ---------- acciones secundarias ---------- */
.login-secondary {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}
.divider-text { color: var(--muted); }
.link-activate {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--blue);
    font-weight: 600;
    text-decoration: none;
    border-radius: 6px;
}
.link-activate:hover { text-decoration: underline; }
.link-activate:focus-visible, .btn-back-landing:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.btn-back-landing {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 14px auto 0;
    width: max-content;
    font-size: 14px;
    color: var(--muted);
    text-decoration: none;
    border-radius: 6px;
}
.btn-back-landing:hover { color: var(--slate); }

.login-footer {
    margin-top: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 12.5px;
    color: var(--muted);
    text-align: center;
}
.login-footer i { margin-right: 4px; }

/* ---------- hero derecho ---------- */
.login-right {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background: linear-gradient(180deg, #EAF2FF 0%, #F5F9FF 100%);
}
.hero-media { position: relative; flex: 1 1 auto; min-height: 0; }
.login-hero { position: absolute; inset: 0; display: block; margin: 0; }
.login-hero img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: right center;   /* mantiene visibles el dashboard y el robot (lado derecho del asset) */
}
/* fundido inferior de ancho completo: enlaza la imagen con la banda de pastillas */
.hero-media::before {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 22%;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(245, 249, 255, 0) 0%, rgba(245, 249, 255, .85) 100%);
}
/* velo inferior-izquierdo para que el titular lea bien sobre el suelo de la imagen (no toca al robot, a la derecha) */
.hero-media::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 46%;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(245, 249, 255, 0) 0%, rgba(245, 249, 255, .55) 45%, rgba(245, 249, 255, .9) 100%);
    -webkit-mask-image: linear-gradient(90deg, #000 0%, #000 55%, transparent 78%);
            mask-image: linear-gradient(90deg, #000 0%, #000 55%, transparent 78%);
}
.hero-tagline {
    position: absolute;
    top: clamp(18px, 3vh, 30px);
    right: clamp(20px, 3vw, 44px);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: clamp(13px, 1.05vw, 15px);
    font-weight: 500;
    color: var(--slate);
    white-space: nowrap;
}
.hero-tagline span { display: inline-block; width: 44px; height: 2px; border-radius: 2px; background: var(--blue); }
.hero-copy {
    position: absolute;
    left: clamp(24px, 3.6vw, 56px);
    right: 36%;
    bottom: clamp(16px, 3vh, 30px);
    z-index: 2;
}
.hero-title {
    margin: 0 0 6px;
    font-size: clamp(38px, 4.6vw, 66px);
    line-height: 1;
    font-weight: 800;
    letter-spacing: -.03em;
    color: var(--navy);
}
.hero-title span { color: var(--blue); }
.hero-subtitle {
    margin: 0;
    font-size: clamp(15px, 1.35vw, 20px);
    line-height: 1.35;
    color: var(--slate);
    max-width: 26em;
}
.hero-pills {
    list-style: none;
    margin: 0;
    padding: 10px clamp(18px, 2.4vw, 40px) clamp(14px, 2.4vh, 22px);
    display: flex;
    flex-wrap: nowrap;
    gap: clamp(8px, .9vw, 14px);
    position: relative;
    z-index: 2;
}
.hero-pills li {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    background: rgba(255, 255, 255, .88);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 6px 18px rgba(14, 58, 110, .06);
    font-size: clamp(11.5px, .9vw, 14px);
    font-weight: 600;
    line-height: 1.2;
    color: var(--ink);
}
.hero-pills li i {
    flex: none;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--blue-soft);
    color: var(--blue);
    font-size: 14px;
}

/* pantallas de escritorio poco altas (p. ej. 1366×768, 1280×720): ritmo vertical compacto, sin scroll */
@media (min-width: 768px) and (max-height: 840px) {
    .login-left { padding: 20px 24px; }
    .brand-header { margin-bottom: 16px; }
    .login-title { margin: 14px 0 6px; font-size: clamp(26px, 2.3vw, 32px); }
    .login-subtitle { font-size: 15px; }
    .field { margin-bottom: 10px; }
    .field-input { height: 52px; }
    .form-extras { margin: 0 0 12px; }
    .turnstile-slot { margin-bottom: 12px; min-height: 71px; padding: 3px; }
    .btn-login { height: 52px; }
    .alert-custom { margin-top: 10px; }
    .login-secondary { margin-top: 14px; padding-top: 12px; gap: 4px; }
    .btn-back-landing { margin-top: 8px; }
    .login-footer { margin-top: 14px; }
}

/* ---------- responsive ---------- */
@media (max-width: 1199.98px) {
    .login-wrapper { grid-template-columns: 45% 55%; }
    .hero-copy { right: 30%; }
    .hero-pills { flex-wrap: wrap; }
    .hero-pills li { flex: 1 1 150px; }
}
@media (max-width: 767.98px) {
    .login-wrapper { grid-template-columns: minmax(0, 1fr); }
    body.login-v2 { overflow-x: hidden; }
    .login-right { display: none; }          /* el <picture> sirve un GIF 1×1 en móvil: el hero no se descarga */
    .login-left { border-right: 0; padding: 28px 20px 32px; align-items: flex-start; }
    .login-title { font-size: 28px; }
    .brand-name { font-size: 24px; }
    .login-subtitle { font-size: 15px; }
}
@media (max-height: 700px) and (min-width: 768px) {
    .brand-header { margin-bottom: 18px; }
    .login-title { margin-top: 16px; }
    .login-footer { margin-top: 18px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}

/* ---------- entrada a la app (2-oct-2026) ----------
   El botón confirma el clic («Verificando…») y, en navegadores que lo soportan, el paso del
   login a la app es un fundido en vez de un corte (la otra mitad vive en includes/entrada_app.php). */
@view-transition { navigation: auto; }
.btn-login.is-busy { pointer-events: none; }
.btn-login.is-busy > .fa-arrow-right-to-bracket, .btn-login.is-busy .btn-chevron { display: none; }

/* Llegada desde «Cerrar sesión» (js/salida-app.js → js/login.js): aviso verde que confirma la salida. */
.login-salida {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
    padding: 11px 14px;
    border-radius: 12px;
    background: #ECFDF3;
    border: 1px solid #ABEFC6;
    color: #067647;
    font-size: 14px;
    font-weight: 600;
    animation: login-salida-in .45s cubic-bezier(.2, .8, .2, 1) .15s both;
}
.login-salida i { font-size: 13px; }
@keyframes login-salida-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .login-salida { animation: none; } }
