/* =====================================================================
   منظومة إدارة المستشفى — نظام التصميم
   ===================================================================== */

/* ---------- الخطوط (ضع الملفات في assets/fonts/) ---------- */
@font-face {
    font-family: 'Almarai';
    src: url('../fonts/Almarai-ExtraBold.woff2') format('woff2');
    font-weight: 800; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Almarai';
    src: url('../fonts/Almarai-Bold.woff2') format('woff2');
    font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'PlexArabic';
    src: url('../fonts/IBMPlexSansArabic-Regular.woff2') format('woff2');
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'PlexArabic';
    src: url('../fonts/IBMPlexSansArabic-Medium.woff2') format('woff2');
    font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'PlexArabic';
    src: url('../fonts/IBMPlexSansArabic-SemiBold.woff2') format('woff2');
    font-weight: 600; font-style: normal; font-display: swap;
}

/* ---------- الرموز ---------- */
:root {
    /* الألوان */
    --ink:        #0D2B2F;
    --ink-soft:   #254A4E;
    --muted:      #6B8083;
    --line:       #DCE5E4;
    --line-soft:  #EAF0EF;
    --paper:      #EFF3F2;
    --card:       #FFFFFF;

    --brand:      #0E7C7B;
    --brand-dark: #0A5F5E;
    --brand-tint: #E4F0EF;

    --brass:      #B08A3E;
    --brass-tint: #F7F1E3;

    --danger:     #A63A3A;
    --danger-tint:#FAECEC;
    --ok:         #2E6B4F;
    --ok-tint:    #E8F2ED;
    --warn:       #9A6A1E;
    --warn-tint:  #FBF2E2;

    /* الخطوط */
    --font-display: 'Almarai', 'Segoe UI', 'Noto Sans Arabic', sans-serif;
    --font-body:    'PlexArabic', 'Segoe UI', 'Noto Sans Arabic', sans-serif;

    /* المقاييس */
    --radius:    6px;
    --radius-lg: 10px;
    --shadow-sm: 0 1px 2px rgba(13, 43, 47, .06);
    --shadow:    0 2px 8px rgba(13, 43, 47, .07);
    --shadow-lg: 0 12px 40px rgba(13, 43, 47, .10);
    --ease:      cubic-bezier(.4, 0, .2, 1);
}

/* ---------- الأساس ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.75;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 800;
    line-height: 1.35;
    margin: 0 0 .5rem;
    letter-spacing: -.01em;
}
h1 { font-size: 1.65rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); text-decoration: underline; }

/* الأرقام تُعرض بعرض ثابت لتصطف في الجداول */
.num, input[type="tel"], input[type="number"], .tabular {
    font-variant-numeric: tabular-nums;
    letter-spacing: .02em;
}

/* ---------- التركيز — إظهار واضح لمستخدمي لوحة المفاتيح ---------- */
:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: 3px;
}

/* ---------- الترويسة الرسمية : خط مزدوج ---------- */
.rule-official {
    border: 0;
    height: 3px;
    background:
        linear-gradient(var(--brass), var(--brass)) top/100% 1px no-repeat,
        linear-gradient(var(--brass), var(--brass)) bottom/100% 2px no-repeat;
    opacity: .55;
    margin: 0;
}

/* ---------- البطاقة ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card__head {
    padding: 1.15rem 1.5rem;
    border-bottom: 1px solid var(--line-soft);
}
.card__body { padding: 1.5rem; }

/* ---------- الحقول ---------- */
.field { margin-bottom: 1.15rem; }

.field__label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: .45rem;
}
.field__label .req { color: var(--danger); margin-inline-start: 2px; }

