/* بوصلة الاستثمار — التنسيق العام (الألوان في theme.css) */

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

html { -webkit-text-size-adjust: 100%; background: var(--banner); }

/* منطقة الساعة والبطارية في الآيفون: دايماً بلون البانر */
.status-shield {
  position: fixed; top: 0; inset-inline: 0; z-index: 25;
  height: env(safe-area-inset-top);
  background: var(--banner);
  pointer-events: none;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--level-1);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", -apple-system, "Segoe UI", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  font-variant-numeric: lining-nums tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.page-title { font-size: 26px; font-weight: 700; margin: 0 0 4px; line-height: 1.3; }
.heading    { font-size: 20px; font-weight: 600; margin: 0 0 12px; }
.card-title { font-size: 17px; font-weight: 600; margin: 0; }
.muted      { color: var(--text-2); }
.num        { direction: ltr; unicode-bidi: isolate; }

/* ── شاشة التحميل ── */
.splash {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--banner);
  z-index: 100;
  transition: opacity .35s ease;
}
.splash.gone { opacity: 0; pointer-events: none; }
.splash img { width: 88px; height: 88px; animation: spin-in 1.2s ease both; }
@keyframes spin-in { from { transform: rotate(-90deg) scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── شاشة الدخول ── */
.login {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 20px calc(32px + env(safe-area-inset-bottom));
  background: var(--banner);
}
.login-brand { text-align: center; color: var(--on-dark); margin-bottom: 28px; }
.login-brand img { width: 84px; height: 84px; border-radius: 22px; margin-bottom: 14px; }
.login-brand .page-title { color: var(--on-dark); }
.login-brand p { margin: 0; color: var(--on-dark-2); }

.login-card {
  width: 100%; max-width: 380px;
  background: var(--level-3);
  border-radius: 22px;
  padding: 24px 20px;
  animation: slide-up .45s ease both;
}
.login-lang { margin-top: 18px; }

/* ── الحقول والأزرار ── */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 14px; color: var(--text-2); margin-bottom: 6px; }
.input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1.5px solid transparent;
  border-radius: 14px;
  background: var(--level-4);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.input.ltr { direction: ltr; text-align: start; }
[dir="rtl"] .input.ltr { text-align: right; }

.pass-wrap { position: relative; }
.pass-wrap .input { padding-inline-end: 64px; }
.pass-toggle {
  position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--accent);
  font-size: 14px; padding: 8px 10px; border-radius: 10px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 12px 20px;
  border: 0; border-radius: 14px;
  font-weight: 600;
  transition: transform .15s ease, background .2s ease, opacity .2s ease;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost-dark { background: rgba(255,255,255,.08); color: var(--on-dark); }

.form-error {
  display: flex; gap: 8px; align-items: flex-start;
  background: color-mix(in srgb, var(--danger) 12%, var(--level-4));
  color: var(--text);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px;
}
.form-error::before { content: ""; flex: 0 0 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: var(--danger); }

/* ── الإطار الرئيسي ── */
.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.banner {
  position: sticky; top: 0; z-index: 20;
  background: var(--banner);
  color: var(--on-dark);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.banner-inner {
  max-width: 960px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
}
.banner-brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.banner-brand img { width: 34px; height: 34px; border-radius: 9px; }
.banner-brand strong { font-size: 17px; font-weight: 600; white-space: nowrap; }
.icon-btn {
  display: inline-grid; place-items: center;
  min-width: 42px; height: 42px; padding: 0 10px;
  border: 0; border-radius: 12px;
  background: rgba(255,255,255,.07); color: var(--on-dark);
  font-size: 14px; font-weight: 600;
}
.icon-btn svg { width: 20px; height: 20px; }

.offline-bar {
  background: var(--nav); color: var(--on-dark);
  font-size: 13px; text-align: center; padding: 6px 12px;
  display: flex; justify-content: center; align-items: center; gap: 8px;
}
.offline-bar::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warning); }

