/* ════════════════════════════════════════════════════════════════
   مذكرات إيريس — styles.css v2
   واجهة PWA عربية RTL · هوية MyT Studio · أوفلاين (بلا خطوط خارجية)
   ────────────────────────────────────────────────────────────────
   v2 — التخطيط المحادثاتي: مربع الكتابة دوك ثابت أسفل الشاشة
        (body flex عمودي 100dvh · القوائم تتوسط وتتمرر · الإدخال أسفل)
   عقد الأنماط (مطابق لبنية app.js الفعلية — تحققت منه):
   .item-card (و .item مرادف) = بطاقة البند · .item-card.done = منجز
   .item-check (و .check مرادف) = مربع الإنجاز (input checkbox فعلي)
   .badge + .cat-grocery / .cat-pharmacy / .cat-electronics / .cat-work /
            .cat-home / .cat-car / .cat-money / .cat-general
   .question-row / .question-text / .question-answer / .question-submit
   .empty-note = الحالة الفارغة التي يصدّرها app.js
   ملاحظة: app.js يتحكم بالظهور عبر style.display السطري — لذا قاعدة
   [hidden] هنا بلا !important وفي آخر الملف (لا تصطدم بتبديل التبويبات)
   ════════════════════════════════════════════════════════════════ */

/* ─────────── أساسيات ومتغيرات ─────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0F172A;            /* كحلي داكن — خلفية التطبيق */
  --card: #1E293B;          /* البطاقات أفتح قليلاً */
  --card-hover: #263449;
  --purple: #8B5CF6;        /* بنفسجي MyT Studio */
  --purple-deep: #7C3AED;
  --turquoise: #2DD4BF;     /* فيروزي MyT Studio */
  --text: #F8FAFC;          /* نصوص بيضاء */
  --text-dim: #94A3B8;
  --border: rgba(148, 163, 184, 0.16);
  --radius: 16px;
  --radius-sm: 12px;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dock-h: 84px;           /* ارتفاع دوك الإدخال التقريبي (لشريط التراجع) */
}

html {
  font-size: 17px;                 /* حجم أساسي 16px+ (عربي مريح) */
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Kufi Arabic",
               "Noto Sans Arabic", Tahoma, Arial, sans-serif;   /* خطوط نظامية — أوفلاين */
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.65;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

/* توهج خلفية خفيف بهوية MyT Studio (بنفسجي + فيروزي) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(600px 420px at 88% -5%, rgba(139, 92, 246, 0.16), transparent 70%),
    radial-gradient(520px 400px at 0% 110%, rgba(45, 212, 191, 0.10), transparent 70%);
}

::selection { background: rgba(139, 92, 246, 0.45); }
:focus-visible { outline: 2px solid var(--turquoise); outline-offset: 2px; }

/* ─────────── الرأس (أعلى الشاشة — عنصر flex لا يتحرك) ─────────── */
.app-header {
  flex-shrink: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--border);
}

.app-title { font-size: 1.35rem; font-weight: 800; }

.accent {
  background: linear-gradient(90deg, var(--purple), var(--turquoise));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 1.25rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 200ms var(--spring), border-color .15s ease, background .15s ease;
}
.icon-btn:active { transform: scale(.9); }

/* ─────────── المنطقة الوسطى: تبويبات + قوائم + تذييل (تتمرر) ─────────── */
.lists {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px 14px;
}

/* التبويبات تلتصق أعلى القائمة أثناء التمرير */
.tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 12px 0 10px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1;
  min-height: 44px;
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 200ms ease, color 200ms ease, box-shadow 200ms ease;
}
.tab.active {
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  color: #fff;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
}

.tab-count {
  font-size: .72rem;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  display: inline-grid;
  place-items: center;
}
.tab-count:empty { display: none; }

/* عداد البنود */
.items-count {
  flex-shrink: 0;
  margin-inline-start: 2px;
  min-width: 30px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(45, 212, 191, 0.14);
  border: 1px solid rgba(45, 212, 191, 0.3);
  color: var(--turquoise);
  font-size: .8rem;
  font-weight: 800;
  display: inline-grid;
  place-items: center;
}

/* ─────────── القوائم وبطاقات البنود ─────────── */
.list {
  list-style: none;
  display: block;   /* app.js يفرض display:block سطرياً — فلا flex gap */
}

