/* Login moderno — Permisos y Vacaciones
   Adaptativo a cualquier resolución sin scroll de página */

:root {
    --login-primary: #1a2d5a;
    --login-primary-dark: #142347;
    --login-primary-light: #2a4478;
    --login-primary-focus: rgba(26, 45, 90, 0.12);
    --login-primary-shadow: rgba(26, 45, 90, 0.28);
    --login-btn: #1a2d5a;
    --login-btn-hover: #142347;
    --login-card-bg: #ffffff;
    --login-panel-bg: #eef0f4;
    --login-input-bg: #f3f4f6;
    --login-text-muted: #8b95a5;
    --login-gap: clamp(8px, 1.5vh, 16px);
    --login-pad: clamp(12px, 2.5vw, 32px);
    --login-card-pad: clamp(16px, 2.8vh + 0.5vw, 32px);
    --login-title: clamp(1.1rem, 1.8vh + 0.4vw, 1.4rem);
    --login-brand-title: clamp(1.65rem, 3.2vh + 0.85vw, 2.75rem);
    --login-input-pad: clamp(10px, 1.4vh, 14px) clamp(12px, 1.5vw, 16px);
    --login-btn-pad: clamp(11px, 1.6vh, 14px) clamp(16px, 2vw, 20px) clamp(11px, 1.6vh, 14px) clamp(36px, 4vw, 44px);
}

*, *::before, *::after { box-sizing: border-box; }

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

body.login-page {
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    font-size: clamp(13px, 1.6vh + 0.2vw, 15px);
    line-height: 1.45;
    color: #1e293b;
    background: var(--login-panel-bg);
    -webkit-font-smoothing: antialiased;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
}

a { color: var(--login-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.login-shell {
    display: flex;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
}

/* —— Panel institucional —— */
.login-brand {
    flex: 1 1 48%;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: clamp(24px, 4vh, 48px) clamp(24px, 4vw, 56px);
    padding-bottom: clamp(48px, 8vh, 72px);
    background: linear-gradient(155deg, #1a1240 0%, #251d55 45%, #32266b 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.login-brand::before {
    content: "";
    position: absolute;
    top: -18%;
    right: -12%;
    width: min(360px, 55%);
    height: min(360px, 55%);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    pointer-events: none;
}

.login-brand::after {
    content: "";
    position: absolute;
    bottom: -12%;
    left: -10%;
    width: min(280px, 48%);
    height: min(280px, 48%);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    pointer-events: none;
}

.login-brand__main {
    position: relative;
    z-index: 1;
    flex: 0 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    max-width: 520px;
    min-height: 0;
    overflow: hidden;
    margin: 0 auto;
}

.login-brand__content {
    position: relative;
    z-index: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
}

.login-brand__logos {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin: 0 0 clamp(40px, 6.5vh, 72px);
    max-width: 100%;
    width: 100%;
}

.login-brand__logos img.logo-sistema {
    max-width: min(200px, 100%);
    filter: none;
    mix-blend-mode: normal;
    opacity: 1;
}

.login-brand__title {
    font-size: var(--login-brand-title);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 clamp(12px, 1.8vh, 20px);
    line-height: 1.2;
    text-align: center;
    width: 100%;
}

.login-brand__subtitle {
    font-size: clamp(1.05rem, 1.9vh + 0.3vw, 1.3rem);
    opacity: 0.9;
    margin: 0 auto clamp(22px, 3.5vh, 42px);
    max-width: 440px;
    text-align: center;
    line-height: 1.45;
    width: 100%;
}

.login-brand__features {
    list-style: none;
    margin: 0 auto;
    padding: 0;
    text-align: center;
    max-width: 440px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-brand__features li {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: clamp(12px, 1.8vh, 20px);
    font-size: clamp(0.98rem, 1.6vh + 0.2vw, 1.15rem);
    opacity: 0.94;
    line-height: 1.4;
    text-align: center;
}

.login-brand__features li::before {
    content: "";
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    margin-top: 0;
    border-radius: 50%;
    background: #c4b5fd;
    box-shadow: 0 0 0 3px rgba(196, 181, 253, 0.25);
}

.login-brand__footer {
    position: absolute;
    z-index: 1;
    left: 0;
    right: 0;
    bottom: clamp(16px, 3vh, 32px);
    font-size: clamp(0.8rem, 1.3vh, 0.95rem);
    opacity: 0.7;
    margin: 0;
    flex-shrink: 0;
    text-align: center;
    padding: 0 clamp(16px, 3vw, 24px);
}

/* —— Panel formulario —— */
.login-main {
    flex: 1 1 52%;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(12px, 3vh, 32px) clamp(12px, 3vw, 28px);
    background: var(--login-panel-bg);
    overflow: hidden;
}

.login-card-wrap {
    width: 100%;
    max-width: min(420px, 100%);
    flex-shrink: 1;
    min-height: 0;
}

.login-card-wrap #container_demo {
    text-align: left;
    margin: 0;
    padding: 0;
}

a.hiddenanchor { display: none; }

#wrapper {
    position: relative;
    width: 100%;
    margin: 0;
}

#login, #forget, #otp {
    position: relative;
    width: 100%;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
}

.login-card form {
    position: relative;
    padding: var(--login-card-pad);
    background: var(--login-card-bg);
    border-radius: clamp(12px, 2vw, 16px);
    box-shadow:
        0 18px 40px rgba(15, 23, 42, 0.08),
        0 4px 12px rgba(15, 23, 42, 0.04);
    overflow: hidden;
}

.login-card__accent {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    z-index: 2;
    background-color: #ed1c24;
    /* La rotación de colores se controla en class/login.class.php */
}

#forget, #otp { z-index: 20; opacity: 0; pointer-events: none; display: none; }
#login { z-index: 22; opacity: 1; pointer-events: auto; display: block; }

#toforget:target ~ #wrapper #forget,
#tologin:target ~ #wrapper #login {
    z-index: 22;
    opacity: 1;
    pointer-events: auto;
    display: block;
    animation: loginScaleIn 0.35s ease-out forwards;
}