.input {
    display: block;
    width: 100%;
    padding: .7rem .9rem;
    font-family: inherit;
    font-size: 1rem;
    color: var(--ink);
    background: #FCFDFD;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}
.input::placeholder { color: #A8B8B9; }
.input:hover { border-color: #C3D2D1; }
.input:focus {
    outline: none;
    background: #fff;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-tint);
}
.input:disabled { background: var(--line-soft); color: var(--muted); cursor: not-allowed; }
.input.is-invalid { border-color: var(--danger); }
.input.is-invalid:focus { box-shadow: 0 0 0 3px var(--danger-tint); }

.field__hint { font-size: .8rem; color: var(--muted); margin-top: .35rem; }
.field__error { font-size: .8rem; color: var(--danger); margin-top: .35rem; font-weight: 500; }

/* حقل كلمة المرور مع زر الإظهار */
.field--password { position: relative; }
.field--password .input { padding-inline-start: 2.9rem; }
.pw-toggle {
    position: absolute;
    inset-inline-start: .35rem;
    bottom: .3rem;
    width: 2.2rem; height: 2.2rem;
    display: grid; place-items: center;
    background: none; border: 0; cursor: pointer;
    color: var(--muted); border-radius: var(--radius);
}
.pw-toggle:hover { color: var(--ink); background: var(--line-soft); }

/* ---------- الأزرار ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .7rem 1.35rem;
    font-family: inherit;
    font-size: .95rem;
    font-weight: 600;
    line-height: 1.4;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .18s var(--ease), border-color .18s var(--ease), transform .1s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--brand-dark); }

.btn--ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn--ghost:hover:not(:disabled) { background: var(--line-soft); }

.btn--danger { background: var(--danger); color: #fff; }
.btn--block { width: 100%; }

/* ---------- التنبيهات ---------- */
.alert {
    display: flex;
    gap: .7rem;
    padding: .8rem 1rem;
    border-radius: var(--radius);
    font-size: .9rem;
    line-height: 1.6;
    margin-bottom: 1.15rem;
    border-inline-start: 3px solid;
}
.alert svg { flex: none; margin-top: .2rem; }
.alert--danger  { background: var(--danger-tint); color: #7E2B2B; border-color: var(--danger); }
.alert--success { background: var(--ok-tint);     color: #1F4C37; border-color: var(--ok); }
.alert--warning { background: var(--warn-tint);   color: #6F4C14; border-color: var(--warn); }
.alert--info    { background: var(--brand-tint);  color: #0A5F5E; border-color: var(--brand); }

/* =====================================================================
   صفحات المصادقة
   ===================================================================== */
.auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 480px;
}

/* ---------- اللوحة المؤسسية ---------- */
.auth__panel {
    position: relative;
    padding: 3.5rem 3rem;
    background: var(--ink);
    color: #DCE8E7;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}
/* شبكة خفيفة جداً توحي بورق النماذج */
.auth__panel::before {
    content: '';
    position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,.028) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.028) 1px, transparent 1px);
    background-size: 44px 44px;
    pointer-events: none;
}
.auth__panel > * { position: relative; }

.brand { display: flex; align-items: center; gap: .9rem; }
.brand__name {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.2rem;
    color: #fff;
    line-height: 1.3;
}
.brand__sub { font-size: .8rem; color: #7FA09E; }

.auth__lede {
    max-width: 30ch;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.9rem;
    line-height: 1.5;
    color: #fff;
    margin: 2.5rem 0 .6rem;
}
.auth__sub { max-width: 40ch; color: #93B2B0; font-size: .95rem; }

/* ---------- العنصر المميز : مسار الاعتماد ---------- */
.chain { list-style: none; margin: 2.5rem 0 0; padding: 0; }
.chain li {
    position: relative;
    padding-inline-start: 1.9rem;
    padding-bottom: 1.05rem;
    font-size: .9rem;
    color: #A8C4C2;
    opacity: 0;
    animation: chain-in .5s var(--ease) forwards;
}
.chain li::before {
    content: '';
    position: absolute;
    inset-inline-start: 0; top: .62rem;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--brass);
}
.chain li::after {
    content: '';
    position: absolute;
    inset-inline-start: 3px; top: 1.25rem;
    width: 1px; height: calc(100% - 1.25rem);
    background: linear-gradient(rgba(176,138,62,.45), rgba(176,138,62,.08));
}
.chain li:last-child { padding-bottom: 0; }
.chain li:last-child::after { display: none; }
.chain li:last-child::before { background: var(--brand); box-shadow: 0 0 0 4px rgba(14,124,123,.2); }

.chain li:nth-child(1) { animation-delay: .30s; }
.chain li:nth-child(2) { animation-delay: .42s; }
.chain li:nth-child(3) { animation-delay: .54s; }
.chain li:nth-child(4) { animation-delay: .66s; }
.chain li:nth-child(5) { animation-delay: .78s; }

@keyframes chain-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

.auth__foot { font-size: .78rem; color: #5E807E; }

/* ---------- جهة النموذج ---------- */
.auth__side {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--card);
}
.auth__box { width: 100%; max-width: 350px; }

.auth__title { font-size: 1.5rem; margin-bottom: .3rem; }
.auth__note  { color: var(--muted); font-size: .9rem; margin: 0 0 2rem; }

.auth__seal {
    margin-top: 2.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--line-soft);
    font-size: .78rem;
    color: var(--muted);
    text-align: center;
}

/* ---------- الاستجابة للشاشات الصغيرة ---------- */
@media (max-width: 900px) {
    .auth { grid-template-columns: 1fr; }
    .auth__panel { padding: 2rem 1.5rem; }
    .auth__lede { font-size: 1.4rem; margin: 1.5rem 0 .5rem; }
    .chain { display: none; }
    .auth__foot { display: none; }
    .auth__side { padding: 2.5rem 1.5rem; }
}

/* ---------- احترام تقليل الحركة ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
    .chain li { opacity: 1; }
}