/* =========================================================
   brand.css — الهوية البصرية لوزارة التعليم العالي والبحث العلمي
   Palette, typeface and shared components for every page. Pages use the
   semantic roles (--page, --surface, --text…) so the dark theme only remaps roles.
   ========================================================= */

@font-face { font-family: 'ITF Qomra Arabic'; src: url('/static/brand/Visual%20Identity/ITFQOMRAARABIC-LIGHT.TTF') format('truetype'); font-weight: 300; font-display: swap; }
@font-face { font-family: 'ITF Qomra Arabic'; src: url('/static/brand/Visual%20Identity/ITFQOMRAARABIC-REGULAR.TTF') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'ITF Qomra Arabic'; src: url('/static/brand/Visual%20Identity/ITFQOMRAARABIC-MEDIUM.TTF') format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'ITF Qomra Arabic'; src: url('/static/brand/Visual%20Identity/ITFQOMRAARABIC-BOLD.TTF') format('truetype'); font-weight: 600 700; font-display: swap; }
@font-face { font-family: 'ITF Qomra Arabic'; src: url('/static/brand/Visual%20Identity/ITFQOMRAARABIC-BLACK.TTF') format('truetype'); font-weight: 800 900; font-display: swap; }

:root {
  --forest: #002623;
  --emerald-shadow: #094239;
  --mountain-teal: #427F77;
  --golden-wheat: #B8A678;
  --antique-sand: #978362;
  --ivory-mist: #EEEADF;
  --black-cherry: #4A151F;
  --damask-red: #6C1E2B;
  --charcoal: #161616;
  --stone: #3C3A3B;
  --white: #FFFFFF;

  --font: 'ITF Qomra Arabic', Tahoma, 'Segoe UI', sans-serif;
  --page: #F6F3EB;
  --surface: var(--white);
  --surface-soft: #F8F6F0;
  --surface-sunken: var(--ivory-mist);
  --text: var(--charcoal);
  --text-soft: #57534B;
  --heading: var(--forest);
  --primary: var(--forest);
  --primary-hover: var(--emerald-shadow);
  --on-primary: var(--white);
  --accent: var(--golden-wheat);
  --accent-soft: #EFE8D5;
  --line: #DDD5C2;
  --line-strong: #BDB39C;
  --success: #0E6B4F;
  --success-soft: #E3F1EA;
  --warning: #7A5A12;
  --warning-soft: #F6ECD2;
  --danger: var(--damask-red);
  --danger-soft: #F7E7E9;
  --info: var(--mountain-teal);
  --focus: #9C8A55;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0, 38, 35, .08);
  --shadow: 0 6px 22px rgba(0, 38, 35, .08);
  --shadow-lg: 0 16px 40px rgba(0, 38, 35, .16);
  color-scheme: light;
}

