/* ============================================================================
   سفراء الذكاء الاصطناعي — تصميم مؤسسي رسمي، هادئ، بدون زخرفة زائدة. RTL بالكامل.
   ============================================================================ */

:root {
  --primary: #17495c;
  --primary-dark: #0e3140;
  --primary-light: #e8f0f2;
  --accent: #c8863a;
  --accent-light: #faf1e3;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e6ea;
  --text: #1c2530;
  --text-muted: #5c6772;
  --text-faint: #87919b;

  --status-new-bg: #eef1f4;      --status-new-fg: #4a5560;
  --status-progress-bg: #e6eef7; --status-progress-fg: #2b5f96;
  --status-done-bg: #e2f4e6;     --status-done-fg: #1f8a3d;
  --status-closed-bg: #f0f0f0;   --status-closed-fg: #6b6b6b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(20, 30, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 30, 40, 0.08);
  --font: "Tajawal", "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 15px;
}
h1, h2, h3, h4 { font-weight: 800; margin: 0 0 8px; line-height: 1.4; }
p { margin: 0 0 10px; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
img { max-width: 100%; }

.app-root { max-width: 1080px; margin: 0 auto; padding: 24px 20px 64px; min-height: 60vh; }

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.header-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; color: var(--primary-dark); }
.brand-badge {
  width: 34px; height: 34px; border-radius: 9px; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; letter-spacing: .02em;
}

