/* Madad ERP — cinematic login */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,600;0,700;1,500&family=Tajawal:wght@400;500;600;700;800&display=swap');

:root {
    --md-navy: #050d1a;
    --md-navy-2: #0a1a33;
    --md-navy-3: #122a4d;
    --md-blue: #1e4a8a;
    --md-gold: #d4af37;
    --md-gold-bright: #f0d875;
    --md-gold-dim: #8b6914;
    --md-glass: rgba(255, 255, 255, 0.07);
    --md-glass-border: rgba(212, 175, 55, 0.28);
    --md-text: #f1f5f9;
    --md-muted: rgba(241, 245, 249, 0.55);
}

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

.md-login {
    margin: 0;
    min-height: 100vh;
    font-family: 'Tajawal', system-ui, sans-serif;
    background: var(--md-navy);
    color: var(--md-text);
    overflow-x: hidden;
}

/* ── Animated scene ── */
.md-scene {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background:
        radial-gradient(ellipse 100% 80% at 70% 0%, rgba(30, 74, 138, 0.45) 0%, transparent 55%),
        radial-gradient(ellipse 60% 50% at 10% 90%, rgba(212, 175, 55, 0.08) 0%, transparent 50%),
        linear-gradient(165deg, #030810 0%, var(--md-navy) 40%, var(--md-navy-2) 100%);
}

.md-scene__grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(212, 175, 55, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(212, 175, 55, 0.03) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 70% 70% at 50% 40%, black 20%, transparent 75%);
    animation: mdGridDrift 40s linear infinite;
}

@keyframes mdGridDrift {
    0% { transform: translate(0, 0); }
    100% { transform: translate(48px, 48px); }
}

.md-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: mdOrbFloat 12s ease-in-out infinite;
}

.md-orb--1 {
    width: 420px;
    height: 420px;
    background: rgba(30, 74, 138, 0.55);
    top: -8%;
    right: 5%;
    animation-delay: 0s;
}

.md-orb--2 {
    width: 320px;
    height: 320px;
    background: rgba(212, 175, 55, 0.18);
    bottom: 10%;
    left: -5%;
    animation-delay: -4s;
}

.md-orb--3 {
    width: 200px;
    height: 200px;
    background: rgba(18, 42, 77, 0.9);
    top: 45%;
    left: 35%;
    animation-delay: -7s;
}

@keyframes mdOrbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(24px, -18px) scale(1.05); }
    66% { transform: translate(-16px, 12px) scale(0.96); }
}

.md-rays {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0.35;
}

.md-rays svg {
    width: min(900px, 120vw);
    height: auto;
}

.md-rays line {
    stroke: url(#mdRayGrad);
    stroke-width: 1;
    stroke-dasharray: 8 12;
    animation: mdRayPulse 4s ease-in-out infinite;
}

.md-rays line:nth-child(odd) { animation-delay: -2s; }

@keyframes mdRayPulse {
    0%, 100% { opacity: 0.25; stroke-dashoffset: 0; }
    50% { opacity: 0.7; stroke-dashoffset: 40; }
}

/* ── Top bar ── */
.md-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 2rem;
    pointer-events: none;
}

.md-topbar > * { pointer-events: auto; }

.md-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--md-gold);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 999px;
    background: rgba(5, 13, 26, 0.6);
    backdrop-filter: blur(12px);
}

.md-lang {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 1.1rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--md-text);
    text-decoration: none;
    border-radius: 999px;
    background: var(--md-glass);
    border: 1px solid var(--md-glass-border);
    backdrop-filter: blur(16px);
    transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
}

.md-lang:hover {
    transform: translateY(-2px);
    border-color: var(--md-gold);
    box-shadow: 0 8px 32px rgba(212, 175, 55, 0.2);
    color: #fff;
}

/* ── Stage layout ── */
.md-stage {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
    min-height: 100vh;
    max-width: 1180px;
    margin: 0 auto;
    padding: 4.5rem 2rem 2rem;
    gap: 2.5rem 3rem;
    align-items: center;
}

/* ── Showcase (logo side) ── */
.md-showcase {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0.5rem 0;
    max-width: 380px;
    margin-inline: auto;
    animation: mdFadeUp 1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes mdFadeUp {
    from { opacity: 0; transform: translateY(28px); }
    to { opacity: 1; transform: translateY(0); }
}

.md-logo-stage {
    position: relative;
    margin-bottom: 1.1rem;
}

.md-logo-stage::before {
    content: '';
    position: absolute;
    inset: -12%;
    background: radial-gradient(circle, rgba(212, 175, 55, 0.14) 0%, transparent 68%);
    filter: blur(28px);
    animation: mdGlowBreath 5s ease-in-out infinite;
}

@keyframes mdGlowBreath {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.08); }
}

.md-logo-frame {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem;
    background: transparent;
    border-radius: 18px;
    box-shadow: none;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), filter 0.4s;
}

.md-showcase:hover .md-logo-frame {
    transform: translateY(-2px);
    filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.35));
}

.md-logo-frame img {
    display: block;
    width: auto;
    max-width: 200px;
    max-height: 118px;
    height: auto;
    object-fit: contain;
}

.md-hero-tag {
    margin: 0 0 0.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--md-muted);
}

.md-hero-tag::before,
.md-hero-tag::after {
    content: '—';
    margin: 0 0.6em;
    color: var(--md-gold-dim);
    opacity: 0.7;
}

.md-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    margin-top: 1.35rem;
    animation: mdFadeUp 1s 0.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.md-stat {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.85rem;
    border-radius: 999px;
    background: var(--md-glass);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    transition: border-color 0.3s, transform 0.3s;
}