.item, .item-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  margin-bottom: 10px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  transition: border-color .18s ease, transform 200ms var(--spring), opacity .2s ease,
              box-shadow .18s ease;
  animation: item-in .25s ease both;
}
.list > :last-child { margin-bottom: 0; }
@media (hover: hover) {
  .item:hover, .item-card:hover {
    border-color: rgba(139, 92, 246, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(139, 92, 246, 0.10);
  }
}

/* مربع الإنجاز */
.check {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin-top: 2px;
  border-radius: 9px;
  border: 2px solid rgba(148, 163, 184, 0.45);
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1rem;
  color: transparent;
  transition: all 180ms var(--spring);
}
.check:active, input.item-check:active { transform: scale(.85); }
.item.done .check, .item-card.done .check {
  background: var(--turquoise);
  border-color: var(--turquoise);
  color: #0F172A;
}
/* مربع الإنجاز الفعلي من app.js (input checkbox) — مظهر مخصص */
input.item-check {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin: 2px 0 0;
  border-radius: 9px;
  border: 2px solid rgba(148, 163, 184, 0.45);
  background: transparent;
  cursor: pointer;
  transition: all 180ms var(--spring);
}
input.item-check:checked {
  background-color: var(--turquoise);
  border-color: var(--turquoise);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230F172A' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>");
  background-size: 16px;
  background-position: center;
  background-repeat: no-repeat;
}

/* جسم البطاقة: النص + الشارة + الوقت */
.item-body { flex: 1; min-width: 0; }

.item-text {
  font-size: 1.02rem;
  line-height: 1.6;
  word-break: break-word;
  transition: color .2s ease, opacity .2s ease;
}

.item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.time {
  font-size: .8rem;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* حالة المنجز: يتوسطه خط + باهت */
.item.done, .item-card.done { opacity: .55; }
.item.done .item-text, .item-card.done .item-text {
  text-decoration: line-through;
  text-decoration-color: rgba(248, 250, 252, 0.55);
}

/* ─────────── شارات الفئات (ألوان مميزة + خلفيات شفافة) ─────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  border: 1px solid transparent;
}
.cat-grocery     { color: #34D399; background: rgba(52, 211, 153, 0.12);  border-color: rgba(52, 211, 153, 0.28); }
.cat-pharmacy    { color: #F472B6; background: rgba(244, 114, 182, 0.12); border-color: rgba(244, 114, 182, 0.28); }
.cat-electronics { color: #FBBF24; background: rgba(251, 191, 36, 0.12);  border-color: rgba(251, 191, 36, 0.28); }
.cat-work        { color: #60A5FA; background: rgba(96, 165, 250, 0.12);  border-color: rgba(96, 165, 250, 0.28); }
.cat-home        { color: #FB923C; background: rgba(251, 146, 60, 0.12);  border-color: rgba(251, 146, 60, 0.28); }
.cat-car         { color: #818CF8; background: rgba(129, 140, 248, 0.12); border-color: rgba(129, 140, 248, 0.28); }
.cat-money       { color: #2DD4BF; background: rgba(45, 212, 191, 0.12);  border-color: rgba(45, 212, 191, 0.28); }
.cat-general     { color: #A5B4CB; background: rgba(148, 163, 184, 0.12); border-color: rgba(148, 163, 184, 0.28); }

/* ─────────── قسم أسئلة إيريس (فوق دوك الإدخال) ─────────── */
.questions-section {
  flex-shrink: 0;
  margin: 0 12px 2px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(139, 92, 246, 0.10);
  border: 1px solid rgba(139, 92, 246, 0.28);
  animation: slide-up .25s ease both;
  max-height: 34dvh;
  overflow-y: auto;
}
.questions-title {
  font-size: .92rem;
  font-weight: 800;
  margin-bottom: 10px;
  color: #C4B5FD;
}
.questions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.question {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(139, 92, 246, 0.2);
}
.question-text {
  font-size: .95rem;
  line-height: 1.6;
  margin-bottom: 10px;
}
.question-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.answer-btn {
  min-height: 42px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 180ms var(--spring);
}
.answer-btn:active { transform: scale(.95); }
.answer-btn.primary {
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  border-color: transparent;
}
.answer-btn.turquoise {
  background: rgba(45, 212, 191, 0.15);
  border-color: rgba(45, 212, 191, 0.35);
  color: var(--turquoise);
}
/* بنية صف السؤال الفعلية من app.js */
.question-row {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(139, 92, 246, 0.2);
}
.question-answer {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: .92rem;
}
.question-answer:focus {
  outline: none;
  border-color: rgba(45, 212, 191, 0.55);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}
.question-submit {
  min-height: 44px;
  margin-top: 8px;
  padding: 8px 22px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: .92rem;
  cursor: pointer;
  transition: transform 180ms var(--spring);
}
.question-submit:active { transform: scale(.95); }

/* ─────────── دوك الإدخال (ثابت أسفل الشاشة — بطاقة زجاجية) ─────────── */
.input-bar {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 6px 12px calc(8px + env(safe-area-inset-bottom));
  padding: 10px;
  border-radius: 22px;
  background: rgba(30, 41, 59, 0.78);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid rgba(148, 163, 184, 0.14);
  box-shadow: 0 12px 36px rgba(2, 6, 23, 0.55), 0 0 0 1px rgba(139, 92, 246, 0.06);
}

#inputText {
  flex: 1;
  min-width: 0;               /* قاعدة RTL: لا يتمدد خارج الشاشة */
  resize: none;
  min-height: 50px;
  max-height: 140px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text);
  font: inherit;
  line-height: 1.6;
  transition: border-color .18s ease, box-shadow .18s ease;
}
#inputText::placeholder { color: #64748B; }
#inputText:focus {
  outline: none;
  border-color: rgba(139, 92, 246, 0.6);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

