@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* ==========================================================================
   1. DESIGN TOKENS & CSS VARIABLES
   ========================================================================== */
:root {
    /* Brand Color Palette (Chifa Roma) */
    --cr-primary: #a92022;
    --cr-primary-hover: #8e181a;
    --cr-primary-active: #731214;
    --cr-primary-light: #fef2f2;
    --cr-primary-glow: rgba(169, 32, 34, 0.14);

    /* Rich Wine / Burgundy Palette */
    --cr-wine-darkest: #100203;
    --cr-wine-darker: #1e0407;
    --cr-wine-dark: #38070b;
    --cr-wine-base: #560c12;
    --cr-wine-accent: #78131a;

    /* Gold / Warm Accents */
    --cr-gold: #d4af37;
    --cr-gold-light: #fdf5d7;
    --cr-gold-glow: rgba(212, 175, 55, 0.3);

    /* Neutral Typography & Surfaces */
    --cr-text-title: #0f172a;
    --cr-text-body: #334155;
    --cr-text-muted: #64748b;
    --cr-text-subtle: #94a3b8;

    --cr-surface-card: #ffffff;
    --cr-surface-input: #f8fafc;
    --cr-surface-input-focus: #ffffff;

    /* Borders */
    --cr-border-subtle: #e2e8f0;
    --cr-border-input: #cbd5e1;
    --cr-border-focus: #a92022;

    /* Radii */
    --cr-radius-card: 16px;
    --cr-radius-control: 10px;
    --cr-radius-pill: 9999px;

    /* Clean Subtle Elevation */
    --cr-shadow-card:
        0 20px 45px -10px rgba(0, 0, 0, 0.65),
        0 8px 18px -4px rgba(0, 0, 0, 0.4);

    --cr-shadow-btn:
        0 1px 2px rgba(0, 0, 0, 0.05);

    --cr-shadow-btn-hover:
        0 2px 6px rgba(200, 30, 37, 0.22);

    /* Transitions */
    --cr-transition-fast: 0.16s cubic-bezier(0.4, 0, 0.2, 1);
    --cr-transition-smooth: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   2. PAGE BASE & VIEWPORT
   ========================================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body.login-body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body.login-body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: radial-gradient(ellipse at 50% 32%, #260508 0%, #130204 65%, #080102 100%);
    background-attachment: fixed;
    color: var(--cr-text-body);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    overflow-x: hidden;
}

/* Viewport Centering Container */
.login-viewport {
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1rem, 2.5vw, 2rem);
    width: 100%;
}

/* Minimal Footer */
.login-footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 0.85rem 1.25rem;
    font-size: 0.76rem;
    color: rgba(255, 255, 255, 0.42);
    letter-spacing: 0.015em;

    strong {
        color: rgba(255, 255, 255, 0.75);
        font-weight: 600;
    }
}

/* ==========================================================================
   3. PROPORTIONED SPLIT CARD CONTAINER (No excessive bloat)
   ========================================================================== */
.login-card {
    display: grid;
    grid-template-columns: 42% 58%;
    width: 100%;
    max-width: 720px;
    min-height: auto;
    background: transparent;
    border-radius: var(--cr-radius-card);
    box-shadow: var(--cr-shadow-card);
    border: none;
    overflow: hidden;
    position: relative;
    isolation: isolate;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
    animation: cardAppear 0.35s var(--cr-transition-smooth);
}

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ==========================================================================
   4. LEFT PANEL: CLEAN BRAND HERO
   ========================================================================== */