#toforget:target ~ #wrapper #login,
#tologin:target ~ #wrapper #forget {
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    display: none;
    animation: loginScaleOut 0.25s ease-in forwards;
}

.login-form-static {
    position: relative !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    display: block !important;
}

@keyframes loginScaleIn {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes loginScaleOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.96); }
}

.login-form-header {
    display: flex;
    align-items: flex-start;
    gap: clamp(10px, 1.5vw, 14px);
    margin-bottom: clamp(14px, 2.4vh, 24px);
    position: relative;
    padding-right: 18px;
}

.login-form-header__icon {
    flex-shrink: 0;
    width: clamp(36px, 5vh, 44px);
    height: clamp(36px, 5vh, 44px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--login-primary);
    color: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(26, 45, 90, 0.25);
}

.login-form-header__icon svg {
    width: clamp(18px, 2.4vh, 22px);
    height: clamp(18px, 2.4vh, 22px);
}

.login-form-header__text {
    flex: 1;
    min-width: 0;
}

.login-form-header__status {
    position: absolute;
    top: 4px;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

.login-form-header h1 {
    font-size: var(--login-title);
    font-weight: 700;
    color: var(--login-primary);
    margin: 0 0 4px;
    letter-spacing: -0.02em;
    background: none;
    -webkit-text-fill-color: unset;
    padding: 0;
    text-align: left;
}

.login-form-header h1::after { display: none; }

.login-form-header p {
    margin: 0;
    font-size: clamp(0.78rem, 1.2vh + 0.15vw, 0.875rem);
    color: var(--login-text-muted);
}

.login-form-header h2 {
    font-size: clamp(0.78rem, 1.2vh + 0.15vw, 0.875rem);
    font-weight: 400;
    color: var(--login-text-muted);
    margin: 4px 0 0;
    line-height: 1.45;
}

#wrapper .field {
    margin-bottom: clamp(10px, 1.8vh, 16px);
}

#wrapper label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: clamp(0.75rem, 1.1vh + 0.1vw, 0.8125rem);
    font-weight: 600;
    color: #64748b;
    margin-bottom: clamp(5px, 0.9vh, 8px);
    letter-spacing: 0;
    position: static;
}

.login-field-icon {
    flex-shrink: 0;
    color: #94a3b8;
}

#wrapper label[data-icon]::after { display: none; }

#wrapper input:not([type="checkbox"]) {
    width: 100%;
    margin: 0;
    padding: var(--login-input-pad);
    font-size: clamp(0.85rem, 1.3vh + 0.15vw, 0.9375rem);
    font-family: inherit;
    color: #1e293b;
    background: var(--login-input-bg);
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    -webkit-appearance: none;
    box-sizing: border-box;
    box-shadow: none;
}

#wrapper input:not([type="checkbox"]):focus {
    border-color: #cbd5e1;
    box-shadow: 0 0 0 3px var(--login-primary-focus);
    background: #fff;
}

#wrapper input:not([type="checkbox"])::placeholder {
    color: #b0b8c4;
    font-style: normal;
}

#codigo_2fa {
    display: none;
}

.login-otp-field {
    margin-bottom: 8px;
}

.login-otp-boxes {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(4px, 1.2vw, 10px);
    margin-top: 4px;
}