.md-stat:hover {
    border-color: var(--md-glass-border);
    transform: translateY(-2px);
}

.md-stat i {
    font-size: 0.75rem;
    color: var(--md-gold);
    margin: 0;
}

.md-stat strong {
    font-size: 0.72rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.92);
}

.md-stat span {
    display: none;
}

/* ── Auth glass panel ── */
.md-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: mdFadeUp 1s 0.15s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.md-panel {
    width: 100%;
    max-width: 400px;
    padding: 2rem 1.85rem 1.65rem;
    border-radius: 24px;
    background: linear-gradient(
        160deg,
        rgba(255, 255, 255, 0.12) 0%,
        rgba(255, 255, 255, 0.04) 100%
    );
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow:
        0 32px 64px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(28px) saturate(1.4);
    position: relative;
    overflow: hidden;
}

.md-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--md-gold), transparent);
}

.md-panel-head {
    margin-bottom: 1.5rem;
}

.md-panel-head h2 {
    margin: 0 0 0.35rem;
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
}

.md-panel-head p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--md-muted);
    line-height: 1.5;
}

.md-field {
    margin-bottom: 1.35rem;
}

.md-field label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.7);
}

.md-input-row {
    position: relative;
    display: flex;
    align-items: stretch;
}

.md-input-row > i:first-child {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    inset-inline-start: 1.1rem;
    color: var(--md-gold);
    font-size: 0.95rem;
    opacity: 0.9;
    pointer-events: none;
    z-index: 1;
}

.md-input {
    width: 100%;
    padding: 1rem 3rem 1rem 2.85rem;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 500;
    color: #fff;
    background: rgba(5, 13, 26, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}

[dir="rtl"] .md-input {
    padding: 1rem 2.85rem 1rem 3rem;
}

.md-input::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.md-input:focus {
    outline: none;
    border-color: var(--md-gold);
    background: rgba(5, 13, 26, 0.75);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15), 0 8px 24px rgba(0, 0, 0, 0.2);
}

.md-toggle-pw {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    inset-inline-end: 0.75rem;
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
    z-index: 1;
}

.md-toggle-pw:hover {
    color: var(--md-gold);
    background: rgba(212, 175, 55, 0.1);
}

.md-submit {
    position: relative;
    width: 100%;
    margin-top: 0.5rem;
    padding: 1.05rem 1.5rem;
    font-size: 1.05rem;
    font-weight: 800;
    font-family: inherit;
    color: var(--md-navy);
    cursor: pointer;
    border: none;
    border-radius: 14px;
    overflow: hidden;
    background: linear-gradient(105deg, #b8942d 0%, var(--md-gold-bright) 45%, var(--md-gold) 70%, #b8942d 100%);
    background-size: 200% auto;
    box-shadow: 0 12px 40px rgba(212, 175, 55, 0.35);
    transition: transform 0.25s, box-shadow 0.25s, background-position 0.4s;
}

.md-submit::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.35) 50%, transparent 60%);
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.md-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 48px rgba(212, 175, 55, 0.45);
    background-position: 100% center;
}

.md-submit:hover::after {
    transform: translateX(100%);
}

.md-submit:active {
    transform: translateY(0);
}

.md-submit i {
    margin-inline-end: 0.5rem;
}

.md-forgot {
    display: inline-block;
    margin-top: 1.35rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--md-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.md-forgot:hover {
    color: var(--md-gold-bright);
}

.md-alert {
    padding: 0.9rem 1rem;
    margin-bottom: 1.25rem;
    border-radius: 12px;
    font-size: 0.88rem;
    font-weight: 600;
    backdrop-filter: blur(8px);
}

.md-alert--err {
    background: rgba(185, 28, 28, 0.2);
    border: 1px solid rgba(248, 113, 113, 0.35);
    color: #fecaca;
}

.md-alert--ok {
    background: rgba(21, 128, 61, 0.2);
    border: 1px solid rgba(74, 222, 128, 0.35);
    color: #bbf7d0;
}

.md-foot {
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
    font-size: 0.75rem;
    color: var(--md-muted);
}

.md-foot a {
    color: var(--md-gold);
    font-weight: 700;
    text-decoration: none;
}

.md-foot a:hover {
    text-decoration: underline;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .md-stage {
        grid-template-columns: 1fr;
        max-width: 440px;
        padding-top: 4rem;
        gap: 1.25rem;
    }

    .md-showcase {
        order: 1;
        max-width: 100%;
    }

    .md-auth {
        order: 2;
        padding-bottom: 1.5rem;
    }

    .md-rays {
        opacity: 0.15;
    }

    .md-logo-frame img {
        max-width: 168px;
        max-height: 100px;
    }
}

@media (max-width: 520px) {
    .md-topbar {
        padding: 1rem;
    }

    .md-stage {
        padding: 3.75rem 1rem 1.25rem;
    }

    .md-logo-frame {
        padding: 0.65rem 0.85rem;
        border-radius: 14px;
    }

    .md-logo-frame img {
        max-width: 148px;
        max-height: 88px;
    }

    .md-stats {
        gap: 0.4rem;
    }

    .md-stat {
        padding: 0.45rem 0.7rem;
    }

    .md-panel {
        padding: 1.65rem 1.25rem 1.35rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .md-orb, .md-scene__grid, .md-rays line, .md-logo-stage::before {
        animation: none;
    }
    .md-showcase, .md-auth {
        animation: none;
    }
}