.main {
  flex: 1;
  width: 100%; max-width: 960px; margin: 0 auto;
  padding: 22px 16px calc(104px + env(safe-area-inset-bottom));
}
.view { animation: view-in .35s ease both; }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slide-up { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

.view-head { margin-bottom: 20px; }

/* ── البطاقات ── */
.card {
  background: var(--level-3);
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 14px;
  animation: slide-up .4s ease both;
}
.card + .card { animation-delay: .06s; }
.card .inner {
  background: var(--level-4);
  border-radius: 14px;
  padding: 14px;
  margin-top: 12px;
}

.empty {
  text-align: center;
  padding: 36px 20px;
}
.empty .empty-icon {
  width: 64px; height: 64px; margin: 0 auto 14px;
  border-radius: 20px; display: grid; place-items: center;
  background: var(--level-4); color: var(--accent);
}
.empty .empty-icon svg { width: 30px; height: 30px; }
.empty p { margin: 6px 0 0; color: var(--text-2); }

/* ── حلقة التقدم ── */
.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring { width: 120px; height: 120px; flex: 0 0 auto; }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: var(--level-2); }
.ring .bar {
  stroke: var(--strength-mid);
  stroke-linecap: round;
  transform: rotate(-90deg); transform-origin: 50% 50%;
  transition: stroke-dashoffset 1.2s cubic-bezier(.22,1,.36,1), stroke .4s ease;
}
.ring text { font-size: 26px; font-weight: 700; fill: var(--text); text-anchor: middle; dominant-baseline: central; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; padding: 4px 10px; border-radius: 999px;
  background: var(--level-4); color: var(--text-2);
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted-2); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warning); }
.dot.danger { background: var(--danger); } .dot.progress { background: var(--progress); }

/* ── شريط التابات العائم (حبة) ── */
.tabbar {
  position: fixed; z-index: 30;
  inset-inline: 12px;
  bottom: calc(2px + env(safe-area-inset-bottom));
  margin: 0 auto; max-width: 520px;
  display: flex; justify-content: space-between; gap: 2px;
  padding: 6px;
  background: var(--nav);
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(17, 28, 40, .35);
}
.tab {
  position: relative;
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 2px 6px;
  border: 0; border-radius: 999px;
  background: transparent;
  color: var(--on-dark-2);
  font-size: 11px; font-weight: 500;
  transition: background .25s ease, color .25s ease;
}
.tab svg { width: 22px; height: 22px; }
.tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tab.active { background: var(--accent); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 45%, transparent); }
.tab.active svg { color: #fff; }
.tab .badge-new {
  position: absolute; top: 5px; inset-inline-end: calc(50% - 18px);
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-light);
  box-shadow: 0 0 0 2px var(--nav);
}

/* ── النماذج من الأسفل (bottom sheet) ── */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(17, 28, 40, .45);
  opacity: 0; transition: opacity .25s ease;
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; z-index: 41;
  inset-inline: 0; bottom: 0;
  margin: 0 auto; max-width: 560px;
  max-height: 88vh; max-height: 88dvh; overflow: auto;
  background: var(--level-2);
  border-radius: 24px 24px 0 0;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.22,1,.36,1);
}
.sheet.open { transform: none; }
.sheet-grip { width: 42px; height: 5px; border-radius: 3px; background: var(--muted-2); margin: 0 auto 14px; opacity: .6; }
.sheet .heading { margin-bottom: 14px; }

.menu-list { list-style: none; margin: 0; padding: 0; background: var(--level-3); border-radius: 18px; overflow: hidden; }
.menu-list li + li { border-top: 1px solid var(--level-2); }
.menu-item {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; min-height: 56px;
  border: 0; background: transparent; text-align: start;
  transition: background .2s ease;
}
.menu-item:active { background: var(--level-4); }
.menu-item svg { width: 22px; height: 22px; color: var(--accent); flex: 0 0 auto; }
.menu-item .label { flex: 1; }
.menu-item .tag { font-size: 12px; color: var(--muted); }
.menu-item .chev { width: 18px; height: 18px; color: var(--muted-2); }
[dir="rtl"] .menu-item .chev { transform: scaleX(-1); }