.login-brand-panel {
    position: relative;
    background: linear-gradient(150deg, #580c11 0%, #300407 55%, #160103 100%);
    padding: 2.25rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    color: #ffffff;
    border-top-left-radius: var(--cr-radius-card);
    border-bottom-left-radius: var(--cr-radius-card);
}

/* Brand Header */
.brand-header {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-logo-frame {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #000000;
    border: 1.5px solid var(--cr-gold);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3), 0 0 0 2px rgba(212, 175, 55, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;

    img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}

.brand-name {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #ffffff;
}

/* Brand Greeting (Clean & Uncluttered) */
.brand-body {
    position: relative;
    z-index: 2;
    margin: auto 0;
}

.brand-headline {
    font-size: clamp(1.6rem, 2.3vw, 1.95rem);
    font-weight: 800;
    line-height: 1.18;
    letter-spacing: -0.025em;
    margin: 0;
    color: #ffffff;

    strong {
        color: #ffffff;
        background: linear-gradient(120deg, #ffffff 40%, var(--cr-gold-light) 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
    }
}

/* Brand Footer */
.brand-footer {
    position: relative;
    z-index: 2;
}

/* ==========================================================================
   5. RIGHT PANEL: REFINED FORM
   ========================================================================== */
.login-form-panel {
    position: relative;
    background: #ffffff;
    padding: 2.25rem 2.25rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-top-right-radius: var(--cr-radius-card);
    border-bottom-right-radius: var(--cr-radius-card);
}

/* Form Header */
.form-header {
    margin-bottom: 1.5rem;
}

.form-title {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--cr-text-title);
    letter-spacing: -0.025em;
    margin: 0 0 0.3rem 0;
}

.form-subtitle {
    font-size: 0.85rem;
    color: var(--cr-text-muted);
    margin: 0;
    line-height: 1.4;
}

/* Form Groups */
.form-group-modern {
    margin-bottom: 1.15rem;
    position: relative;
}

.label-row-modern {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}

.form-label-modern {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--cr-text-body);
    letter-spacing: 0.01em;
    margin-bottom: 0.4rem;
}

.label-row-modern .form-label-modern {
    margin-bottom: 0;
}

.link-forgot-modern {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--cr-text-muted);
    text-decoration: none;
    transition: var(--cr-transition-fast);

    &:hover,
    &:focus {
        color: var(--cr-primary);
        text-decoration: underline;
    }
}

/* Modern Input Group with :focus-within */
.input-wrapper-modern {
    display: flex;
    align-items: center;
    background: var(--cr-surface-input);
    border: 1.5px solid var(--cr-border-subtle);
    border-radius: var(--cr-radius-control);
    padding: 0 0.8rem;
    height: 46px;
    transition: var(--cr-transition-fast);

    &:hover {
        border-color: var(--cr-border-input);
        background: #ffffff;
    }

    &:focus-within {
        background: #ffffff;
        border-color: var(--cr-border-focus);
        box-shadow: 0 0 0 3.5px var(--cr-primary-glow);
    }
}

.input-icon-modern {
    font-size: 0.9rem;
    color: var(--cr-text-subtle);
    margin-right: 0.65rem;
    flex-shrink: 0;
    transition: color var(--cr-transition-fast);
}

.input-wrapper-modern:focus-within .input-icon-modern {
    color: var(--cr-primary);
}

.input-modern {
    flex: 1;
    height: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--cr-text-title);
    min-width: 0;

    &::placeholder {
        color: var(--cr-text-subtle);
        font-weight: 400;
    }
}

/* Toggle Password Button */
.btn-toggle-modern {
    background: transparent;
    border: none;
    outline: none;
    color: var(--cr-text-subtle);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.4rem;
    transition: var(--cr-transition-fast);

    &:hover {
        color: var(--cr-text-body);
        background: rgba(0, 0, 0, 0.05);
    }
}

/* Submit Action Button - Formal, Moderno y Distinguido */
.btn-submit-modern {
    width: 100%;
    height: 44px;
    background: #0f172a;
    color: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.9);
    border-radius: var(--cr-radius-control);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    margin-top: 0.65rem;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.08),
        0 2px 4px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
    user-select: none;

    i {
        font-size: 0.82rem;
        color: rgba(255, 255, 255, 0.85);
        transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    }

    &:hover {
        background: #1e293b;
        border-color: #1e293b;
        box-shadow:
            0 4px 12px rgba(15, 23, 42, 0.16),
            inset 0 1px 0 rgba(255, 255, 255, 0.15);
        transform: translateY(-1px);

        i {
            transform: translateX(3px);
            color: #ffffff;
        }
    }

    &:active {
        background: #090d16;
        transform: scale(0.985);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    }

    &:focus-visible {
        outline: none;
        box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.2);
    }

    /* Estado de Carga / Deshabilitado - Sin gris deslavado, mantiene presencia formal */
    &:disabled,
    &.disabled,
    &.is-loading {
        background: #0f172a !important;
        border-color: #0f172a !important;
        color: #ffffff !important;
        opacity: 0.92 !important;
        cursor: wait !important;
        pointer-events: none !important;
        transform: none !important;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06) !important;

        i {
            transform: none !important;
            color: #ffffff !important;
        }
    }

    .fa-spin {
        font-size: 0.88rem;
        animation: fa-spin 0.85s infinite linear;
    }
}

