/* =============================================
   Facturro Login — Glassmorphism Card (light + dark)
   Paleta vía variables CSS. Dark se activa por:
     - clase explícita .facturro-dark / .facturro-light en el wrapper (cookie FacturroTheme)
     - fallback @media (prefers-color-scheme: dark) cuando no hay cookie
   Única hoja de estilo custom permitida (excepción de diseño del login).
   ============================================= */

:root {
    --facturro-bg-base: #dce8f3;
    --facturro-bg-grad-top: rgba(186, 220, 255, 0.5);
    --facturro-bg-grad-side: rgba(200, 228, 255, 0.4);
    --facturro-bg-glow: rgba(255, 255, 255, 0.7);
    --facturro-page-gradient: linear-gradient(180deg, #b8d8f8 0%, #d4e6f6 30%, #e8eff8 60%, #dce8f3 100%);
    --facturro-page-bottom-glow-1: rgba(255, 255, 255, 0.6);
    --facturro-page-bottom-glow-2: rgba(255, 255, 255, 0.5);
    --facturro-page-bottom-glow-3: rgba(255, 255, 255, 0.55);
    --facturro-card-bg: rgba(255, 255, 255, 0.72);
    --facturro-card-border: rgba(255, 255, 255, 0.6);
    --facturro-card-shadow: rgba(140, 170, 210, 0.18);
    --facturro-card-shadow-soft: rgba(140, 170, 210, 0.10);
    --facturro-card-shadow-inset: rgba(255, 255, 255, 0.5);
    --facturro-text-title: #1a2d42;
    --facturro-text-footer: #8da3b8;
    --facturro-input-bg: rgba(235, 242, 250, 0.6);
    --facturro-input-border: rgba(170, 195, 220, 0.5);
    --facturro-input-focus-border: rgba(45, 140, 255, 0.6);
    --facturro-input-focus-bg: rgba(245, 249, 255, 0.8);
    --facturro-input-focus-glow: rgba(45, 140, 255, 0.12);
    --facturro-divider: rgba(180, 200, 220, 0.4);
    --facturro-recover-border: rgba(170, 195, 220, 0.4);
    --facturro-logo-shadow: rgba(45, 140, 255, 0.15);
}

/* Override explícito dark (cookie FacturroTheme contiene "dark") */
.facturro-login-page.facturro-dark {
    --facturro-bg-base: #0c1622;
    --facturro-bg-grad-top: rgba(40, 80, 140, 0.4);
    --facturro-bg-grad-side: rgba(50, 90, 160, 0.3);
    --facturro-bg-glow: rgba(80, 120, 180, 0.18);
    --facturro-page-gradient: linear-gradient(180deg, #0a1320 0%, #101c2e 30%, #182438 60%, #0c1622 100%);
    --facturro-page-bottom-glow-1: rgba(60, 100, 160, 0.25);
    --facturro-page-bottom-glow-2: rgba(60, 100, 160, 0.20);
    --facturro-page-bottom-glow-3: rgba(60, 100, 160, 0.22);
    --facturro-card-bg: rgba(24, 32, 46, 0.78);
    --facturro-card-border: rgba(80, 100, 130, 0.4);
    --facturro-card-shadow: rgba(0, 0, 0, 0.55);
    --facturro-card-shadow-soft: rgba(0, 0, 0, 0.25);
    --facturro-card-shadow-inset: rgba(255, 255, 255, 0.04);
    --facturro-text-title: #e0eaf6;
    --facturro-text-footer: #8a99ac;
    --facturro-input-bg: rgba(35, 45, 62, 0.7);
    --facturro-input-border: rgba(90, 110, 140, 0.55);
    --facturro-input-focus-border: rgba(86, 156, 255, 0.7);
    --facturro-input-focus-bg: rgba(40, 55, 78, 0.85);
    --facturro-input-focus-glow: rgba(86, 156, 255, 0.18);
    --facturro-divider: rgba(90, 110, 140, 0.3);
    --facturro-recover-border: rgba(90, 110, 140, 0.4);
    --facturro-logo-shadow: rgba(86, 156, 255, 0.18);
}

/* Fallback prefers-color-scheme: solo cuando no hay elección explícita */
@media (prefers-color-scheme: dark) {
    .facturro-login-page:not(.facturro-light):not(.facturro-dark) {
        --facturro-bg-base: #0c1622;
        --facturro-bg-grad-top: rgba(40, 80, 140, 0.4);
        --facturro-bg-grad-side: rgba(50, 90, 160, 0.3);
        --facturro-bg-glow: rgba(80, 120, 180, 0.18);
        --facturro-page-gradient: linear-gradient(180deg, #0a1320 0%, #101c2e 30%, #182438 60%, #0c1622 100%);
        --facturro-page-bottom-glow-1: rgba(60, 100, 160, 0.25);
        --facturro-page-bottom-glow-2: rgba(60, 100, 160, 0.20);
        --facturro-page-bottom-glow-3: rgba(60, 100, 160, 0.22);
        --facturro-card-bg: rgba(24, 32, 46, 0.78);
        --facturro-card-border: rgba(80, 100, 130, 0.4);
        --facturro-card-shadow: rgba(0, 0, 0, 0.55);
        --facturro-card-shadow-soft: rgba(0, 0, 0, 0.25);
        --facturro-card-shadow-inset: rgba(255, 255, 255, 0.04);
        --facturro-text-title: #e0eaf6;
        --facturro-text-footer: #8a99ac;
        --facturro-input-bg: rgba(35, 45, 62, 0.7);
        --facturro-input-border: rgba(90, 110, 140, 0.55);
        --facturro-input-focus-border: rgba(86, 156, 255, 0.7);
        --facturro-input-focus-bg: rgba(40, 55, 78, 0.85);
        --facturro-input-focus-glow: rgba(86, 156, 255, 0.18);
        --facturro-divider: rgba(90, 110, 140, 0.3);
        --facturro-recover-border: rgba(90, 110, 140, 0.4);
        --facturro-logo-shadow: rgba(86, 156, 255, 0.18);
    }
}

html:has(.facturro-login-page),
html:has(.facturro-login-page) body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--facturro-bg-base);
    overflow-x: hidden;
}

.facturro-login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    background:
        radial-gradient(ellipse 120% 80% at 50% 120%, var(--facturro-bg-glow), transparent 60%),
        radial-gradient(ellipse 100% 60% at 30% 0%, var(--facturro-bg-grad-top), transparent 50%),
        radial-gradient(ellipse 80% 50% at 80% 10%, var(--facturro-bg-grad-side), transparent 50%),
        var(--facturro-page-gradient);
    position: relative;
}

