/* ═════════════ صفحة تسجيل الدخول — v3 ═════════════ */

:root {
    --navy-950: #071433;
    --navy-900: #0b1f4d;
    --blue-800: #1e3a8a;
    --blue-700: #1d4ed8;
    --blue-600: #2563eb;
    --blue-500: #3b82f6;
    --blue-400: #60a5fa;
    --blue-200: #bfdbfe;
    --blue-100: #dbeafe;
    --blue-50:  #eff6ff;

    --ink:      #0f172a;
    --text:     #334155;
    --muted:    #64748b;
    --subtle:   #94a3b8;
    --line:     #e2e8f0;
    --field:    #f8fafc;
    --surface:  #ffffff;
    --page:     #f3f6fc;

    --danger:      #dc2626;
    --danger-bg:   #fef2f2;
    --danger-line: #fecaca;
    --warn:        #b45309;
    --warn-bg:     #fffbeb;

    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;
    --ease: cubic-bezier(.4, 0, .2, 1);
}

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

html, body { height: 100%; }

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    background: var(--page);
    color: var(--text);
    direction: rtl;
    -webkit-font-smoothing: antialiased;
}

svg {
    width: 1em; height: 1em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* ── التخطيط العام ── */
.auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
}

/* ═════════════ اللوحة التعريفية ═════════════ */
.auth-brand {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2.5rem 3rem;
    color: #fff;
    background:
        radial-gradient(circle at 1px 1px, rgba(255,255,255,.07) 1px, transparent 0) 0 0 / 26px 26px,
        linear-gradient(150deg, var(--navy-950) 0%, var(--navy-900) 35%, var(--blue-800) 75%, var(--blue-700) 100%);
}

.brand-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    pointer-events: none;
}
.brand-glow--a { width: 420px; height: 420px; background: rgba(59,130,246,.35); top: -140px; left: -120px; }
.brand-glow--b { width: 340px; height: 340px; background: rgba(96,165,250,.22); bottom: -120px; right: -80px; }

.brand-top, .brand-hero, .brand-foot { position: relative; z-index: 1; }

.brand-top { display: flex; align-items: center; gap: .9rem; }

.brand-logo {
    width: 56px; height: 56px;
    border-radius: var(--r-lg);
    background: #fff;
    display: grid;
    place-items: center;
    padding: 7px;
    box-shadow: 0 10px 25px rgba(0,0,0,.25);
}
.brand-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.brand-logo--sm { width: 46px; height: 46px; border-radius: var(--r-md); padding: 6px; }

.brand-name    { font-size: 1.15rem; font-weight: 800; letter-spacing: .01em; }
.brand-tagline { font-size: .8rem; color: var(--blue-200); font-weight: 500; }

.brand-hero { max-width: 460px; }

.brand-hero h2 {
    font-size: clamp(1.9rem, 3vw, 2.6rem);
    font-weight: 800;
    line-height: 1.35;
    margin-bottom: 1rem;
}
.brand-hero h2 span {
    background: linear-gradient(90deg, #93c5fd, #dbeafe);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.brand-hero p {
    color: rgba(219,234,254,.82);
    font-size: .98rem;
    line-height: 1.9;
    margin-bottom: 2rem;
}

.brand-features { list-style: none; display: grid; gap: .75rem; }
.brand-features li {
    display: flex;
    align-items: center;
    gap: .85rem;
    font-size: .92rem;
    font-weight: 600;
    padding: .7rem .9rem;
    border-radius: var(--r-md);
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.1);
    backdrop-filter: blur(4px);
}
.feat-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 1.05rem;
    color: #fff;
    background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
    box-shadow: 0 6px 14px rgba(29,78,216,.45);
}

.brand-foot { font-size: .78rem; color: rgba(191,219,254,.65); }

/* ═════════════ لوحة النموذج ═════════════ */
.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    background:
        radial-gradient(ellipse at top left, rgba(219,234,254,.7), transparent 55%),
        var(--page);
}

.auth-card {
    width: 100%;
    max-width: 410px;
    animation: rise .5s var(--ease) both;
}

@keyframes rise {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: none; }
}

.mobile-brand, .mobile-foot { display: none; }

.auth-head { margin-bottom: 1.75rem; }
.auth-head h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--ink);
    margin-bottom: .3rem;
}
.auth-head p { color: var(--muted); font-size: .92rem; }

/* ── التنبيه ── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .8rem 1rem;
    border-radius: var(--r-md);
    font-size: .87rem;
    font-weight: 600;
    line-height: 1.6;
    margin-bottom: 1.25rem;
}
.alert svg { font-size: 1.15rem; margin-top: .15rem; }
.alert--error {
    background: var(--danger-bg);
    border: 1px solid var(--danger-line);
    border-inline-start: 4px solid var(--danger);
    color: #991b1b;
    animation: shake .4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-3px); }
}

/* ── الحقول ── */
.field { margin-bottom: 1.15rem; }