/* Supresión de cualquier layer-process en el login */
.login-form-panel .layer-process {
    display: none !important;
}

/* Security Footnote */
.form-footer-note {
    margin-top: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-size: 0.74rem;
    color: var(--cr-text-muted);

    i {
        color: #22c55e;
        font-size: 0.8rem;
    }
}

/* Validation Feedback */
.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.3rem;
    font-size: 0.76rem;
    color: #dc2626;
    font-weight: 500;
}

.was-validated .input-wrapper-modern:has(:invalid),
.input-wrapper-modern.is-invalid {
    border-color: #ef4444;
    background: #fff5f5;
}

.was-validated .input-wrapper-modern:has(:invalid) ~ .invalid-feedback,
.input-wrapper-modern.is-invalid ~ .invalid-feedback {
    display: block;
}

/* ==========================================================================
   6. RESPONSIVE BREAKPOINTS (Optimized for TABLETS & MOBILE)
   ========================================================================== */

/* TABLET LANDSCAPE (992px - 1199px) */
@media (max-width: 1199px) and (min-width: 992px) {
    .login-card {
        max-width: 640px;
    }

    .login-brand-panel {
        padding: 1.75rem 1.5rem;
    }

    .brand-headline {
        font-size: 1.45rem;
    }

    .login-form-panel {
        padding: 1.75rem 1.65rem;
    }

    .form-title {
        font-size: 1.45rem;
    }
}

/* TABLET PORTRAIT (768px - 991px) — Harmonious balanced card */
@media (max-width: 991px) and (min-width: 768px) {
    .login-viewport {
        padding: 1.5rem;
    }

    .login-card {
        grid-template-columns: 38% 62%;
        max-width: 540px;
        border-radius: 16px;
    }

    .login-brand-panel {
        padding: 1.5rem 1.25rem;
        border-top-left-radius: 16px;
        border-bottom-left-radius: 16px;
    }

    .brand-body {
        margin: 1rem 0;
    }

    .brand-headline {
        font-size: 1.3rem;
    }

    .brand-logo-frame {
        width: 36px;
        height: 36px;
    }

    .brand-name {
        font-size: 1rem;
    }

    .login-form-panel {
        padding: 1.65rem 1.5rem;
        border-top-right-radius: 16px;
        border-bottom-right-radius: 16px;
    }

    .form-title {
        font-size: 1.35rem;
    }

    .form-header {
        margin-bottom: 1.1rem;
    }

    .input-wrapper-modern {
        height: 46px;
    }

    .btn-submit-modern {
        height: 44px;
    }
}

/* MOBILE SCREENS (< 768px) — Clean stacked card */
@media (max-width: 767px) {
    .login-viewport {
        padding: 1rem;
        align-items: center;
    }

    .login-card {
        grid-template-columns: 1fr;
        max-width: 400px;
        border-radius: 16px;
    }

    .login-brand-panel {
        padding: 1.5rem 1.25rem 1.25rem;
        text-align: center;
        align-items: center;
        border-radius: 16px 16px 0 0;
    }

    .brand-header {
        margin-bottom: 0.35rem;
    }

    .brand-body {
        margin: 0.5rem 0 0.5rem;
    }

    .brand-headline {
        font-size: 1.4rem;
    }

    .brand-footer {
        display: none;
    }

    .login-form-panel {
        padding: 1.5rem 1.35rem 1.65rem;
        border-radius: 0 0 16px 16px;
    }

    .form-header {
        margin-bottom: 1.15rem;
        text-align: center;
    }

    .form-title {
        font-size: 1.35rem;
    }

    .form-subtitle {
        font-size: 0.8rem;
    }

    .input-wrapper-modern {
        height: 48px;
    }

    .btn-submit-modern {
        height: 46px;
        font-size: 0.9rem;
    }

    .form-footer-note {
        margin-top: 1.1rem;
        font-size: 0.7rem;
    }
}