.facturro-login-page::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 35%;
    background:
        radial-gradient(ellipse 50% 100% at 15% 100%, var(--facturro-page-bottom-glow-1), transparent 60%),
        radial-gradient(ellipse 40% 80% at 50% 100%, var(--facturro-page-bottom-glow-2), transparent 55%),
        radial-gradient(ellipse 45% 90% at 80% 100%, var(--facturro-page-bottom-glow-3), transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.facturro-login-page > * {
    position: relative;
    z-index: 1;
}

.facturro-toggle-fixed {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
}

.facturro-login-card {
    width: min(520px, 100%);
    background: var(--facturro-card-bg) !important;
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid var(--facturro-card-border) !important;
    box-shadow:
        0 8px 32px var(--facturro-card-shadow),
        0 1px 3px var(--facturro-card-shadow-soft),
        inset 0 1px 0 var(--facturro-card-shadow-inset);
    border-radius: 20px !important;
    padding: 40px 36px 32px !important;
    overflow: visible;
}

.facturro-login-card > .rz-stack {
    width: 100%;
}

.facturro-logo {
    width: 220px;
    height: auto;
    filter: drop-shadow(0 2px 12px var(--facturro-logo-shadow));
}

.facturro-brand-title {
    color: var(--facturro-text-title) !important;
    text-align: center;
    font-weight: 600 !important;
    letter-spacing: -0.01em;
    margin: 0 !important;
    font-size: 1.1rem !important;
}

.facturro-form-area {
    width: 100%;
    margin-top: 8px;
}

.facturro-form-area .rz-row {
    width: 100%;
}

.facturro-login-card .rz-textbox,
.facturro-login-card .rz-password {
    background: var(--facturro-input-bg) !important;
    border: 1px solid var(--facturro-input-border) !important;
    border-radius: 10px !important;
    padding: 10px 14px !important;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.facturro-login-card .rz-textbox:focus,
.facturro-login-card .rz-password:focus-within {
    border-color: var(--facturro-input-focus-border) !important;
    box-shadow: 0 0 0 3px var(--facturro-input-focus-glow) !important;
    background: var(--facturro-input-focus-bg) !important;
}

.facturro-login-card .rz-button.rz-variant-filled {
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 10px 28px;
}

.facturro-divider {
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--facturro-divider) 50%, transparent 100%);
    margin: 16px 0;
}

.facturro-footer {
    color: var(--facturro-text-footer) !important;
    margin-top: 24px;
    width: 100%;
    font-size: 0.78rem;
}

.facturro-recover-accordion {
    background: transparent !important;
    box-shadow: none !important;
}

.facturro-recover-accordion .rz-accordion-header {
    background: transparent !important;
    border: 1px solid var(--facturro-recover-border);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 0.92rem;
}

.facturro-recover-accordion .rz-accordion-content {
    padding-top: 12px;
}

@media (max-width: 576px) {
    .facturro-login-page {
        padding: 16px;
    }

    .facturro-login-card {
        padding: 32px 24px 24px !important;
        border-radius: 16px !important;
    }

    .facturro-logo {
        width: 140px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}