.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a, .nav button.nav-link {
  background: none; border: none; cursor: pointer;
  padding: 9px 14px; border-radius: var(--radius-sm); font-weight: 700; font-size: 14px;
  color: var(--text-muted);
}
.nav a:hover, .nav button.nav-link:hover { background: var(--bg); color: var(--text); }
.nav a.active, .nav button.nav-link.active { background: var(--primary-light); color: var(--primary-dark); }
.nav .workspace-link { border: 1px solid var(--border); margin-inline-start: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 20px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 700; font-size: 14px; cursor: pointer; transition: all .15s ease;
  background: var(--surface); color: var(--text);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-lg { padding: 14px 28px; font-size: 15.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Cards / Sections ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 20px; box-shadow: var(--shadow-sm);
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- Hero (Home) ---------- */
.hero {
  background: var(--primary-light);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 48px 32px; text-align: center; margin-bottom: 20px;
}
.hero h1 { font-size: 30px; color: var(--primary-dark); text-wrap: balance; }
.hero p.lead { font-size: 15.5px; color: var(--text-muted); max-width: 640px; margin: 0 auto 24px; text-wrap: balance; }

.callout-card { max-width: 680px; margin: 16px auto 0; text-align: center; }
.callout-card h3 { margin-bottom: 8px; }
.callout-card p { margin-bottom: 14px; }

.branch-card { display: block; text-decoration: none; color: inherit; }
.branch-card .btn { margin-top: 8px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; }
label.field-label { display: block; font-weight: 700; font-size: 13.5px; margin-bottom: 7px; color: var(--text); }
.field-hint { font-size: 12px; color: var(--text-faint); margin-top: 5px; }
input[type=text], input[type=number], input[type=time], select, textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 84px; }

.choice-group { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-pill {
  border: 1px solid var(--border); border-radius: 999px; padding: 9px 16px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--text-muted); background: var(--surface);
  user-select: none;
}
.choice-pill { position: relative; }
.choice-pill input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.choice-pill:has(input:checked) { background: var(--primary); border-color: var(--primary); color: #fff; }

.notice-box {
  background: var(--accent-light); border: 1px solid #eeddc0; color: #7a5320;
  border-radius: var(--radius-sm); padding: 11px 14px; font-size: 13px;
}
.closure-box { margin-top: 14px; }

/* ---------- Badges / Status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.status-new { background: var(--status-new-bg); color: var(--status-new-fg); }
.status-progress { background: var(--status-progress-bg); color: var(--status-progress-fg); }
.status-done { background: var(--status-done-bg); color: var(--status-done-fg); }
.status-closed { background: var(--status-closed-bg); color: var(--status-closed-fg); }
.badge-outline { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }

/* ---------- Workspace: summary tiles ---------- */
.stat-tile { text-align: center; padding: 18px 10px; }
.stat-tile-link { display: block; text-decoration: none; color: inherit; transition: all .15s ease; }
.stat-tile-link:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.stat-num { font-size: 26px; font-weight: 800; color: var(--primary-dark); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12.5px; color: var(--text-faint); margin-top: 4px; }

/* ---------- Tabs (workspace sub-nav) ---------- */
.subnav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.subnav a {
  padding: 12px 16px; font-weight: 700; font-size: 13.5px;
  color: var(--text-muted); border-bottom: 2px solid transparent; white-space: nowrap;
}
.subnav a.active { color: var(--primary-dark); border-bottom-color: var(--primary); }

.toggle-group { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 3px; margin-bottom: 16px; background: var(--surface); }
.toggle-btn { padding: 7px 18px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--text-muted); }
.toggle-btn.active { background: var(--primary); color: #fff; }

/* ---------- Filters ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; align-items: center; }
.filter-bar input[type=text] { flex: 1 1 220px; }
.filter-bar select { flex: 0 1 180px; }

/* ---------- Lists ---------- */
.list-stack { display: flex; flex-direction: column; gap: 10px; }
.list-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; text-decoration: none; color: inherit; cursor: pointer; }
.list-row:hover { border-color: var(--primary); }
.list-row-main { display: flex; flex-direction: column; gap: 4px; }
.req-title { font-weight: 800; font-size: 15px; }
.req-meta { font-size: 12.5px; color: var(--text-faint); display: flex; flex-wrap: wrap; gap: 10px; }
.req-id { font-family: monospace; font-size: 12px; color: var(--text-faint); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 25, 35, .5); display: flex; align-items: center;
  justify-content: center; z-index: 200; padding: 20px;
}
.modal-box { background: var(--surface); border-radius: var(--radius-lg); max-width: 560px; width: 100%; max-height: 88vh; overflow-y: auto; padding: 26px; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--primary-dark); color: #fff; padding: 12px 20px; border-radius: var(--radius-sm); font-size: 13.5px; box-shadow: var(--shadow-md); animation: fadein .15s ease; }
.toast.error { background: #a3382f; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Empty / loading states ---------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-faint); }
.loading-state { text-align: center; padding: 48px 20px; color: var(--text-faint); }
.config-banner {
  background: #fff4d6; color: #7a5320; padding: 12px 20px; text-align: center; font-size: 13.5px;
  border-bottom: 1px solid #e0c568;
}
.config-banner code { background: rgba(0,0,0,.06); padding: 1px 6px; border-radius: 4px; }

/* ---------- Misc ---------- */
.kv-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
@media (max-width: 560px) { .kv-list { grid-template-columns: 1fr; } }
.kv-item .k { font-size: 11.5px; color: var(--text-faint); font-weight: 700; margin-bottom: 3px; }
.kv-item .v { font-size: 14px; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); font-size: 12.5px; }
.mb-0 { margin-bottom: 0; }
.breadcrumb { font-size: 13px; color: var(--text-faint); margin-bottom: 14px; }
.breadcrumb a { color: var(--text-muted); font-weight: 700; }
.page-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.note-list { display: flex; flex-direction: column; gap: 8px; }
.note-item { padding: 10px 12px; background: var(--bg); border-radius: var(--radius-sm); }
.note-item .meta { font-size: 11px; color: var(--text-faint); margin-top: 4px; }

.site-footer { text-align: center; font-size: 12.5px; color: var(--text-faint); padding: 24px 20px 40px; }

@media (max-width: 720px) {
  .header-inner { height: auto; padding: 12px 16px; flex-wrap: wrap; }
  .nav { width: 100%; justify-content: flex-start; }
  .hero { padding: 30px 18px; }
  .hero h1 { font-size: 23px; }
  .filter-bar select, .filter-bar input[type=text] { flex: 1 1 100%; }
}
