/* المصمم العراقي: الواجهة */
:root {
  --brand: #0F2B8F;
  --brand-dark: #0A1F6B;
  --brand-soft: #DCE8FB;
  --brand-tint: #F4F8FF;
  --ground: #EFF6FE;
  --surface: #FFFFFF;
  --ink: #0B1B4D;
  --ink-2: #3D4C7A;
  --muted: #4A5785;
  --line: #DCE8FB;
  --line-2: #C9D8F7;
  --warn: #9A3B10;
  --warn-bg: #FCE7DC;
  --accent: #E0662E;
  --ok: #14532D;
  --ok-bg: #E3F4EA;
  --ok-strong: #15803D;
  --danger: #B42318;
  --danger-bg: #FDE8E6;
  --star: #E0A42E;
  --radius: 18px;
  --radius-sm: 12px;
  --font: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --display: 'Alexandria', 'IBM Plex Sans Arabic', sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink); font-family: var(--font);
  font-size: 15px; line-height: 1.6; -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand); }
img, video { max-width: 100%; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; margin: 0; line-height: 1.3; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #7FA2F0; outline-offset: 2px; }

/* ---------- الهيكل ---------- */
.shell { min-height: 100dvh; display: flex; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(239, 246, 254, 0.94); backdrop-filter: blur(10px);
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.brand-sm { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--brand); }
.brand-sm img { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.brand-sm span { font-family: var(--display); font-weight: 800; font-size: 17px; white-space: nowrap; }
.content { width: 100%; max-width: 760px; margin: 0 auto; padding: 16px 16px calc(96px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 16px; }
.content.wide { max-width: 1180px; }
.page-head { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.page-head h1 { font-size: 22px; min-width: 0; overflow-wrap: anywhere; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* القائمة الجانبية: منسدلة على الهاتف، ثابتة على الحاسوب */
.sidebar {
  position: fixed; top: 0; bottom: 0; inset-inline-start: 0; z-index: 45; width: min(300px, 86vw);
  background: var(--surface); display: flex; flex-direction: column; gap: 10px; padding: 16px 14px calc(16px + var(--safe-bottom));
  overflow-y: auto; transform: translateX(105%); transition: transform .22s ease; box-shadow: -12px 0 32px rgba(11,27,77,.12);
}
[dir=rtl] .sidebar { transform: translateX(105%); }
.menu-open .sidebar { transform: none; }
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(11,27,77,.4); opacity: 0; pointer-events: none; transition: opacity .2s; }
.menu-open .scrim { opacity: 1; pointer-events: auto; }
.menu-open { overflow: hidden; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px 6px; }
.brand img { width: 52px; height: 52px; border-radius: 50%; }
.brand-name { flex: 1; font-family: var(--display); font-weight: 900; font-size: 19px; color: var(--brand); }
.acct { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: var(--brand-tint); border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.menu { display: flex; flex-direction: column; gap: 2px; }
.menu a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; text-decoration: none; color: var(--ink-2); font-weight: 600; position: relative; min-height: 44px; }
.menu a:hover { background: var(--brand-tint); }
.menu a.on { background: var(--brand-soft); color: var(--brand); }
.menu svg { width: 20px; height: 20px; flex-shrink: 0; }
.menu .dot-badge { position: static; margin-inline-start: auto; }
.sidebar .spacer { flex: 1; min-height: 8px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; padding: 6px 4px calc(8px + var(--safe-bottom));
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 48px; justify-content: center;
  text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 500; position: relative; text-align: center;
}
.tabbar a.on { color: var(--brand); font-weight: 700; }
.tabbar svg { width: 22px; height: 22px; }

@media (min-width: 960px) {
  .sidebar { position: sticky; transform: none !important; width: 264px; flex-shrink: 0; height: 100dvh; box-shadow: none; border-inline-end: 1px solid var(--line); z-index: 1; }
  .scrim, .menu-btn, .drawer-close, .tabbar { display: none !important; }
  .topbar .brand-sm { visibility: hidden; }
  .topbar { justify-content: flex-end; }
  .content { padding-bottom: 48px; }
  .menu-open { overflow: auto; }
}
@media (prefers-reduced-motion: reduce) { .sidebar, .scrim { transition: none; } }

.dot-badge {
  position: absolute; top: 4px; inset-inline-end: calc(50% - 18px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}

/* ---------- معرض الأعمال ---------- */
.works { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.work { position: relative; border-radius: 14px; overflow: hidden; background: var(--brand-soft); aspect-ratio: 1 / 1; border: 1px solid var(--line); }
.work img, .work video { width: 100%; height: 100%; object-fit: cover; display: block; }
.work .cap { position: absolute; inset-inline: 0; bottom: 0; padding: 18px 10px 8px; background: linear-gradient(transparent, rgba(11,27,77,.75)); color: #fff; font-size: 12px; font-weight: 600; }
.work .badge { position: absolute; top: 8px; inset-inline-start: 8px; }
.work .del { position: absolute; top: 6px; inset-inline-end: 6px; width: 36px; height: 36px; border-radius: 10px; border: none; background: rgba(255,255,255,.92); color: var(--danger); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.work .del svg { width: 18px; height: 18px; }
.work button.open { all: unset; position: absolute; inset: 0; cursor: zoom-in; }
.profile-head { display: flex; align-items: center; gap: 14px; }
.profile-head .avatar { width: 68px; height: 68px; font-size: 26px; }
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(11,27,77,.88); display: flex; align-items: center; justify-content: center; padding: 16px; }
.lightbox img, .lightbox video { max-width: 100%; max-height: 86dvh; border-radius: 12px; }
.lightbox .icon-btn { position: absolute; top: 16px; inset-inline-end: 16px; }

/* ---------- عناصر ---------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; border: 1px solid var(--line); }
.card.flat { border: none; }
.card.hero { background: var(--brand); color: #fff; border: none; }
.card.hero .muted { color: #C9D8F7; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 700; }
.big-num { font-family: var(--display); font-weight: 800; font-size: 38px; line-height: 1.05; }
.num { font-family: var(--display); font-weight: 800; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.center { text-align: center; }
.hidden { display: none !important; }
.sep { height: 1px; background: var(--line); border: 0; margin: 4px 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border-radius: 14px; border: 1.5px solid transparent; background: var(--brand); color: #fff; font-weight: 700; font-size: 15px;
  cursor: pointer; text-decoration: none; transition: background .15s, transform .1s; white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: scale(0.98); }
.btn[disabled] { background: var(--brand-soft); color: var(--muted); cursor: not-allowed; transform: none; }
.btn.block { width: 100%; }
.btn.lg { min-height: 54px; font-family: var(--display); font-weight: 800; font-size: 16px; border-radius: 16px; }
.btn.ghost { background: var(--surface); color: var(--brand); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--brand-tint); }
.btn.soft { background: var(--brand-soft); color: var(--brand); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: #F3B8B2; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.ok { background: var(--ok-strong); }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.white { background: #fff; color: var(--brand); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 1.5px solid var(--line-2); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; position: relative; color: var(--brand); text-decoration: none; flex-shrink: 0;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .dot-badge { top: -6px; inset-inline-end: -6px; }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.gray { background: #EEF1F7; color: var(--muted); }
.chip.danger { background: var(--danger-bg); color: var(--danger); }
.chip.light { background: rgba(255,255,255,0.16); color: #fff; }

.bar { height: 8px; border-radius: 999px; background: #E6EEFB; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.slots { display: flex; gap: 6px; }
.slots span { flex: 1; height: 8px; border-radius: 999px; background: var(--brand-soft); }
.slots span.on { background: var(--brand); }

/* ---------- النماذج ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 14px; font-weight: 600; }
.input, .field input:not([type=checkbox]):not([type=radio]):not([type=file]), .field select, .field textarea {
  width: 100%; min-height: 48px; border-radius: 14px; border: 1.5px solid var(--line-2); background: var(--surface);
  padding: 10px 14px; font-size: 16px; color: var(--ink);
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgba(15,43,143,0.12); }
.hint { font-size: 12px; color: var(--muted); }

.choice {
  display: flex; align-items: center; gap: 12px; text-align: start; width: 100%; border-radius: 16px; padding: 14px 16px; min-height: 60px;
  background: var(--surface); border: 1.5px solid var(--line); cursor: pointer; color: var(--ink);
}
.choice:hover { border-color: var(--line-2); }
.choice.on { border: 2px solid var(--brand); background: var(--brand-tint); padding: 13.5px 15.5px; }
.choice .radio { width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%; border: 2px solid #9DB4E8; background: #fff; }
.choice.on .radio { border: 7px solid var(--brand); }
.choice .price { font-family: var(--display); font-weight: 800; color: var(--brand); white-space: nowrap; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; background: var(--brand-soft); padding: 5px; border-radius: 14px; }
.seg button { min-height: 42px; border: none; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.seg button.on { background: #fff; color: var(--brand); box-shadow: 0 1px 2px rgba(11,27,77,0.08); }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line-2); background: #fff; font-weight: 600; font-size: 13px; cursor: pointer; }
.pill.on { background: var(--brand); color: #fff; border-color: var(--brand); }

.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 110px; border-radius: 16px;
  border: 2px dashed #9DB4E8; background: #F7FAFF; color: var(--brand); cursor: pointer; text-align: center; padding: 14px; position: relative;
}
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop svg { width: 28px; height: 28px; }
.file-list { display: flex; flex-direction: column; gap: 6px; }
.file-item { display: flex; align-items: center; gap: 10px; background: var(--brand-tint); border-radius: 12px; padding: 8px 12px; font-size: 13px; }

.alert { border-radius: 14px; padding: 12px 14px; font-size: 14px; line-height: 1.7; }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.info { background: var(--brand-soft); color: var(--brand); }
.alert.danger { background: var(--danger-bg); color: var(--danger); }

/* ---------- القوائم ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; flex-direction: column; gap: 8px; background: var(--surface); border-radius: var(--radius); padding: 14px 16px;
  border: 1px solid var(--line); text-decoration: none; color: var(--ink);
}
a.item:hover { border-color: var(--line-2); }
.item.attn { border: 1.5px solid var(--accent); }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 17px; flex-shrink: 0;
}
.stars { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-size: 13px; }
.stars svg { width: 14px; height: 14px; fill: var(--star); stroke: var(--star); }
.rate { display: flex; gap: 6px; justify-content: center; }
.rate button { width: 46px; height: 46px; border: none; background: none; cursor: pointer; padding: 4px; }
.rate svg { width: 100%; height: 100%; fill: #E2E8F5; stroke: none; }
.rate button.on svg { fill: var(--star); }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty svg { width: 44px; height: 44px; color: #9DB4E8; }

/* ---------- المعاينة المحمية ---------- */
.preview { position: relative; border-radius: 18px; overflow: hidden; background: #0B1B4D; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.preview img, .preview video { display: block; width: 100%; height: auto; pointer-events: none; }
.preview video { pointer-events: auto; }
.preview .shield { position: absolute; inset: 0; }
.preview .tag {
  position: absolute; top: 10px; inset-inline-end: 10px; display: flex; align-items: center; gap: 6px; background: rgba(11,27,77,0.8);
  color: #fff; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px;
}
.preview .wm { position: absolute; inset: -50%; transform: rotate(-30deg); display: flex; flex-direction: column; justify-content: space-around; pointer-events: none; }
.preview .wm span { white-space: nowrap; font-family: var(--display); font-weight: 800; font-size: 18px; color: rgba(255,255,255,0.3); }
.thumbs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.thumbs button { flex-shrink: 0; border: 2px solid transparent; border-radius: 12px; padding: 0; background: var(--brand-soft); cursor: pointer; font-size: 12px; font-weight: 700; color: var(--brand); width: 64px; height: 44px; }
.thumbs button.on { border-color: var(--brand); }

/* ---------- المحادثة ---------- */
.chat { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 86%; padding: 9px 13px; border-radius: 16px; font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.msg.them { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-start-start-radius: 4px; }
.msg.me { align-self: flex-end; background: var(--brand-soft); border-start-end-radius: 4px; }
.msg.sys { align-self: center; background: #EEF1F7; color: var(--ink-2); font-size: 13px; text-align: center; max-width: 100%; }
.msg.rev { align-self: flex-end; background: var(--warn-bg); color: #5C2408; border-start-end-radius: 4px; }
.msg .who { display: block; font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; min-height: 48px; max-height: 140px; border-radius: 14px; border: 1.5px solid var(--line-2); padding: 11px 14px; resize: none; background: #fff; font-size: 16px; }

/* ---------- الصفحات الأولى ---------- */
.auth { min-height: 100dvh; display: flex; flex-direction: column; max-width: 460px; margin: 0 auto; padding: 48px 20px 32px; gap: 24px; }
.auth .logo-big { width: 230px; height: auto; }
.role-card { display: flex; align-items: center; gap: 14px; text-decoration: none; border-radius: 18px; padding: 18px 20px; min-height: 76px; }
.role-card.primary { background: var(--brand); color: #fff; }
.role-card.secondary { background: #fff; color: var(--ink); border: 1.5px solid var(--line-2); }
.role-card svg { width: 28px; height: 28px; flex-shrink: 0; }

/* ---------- الجداول (لوحة الإدارة) ---------- */
.table-wrap { overflow-x: auto; background: #fff; border-radius: var(--radius); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 14px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 700; background: var(--brand-tint); }
tr:last-child td { border-bottom: none; }
td a { font-weight: 600; }
.stat { background: #fff; border-radius: 16px; border: 1px solid var(--line); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--ink); }
.stat .num { font-size: 26px; color: var(--brand); }
.stat.attn { border-color: var(--accent); }

/* ---------- النوافذ والتنبيهات ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(11,27,77,0.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 560px; border-radius: 24px 24px 0 0; padding: 22px 20px calc(24px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 14px; max-height: 90dvh; overflow-y: auto; }
@media (min-width: 640px) { .sheet-back { align-items: center; } .sheet { border-radius: 24px; } }
.toast {
  position: fixed; bottom: calc(90px + var(--safe-bottom)); left: 50%; transform: translateX(-50%); z-index: 60; background: var(--ink);
  color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(11,27,77,0.25);
  animation: toast-in .2s ease-out;
}
.toast.error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } .btn { transition: none; } }

.loading { display: flex; justify-content: center; padding: 48px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.btn.sm svg { width: 16px; height: 16px; }

/* الشروط والأحكام وسياسة الخصوصية */
.seg a { min-height: 42px; border-radius: 10px; color: var(--muted); font-weight: 700; display: flex; align-items: center; justify-content: center; text-decoration: none; font-size: 14px; }
.seg a.on { background: #fff; color: var(--brand); box-shadow: 0 1px 2px rgba(11,27,77,0.08); }
.legal-page { max-width: 760px; }
.legal { line-height: 1.95; font-size: 15px; color: var(--ink-2); }
.legal h3 { font-size: 17px; color: var(--brand); margin: 22px 0 8px; }
.legal ol { margin: 0; padding-inline-start: 22px; display: grid; gap: 6px; }
.legal p { margin: 8px 0; }
.legal b { color: var(--ink); }
.sheet .legal { font-size: 14px; }
.legal-agree a { font-weight: 700; text-decoration: underline; }

/* محتوى ثابت تقرؤه محركات البحث، ويستبدله التطبيق عند التحميل */
.seo-intro { gap: 12px; text-align: center; align-items: center; justify-content: center; }
.seo-intro h1 { font-size: 34px; color: var(--brand); }
.seo-intro h2 { font-size: 17px; color: var(--ink); margin-top: 8px; }
.seo-intro p { color: var(--ink-2); line-height: 1.8; max-width: 420px; }