.login-otp-digit {
    width: clamp(36px, 8vw, 48px) !important;
    height: clamp(42px, 7vh, 56px) !important;
    padding: 0 !important;
    margin: 0 !important;
    text-align: center !important;
    font-size: clamp(1.1rem, 2.5vh, 1.5rem) !important;
    font-weight: 700 !important;
    letter-spacing: 0 !important;
    color: #32266b !important;
    background: #f8fafc !important;
    border: 2px solid #cbd5e1 !important;
    border-radius: 10px !important;
    box-shadow: none !important;
    caret-color: var(--login-primary);
}

.login-otp-digit:focus {
    border-color: var(--login-primary) !important;
    background: #fff !important;
    box-shadow: 0 0 0 3px var(--login-primary-focus) !important;
}

.login-otp-digit.is-error {
    border-color: #ef4444 !important;
    background: #fef2f2 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12) !important;
}

.login-otp-extra {
    margin: 12px 0 0;
    text-align: center;
    font-size: 0.8125rem;
}

.login-otp-extra a {
    font-weight: 600;
}

#wrapper p.button,
#wrapper p.login.button,
#wrapper p.signin.button {
    text-align: stretch;
    margin: clamp(12px, 2vh, 20px) 0 0;
}

#wrapper p.button input[type="button"],
#wrapper p.login.button input[type="button"],
#wrapper p.signin.button input[type="button"] {
    width: 100%;
    padding: var(--login-btn-pad);
    font-size: clamp(0.85rem, 1.3vh + 0.15vw, 0.9375rem);
    font-weight: 600;
    font-family: inherit;
    letter-spacing: 0.01em;
    color: #fff;
    background: var(--login-btn);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(26, 45, 90, 0.35);
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
    text-shadow: none;
    margin: 0;
    position: relative;
    opacity: 1;
}

#wrapper p.button input[type="button"]::before,
#wrapper p.login.button input[type="button"]::before,
#wrapper p.signin.button input[type="button"]::before {
    content: "";
    position: absolute;
    left: clamp(14px, 2vw, 18px);
    top: 50%;
    width: 18px;
    height: 18px;
    margin-top: -9px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 3h4a2 2 0 012 2v14a2 2 0 01-2 2h-4'/%3E%3Cpolyline points='10 17 15 12 10 7'/%3E%3Cline x1='15' y1='12' x2='3' y2='12'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 18px 18px;
    opacity: 0.95;
}

#wrapper p.button input[type="button"]:hover {
    background: var(--login-btn-hover);
    box-shadow: 0 6px 18px rgba(26, 45, 90, 0.45);
}

#wrapper p.button input[type="button"]:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(26, 45, 90, 0.3);
}

#mensaje, #mensaje1, #mensaje2, #mensaje3 {
    min-height: 0;
    margin-top: clamp(8px, 1.4vh, 12px) !important;
    padding: 8px 12px;
    font-size: clamp(0.75rem, 1.1vh, 0.8125rem);
    font-weight: 500;
    line-height: 1.35;
    border-radius: 8px;
    color: #b91c1c !important;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

#mensaje.is-ok, #mensaje1.is-ok, #mensaje2.is-ok, #mensaje3.is-ok {
    color: var(--login-primary) !important;
    background: #eef3fb;
    border-color: #c7d5ee;
}

#mensaje:empty, #mensaje1:empty, #mensaje2:empty, #mensaje3:empty {
    display: none;
    padding: 0;
    border: none;
    background: transparent;
    min-height: 0;
    margin-top: 0 !important;
}

p.change_link {
    position: static;
    width: auto;
    height: auto;
    padding: clamp(10px, 1.6vh, 16px) 0 0;
    margin: 0;
    font-size: clamp(0.75rem, 1.1vh, 0.8125rem);
    color: var(--login-text-muted);
    text-align: center;
    border-top: none;
    margin-top: 0;
    background: none;
    border-radius: 0;
}

#wrapper p.change_link a {
    display: inline;
    font-weight: 500;
    background: none;
    padding: 0;
    margin: 0;
    color: #94a3b8;
    border: none;
    text-decoration: none;
}

#wrapper p.change_link a:hover {
    text-decoration: underline;
    color: #64748b;
    background: none;
    border: none;
}

.login-turnstile {
    margin: 0 0 2px;
    min-height: 0;
    display: flex;
    justify-content: center;
    transform: scale(clamp(0.78, 0.55 + 0.5vh, 0.92));
    transform-origin: center top;
}

.login-turnstile .cf-turnstile {
    display: flex;
    justify-content: center;
}

/* ========== Desktop estrecho / tablet landscape ========== */
@media (max-width: 1100px) and (min-width: 961px) {
    .login-brand {
        flex: 1 1 42%;
        padding: clamp(20px, 3vh, 36px) clamp(20px, 3vw, 36px);
    }

    .login-brand__features li:nth-child(n+3) {
        display: none;
    }
}

