/* هوية Mudif البصرية — مبادئ أبل: المحتوى أولاً، مساحات واسعة، ولون واحد للعلامة.
   الكحلي (Midnight Navy): ثقة وسلطة هادئة ورصانة، لون البنوك الخاصة والساعات الفاخرة، ومختلف عن أخضر واتساب وأزرق Meta الفاتح.
   الأبيض: نقاء ومساحة. لا لون ثالث للعلامة؛ الأحمر للأخطاء فقط.
   ملاحظة: لا letter-spacing على النص العربي، لأنه يكسر اتصال الحروف. */
:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --field: #f4f6fa;
  --text: #0b1a33;
  --muted: #5b6b85;
  --line: #d5dce8;
  --card-border: rgba(11, 26, 51, 0.06);
  --brand: #14284b;
  --brand-hover: #0b1a33;
  --brand-text: #ffffff;
  --brand-soft: #e7ecf5;
  --danger: #d70015;
  --ok-bg: #e7ecf5;
  --warn-bg: #fff1dc;
  --segment: #e6eaf2;
  --radius: 22px;
  --shadow: 0 1px 2px rgba(11, 26, 51, 0.04), 0 10px 32px rgba(11, 26, 51, 0.06);
  --shadow-lg: 0 20px 50px -12px rgba(11, 26, 51, 0.14), 0 2px 6px rgba(11, 26, 51, 0.05);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #050b18;
    --card: #0d1729;
    --field: #16223a;
    --text: #f5f7fb;
    --muted: #8e9ab2;
    --line: #22304b;
    --card-border: rgba(255, 255, 255, 0.08);
    --brand: #ffffff;
    --brand-hover: #e7ecf5;
    --brand-text: #0b1a33;
    --brand-soft: #1a2742;
    --danger: #ff6961;
    --ok-bg: #1a2742;
    --warn-bg: #3a2a14;
    --segment: #16223a;
    --shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 12px 32px rgba(0, 0, 0, 0.35);
    --shadow-lg: inset 0 1px 0 rgba(255, 255, 255, 0.09), 0 24px 60px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 -apple-system, BlinkMacSystemFont, "SF Arabic", "IBM Plex Sans Arabic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
main { max-width: 760px; margin: 0 auto; padding: 16px; }
h1, h2, h3 { line-height: 1.22; margin: 0 0 8px; font-weight: 700; text-wrap: balance; }
h1 { font-size: 30px; }
h2 { font-size: 21px; }
p { text-wrap: pretty; }
a { color: var(--brand); text-underline-offset: 4px; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* شعار */
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); }
.brand img { width: 32px; height: 32px; display: block; }
.brand span { font: 600 22px/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif; letter-spacing: -0.02em; }

/* بطاقات */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 12px 0;
  box-shadow: var(--shadow);
}
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* أزرار بشكل حبة الدواء كما في أبل */
button, .button {
  font: inherit; font-size: 16px; border: 0; background: var(--segment); color: var(--text);
  border-radius: 980px; padding: 9px 18px; cursor: pointer; text-decoration: none; display: inline-block;
  transition: background 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
button:hover:not(:disabled), .button:hover { filter: brightness(0.97); }
button:active:not(:disabled), .button:active { transform: scale(0.97); }
button.primary, .button.primary { background: var(--brand); color: var(--brand-text); font-weight: 600; }
button.primary:hover:not(:disabled), .button.primary:hover { background: var(--brand-hover); filter: none; }
button.danger { color: var(--danger); }
button:disabled { opacity: 0.5; cursor: default; transform: none; }

/* حقول الإدخال */
input, select, textarea {
  font: inherit; width: 100%; padding: 11px 13px; border: 1px solid color-mix(in srgb, var(--line) 65%, transparent); border-radius: 13px;
  background: var(--field); color: var(--text); transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); background: var(--card); }
label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-top: 10px; }
label > input, label > select, label > textarea { margin-top: 5px; font-weight: 400; }

.badge { font-size: 13px; font-weight: 600; padding: 4px 11px; border-radius: 980px; background: var(--ok-bg); white-space: nowrap; }
.badge.off { background: var(--warn-bg); }

/* تبويبات بشكل Segmented Control من iOS */
.tabs { display: flex; gap: 3px; padding: 4px; border-radius: 14px; background: var(--segment); margin-top: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 1; border-radius: 10px; background: none; color: var(--muted); padding: 8px 14px; white-space: nowrap; font-size: 15px; font-weight: 600; }
.tabs button.active { background: var(--card); color: var(--text); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
.price { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* المحادثة بأسلوب iMessage: ردود المحل بلون العلامة */
.chat-log { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; min-height: 120px; }
.bubble { max-width: 82%; padding: 10px 15px; border-radius: 20px; white-space: pre-wrap; unicode-bidi: plaintext; text-align: start; font-size: 16px; line-height: 1.5; }
.bubble.user { align-self: flex-start; background: var(--segment); border-bottom-right-radius: 6px; }
.bubble.model { align-self: flex-end; background: var(--brand); color: var(--brand-text); border-bottom-left-radius: 6px; }
.bubble.photo { padding: 4px; width: 220px; max-width: 70%; aspect-ratio: 1; object-fit: cover; }
.tag { align-self: center; font-size: 13px; color: var(--muted); background: var(--brand-soft); padding: 4px 12px; border-radius: 980px; text-align: center; }

.import-row { display: grid; grid-template-columns: auto 2fr 1fr; gap: 8px; align-items: center; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.import-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--brand); }
.hidden { display: none !important; }