.field label {
    display: block;
    font-size: .86rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: .45rem;
}

.input-wrap { position: relative; }

.input-wrap input {
    width: 100%;
    height: 50px;
    padding: 0 2.9rem;
    font-family: inherit;
    font-size: .95rem;
    font-weight: 500;
    color: var(--ink);
    background: var(--field);
    border: 1.5px solid var(--line);
    border-radius: var(--r-md);
    outline: none;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
}
.input-wrap input::placeholder { color: var(--subtle); font-weight: 400; }
.input-wrap input:hover { border-color: #cbd5e1; }
.input-wrap input:focus {
    background: var(--surface);
    border-color: var(--blue-600);
    box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}

.input-icon {
    position: absolute;
    inset-inline-start: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    color: var(--subtle);
    pointer-events: none;
    transition: color .2s var(--ease);
}
.input-wrap:focus-within .input-icon { color: var(--blue-600); }

.field.has-error input {
    border-color: var(--danger);
    box-shadow: 0 0 0 4px rgba(220,38,38,.08);
}
.field.has-error .input-icon { color: var(--danger); }

.field-error {
    font-size: .78rem;
    font-weight: 600;
    color: var(--danger);
    margin-top: .35rem;
    min-height: 0;
}
.field-error:empty { display: none; }

.toggle-pw {
    position: absolute;
    inset-inline-end: .55rem;
    top: 50%;
    transform: translateY(-50%);
    width: 36px; height: 36px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--subtle);
    font-size: 1.1rem;
    cursor: pointer;
    transition: color .2s var(--ease), background .2s var(--ease);
}
.toggle-pw:hover { color: var(--blue-600); background: var(--blue-50); }
.toggle-pw:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 1px; }
.toggle-pw .ico-hide { display: none; }
.toggle-pw[aria-pressed="true"] .ico-show { display: none; }
.toggle-pw[aria-pressed="true"] .ico-hide { display: block; }

.caps-warn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin-top: .45rem;
    padding: .2rem .6rem;
    font-size: .76rem;
    font-weight: 700;
    color: var(--warn);
    background: var(--warn-bg);
    border-radius: 6px;
}
.caps-warn[hidden] { display: none; }

/* ── زر الدخول ── */
.btn-primary {
    position: relative;
    width: 100%;
    height: 52px;
    margin-top: .5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    border: none;
    border-radius: var(--r-md);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(135deg, var(--blue-600) 0%, var(--blue-700) 55%, var(--blue-800) 100%);
    box-shadow: 0 8px 20px rgba(37,99,235,.32), inset 0 1px 0 rgba(255,255,255,.15);
    transition: transform .2s var(--ease), box-shadow .2s var(--ease), filter .2s var(--ease);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 26px rgba(37,99,235,.4), inset 0 1px 0 rgba(255,255,255,.15);
    filter: brightness(1.05);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:focus-visible { outline: 3px solid var(--blue-200); outline-offset: 2px; }

.btn-arrow { font-size: 1.1rem; transition: transform .2s var(--ease); }
.btn-primary:hover .btn-arrow { transform: translateX(-3px); }

.spinner {
    display: none;
    width: 18px; height: 18px;
    border: 2.5px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-primary.is-loading { cursor: wait; filter: saturate(.85); }
.btn-primary.is-loading .spinner { display: block; }
.btn-primary.is-loading .btn-arrow { display: none; }

/* ── ملاحظة الأمان ── */
.secure-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    margin-top: 1.5rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--muted);
}
.secure-note svg { color: #059669; font-size: 1rem; }

/* ── أنواع التنبيه الإضافية ── */
.alert--success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-inline-start: 4px solid #059669;
    color: #065f46;
}
.alert--info {
    background: var(--blue-50);
    border: 1px solid var(--blue-200);
    border-inline-start: 4px solid var(--blue-600);
    color: var(--blue-800);
}

/* ═════════════ صفحة تأكيد الرمز ═════════════ */
.auth-icon {
    width: 64px; height: 64px;
    margin: 0 auto 1.1rem;
    display: grid;
    place-items: center;
    border-radius: 18px;
    font-size: 1.75rem;
    color: #fff;
    background: linear-gradient(135deg, var(--blue-500), var(--blue-800));
    box-shadow: 0 12px 26px rgba(29,78,216,.32), inset 0 1px 0 rgba(255,255,255,.2);
}

