/* =============================================================
   Login corporativo Malvón — Centro de Mando
   Referencia: login.md + redesign.md
   ============================================================= */

:root {
    --color-login-page: #000000;
    --color-brand-red: #8e0800;
    --color-brand-taupe: #bfac98;
    --color-brand-black: #000000;
    --color-text: #f7f4f1;
    --color-text-soft: #bfac98;
    --color-accent: #8e0800;
    --color-login-error-text: #ffd0d0;
    --color-login-error-bg: rgba(196, 30, 30, 0.12);
    --color-login-ms-text: #000000;
    --color-login-ms-hover: #f7f4f1;
    --font-sans: "Raleway", "Raleway Fallback", ui-sans-serif, system-ui, sans-serif;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

@font-face {
    font-family: "Raleway Fallback";
    src: local("Arial");
    size-adjust: 100%;
    ascent-override: 90%;
    descent-override: 22%;
    line-gap-override: 0%;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html:has(.login-page--split),
body:has(.login-page--split) {
    overflow: hidden;
    height: 100%;
}

html {
    font-family: var(--font-sans);
}

body {
    margin: 0;
    font-family: inherit;
    background: var(--color-login-page);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Shell ===== */
.login-page {
    min-height: 100dvh;
    background: var(--color-login-page);
    font-family: var(--font-sans);
    color: var(--color-text);
}

.login-page--split {
    display: flex;
    position: relative;
    isolation: isolate;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
}

/* ===== Visual panels ===== */
.login-visual {
    display: none;
    overflow: hidden;
}

.login-visual-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.login-visual-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.52);
    pointer-events: none;
}

/* Mobile background */
@media (max-width: 639px) {
    .login-page--split {
        flex-direction: column;
        height: auto;
        min-height: 100dvh;
        max-height: none;
        overflow: visible;
    }

    html:has(.login-page--split),
    body:has(.login-page--split) {
        overflow: auto;
        height: auto;
    }

    .login-visual--mobile {
        display: block;
        position: absolute;
        inset: 0;
        z-index: 0;
    }

    .login-visual--mobile .login-visual-img {
        position: absolute;
        inset: 0;
    }

    .login-visual--mobile .login-visual-overlay {
        z-index: 1;
    }

    .login-visual--desktop {
        display: none;
    }
}

/* Desktop split */
@media (min-width: 640px) {
    .login-visual--desktop {
        display: block;
        flex: 1 1 50%;
        min-height: 0;
    }

    .login-visual--mobile {
        display: none;
    }
}

/* ===== Content layout ===== */
.login-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: clamp(1.25rem, 4vw, 2rem);
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
    animation: mvFadeUp 0.55s var(--ease-out) both;
}

.login-layout--centered {
    text-align: center;
}

.login-version {
    margin-top: auto;
    padding-top: 1.25rem;
    font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-align: center;
    color: rgba(255, 255, 255, 0.35);
    user-select: none;
}

@media (max-width: 639px) {
    .login-layout {
        position: relative;
        z-index: 1;
        flex: 1;
        min-height: 100dvh;
        justify-content: flex-start;
    }
}

@media (min-width: 640px) {
    .login-layout {
        flex: 1 1 50%;
        justify-content: flex-start;
        min-height: 0;
        overflow: hidden;
    }
}

/* ===== Logo ===== */
.login-logo-img {
    flex-shrink: 0;
    height: clamp(4.25rem, 22vw, 5.5rem);
    width: auto;
    margin-bottom: clamp(1.5rem, 5vw, 2.5rem);
}

@media (min-width: 640px) {
    .login-logo-img {
        height: clamp(5rem, 11vh, 7rem);
        margin-bottom: clamp(1rem, 3vh, 2rem);
    }
}

/* ===== Panel ===== */
.login-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 28rem;
    gap: clamp(1.25rem, 3vw, 1.75rem);
}

@media (max-width: 639px) {
    .login-panel {
        flex: 1;
        justify-content: space-between;
    }
}

@media (min-width: 640px) {
    .login-panel {
        flex: 1;
        justify-content: center;
        min-height: 0;
    }
}

/* ===== Copy ===== */
.login-copy {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.625rem, 2vw, 0.875rem);
}

.login-eyebrow {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--color-brand-taupe);
}

.login-title {
    font-size: clamp(1.75rem, 6vw, 2.25rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: #ffffff;
}

.login-lead {
    font-size: clamp(0.9375rem, 2.8vw, 1rem);
    font-weight: 400;
    line-height: 1.6;
    color: var(--color-brand-taupe);
    max-width: 36ch;
}

.login-lead--centered {
    text-align: center;
}

/* ===== Alert ===== */
.login-alert {
    display: none;
    width: 100%;
    padding: 0.75rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--color-login-error-text);
    background: var(--color-login-error-bg);
    border-left: 2px solid var(--color-accent);
    text-align: left;
}

.login-alert.is-visible {
    display: block;
}

/* ===== Actions ===== */
.login-actions {
    width: 100%;
}

@media (max-width: 639px) {
    .login-actions {
        margin-top: auto;
    }
}

/* ===== Microsoft button ===== */
.btn-login-ms {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    min-height: 3rem;
    padding: 0.75rem 1.125rem;
    border: none;
    border-radius: 2px;
    background: #ffffff;
    color: var(--color-login-ms-text);
    font-family: var(--font-sans);
    font-size: clamp(0.9rem, 2.5vw, 0.95rem);
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-login-ms:hover {
    background: var(--color-login-ms-hover);
}

.btn-login-ms:active {
    transform: translateY(1px);
}

.btn-login-ms:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
}

.btn-login-ms:disabled,
.btn-login-ms.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-login-ms.is-loading {
    cursor: wait;
}

.btn-login-ms .microsoft-logo {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.btn-login-ms-spinner {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    border: 2px solid rgba(0, 0, 0, 0.15);
    border-top-color: #000000;
    border-radius: 50%;
    animation: loginMsSpin 0.7s linear infinite;
}

@keyframes loginMsSpin {
    to { transform: rotate(360deg); }
}

/* ===== Desktop compact (short viewports) ===== */
@media (min-width: 640px) and (max-height: 720px) {
    .login-logo-img {
        height: clamp(4rem, 9vh, 4.75rem);
        margin-bottom: 1rem;
    }

    .login-title {
        font-size: 1.5rem;
    }

    .login-lead {
        font-size: 0.9rem;
    }

    .login-panel {
        gap: 1rem;
    }

    .login-layout {
        padding: 1rem 1.5rem;
    }
}

/* ===== Animations ===== */
@keyframes mvFadeUp {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .login-layout {
        animation: none;
    }

    .btn-login-ms-spinner {
        animation: none;
        border-top-color: rgba(0, 0, 0, 0.4);
    }
}
