/* ================================================================
   بوابة الجهات — صفحة الدخول (/portal)
   صفحة مستقلة: لا تعتمد على index.css أو login.css أو design-system.css،
   ولا على Font Awesome (الأيقونات SVG داخل الصفحة)، والخط مستضاف محليًا.
   ================================================================ */

@font-face { font-family: "PL Plex"; src: url("../../assets/fonts/routes/ibm-plex-sans-arabic-arabic-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "PL Plex"; src: url("../../assets/fonts/routes/ibm-plex-sans-arabic-arabic-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "PL Plex"; src: url("../../assets/fonts/routes/ibm-plex-sans-arabic-arabic-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "PL Plex"; src: url("../../assets/fonts/routes/ibm-plex-sans-arabic-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "PL Plex"; src: url("../../assets/fonts/routes/ibm-plex-sans-arabic-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: "PL Plex"; src: url("../../assets/fonts/routes/ibm-plex-sans-arabic-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+20AC, U+2122; }

:root {
    --pl-ink: #0e2a47;          /* كحلي المؤسسة: لوحة الهوية ونص العناوين */
    --pl-blue: #1a5276;         /* لون الموقع الأساسي: الزر والروابط */
    --pl-blue-deep: #143f5c;
    --pl-brass: #c09a5b;        /* نحاس الأختام: خطوط الختم فقط */
    --pl-page: #f4f6f8;
    --pl-surface: #ffffff;
    --pl-text: #1c2733;
    --pl-muted: #5a6878;
    --pl-line: #d5dce4;
    --pl-line-strong: #b4c0cc;
    --pl-focus: #2f7ab8;
    --pl-error: #b42318;
    --pl-error-bg: #fef3f2;
    --pl-success: #067647;
    --pl-success-bg: #ecfdf3;
    --pl-font: "PL Plex", "Segoe UI", Tahoma, system-ui, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body.pl-page {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--pl-page);
    color: var(--pl-text);
    font-family: var(--pl-font);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.pl-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- الهيكل: عمود النموذج (بداية السطر) ولوحة الهوية ---------- */
.pl-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.92fr);
    min-height: 100vh;
    min-height: 100dvh;
}

.pl-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 32px;
    background: var(--pl-surface);
}

.pl-main-inner { width: 100%; max-width: 420px; }

.pl-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 48px;
    color: var(--pl-muted);
    font-size: .875rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: 6px;
}
.pl-back svg { width: 16px; height: 16px; }
.pl-back:hover { color: var(--pl-blue); }

.pl-head { margin-bottom: 32px; }
.pl-head-logo { display: none; width: 56px; height: auto; margin-bottom: 16px; }
.pl-head h1 {
    margin: 0 0 8px;
    color: var(--pl-ink);
    font-size: 1.875rem;
    font-weight: 600;
    line-height: 1.3;
}
.pl-head p { margin: 0; color: var(--pl-muted); font-size: 1rem; max-width: 36ch; }

/* ---------- الحقول ---------- */
.pl-field { margin-bottom: 20px; }
.pl-field label {
    display: block;
    margin-bottom: 6px;
    color: var(--pl-text);
    font-size: .9375rem;
    font-weight: 500;
}
.pl-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.pl-label-row label { margin-bottom: 6px; }

.pl-control { position: relative; }
.pl-control-icon {
    position: absolute;
    inset-inline-start: 14px;
    top: 50%;
    width: 20px;
    height: 20px;
    transform: translateY(-50%);
    color: #8593a3;
    pointer-events: none;
}