/* Extra small mobile (< 380px) */
@media (max-width: 380px) {
    .login-viewport {
        padding: 0.75rem;
    }

    .login-form-panel {
        padding: 1.15rem 1rem 1.35rem;
    }

    .brand-headline {
        font-size: 1.25rem;
    }
}

/* Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .login-card {
        animation: none;
    }

    .btn-submit-modern,
    .btn-submit-modern i,
    .input-wrapper-modern {
        transition: none;
    }
}

/* ==========================================================================
   7. SWEETALERT2 MODERN DESIGN SYSTEM (Hierarchical, Subtle & Crisp)
   ========================================================================== */
.swal2-container.swal2-backdrop-show {
    background: rgba(16, 2, 3, 0.6) !important;
    backdrop-filter: blur(5px) !important;
    -webkit-backdrop-filter: blur(5px) !important;
}

.swal2-popup:not(.swal2-toast) {
    width: 380px !important;
    max-width: calc(100vw - 32px) !important;
    background: #ffffff !important;
    border-radius: 18px !important;
    border: 1px solid rgba(226, 232, 240, 0.85) !important;
    box-shadow:
        0 24px 48px -12px rgba(16, 2, 3, 0.3),
        0 8px 20px -6px rgba(0, 0, 0, 0.12) !important;
    padding: 1.75rem 1.5rem 1.5rem !important;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    box-sizing: border-box !important;
}

/* Refined Icon Badges (Scale down from harsh 80px to elegant 54px) */
.swal2-popup:not(.swal2-toast) .swal2-icon {
    width: 54px !important;
    height: 54px !important;
    margin: 0 auto 1.1rem !important;
    border-radius: 50% !important;
    border-width: 2px !important;
    box-sizing: border-box !important;
    position: relative !important;
}

/* Error Type (Primary Brand Palette) */
.swal2-popup:not(.swal2-toast) .swal2-icon.swal2-error {
    background: #fef2f2 !important;
    border-color: #fecaca !important;
    color: #a92022 !important;
}

.swal2-popup:not(.swal2-toast) .swal2-icon.swal2-error .swal2-x-mark {
    position: relative !important;
    flex-grow: 1 !important;
}

.swal2-popup:not(.swal2-toast) .swal2-icon.swal2-error [class^='swal2-x-mark-line'] {
    background-color: #a92022 !important;
    height: 2.5px !important;
    width: 1.6em !important;
    top: 1.6em !important;
    border-radius: 2px !important;
}

.swal2-popup:not(.swal2-toast) .swal2-icon.swal2-error [class^='swal2-x-mark-line'][class$='left'] {
    left: 0.9em !important;
}

.swal2-popup:not(.swal2-toast) .swal2-icon.swal2-error [class^='swal2-x-mark-line'][class$='right'] {
    right: 0.85em !important;
}

/* Warning Type (Warm Amber/Gold) */
.swal2-popup:not(.swal2-toast) .swal2-icon.swal2-warning {
    background: #fffbeb !important;
    border-color: #fde68a !important;
    color: #d97706 !important;
    font-size: 1.9rem !important;
    line-height: 50px !important;
}

/* Info Type (Subtle Sky Blue) */
.swal2-popup:not(.swal2-toast) .swal2-icon.swal2-info {
    background: #f0f9ff !important;
    border-color: #bae6fd !important;
    color: #0284c7 !important;
    font-size: 1.9rem !important;
    line-height: 50px !important;
}