.add-btn {
  flex-shrink: 0;             /* زر لمس كبير — لا ينكمش */
  width: 50px;
  height: 50px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  color: #fff;
  font-size: 1.15rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.35);
  transition: transform 200ms var(--spring), box-shadow .18s ease, filter .18s ease;
}
.add-btn:active { transform: scale(.88); }
.add-btn:disabled { opacity: .5; filter: grayscale(.4); box-shadow: none; }

/* ─────────── شريط التراجع (يطفو فوق دوك الإدخال) ─────────── */
.undo-bar {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + var(--dock-h));
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 560px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 12px 18px;
  border-radius: 16px;
  background: #1B2540;
  border: 1px solid rgba(139, 92, 246, 0.35);
  box-shadow: 0 12px 34px rgba(2, 6, 23, 0.6);
  z-index: 50;
  animation: undo-in .25s ease both;
}
.undo-msg {
  font-size: .92rem;
  font-weight: 700;
  color: var(--text);
}
.undo-btn {
  flex-shrink: 0;
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: .95rem;
  cursor: pointer;
  transition: transform 180ms var(--spring);
}
.undo-btn:active { transform: scale(.94); }

/* ─────────── لوحة الإعدادات ─────────── */
.settings-panel {
  flex-shrink: 0;
  margin: 0 16px 8px;
  padding: 6px 16px 16px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  animation: slide-down .25s ease both;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  cursor: pointer;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}
.setting-row:last-of-type { border-bottom: none; }
.setting-label { font-size: .98rem; font-weight: 700; }
.setting-column {
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 6px;
  padding: 10px 0;
}

/* مفتاح تبديل (switch) — يدعم RTL */
.switch {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: #334155;
  border: 1px solid rgba(148, 163, 184, 0.25);
  position: relative;
  cursor: pointer;
  transition: background .2s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;   /* الكرة تبدأ من اليمين في RTL */
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #E2E8F0;
  transition: transform .2s ease, background .2s ease;
}
.switch:checked {
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  border-color: transparent;
}
.switch:checked::after {
  transform: translateX(-22px);  /* تتحرك لليسار عند التفعيل */
  background: #fff;
}

/* حقل عنوان API */
.api-url {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #0F172A;
  color: var(--text);
  font: inherit;
  font-size: .9rem;
  text-align: left;
  direction: ltr;
}
.api-url:focus {
  outline: none;
  border-color: rgba(45, 212, 191, 0.55);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}

/* زر نسخ القائمة */
.copy-btn {
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  border-radius: 14px;
  border: 1px solid rgba(45, 212, 191, 0.4);
  background: rgba(45, 212, 191, 0.12);
  color: var(--turquoise);
  font: inherit;
  font-size: .98rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 180ms var(--spring);
}
.copy-btn:active { transform: scale(.97); }

/* ─────────── حالات فارغة (رسالة لطيفة تلقائية) ─────────── */
#listToday:empty::after   { content: "✨ لا بندات لليوم — اكتب طلبك بالأسفل وستظهر هنا"; }
#listPending:empty::after { content: "🌙 لا بندات معلقة — كل شيء في اليوم أو منجز"; }
#listDone:empty::after    { content: "🎉 لا إنجازات بعد — أنهِ أول بند واحتفل!"; }
.list:empty::after {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 120px;
  padding: 24px 16px;
  border-radius: var(--radius);
  border: 1.5px dashed rgba(148, 163, 184, 0.22);
  color: var(--text-dim);
  font-size: .92rem;
  line-height: 1.7;
}

/* ─────────── تذييل الهوية (نهاية القائمة الممررة) ─────────── */
.app-footer {
  margin-top: 26px;
  padding: 12px 16px 30px;
  text-align: center;
  font-size: .72rem;
  color: #64748B;
}

/* ─────────── حركات ─────────── */
@keyframes item-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@keyframes undo-in {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ─────────── متجاوب حتى اللابتوب ─────────── */
@media (min-width: 640px) {
  body { max-width: 720px; margin: 0 auto; }
  .app-title { font-size: 1.5rem; }
  .lists { padding: 0 20px 14px; }
}

/* تفضيل تقليل الحركة */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