/* ========== Móvil / tablet portrait: apilar ========== */
@media (max-width: 960px) {
    .login-shell {
        flex-direction: column;
    }

    .login-brand {
        flex: 0 0 auto;
        max-height: min(32vh, 240px);
        padding: 0;
        text-align: center;
        justify-content: center;
        overflow: hidden;
    }

    .login-brand::before,
    .login-brand::after {
        display: none;
    }

    .login-brand__main {
        flex: none;
        justify-content: center;
        align-items: center;
        padding: clamp(8px, 1.5vh, 16px) clamp(12px, 3vw, 20px) clamp(6px, 1vh, 12px);
        max-width: 100%;
    }

    .login-brand__logos {
        width: 100%;
        margin: 0 0 clamp(16px, 2.5vh, 28px);
        padding: 0;
        align-items: center;
        justify-content: center;
    }

    .login-brand__content {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 0;
    }

    .login-brand__title {
        margin: 0;
        text-align: center;
    }

    .login-brand__subtitle,
    .login-brand__features,
    .login-brand__footer {
        display: none;
    }

    .login-main {
        flex: 1 1 auto;
        padding: clamp(8px, 1.5vh, 16px) clamp(12px, 4vw, 20px) clamp(10px, 2vh, 20px);
        justify-content: center;
        padding-bottom: max(clamp(10px, 2vh, 20px), env(safe-area-inset-bottom, 0px));
    }

    .login-card-wrap {
        max-width: min(400px, 100%);
        width: 100%;
    }

    .login-turnstile {
        transform: scale(0.86);
    }
}

/* ========== Teléfonos ========== */
@media (max-width: 480px) {
    .login-brand {
        max-height: min(22vh, 150px);
    }

    .login-brand__main {
        padding: clamp(6px, 1.2vh, 12px) 12px clamp(4px, 0.8vh, 8px);
    }

    .login-main {
        padding-left: max(12px, env(safe-area-inset-left, 0px));
        padding-right: max(12px, env(safe-area-inset-right, 0px));
    }

    .login-card form {
        border-radius: 14px;
    }

    .login-turnstile {
        transform: scale(0.8);
        margin-bottom: -4px;
    }
}

/* ========== Pantallas bajas (cualquier ancho) ========== */
@media (max-height: 720px) {
    .login-brand__features li:nth-child(n+3) {
        display: none;
    }

    .login-brand__subtitle {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .login-turnstile {
        transform: scale(0.8);
        margin-bottom: -6px;
    }
}

@media (max-height: 600px) {
    .login-brand__features,
    .login-brand__subtitle {
        display: none;
    }

    .login-brand__footer {
        display: none;
    }

    .login-form-header__status {
        display: none;
    }

    .login-turnstile {
        transform: scale(0.72);
        margin-bottom: -10px;
    }
}

/* ========== Móvil + altura baja ========== */
@media (max-width: 960px) and (max-height: 700px) {
    .login-brand {
        max-height: min(18vh, 120px);
    }

    .login-brand__title {
        font-size: clamp(0.95rem, 2.2vh, 1.1rem);
    }
}

@media (max-width: 960px) and (max-height: 560px) {
    .login-brand {
        max-height: min(14vh, 90px);
    }

    .login-brand__title {
        display: none;
    }

    .login-main {
        justify-content: flex-start;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .login-card-wrap {
        margin: auto 0;
    }
}

/* ========== Landscape móvil ========== */
@media (max-height: 480px) and (orientation: landscape) {
    .login-shell {
        flex-direction: row;
    }

    .login-brand {
        flex: 0 0 36%;
        max-height: none;
        height: 100%;
        padding: clamp(12px, 3vh, 20px) clamp(12px, 2vw, 20px);
        text-align: center;
        justify-content: center;
        align-items: center;
    }

    .login-brand__main {
        padding: 0;
        align-items: center;
        justify-content: center;
        text-align: center;
        max-width: 100%;
    }

    .login-brand__logos {
        align-items: center;
        margin-bottom: 20px;
    }

    .login-brand__content {
        align-items: center;
        justify-content: center;
    }

    .login-brand__title {
        display: block;
        font-size: clamp(0.95rem, 3vh, 1.2rem);
        text-align: center;
    }

    .login-brand__subtitle,
    .login-brand__features,
    .login-brand__footer {
        display: none;
    }

    .login-main {
        flex: 1;
        padding: 8px 12px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: center;
    }

    .login-card-wrap {
        max-width: 360px;
    }

    .login-card form {
        padding: 14px 18px 12px;
    }

    .login-form-header {
        margin-bottom: 10px;
    }

    #wrapper .field {
        margin-bottom: 8px;
    }

    .login-turnstile {
        transform: scale(0.7);
        margin-bottom: -8px;
    }
}

/* ========== Pantallas muy anchas ========== */
@media (min-width: 1400px) {
    .login-card-wrap {
        max-width: 440px;
    }

    .login-brand {
        flex: 1 1 46%;
    }
}