@media screen {
  html[data-theme="dark"] {
    color-scheme: dark;
    --page: #0B1413;
    --surface: #10201E;
    --surface-soft: #132623;
    --surface-sunken: #0D1B19;
    --text: #EEEADF;
    --text-soft: #C4BDAC;
    --heading: #E4D6AE;
    --primary: var(--golden-wheat);
    --primary-hover: #CDBD91;
    --on-primary: var(--forest);
    --accent-soft: #23302A;
    --line: #25403B;
    --line-strong: #3F6A63;
    --success: #7FD1AE;
    --success-soft: #12352B;
    --warning: #E7CC86;
    --warning-soft: #3A3218;
    --danger: #F0A2AD;
    --danger-soft: #3B1A20;
    --info: #9ED3CB;
    --focus: var(--golden-wheat);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow: 0 6px 22px rgba(0, 0, 0, .35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.7; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
h1, h2, h3, h4 { color: var(--heading); line-height: 1.4; margin: 0 0 .5em; }
a { color: var(--info); }
a:hover { color: var(--primary); }
p { margin: 0 0 .8em; }
[hidden] { display: none !important; }
.ltr { direction: ltr; text-align: left; unicode-bidi: plaintext; }
/* The brand face draws Latin "1" like "I"; codes, numbers and e-mails use a Latin face. */
.ltr, .latin, input[type="number"], input[type="email"], input[type="date"], input[type="datetime-local"] { font-family: 'Segoe UI', Tahoma, Arial, sans-serif; }
.muted { color: var(--text-soft); }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; top: -48px; right: 12px; background: var(--primary); color: var(--on-primary); padding: 8px 14px; border-radius: var(--radius-sm); z-index: 50; }
.skip-link:focus { top: 12px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- header / footer ---------- */
.hero { position: relative; background: linear-gradient(115deg, rgba(0, 38, 35, .97), rgba(9, 66, 57, .93)), url('/static/brand/Visual%20Identity/Patterns.jpg') center/cover; color: var(--white); border-bottom: 4px solid var(--golden-wheat); }
.hero::after { content: ""; position: absolute; inset: auto 0 -8px 0; height: 4px; background: var(--damask-red); opacity: .85; }
.hero-inner { max-width: 1180px; margin: 0 auto; padding: 18px 20px; display: flex; align-items: center; gap: 16px; }
.hero .brand-mark { width: 64px; height: 64px; object-fit: contain; flex: 0 0 auto; }
.hero h1 { color: var(--white); font-size: clamp(1.15rem, 2.4vw, 1.6rem); margin: 0; }
.hero p { margin: 2px 0 0; color: #E9DFC2; font-size: .95rem; }
.hero-actions { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }
.footer { background: var(--forest); color: #EDE6D3; text-align: center; padding: 18px 16px; margin-top: 40px; font-size: .9rem; }
.footer strong { color: var(--golden-wheat); font-weight: 600; }

/* ---------- buttons ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 9px 20px; border-radius: var(--radius-sm); border: 1px solid transparent; font: 600 1rem var(--font); cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, color .15s, box-shadow .15s; }
.button:disabled, .button[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.button.primary { background: var(--primary); color: var(--on-primary); }
.button.primary:hover:not(:disabled) { background: var(--primary-hover); color: var(--on-primary); }
.button.secondary { background: var(--accent-soft); color: var(--heading); border-color: var(--line); }
.button.secondary:hover:not(:disabled) { border-color: var(--golden-wheat); color: var(--heading); }
.button.ghost { background: transparent; color: var(--heading); border-color: var(--line-strong); }
.button.ghost:hover:not(:disabled) { background: var(--surface-soft); color: var(--heading); }
.button.danger { background: var(--danger); color: var(--white); }
.button.small { min-height: 34px; padding: 5px 12px; font-size: .9rem; }
.button.block { width: 100%; }
.hero .button.ghost { color: var(--white); border-color: rgba(255, 255, 255, .45); }
.hero .button.ghost:hover { background: rgba(255, 255, 255, .1); color: var(--white); }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: transparent; color: inherit; cursor: pointer; font: inherit; }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 24px; }
.card + .card { margin-top: 18px; }
.card-title { font-size: 1.2rem; margin: 0 0 4px; }
.card-subtitle { color: var(--text-soft); margin: 0 0 18px; }

/* ---------- forms ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px 18px; }
.field { grid-column: span 4; min-width: 0; }
.field.half { grid-column: span 6; }
.field.full, .grid > .full { grid-column: 1 / -1; }
.field.two-thirds { grid-column: span 8; }
.field label, .label { display: block; font-weight: 600; font-size: .95rem; margin-bottom: 6px; color: var(--text); }
.req { color: var(--danger); margin-inline-start: 2px; }
.optional { color: var(--text-soft); font-weight: 400; font-size: .85rem; }
input, select, textarea { width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: 400 1rem var(--font); transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 88px; resize: vertical; line-height: 1.6; }
input:hover, select:hover, textarea:hover { border-color: var(--antique-sand); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(184, 166, 120, .35); }
input[readonly], .readonly { background: var(--surface-sunken); color: var(--text-soft); cursor: default; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-sunken); color: var(--text-soft); cursor: not-allowed; opacity: .75; }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--primary); margin: 0; flex: 0 0 auto; }
input[type="number"] { direction: ltr; text-align: right; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(108, 30, 43, .12); }
.hint { display: block; color: var(--text-soft); font-size: .85rem; margin-top: 5px; line-height: 1.55; }
.keyboard-note { margin: 6px 0 0; padding: 6px 10px; border-radius: var(--radius-sm); background: var(--warning-soft); color: var(--warning); font-size: .88rem; font-weight: 600; }
.hint-warning { display: block; margin-top: 3px; color: var(--danger); font-weight: 700; }
.field-error { color: var(--danger); font-size: .88rem; font-weight: 600; margin: 6px 0 0; }
.field-error::before { content: "⚠ "; }
.input-group { display: flex; gap: 8px; align-items: stretch; }
.input-group > :first-child { flex: 1; min-width: 0; }
.button.reveal-button { width: 48px; padding: 0; flex: 0 0 auto; }
.button.reveal-button svg { display: block; }
.input-suffix { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-sunken); color: var(--text-soft); font-weight: 600; white-space: nowrap; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400 !important; cursor: pointer; }
.check span { line-height: 1.6; }

/* ---------- messages ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; border-radius: var(--radius-sm); padding: 12px 14px; border: 1px solid; margin-bottom: 16px; font-size: .95rem; }
.alert.info { background: var(--accent-soft); border-color: var(--line); color: var(--text); }
.alert.success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.alert.warning { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.alert.error { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.alert ul { margin: 4px 0 0; padding-inline-start: 20px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--accent-soft); color: var(--heading); white-space: nowrap; }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--surface-sunken); color: var(--info); }
.status-pill { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: .9rem; padding: 4px 12px; border-radius: 999px; background: var(--surface-sunken); }
.status-pill::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 3px rgba(108, 30, 43, .2); }
.status-pill.open::before { background: #1FA971; box-shadow: 0 0 0 3px rgba(31, 169, 113, .25); }
.status-pill.pending::before { background: var(--golden-wheat); box-shadow: 0 0 0 3px rgba(184, 166, 120, .3); }

.toast-region { position: fixed; top: 16px; left: 16px; z-index: 60; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--surface); color: var(--text); padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); border-inline-start: 5px solid var(--success); animation: toast-in .2s ease-out; }
.toast.error { border-color: var(--danger); }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } }

/* ---------- dialog ---------- */
.dialog-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 70; display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: min(460px, 100%); padding: 22px; border-top: 4px solid var(--golden-wheat); }
.dialog h2 { font-size: 1.15rem; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 18px; flex-wrap: wrap; }

@media (max-width: 760px) {
  .field, .field.half, .field.two-thirds { grid-column: 1 / -1; }
  .card { padding: 18px 16px; }
  .hero-inner { padding: 14px 16px; flex-wrap: wrap; }
  .hero-inner > div { flex: 1 1 200px; }
  .hero-actions { width: 100%; justify-content: flex-end; }
  .hero .brand-mark { width: 48px; height: 48px; }
  .hero p { display: none; }
}

@media print {
  body { background: #fff; color: #000; }
  .no-print, .footer, .toast-region { display: none !important; }
  .hero { background: none; color: #000; border-bottom: 2px solid #000; }
  .hero::after { display: none; }
  .hero h1, .hero p { color: #000; }
  .card { box-shadow: none; border-color: #999; break-inside: avoid; }
}