.auth-head--center { text-align: center; }
.auth-head--center p { line-height: 1.9; }

.email-chip {
    display: inline-block;
    direction: ltr;
    padding: 0 .55rem;
    border-radius: 6px;
    background: var(--blue-50);
    color: var(--blue-800);
    font-weight: 700;
}

/* حقل الرمز: يظهر كحقل عادي بدون JavaScript، وكخانات منفصلة مع JavaScript */
.otp { position: relative; direction: ltr; }

.otp-input {
    width: 100%;
    height: 60px;
    text-align: center;
    font-family: inherit;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: .6em;
    color: var(--ink);
    background: var(--field);
    border: 1.5px solid var(--line);
    border-radius: var(--r-md);
    outline: none;
}
.otp-input:focus { border-color: var(--blue-600); box-shadow: 0 0 0 4px rgba(37,99,235,.12); }

.otp-slots { display: none; }

.js .otp-input {
    position: absolute;
    inset: 0;
    height: 100%;
    opacity: 0;
    z-index: 2;
    cursor: text;
}

.js .otp-slots {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: .55rem;
}

.otp-slot {
    position: relative;
    height: 58px;
    display: grid;
    place-items: center;
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--ink);
    background: var(--field);
    border: 1.5px solid var(--line);
    border-radius: var(--r-md);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
.otp-slot.is-filled {
    background: var(--surface);
    border-color: var(--blue-200);
    color: var(--blue-800);
}
.otp.is-focused .otp-slot.is-active {
    background: var(--surface);
    border-color: var(--blue-600);
    box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}
.otp.is-focused .otp-slot.is-active:empty::after {
    content: '';
    width: 2px; height: 26px;
    background: var(--blue-600);
    animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.field.has-error .otp-slot { border-color: var(--danger); }

.otp-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    margin: .2rem 0 1rem;
    font-size: .84rem;
    font-weight: 600;
    color: var(--muted);
}
.otp-timer svg { font-size: 1rem; color: var(--blue-600); }
.otp-timer b { color: var(--blue-800); font-weight: 800; }
.otp-timer.is-expired, .otp-timer.is-expired svg { color: var(--danger); }

.btn-primary:disabled {
    cursor: not-allowed;
    filter: grayscale(.4) opacity(.6);
    transform: none;
    box-shadow: none;
}

.resend-form {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    margin-top: 1.25rem;
    font-size: .86rem;
    color: var(--muted);
}

.link-btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .2rem .35rem;
    border: none;
    border-radius: 6px;
    background: none;
    font-family: inherit;
    font-size: .86rem;
    font-weight: 700;
    color: var(--blue-600);
    cursor: pointer;
    transition: color .2s var(--ease), background .2s var(--ease);
}
.link-btn:hover:not(:disabled) { color: var(--blue-800); background: var(--blue-50); }
.link-btn:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 1px; }
.link-btn:disabled { color: var(--subtle); cursor: default; }
.link-btn--muted { color: var(--muted); }
.link-btn svg { font-size: 1rem; }

.resend-count { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

.back-form {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

/* ═════════════ الشاشات المتوسطة والصغيرة ═════════════ */
@media (max-width: 960px) {
    .auth { grid-template-columns: 1fr; }
    .auth-brand { display: none; }

    .auth-panel {
        min-height: 100vh;
        padding: 1.5rem 1rem;
        background:
            radial-gradient(circle at 1px 1px, rgba(255,255,255,.07) 1px, transparent 0) 0 0 / 24px 24px,
            linear-gradient(160deg, var(--navy-950) 0%, var(--blue-800) 60%, var(--blue-700) 100%);
    }

    .auth-card {
        background: var(--surface);
        border-radius: var(--r-xl);
        padding: 2rem 1.5rem 1.5rem;
        box-shadow: 0 25px 60px rgba(2,6,23,.35);
    }

    .mobile-brand {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: .65rem;
        margin-bottom: 1.5rem;
        padding-bottom: 1.25rem;
        border-bottom: 1px solid var(--line);
    }
    .mobile-brand .brand-logo { box-shadow: 0 4px 12px rgba(30,58,138,.18); border: 1px solid var(--line); }
    .mobile-brand .brand-name { color: var(--blue-800); }

    .auth-head { text-align: center; }
    .auth-head h1 { font-size: 1.45rem; }

    .mobile-foot {
        display: block;
        text-align: center;
        margin-top: 1rem;
        font-size: .74rem;
        color: var(--subtle);
    }
}

@media (max-width: 380px) {
    .auth-card { padding: 1.5rem 1.1rem 1.25rem; }
    .js .otp-slots { gap: .4rem; }
    .otp-slot { height: 52px; font-size: 1.35rem; }
}

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