﻿/* ═══════════════════════════════════════════════════════════════════
   🏛️ MEW LEGAL PLATFORM - LOGIN PAGE
   ═══════════════════════════════════════════════════════════════════
   Premium Government-Grade Login Experience
   
   📋 Design Tokens:
      • Primary: #1f4e79 (MEW Blue)
      • Accent: #0078d4 (Microsoft Blue)
      • Surface: #ffffff
      • Background: #f4f6f9
   
   🎯 Features:
      • Fully responsive (320px → 4K)
      • RTL-first design
      • Dark mode support
      • Reduced motion support
      • High contrast support
      • Print-friendly
   
   📐 Layout:
      • Desktop: Cover image (left) + Login form (right)
      • Mobile: Login form full-screen with subtle pattern bg
   ═══════════════════════════════════════════════════════════════════ */


/* ═══════════════════════════════════════════════════════════════════
   🎨 DESIGN TOKENS
═══════════════════════════════════════════════════════════════════ */

:root {
    /* Brand Colors */
    --mew-primary: #1f4e79;
    --mew-primary-dark: #163a5b;
    --mew-primary-light: #e6edf5;
    --mew-accent: #0078d4;
    --mew-accent-hover: #106ebe;
    --mew-success: #16a34a;
    --mew-warning: #f59e0b;
    --mew-danger: #dc2626;
    /* Neutrals */
    --mew-text: #111827;
    --mew-text-soft: #374151;
    --mew-text-muted: #6b7280;
    --mew-text-subtle: #9ca3af;
    /* Surfaces */
    --mew-bg: #f4f6f9;
    --mew-surface: #ffffff;
    --mew-surface-elevated: #ffffff;
    /* Borders */
    --mew-border: #e5e7eb;
    --mew-border-soft: #f3f4f6;
    --mew-border-strong: #d1d5db;
    --mew-border-focus: #93c5fd;
    /* Shadows */
    --mew-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --mew-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --mew-shadow-md: 0 4px 6px rgba(15, 23, 42, 0.05), 0 2px 4px rgba(15, 23, 42, 0.04);
    --mew-shadow-lg: 0 10px 15px rgba(15, 23, 42, 0.08), 0 4px 6px rgba(15, 23, 42, 0.05);
    --mew-shadow-xl: 0 20px 25px rgba(15, 23, 42, 0.10), 0 10px 10px rgba(15, 23, 42, 0.04);
    /* Radius */
    --mew-radius-sm: 6px;
    --mew-radius: 10px;
    --mew-radius-lg: 14px;
    --mew-radius-xl: 20px;
    --mew-radius-pill: 999px;
    /* Transitions */
    --mew-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --mew-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

/* ═══════════════════════════════════════════════════════════════════
   🔧 CRITICAL FIX - Add at the TOP of login.css (after :root)
═══════════════════════════════════════════════════════════════════ 
   
   🐛 Issue: .authentication-wrapper was display:none on mobile due 
            to Bootstrap/Frest theme conflicts.
   
   ✅ Fix: Force visibility at all screen sizes with high specificity
   
═══════════════════════════════════════════════════════════════════ */

/* Force wrapper to always show */
.authentication-wrapper,
.authentication-wrapper.authentication-cover {
    display: flex !important;
    width: 100% !important;
    min-height: 100vh !important;
}

    /* Inner row */
    .authentication-wrapper .authentication-inner {
        display: flex !important;
        width: 100% !important;
        min-height: 100vh !important;
        margin: 0 !important;
        flex: 1 !important;
    }

/* RTL flow */
html[dir="rtl"] .authentication-inner {
    flex-direction: row-reverse !important;
}

/* Mobile: stack vertically */
@media (max-width: 991.98px) {

    html[dir="rtl"] .authentication-inner,
    .authentication-inner {
        flex-direction: column !important;
    }

    /* Hide the cover image on mobile */
    .authentication-cover.col-lg-7,
    .authentication-cover.col-xl-8 {
        display: none !important;
    }

    /* Force form panel to be full-width and visible */
    .authentication-bg {
        display: flex !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        min-height: 100vh !important;
    }
}
/* ═══════════════════════════════════════════════════════════════════
   📦 BASE
═══════════════════════════════════════════════════════════════════ */

body.login-page {
    font-family: 'Cairo', 'Tajawal', 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--mew-bg);
    color: var(--mew-text);
    min-height: 100vh;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.authentication-wrapper {
    min-height: 100vh;
    overflow: hidden;
}

.authentication-inner {
    min-height: 100vh;
}


/* ═══════════════════════════════════════════════════════════════════
   🖼️ LEFT SIDE - COVER (Desktop only)
═══════════════════════════════════════════════════════════════════ */

.authentication-cover {
    position: relative;
    background: linear-gradient(135deg, #1b2133 0%, #141a2b 50%, #0f1629 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

    /* Subtle pattern overlay on cover */
    .authentication-cover::before {
        content: "";
        position: absolute;
        inset: 0;
        background-image: radial-gradient(circle at 25% 25%, rgba(31, 78, 121, 0.15) 0%, transparent 50%), radial-gradient(circle at 75% 75%, rgba(0, 120, 212, 0.10) 0%, transparent 50%);
        pointer-events: none;
    }

/* ═══════════════════════════════════════════════════════════════════
   🖼️ COVER IMAGE - الصورة كاملة بدون قطع
═══════════════════════════════════════════════════════════════════ */

.auth-cover-picture {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100vh;
    position: relative;
    z-index: 1;
    overflow: hidden;
    /* Gradient يماثل لون الصورة */
    background: linear-gradient(180deg, #0a1832 0%, /* أزرق غامق فوق */
    #102347 50%, /* أزرق متوسط في النص */
    #0a1832 100% /* أزرق غامق تحت */
    );
}

.auth-cover-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center center;
    display: block;
    transform: translateZ(0);
    transition: opacity 0.4s ease-in;
}

    .auth-cover-img[loading="lazy"] {
        opacity: 0;
    }

    .auth-cover-img.loaded,
    .auth-cover-img:not([loading="lazy"]) {
        opacity: 1;
    }

/* Optional text overlay (kept for backward compat) */
.auth-cover-text-only,
.auth-cover-wrapper {
    text-align: center;
    max-width: 480px;
    padding: 2rem;
    position: relative;
    z-index: 2;
}

    .auth-cover-text-only h3,
    .auth-cover-text h3 {
        color: #ffffff;
        font-weight: 800;
        font-size: 1.75rem;
        margin-bottom: 1rem;
        letter-spacing: -0.02em;
    }

    .auth-cover-text-only p,
    .auth-cover-text p {
        color: rgba(255, 255, 255, 0.85);
        font-size: 1rem;
        line-height: 1.8;
    }


/* ═══════════════════════════════════════════════════════════════════
   📋 RIGHT SIDE - LOGIN PANEL
═══════════════════════════════════════════════════════════════════ */

.authentication-bg {
    background: var(--mew-surface);
    position: relative;
    min-height: 100vh;
}

    /* Decorative accent line at the inner edge (desktop) */
    .authentication-bg::before {
        content: "";
        position: absolute;
        inset-inline-end: 0;
        top: 10%;
        bottom: 10%;
        width: 2px;
        background: linear-gradient(180deg, transparent, var(--mew-primary), transparent);
        opacity: 0.15;
        pointer-events: none;
    }

/* Form container width - responsive */
.w-px-400 {
    width: 100%;
    max-width: 380px;
    margin-inline: auto;
}


/* ═══════════════════════════════════════════════════════════════════
   🇰🇼 BRAND BLOCK
═══════════════════════════════════════════════════════════════════ */

.app-brand {
    margin-bottom: 2rem;
}

.app-brand-link {
    text-decoration: none !important;
    color: inherit !important;
    transition: transform 0.3s var(--mew-ease-out);
}

    .app-brand-link:hover {
        transform: scale(1.02);
    }

.app-brand img,
.app-brand-logo img {
    height: 56px;
    width: auto;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 4px 8px rgba(31, 78, 121, 0.15));
}

.app-brand h4 {
    font-weight: 800;
    font-size: 1.35rem;
    color: var(--mew-primary);
    letter-spacing: -0.02em;
    margin-bottom: 0.35rem;
    line-height: 1.3;
}

.app-brand p {
    font-size: 0.85rem;
    color: var(--mew-text-muted);
    line-height: 1.7;
    margin: 0;
}


/* ═══════════════════════════════════════════════════════════════════
   📝 TITLE & SUBTITLE
═══════════════════════════════════════════════════════════════════ */

.authentication-bg h4 {
    font-weight: 700;
    color: var(--mew-text);
    font-size: 1.2rem;
    margin-bottom: 0.5rem !important;
    letter-spacing: -0.01em;
}

.authentication-bg p.text-muted,
p.text-muted {
    color: var(--mew-text-muted) !important;
    font-size: 0.875rem;
    line-height: 1.6;
}


/* ═══════════════════════════════════════════════════════════════════
   🎚️ SWIPE LOGIN COMPONENT
═══════════════════════════════════════════════════════════════════ */

.swipe-container {
    margin-top: 1.5rem;
    width: 100%;
}

/* Track */
.swipe-button {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-right: 60px;
    height: 56px;
    background: linear-gradient(180deg, #fafbfc 0%, #f1f5f9 100%);
    border-radius: var(--mew-radius-pill);
    border: 1.5px solid var(--mew-border-strong);
    overflow: hidden;
    direction: rtl;
    cursor: pointer;
    transition: all 0.25s var(--mew-ease-out);
    user-select: none;
    box-shadow: var(--mew-shadow-xs);
}

    .swipe-button:hover {
        border-color: var(--mew-primary);
        box-shadow: 0 4px 12px rgba(31, 78, 121, 0.12);
        transform: translateY(-1px);
    }

    .swipe-button.swipe-active {
        background: linear-gradient(180deg, #eef2f7 0%, #dde6f0 100%);
        border-color: var(--mew-primary);
        box-shadow: 0 6px 18px rgba(31, 78, 121, 0.18);
    }

    /* Completion state */
    .swipe-button.is-complete {
        background: linear-gradient(180deg, #dcfce7 0%, #bbf7d0 100%);
        border-color: var(--mew-success);
        box-shadow: 0 6px 18px rgba(22, 163, 74, 0.18);
    }

/* Progress fill */
.swipe-progress {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 0%;
    background: linear-gradient(90deg, var(--mew-primary), var(--mew-accent));
    opacity: 0.18;
    transition: width 0.1s linear;
    pointer-events: none;
    border-radius: var(--mew-radius-pill);
}

/* Handle */
.swipe-handle {
    position: absolute;
    top: 0;
    left: 0;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--mew-surface);
    border: 1.5px solid var(--mew-border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    box-shadow: 0 3px 8px rgba(15, 23, 42, 0.12);
    transition: left 0.12s ease, transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 2;
}

    .swipe-handle:hover {
        box-shadow: 0 6px 16px rgba(31, 78, 121, 0.22);
        transform: scale(1.05);
    }

.swipe-button.swipe-active .swipe-handle {
    cursor: grabbing;
    transform: scale(0.94);
}

/* Subtle pulse animation */
@keyframes login-pulse-handle {
    0%, 100% {
        box-shadow: 0 3px 8px rgba(15, 23, 42, 0.12), 0 0 0 0 rgba(0, 120, 212, 0);
    }

    50% {
        box-shadow: 0 3px 8px rgba(15, 23, 42, 0.12), 0 0 0 8px rgba(0, 120, 212, 0.10);
    }
}

.swipe-button:not(.swipe-active):not(.is-complete) .swipe-handle {
    animation: login-pulse-handle 2.5s ease-in-out infinite;
}

/* Text */
.swipe-text {
    font-weight: 600;
    font-size: 13.5px;
    color: var(--mew-text);
    width: 100%;
    text-align: center;
    padding-left: 56px;
    pointer-events: none;
    transition: opacity 0.2s ease;
    letter-spacing: -0.01em;
}

.swipe-button.swipe-active .swipe-text {
    opacity: 0.55;
}

/* Microsoft icon */
.microsoft-icon {
    color: var(--mew-accent);
    font-size: 26px;
    line-height: 1;
}

/* Focus state for accessibility */
.swipe-handle:focus,
.swipe-handle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(0, 120, 212, 0.25), 0 3px 8px rgba(15, 23, 42, 0.12);
}


/* ═══════════════════════════════════════════════════════════════════
   📋 FORM ELEMENTS (legacy support)
═══════════════════════════════════════════════════════════════════ */

.form-control {
    border-radius: var(--mew-radius);
    border: 1.5px solid var(--mew-border-strong);
    font-size: 0.9rem;
    font-family: inherit;
    padding: 0.625rem 1rem;
    transition: all 0.2s var(--mew-ease-out);
}

    .form-control:focus {
        border-color: var(--mew-accent);
        box-shadow: 0 0 0 4px rgba(0, 120, 212, 0.10);
        outline: none;
    }

.form-label {
    font-weight: 600;
    color: var(--mew-text-soft);
    font-size: 13px;
    margin-bottom: 0.4rem;
}

.form-check-input {
    width: 1.15em;
    height: 1.15em;
    border: 1.5px solid var(--mew-border-strong);
    cursor: pointer;
}

    .form-check-input:checked {
        background-color: var(--mew-primary);
        border-color: var(--mew-primary);
    }

    .form-check-input:focus {
        box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.15);
        border-color: var(--mew-accent);
    }

/* Hint icon below swipe */
.swipe-container + p.text-muted {
    margin-top: 1rem;
    font-size: 0.8rem;
    line-height: 1.6;
}

    .swipe-container + p.text-muted i {
        color: var(--mew-primary);
        margin-inline-end: 4px;
        font-size: 1rem;
        vertical-align: middle;
    }


/* ═══════════════════════════════════════════════════════════════════
   📱 RESPONSIVE - TABLET (≤ 991.98px)
═══════════════════════════════════════════════════════════════════ */

@media (max-width: 991.98px) {

    /* Hide cover image */
    .authentication-cover {
        display: none !important;
    }

    /* Hide accent line */
    .authentication-bg::before {
        display: none;
    }

    /* Make form panel fill screen */
    .authentication-inner {
        min-height: 100vh;
        width: 100%;
        margin: 0;
    }

    .authentication-bg {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        min-height: 100vh;
        background: radial-gradient(ellipse at 20% 0%, rgba(31, 78, 121, 0.06) 0%, transparent 60%), radial-gradient(ellipse at 80% 100%, rgba(0, 120, 212, 0.04) 0%, transparent 60%), #ffffff;
    }

    /* Form container */
    .w-px-400 {
        max-width: 420px;
        width: 100%;
    }

    .app-brand {
        margin-bottom: 1.75rem !important;
    }

        /* Slightly smaller logo on tablets */
        .app-brand img,
        .app-brand-logo img {
            height: 50px;
        }

        .app-brand h4 {
            font-size: 1.25rem;
        }
}


/* ═══════════════════════════════════════════════════════════════════
   📱 RESPONSIVE - MOBILE (≤ 575.98px)
═══════════════════════════════════════════════════════════════════ */

@media (max-width: 575.98px) {

    .authentication-bg {
        padding: 1.5rem 1.25rem !important;
    }

    .w-px-400 {
        max-width: 100%;
    }

    /* Compact brand */
    .app-brand img,
    .app-brand-logo img {
        height: 44px;
    }

    .app-brand h4 {
        font-size: 1.1rem;
    }

    .app-brand p {
        font-size: 0.8rem;
    }

    /* Smaller titles */
    .authentication-bg h4 {
        font-size: 1.05rem;
    }

    .authentication-bg p.text-muted {
        font-size: 0.825rem;
    }

    /* Compact swipe button */
    .swipe-button {
        height: 52px;
        padding-right: 54px;
    }

    .swipe-handle {
        width: 52px;
        height: 52px;
    }

    .swipe-text {
        font-size: 12.5px;
        padding-left: 50px;
    }

    .microsoft-icon {
        font-size: 24px;
    }

    /* Compact hint */
    .swipe-container + p.text-muted {
        font-size: 0.75rem;
    }
}


/* ═══════════════════════════════════════════════════════════════════
   📱 RESPONSIVE - VERY SMALL (≤ 374px)
═══════════════════════════════════════════════════════════════════ */

@media (max-width: 374.98px) {

    .authentication-bg {
        padding: 1rem !important;
    }

    .swipe-text {
        font-size: 11.5px;
    }
}


/* ═══════════════════════════════════════════════════════════════════
   🖥️ RESPONSIVE - LARGE DESKTOP (≥ 1400px)
═══════════════════════════════════════════════════════════════════ */

@media (min-width: 1400px) {

    .w-px-400 {
        max-width: 420px;
    }

    .app-brand img,
    .app-brand-logo img {
        height: 64px;
    }

    .app-brand h4 {
        font-size: 1.5rem;
    }
}


/* ═══════════════════════════════════════════════════════════════════
   🌙 DARK MODE
═══════════════════════════════════════════════════════════════════ */

html[data-theme="dark"] body.login-page,
.dark-style body.login-page {
    background: #0f172a;
    color: #e2e8f0;
}

html[data-theme="dark"] .authentication-bg,
.dark-style .authentication-bg {
    background: #1e293b;
}

html[data-theme="dark"] .app-brand h4,
.dark-style .app-brand h4 {
    color: #7db7e8;
}

html[data-theme="dark"] .app-brand p,
.dark-style .app-brand p {
    color: #94a3b8;
}

html[data-theme="dark"] .authentication-bg h4,
.dark-style .authentication-bg h4 {
    color: #e2e8f0;
}

html[data-theme="dark"] .swipe-button,
.dark-style .swipe-button {
    background: linear-gradient(180deg, #243247 0%, #1e293b 100%);
    border-color: #475569;
}

html[data-theme="dark"] .swipe-text,
.dark-style .swipe-text {
    color: #e2e8f0;
}

html[data-theme="dark"] .swipe-handle,
.dark-style .swipe-handle {
    background: #1e293b;
    border-color: #475569;
}

html[data-theme="dark"] .form-control,
.dark-style .form-control {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

    html[data-theme="dark"] .form-control:focus,
    .dark-style .form-control:focus {
        border-color: #60a5fa;
        box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.15);
    }

html[data-theme="dark"] .form-label,
.dark-style .form-label {
    color: #cbd5e1;
}


/* ═══════════════════════════════════════════════════════════════════
   ♿ ACCESSIBILITY - REDUCED MOTION
═══════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .swipe-button:not(.swipe-active):not(.is-complete) .swipe-handle {
        animation: none;
    }

    .swipe-progress,
    .swipe-handle {
        transition: none;
    }
}


/* ═══════════════════════════════════════════════════════════════════
   ♿ ACCESSIBILITY - HIGH CONTRAST
═══════════════════════════════════════════════════════════════════ */

@media (prefers-contrast: more) {

    .swipe-button {
        border-width: 2.5px;
        border-color: var(--mew-text);
    }

    .swipe-handle {
        border-width: 2.5px;
    }

    .form-control {
        border-width: 2px;
    }
}


/* ═══════════════════════════════════════════════════════════════════
   🖨️ PRINT STYLES
═══════════════════════════════════════════════════════════════════ */

@media print {

    body.login-page {
        background: #fff !important;
        color: #000 !important;
    }

    .authentication-cover {
        display: none !important;
    }

    .authentication-bg::before {
        display: none !important;
    }

    .swipe-button {
        background: #fff !important;
        border: 2px solid #000 !important;
    }
}


/* ═══════════════════════════════════════════════════════════════════
   🔧 LEGACY UTILITY - JS-disabled warning
═══════════════════════════════════════════════════════════════════ */

.no-js-warning {
    display: none;
}

html.no-js .no-js-warning {
    display: block;
    padding: 12px 16px;
    background: var(--mew-warning);
    color: #ffffff;
    border-bottom: 1px solid #d97706;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    position: sticky;
    top: 0;
    z-index: 999;
}


/* ═══════════════════════════════════════════════════════════════════
   🎯 SHIFT FOCUS BEHAVIOR
═══════════════════════════════════════════════════════════════════ */

/* Show focus only when using keyboard, not mouse */
*:focus:not(:focus-visible) {
    outline: none;
    box-shadow: none;
}

*:focus-visible {
    outline: 2px solid var(--mew-accent);
    outline-offset: 2px;
}


/* ═══════════════════════════════════════════════════════════════════
   📐 RTL FINE-TUNING
═══════════════════════════════════════════════════════════════════ */

/* RTL flow - Login on LEFT, Cover on RIGHT */
html[dir="rtl"] .authentication-inner {
    flex-direction: row !important;
}

html[dir="rtl"] .form-check {
    padding-right: 1.25rem;
    padding-left: 0;
}

html[dir="rtl"] .form-check-input {
    margin-right: -1.25rem;
    margin-left: 0;
}

html[dir="rtl"] .swipe-text {
    padding-left: 56px;
    padding-right: 0;
}

@media (max-width: 575.98px) {
    html[dir="rtl"] .swipe-text {
        padding-left: 50px;
    }
}