.pl-page input[type="email"],
.pl-page input[type="password"],
.pl-page input[type="text"] {
    width: 100%;
    height: 50px;
    margin: 0;
    padding: 0 14px;
    border: 1px solid var(--pl-line-strong);
    border-radius: 8px;
    background: #fff;
    color: var(--pl-text);
    font: inherit;
    font-size: 1rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.pl-control-icon { inset-inline-start: auto; right: 14px; }
/* البريد وكلمة المرور تُكتبان من اليسار (dir="ltr")، والأيقونة يمين الحقل وزر الإظهار يساره،
   فتُستعمل الجهات الفعلية هنا لا المنطقية. */
.pl-page .pl-control input { padding-right: 44px; padding-left: 14px; text-align: left; }
.pl-page .pl-control input:placeholder-shown { text-align: right; }
.pl-page .pl-control input#password { padding-left: 50px; }
.pl-control-action { inset-inline-end: auto; left: 4px; }
.pl-page input::placeholder { color: #98a4b1; }
.pl-page input:hover { border-color: #8e9cab; }
.pl-page input:focus {
    outline: none;
    border-color: var(--pl-focus);
    box-shadow: 0 0 0 3px rgba(47, 122, 184, .18);
}
.pl-page input[aria-invalid="true"] { border-color: var(--pl-error); }
.pl-page input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(180, 35, 24, .14); }

.pl-control-action {
    position: absolute;
    inset-inline-end: 4px;
    top: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    transform: translateY(-50%);
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--pl-muted);
    cursor: pointer;
}
.pl-control-action svg { width: 20px; height: 20px; }
.pl-control-action:hover { color: var(--pl-blue); background: #eef3f8; }
.pl-control-action .pl-eye-off,
.pl-control-action[aria-pressed="true"] .pl-eye { display: none; }
.pl-control-action[aria-pressed="true"] .pl-eye-off { display: block; }

.pl-link-quiet {
    color: var(--pl-blue);
    font-size: .875rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: 4px;
}
.pl-link-quiet:hover { text-decoration: underline; text-underline-offset: 3px; }

.pl-note { margin: 6px 0 0; color: #9a5b00; font-size: .8125rem; }
.pl-hint { margin: 6px 0 0; color: var(--pl-muted); font-size: .8125rem; }

/* ---------- التحقق الحسابي: السؤال والإجابة في سطر واحد ---------- */
.pl-captcha { display: grid; grid-template-columns: minmax(0, 1fr) 112px; gap: 8px; }
.pl-captcha-question {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: 50px;
    padding-inline: 16px 4px;
    border: 1px dashed var(--pl-line-strong);
    border-radius: 8px;
    background: #f7f9fb;
    color: var(--pl-ink);
    font-size: 1.125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: .02em;
    min-width: 0;
}
.pl-captcha-question > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-captcha-refresh {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--pl-muted);
    cursor: pointer;
}
.pl-captcha-refresh svg { width: 20px; height: 20px; }
.pl-captcha-refresh:hover { color: var(--pl-blue); background: #e9eff5; }
.pl-captcha-refresh:disabled { opacity: .5; cursor: progress; }
.pl-captcha-refresh:disabled svg { animation: pl-spin .9s linear infinite; }
.pl-captcha input { text-align: center; font-variant-numeric: tabular-nums; font-size: 1.125rem; }

/* ---------- الرسائل ---------- */
.pl-msg:empty { display: none; }
.pl-msg {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin: 4px 0 20px;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: .9375rem;
    line-height: 1.55;
}
.pl-msg svg { flex: 0 0 20px; width: 20px; height: 20px; margin-top: 1px; }
.pl-msg-code { display: block; margin-top: 2px; font-size: .75rem; opacity: .75; }
.pl-msg.error { border-color: #f6c8c3; background: var(--pl-error-bg); color: var(--pl-error); }
.pl-msg.success { border-color: #abefc6; background: var(--pl-success-bg); color: var(--pl-success); }

/* ---------- زر الدخول ---------- */
.pl-submit {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 52px;
    margin-top: 4px;
    border: 0;
    border-radius: 8px;
    background: var(--pl-blue);
    color: #fff;
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .15s ease;
}
.pl-submit:hover { background: var(--pl-blue-deep); }
.pl-submit:active { background: var(--pl-ink); }
.pl-submit:disabled { background: #7d97ad; cursor: not-allowed; }
.pl-submit.is-busy { cursor: progress; }
.pl-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: pl-spin .8s linear infinite;
}
.pl-submit.is-busy .pl-spinner { display: inline-block; }
@keyframes pl-spin { to { transform: rotate(360deg); } }

.pl-register {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #e6ebf0;
    font-size: .9375rem;
}
.pl-register p { margin: 0; color: var(--pl-muted); }
.pl-register-link { color: var(--pl-blue); font-weight: 600; text-decoration: none; border-radius: 4px; }
.pl-register-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.pl-copyright { margin: 40px 0 0; color: #8593a3; font-size: .8125rem; }
.pl-copyright .libac-app-version { justify-content: flex-start; margin-top: 6px; padding: 0; border-top: 0; font-family: var(--pl-font); color: #8593a3; }

/* ---------- لوحة الهوية: الختم وأنواع الاعتماد ---------- */
.pl-brand {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 56px 48px;
    background: var(--pl-ink);
    color: #e7edf3;
    overflow: hidden;
}
.pl-brand::before {
    /* نقش خطوط دقيقة كخلفية الشهادات الرسمية */
    content: "";
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 9px);
    pointer-events: none;
}
.pl-brand-inner { position: relative; width: 100%; max-width: 440px; }

.pl-seal { position: relative; width: 248px; aspect-ratio: 1; margin: 0 0 36px; }
.pl-seal-art { position: absolute; inset: 0; width: 100%; height: 100%; animation: pl-seal-turn 120s linear infinite; }
.pl-seal-edge { fill: none; stroke: var(--pl-brass); stroke-width: 1.2; opacity: .75; }
.pl-seal-ring { fill: none; stroke: var(--pl-brass); stroke-width: 1.6; }
.pl-seal-ring.is-thin { stroke-width: .9; opacity: .8; }
.pl-seal-ticks { fill: none; stroke: var(--pl-brass); stroke-width: 1.1; opacity: .85; }
.pl-seal-core { fill: #f7f3ea; }
.pl-seal-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 46%;
    height: auto;
    transform: translate(-50%, -50%);
}
@keyframes pl-seal-turn { to { transform: rotate(360deg); } }

.pl-brand h2 { margin: 0 0 10px; color: #fff; font-size: 1.625rem; font-weight: 600; line-height: 1.35; }
.pl-brand-lead { margin: 0 0 32px; color: #b9c7d5; font-size: 1rem; max-width: 34ch; }

.pl-schemes { margin: 0; padding: 0; list-style: none; border-top: 1px solid rgba(192, 154, 91, .35); }
.pl-schemes li {
    display: grid;
    grid-template-columns: 9.5em minmax(0, 1fr);
    align-items: baseline;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .09);
    font-size: .9375rem;
}
.pl-std { color: #e3c891; font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pl-schemes li > span:last-child { color: #dbe4ec; }

/* ---------- التركيز من لوحة المفاتيح ---------- */
.pl-page a:focus-visible,
.pl-page button:focus-visible {
    outline: 3px solid var(--pl-focus);
    outline-offset: 2px;
}
.pl-submit:focus-visible { outline-color: #f0b35a; }

/* ---------- الشاشات المتوسطة والجوال ---------- */
@media (max-width: 1080px) {
    .pl-shell { grid-template-columns: minmax(0, 1fr) minmax(0, .8fr); }
    .pl-brand { padding: 48px 36px; }
    .pl-seal { width: 200px; }
}

@media (max-width: 860px) {
    .pl-shell { display: flex; flex-direction: column-reverse; }
    .pl-brand { padding: 20px 20px; justify-content: flex-start; }
    .pl-brand::before { display: none; }
    .pl-brand-inner { display: flex; align-items: center; gap: 14px; max-width: none; }
    .pl-seal { width: 56px; margin: 0; flex: 0 0 auto; }
    .pl-seal-art { animation: none; }
    .pl-seal-edge, .pl-seal-ticks, .pl-seal-ring.is-thin { display: none; }
    .pl-seal-logo { width: 62%; }
    .pl-brand h2 { margin: 0; font-size: 1.0625rem; }
    .pl-brand-lead, .pl-schemes { display: none; }
    .pl-main { align-items: flex-start; padding: 28px 20px 40px; }
    .pl-back { margin-bottom: 28px; }
    .pl-head { margin-bottom: 24px; }
    .pl-head h1 { font-size: 1.625rem; }
}

@media (max-width: 380px) {
    .pl-captcha { grid-template-columns: minmax(0, 1fr) 92px; }
}

@media (prefers-reduced-motion: reduce) {
    .pl-seal-art, .pl-spinner, .pl-captcha-refresh:disabled svg { animation: none; }
    .pl-page * { transition: none !important; }
}