/* ── شاشة كبيرة ── */
@media (min-width: 768px) {
  .main { padding-top: 32px; }
  .tabbar { max-width: 600px; bottom: 20px; }
  .tab { flex-direction: row; justify-content: center; gap: 8px; font-size: 14px; padding: 10px 6px; }
  .tab .badge-new { top: 8px; inset-inline-end: 10px; }
  .sheet { bottom: 50%; transform: translateY(calc(50% + 100vh)); border-radius: 24px; }
  .sheet.open { transform: translateY(50%); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ───────── المرحلة 2أ: الأفكار ───────── */

.small { font-size: 13px; }
.center { text-align: center; }
.danger-text { color: var(--danger); }

/* رسالة قصيرة */
.toast {
  position: fixed; z-index: 60; inset-inline: 16px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  margin: 0 auto; max-width: 420px;
  background: var(--banner); color: var(--on-dark);
  padding: 12px 16px; border-radius: 14px; text-align: center;
  font-size: 14px; box-shadow: 0 10px 30px rgba(17,28,40,.3);
  opacity: 0; transform: translateY(12px); transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: none; }
.toast-warn { border-inline-start: 4px solid var(--warning); }
.toast-danger { border-inline-start: 4px solid var(--danger); }

/* تحميل */
.loading-card {
  height: 140px; border-radius: 20px; margin-bottom: 14px;
  background: linear-gradient(90deg, var(--level-2) 25%, var(--level-3) 50%, var(--level-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* أزرار إضافية */
.btn-small { min-height: 38px; padding: 6px 14px; font-size: 14px; border-radius: 12px; background: var(--accent); color: #fff; }
.btn-soft { background: var(--level-4); color: var(--accent-dark); }
.btn svg { width: 20px; height: 20px; }
.sheet-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; }
.sheet-actions .btn { flex: 1; }
.sheet-actions > span { flex: 1; }

/* اختيار من قائمة (حبات) */
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.pick {
  min-height: 42px; padding: 8px 14px;
  border: 1.5px solid transparent; border-radius: 999px;
  background: var(--level-4); color: var(--text-2); font-size: 14px;
  transition: background .2s ease, color .2s ease, border-color .2s ease, transform .15s ease;
}
.pick:active { transform: scale(.96); }
.pick.on { background: var(--accent); color: #fff; }

/* الإدخال على خطوات */
.wiz-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.strength-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; font-size: 13px;
  background: var(--level-4); color: var(--text-2);
}
.strength-pill b { color: var(--c, var(--accent)); font-size: 16px; transition: color .3s ease; }
.steps-bar { height: 6px; border-radius: 3px; background: var(--level-4); overflow: hidden; }
.steps-bar > div { height: 100%; background: var(--accent); border-radius: 3px; transition: width .45s cubic-bezier(.22,1,.36,1); }
.step-label { font-size: 13px; color: var(--text-2); margin: 8px 0 14px; }
.wiz-body { animation: view-in .3s ease both; }
.note-ok { font-size: 13px; background: color-mix(in srgb, var(--ok) 14%, var(--level-4)); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; }
textarea.input { resize: vertical; min-height: 90px; line-height: 1.6; }

/* تقسيمات داخل الصفحة */
.segments {
  display: flex; gap: 4px; padding: 4px; margin-bottom: 14px;
  background: var(--level-2); border-radius: 14px; overflow-x: auto; scrollbar-width: none;
}
.segments::-webkit-scrollbar { display: none; }
.seg {
  flex: 1 0 auto; min-height: 40px; padding: 6px 12px;
  border: 0; border-radius: 11px; background: transparent;
  color: var(--text-2); font-size: 14px; white-space: nowrap;
  transition: background .2s ease, color .2s ease;
}
.seg.on { background: var(--level-4); color: var(--text); font-weight: 600; box-shadow: 0 1px 4px rgba(17,28,40,.08); }
.seg-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent-light); color: var(--accent-dark); font-size: 12px; margin-inline-start: 4px; }
.seg-body { animation: view-in .3s ease both; }
.seg-body > * + * { margin-top: 10px; }
.section-label { font-size: 14px; font-weight: 600; color: var(--text-2); margin: 4px 0 8px; }

/* بطاقات الأفكار */
.idea-card {
  display: block; width: 100%; text-align: start;
  background: var(--level-3); border: 0; border-radius: 20px; padding: 16px 18px;
  animation: slide-up .4s ease both; transition: transform .15s ease;
}
.idea-card:active { transform: scale(.985); }
.idea-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.strength-num { font-size: 22px; font-weight: 700; line-height: 1; }
.meter { height: 6px; border-radius: 3px; background: var(--level-2); overflow: hidden; margin: 6px 0 10px; }
.meter > div { height: 100%; border-radius: 3px; background: var(--accent); transition: width .8s cubic-bezier(.22,1,.36,1); }
.idea-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* المراحل */
.stage-new .dot { background: var(--muted-2); }
.stage-studying .dot { background: var(--progress); }
.stage-rated .dot { background: var(--accent); }
.stage-chosen .dot { background: var(--ok); }
.stage-archived .dot { background: var(--muted); }

/* صفوف */
.row-card {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: start;
  background: var(--level-3); border: 0; border-radius: 16px; padding: 12px 14px; min-height: 58px;
}
.row-card > svg { width: 22px; height: 22px; color: var(--accent); flex: 0 0 auto; }
.row-card .label { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-card .label small { font-size: 12px; margin-top: 2px; }
.q-row .dot { flex: 0 0 auto; }

.add-row { display: flex; gap: 8px; }
.add-row .input { flex: 1; min-height: 46px; }
.add-row .btn { min-height: 46px; }

/* زر الفكرة السريعة العائم */
.fab {
  position: fixed; z-index: 29;
  inset-inline-end: 18px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  width: 54px; height: 54px; border-radius: 50%;
  border: 0; background: var(--accent); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 45%, transparent);
  transition: transform .2s ease;
}
.fab:active { transform: scale(.92); }
.fab svg { width: 24px; height: 24px; }
@media (min-width: 768px) { .fab { bottom: 100px; inset-inline-end: calc(50% - 300px); } }

/* صفحة الفكرة */
.back-link { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--accent); padding: 4px 0; margin-bottom: 6px; font-size: 14px; }
.back-link svg { width: 18px; height: 18px; }
[dir="ltr"] .back-link svg { transform: scaleX(-1); }
.idea-head { display: flex; align-items: flex-start; gap: 14px; }
.ring-sm { width: 76px; height: 76px; }
.ring-sm circle { stroke-width: 8; }
.ring-sm text { font-size: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.callout { background: color-mix(in srgb, var(--accent-light) 35%, var(--level-3)); }
.callout p { margin: 0 0 10px; }
.facts { margin: 0; }
.facts dt { font-size: 13px; color: var(--text-2); }
.facts dd { margin: 2px 0 12px; white-space: pre-wrap; }
.fact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.fact-grid > div { background: var(--level-3); border-radius: 12px; padding: 10px 12px; }
.fact-grid span { display: block; font-size: 12px; color: var(--text-2); }
.fact-grid b { font-weight: 600; font-size: 14px; }
.gate-ok { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checklist li { display: flex; align-items: center; gap: 10px; color: var(--text); }
.checklist .tick { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--muted-2); flex: 0 0 auto; position: relative; }
.checklist li.done { color: var(--text-2); }
.checklist li.done .tick { background: var(--ok); border-color: var(--ok); }
.checklist li.done .tick::after { content: ""; position: absolute; inset: 3px 5px 5px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

/* الأدلة والتعليقات */
.ev-card { background: var(--level-3); border-radius: 16px; padding: 14px; animation: slide-up .35s ease both; }
.ev-top { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ev-details { margin: 6px 0 0; white-space: pre-wrap; color: var(--text-2); }
.ev-link { display: inline-block; margin-top: 6px; color: var(--accent); direction: ltr; word-break: break-all; font-size: 14px; }
.ev-img { display: block; width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; margin-top: 10px; background: var(--level-2); cursor: zoom-in; }
.full-img { width: 100%; border-radius: 14px; }
.icon-mini { border: 0; background: transparent; color: var(--muted-2); width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; }
.icon-mini svg { width: 18px; height: 18px; }
.chip-btn { border: 0; cursor: pointer; }
.chip-btn[disabled] { cursor: default; }
.comment { background: var(--level-3); border-radius: 16px; padding: 12px 14px; }
.comment-head { display: flex; align-items: center; gap: 8px; }
.comment-head .icon-mini { margin-inline-start: auto; }
.comment p { margin: 4px 0 0; white-space: pre-wrap; }
.file-pick {
  display: flex; align-items: center; justify-content: center;
  min-height: 50px; border: 1.5px dashed var(--muted-2); border-radius: 14px;
  color: var(--accent); cursor: pointer; background: var(--level-4);
}
.file-pick.disabled { color: var(--muted-2); cursor: not-allowed; }