/* Success Type (Subtle Emerald) */
.swal2-popup:not(.swal2-toast) .swal2-icon.swal2-success {
    background: #f0fdf4 !important;
    border-color: #bbf7d0 !important;
    color: #16a34a !important;
}

.swal2-popup:not(.swal2-toast) .swal2-icon.swal2-success .swal2-success-ring {
    border: 2px solid rgba(22, 163, 74, 0.2) !important;
    width: 50px !important;
    height: 50px !important;
}

.swal2-popup:not(.swal2-toast) .swal2-icon.swal2-success [class^='swal2-success-line'] {
    background-color: #16a34a !important;
    height: 2.5px !important;
}

.swal2-popup:not(.swal2-toast) .swal2-icon.swal2-success [class^='swal2-success-line'][class$='tip'] {
    top: 1.75em !important;
    left: 0.7em !important;
    width: 1.1em !important;
}

.swal2-popup:not(.swal2-toast) .swal2-icon.swal2-success [class^='swal2-success-line'][class$='long'] {
    top: 1.45em !important;
    right: 0.6em !important;
    width: 1.8em !important;
}

.swal2-popup:not(.swal2-toast) .swal2-icon.swal2-success [class^='swal2-success-circular-line'],
.swal2-popup:not(.swal2-toast) .swal2-icon.swal2-success .swal2-success-fix {
    background: transparent !important;
}

/* Typography Hierarchy */
.swal2-popup:not(.swal2-toast) .swal2-title {
    font-size: 1.22rem !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    letter-spacing: -0.02em !important;
    margin: 0 0 0.45rem 0 !important;
    padding: 0 !important;
    line-height: 1.3 !important;
}

.swal2-popup:not(.swal2-toast) .swal2-html-container,
.swal2-popup:not(.swal2-toast) .swal2-content {
    font-size: 0.88rem !important;
    color: #475569 !important;
    line-height: 1.5 !important;
    margin: 0 0 1.35rem 0 !important;
    padding: 0 !important;
}

/* Action Buttons */
.swal2-popup:not(.swal2-toast) .swal2-actions {
    width: 100% !important;
    margin: 0 !important;
    display: flex !important;
    gap: 0.5rem !important;
}

.swal2-popup:not(.swal2-toast) .swal2-styled.swal2-confirm {
    flex: 1 1 auto;
    width: 100% !important;
    height: 42px !important;
    border-radius: 10px !important;
    background: #0f172a !important;
    background-color: #0f172a !important;
    border: 1px solid rgba(15, 23, 42, 0.9) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08) !important;
    color: #ffffff !important;
    font-size: 0.88rem !important;
    font-weight: 600 !important;
    letter-spacing: -0.01em !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.18s ease !important;
}

.swal2-popup:not(.swal2-toast) .swal2-styled.swal2-confirm:hover {
    background: #1e293b !important;
    border-color: #1e293b !important;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.16) !important;
    transform: translateY(-1px) !important;
}

.swal2-popup:not(.swal2-toast) .swal2-styled.swal2-confirm:active {
    background: #090d16 !important;
    transform: scale(0.985) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06) !important;
}

.swal2-popup:not(.swal2-toast) .swal2-styled.swal2-cancel {
    flex: 1 1 auto;
    width: 100% !important;
    height: 42px !important;
    border-radius: 10px !important;
    background: #f1f5f9 !important;
    border: 1px solid #cbd5e1 !important;
    color: #475569 !important;
    font-size: 0.88rem !important;
    font-weight: 600 !important;
    box-shadow: none !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.16s ease !important;
}

.swal2-popup:not(.swal2-toast) .swal2-styled.swal2-cancel:hover {
    background: #e2e8f0 !important;
    color: #1e293b !important;
}

/* Respetar categóricamente display: none asignado por SweetAlert2 */
.swal2-popup:not(.swal2-toast) .swal2-actions button[style*="display: none"],
.swal2-popup:not(.swal2-toast) .swal2-styled[style*="display: none"],
.swal2-popup:not(.swal2-toast) .swal2-cancel[style*="display: none"],
.swal2-popup:not(.swal2-toast) .swal2-confirm[style*="display: none"] {
    display: none !important;
}

