/* =====================================================================
   LifeOS — نظام التصميم (Dark · Minimalist · Glassmorphism · RTL)
   كل شيء محلي بالكامل — بلا أي CDN خارجي.
   ===================================================================== */

/* ---- الخطوط المحلية (تُوضع في assets/fonts؛ يوجد تراجع نظامي) ---- */
@font-face {
  font-family: 'Tajawal';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local('Tajawal'), url('../fonts/Tajawal-Regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Tajawal';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: local('Tajawal'), url('../fonts/Tajawal-Bold.woff2') format('woff2');
}

:root {
  /* لوحة الألوان — وضع داكن عميق */
  --bg-0: #070a12;
  --bg-1: #0b0f1a;
  --bg-2: #111827;
  --glass: rgba(24, 32, 51, 0.55);
  --glass-strong: rgba(30, 41, 64, 0.75);
  --border: rgba(148, 163, 184, 0.14);
  --border-hover: rgba(148, 163, 184, 0.28);

  --text: #e5e7eb;
  --text-dim: #94a3b8;
  --text-faint: #64748b;

  --primary: #6366f1;
  --primary-2: #818cf8;
  --primary-glow: rgba(99, 102, 241, 0.35);
  --accent: #22d3ee;
  --success: #10b981;
  --success-2: #34d399;
  --warn: #f59e0b;
  --danger: #f43f5e;
  --water: #38bdf8;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 20px 45px -20px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 40px -10px var(--primary-glow);

  --sidebar-w: 250px;
  --font: 'Tajawal', 'Segoe UI', 'Cairo', Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(99, 102, 241, 0.16), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(34, 211, 238, 0.10), transparent 55%),
    var(--bg-0);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

::selection { background: var(--primary-glow); }

/* شريط تمرير رفيع */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(148,163,184,.2); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,.35); }
::-webkit-scrollbar-track { background: transparent; }

/* =========================== التخطيط =========================== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: linear-gradient(180deg, rgba(17,24,39,.7), rgba(7,10,18,.4));
  border-inline-start: 1px solid var(--border);
  backdrop-filter: blur(14px);
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 8px 10px 20px; }
.brand .logo {
  width: 42px; height: 42px; border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow-glow); flex-shrink: 0;
}
.brand .logo img { width: 100%; height: 100%; display: block; }
.brand b { font-size: 20px; letter-spacing: .3px; }
.brand span { display: block; font-size: 11px; color: var(--text-faint); }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 12px;
  color: var(--text-dim); cursor: pointer;
  font-size: 15px; font-weight: 500;
  border: 1px solid transparent;
  transition: all .18s ease;
  user-select: none;
}
.nav-item:hover { background: rgba(148,163,184,.07); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(99,102,241,.22), rgba(99,102,241,.05));
  color: #fff; border-color: rgba(99,102,241,.35);
}
.nav-item .ico { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item .badge {
  margin-inline-start: auto; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; min-width: 20px; height: 20px;
  border-radius: 999px; display: grid; place-items: center; padding: 0 5px;
}
.nav-spacer { flex: 1; }
.nav-foot { font-size: 11px; color: var(--text-faint); padding: 10px 12px; }

.main { flex: 1; min-width: 0; padding: 26px clamp(16px, 3vw, 40px) 60px; }

.topbar {
  display: flex; align-items: center; gap: 16px; margin-bottom: 26px; flex-wrap: wrap;
}
.topbar h1 { font-size: clamp(22px, 3vw, 30px); font-weight: 700; }
.topbar .sub { color: var(--text-dim); font-size: 14px; }
.topbar .spacer { flex: 1; }
.chip-date {
  background: var(--glass); border: 1px solid var(--border);
  padding: 8px 16px; border-radius: 999px; font-size: 13px; color: var(--text-dim);
  backdrop-filter: blur(8px);
}

/* =========================== البطاقات الزجاجية =========================== */
.card {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  transition: border-color .2s ease, transform .2s ease;
}
.card:hover { border-color: var(--border-hover); }

.card-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700; margin-bottom: 16px;
}
.card-title .ico { width: 20px; height: 20px; color: var(--primary-2); }
.card-title .count { margin-inline-start: auto; font-size: 13px; color: var(--text-faint); font-weight: 500; }

.grid { display: grid; gap: 18px; }
.dash-grid {
  grid-template-columns: repeat(12, 1fr);
  align-items: start;
}
.col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; }
.col-12 { grid-column: span 12; }

.zone-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--text-faint);
  margin: 4px 0 2px; grid-column: 1 / -1;
}
.zone-label::before { content: ''; width: 8px; height: 8px; border-radius: 3px; }
.zone-work::before { background: var(--primary); box-shadow: 0 0 10px var(--primary); }
.zone-health::before { background: var(--success); box-shadow: 0 0 10px var(--success); }

/* =========================== المدخلات والأزرار =========================== */
.input, .textarea, .select {
  width: 100%; background: rgba(2,6,23,.5);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 12px 14px; font-family: inherit; font-size: 14px;
  transition: border-color .16s, box-shadow .16s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.18);
}
.textarea { resize: vertical; min-height: 80px; }
.input::placeholder { color: var(--text-faint); }

.quick-inbox { position: relative; }
.quick-inbox .input { padding-inline-end: 44px; font-size: 15px; }
.quick-inbox .hint {
  position: absolute; inset-inline-end: 12px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--text-faint);
  border: 1px solid var(--border); padding: 2px 7px; border-radius: 6px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--glass-strong);
  color: var(--text); font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .16s ease; user-select: none;
}
.btn:hover { border-color: var(--border-hover); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(135deg, var(--primary), #4f46e5); border-color: transparent; color: #fff; }
.btn-primary:hover { box-shadow: var(--shadow-glow); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-water { background: rgba(56,189,248,.14); border-color: rgba(56,189,248,.3); color: var(--water); font-weight: 700; }
.btn-water:hover { background: rgba(56,189,248,.22); }
.btn-icon { padding: 8px; width: 36px; height: 36px; }
.btn-danger { color: var(--danger); border-color: rgba(244,63,94,.3); }
.btn-danger:hover { background: rgba(244,63,94,.12); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* =========================== قوائم المهام =========================== */
.task-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: rgba(2,6,23,.35); border: 1px solid var(--border);
  transition: all .16s ease; margin-bottom: 10px;
}
.task-row:hover { border-color: var(--border-hover); background: rgba(2,6,23,.5); }
.task-row.done { opacity: .55; }
.task-row.done .task-title { text-decoration: line-through; color: var(--text-dim); }

.checkbox {
  width: 22px; height: 22px; flex-shrink: 0; border-radius: 7px;
  border: 2px solid var(--border-hover); cursor: pointer;
  display: grid; place-items: center; transition: all .16s ease; background: transparent;
}
.checkbox:hover { border-color: var(--primary-2); }
.checkbox.checked { background: var(--success); border-color: var(--success); }
.checkbox.checked svg { width: 14px; height: 14px; color: #04120b; }
.checkbox svg { width: 0; }

.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 14.5px; font-weight: 500; word-break: break-word; }
.task-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }

.tag {
  font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 5px;
}
.tag-project { background: rgba(99,102,241,.15); color: var(--primary-2); }
.tag-dot { width: 7px; height: 7px; border-radius: 50%; }
.prio-high { background: rgba(244,63,94,.15); color: #fb7185; }
.prio-medium { background: rgba(245,158,11,.15); color: #fbbf24; }
.prio-low { background: rgba(148,163,184,.13); color: var(--text-dim); }
.status-tag { background: rgba(148,163,184,.12); color: var(--text-dim); }

.focus-slot {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  border: 1px dashed var(--border-hover); border-radius: var(--radius-sm);
  color: var(--text-faint); font-size: 14px; margin-bottom: 10px; cursor: pointer;
  transition: all .16s;
}
.focus-slot:hover { border-color: var(--primary); color: var(--primary-2); background: rgba(99,102,241,.05); }
.focus-num {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  background: rgba(99,102,241,.15); color: var(--primary-2);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}

.star-btn { background: none; border: none; cursor: pointer; color: var(--text-faint); padding: 4px; }
.star-btn svg { width: 18px; height: 18px; }
.star-btn.on { color: var(--warn); }
.icon-btn { background: none; border: none; color: var(--text-faint); cursor: pointer; padding: 5px; border-radius: 8px; transition: all .15s; }
.icon-btn:hover { color: var(--text); background: rgba(148,163,184,.1); }
.icon-btn svg { width: 17px; height: 17px; }

/* =========================== الصحة =========================== */
.water-visual { display: flex; align-items: center; gap: 18px; margin-bottom: 16px; }
.water-ring {
  --pct: 0; width: 96px; height: 96px; border-radius: 50%; flex-shrink: 0;
  background: conic-gradient(var(--water) calc(var(--pct) * 1%), rgba(56,189,248,.12) 0);
  display: grid; place-items: center; position: relative;
  transition: background .5s ease;
}
.water-ring::before { content: ''; position: absolute; inset: 9px; border-radius: 50%; background: var(--bg-1); }
.water-ring .val { position: relative; text-align: center; }
.water-ring .val b { font-size: 20px; color: var(--water); display: block; line-height: 1.1; }
.water-ring .val small { font-size: 10px; color: var(--text-faint); }
.water-info { flex: 1; }
.water-info .big { font-size: 24px; font-weight: 700; }
.water-info .lbl { font-size: 13px; color: var(--text-dim); }
.water-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.stat-row { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-box {
  flex: 1; min-width: 90px; background: rgba(2,6,23,.35);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px;
  text-align: center;
}
.stat-box .n { font-size: 26px; font-weight: 700; }
.stat-box .l { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

/* مؤقت البومودورو */
.timer-display {
  text-align: center; font-size: 56px; font-weight: 700; letter-spacing: 2px;
  font-variant-numeric: tabular-nums; margin: 4px 0 6px;
  background: linear-gradient(135deg, var(--primary-2), var(--accent));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.timer-phase { text-align: center; font-size: 13px; color: var(--text-dim); margin-bottom: 16px; }
.timer-phase.break { color: var(--success-2); }
.timer-btns { display: flex; gap: 10px; justify-content: center; }

.meal-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 10px; background: rgba(2,6,23,.3); border: 1px solid var(--border); margin-bottom: 8px;
}
.meal-item.eaten { opacity: .55; }
.meal-item.eaten .m-title { text-decoration: line-through; }
.meal-type {
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 6px;
  background: rgba(16,185,129,.14); color: var(--success-2); flex-shrink: 0;
}
.m-title { flex: 1; font-size: 14px; }

/* =========================== المشاريع =========================== */
.project-card { position: relative; overflow: hidden; }
.project-card .bar {
  position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px;
}
.progress-track { height: 8px; background: rgba(2,6,23,.5); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress-fill { height: 100%; border-radius: 999px; transition: width .5s ease; }

/* =========================== سجل التكاسل =========================== */
.stuck-card { border-color: rgba(244,63,94,.3); background: linear-gradient(180deg, rgba(244,63,94,.06), var(--glass)); }
.stuck-count-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(244,63,94,.15); color: #fb7185; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; font-size: 12px;
}
.reason-note {
  font-size: 12.5px; color: #fca5a5; background: rgba(244,63,94,.08);
  border-inline-start: 3px solid var(--danger); padding: 8px 12px;
  border-radius: 8px; margin-top: 8px;
}

/* =========================== الرسم البياني =========================== */
.chart-wrap { position: relative; height: 220px; margin-top: 10px; }
.corr-badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px;
  border-radius: 12px; font-weight: 700; font-size: 14px; margin-bottom: 14px;
}
.corr-strong { background: rgba(16,185,129,.14); color: var(--success-2); }
.corr-weak { background: rgba(245,158,11,.14); color: #fbbf24; }
.corr-none { background: rgba(148,163,184,.12); color: var(--text-dim); }
.legend { display: flex; gap: 18px; justify-content: center; margin-top: 10px; font-size: 12px; color: var(--text-dim); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .k { width: 12px; height: 12px; border-radius: 4px; }

/* =========================== شارة التقييم =========================== */
.rating-stars { display: flex; gap: 6px; }
.rating-stars button { background: none; border: none; cursor: pointer; color: var(--text-faint); padding: 2px; }
.rating-stars button svg { width: 26px; height: 26px; }
.rating-stars button.on { color: var(--warn); }

.seg { display: inline-flex; background: rgba(2,6,23,.4); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: none; background: none; color: var(--text-dim); padding: 6px 14px; border-radius: 7px; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600; }
.seg button.on { background: var(--primary); color: #fff; }

/* =========================== النوافذ المنبثقة =========================== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(3,7,18,.7); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-2); border: 1px solid var(--border-hover);
  border-radius: var(--radius); padding: 24px; width: 100%; max-width: 480px;
  box-shadow: var(--shadow); animation: pop .2s ease;
}
@keyframes pop { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h3 { margin-bottom: 16px; font-size: 18px; }
.modal .row { margin-bottom: 14px; }
.modal .row label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 20px; }

/* =========================== التنبيهات =========================== */
.toast-wrap { position: fixed; bottom: 24px; inset-inline-start: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--glass-strong); border: 1px solid var(--border-hover);
  border-inline-start: 3px solid var(--primary); border-radius: 12px;
  padding: 12px 18px; font-size: 14px; backdrop-filter: blur(12px);
  box-shadow: var(--shadow); animation: slidein .25s ease; max-width: 340px;
}
.toast.success { border-inline-start-color: var(--success); }
.toast.error { border-inline-start-color: var(--danger); }
@keyframes slidein { from { transform: translateX(-20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* =========================== حالات فارغة =========================== */
.empty { text-align: center; padding: 30px 20px; color: var(--text-faint); }
.empty svg { width: 40px; height: 40px; margin: 0 auto 10px; opacity: .5; display: block; }
.empty p { font-size: 14px; }

/* =========================== المشاهد =========================== */
.view { display: none; animation: fade .3s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* =========================== شريط الجوال السفلي =========================== */
.mobile-nav { display: none; }

/* =========================== الاستجابة =========================== */
@media (max-width: 1100px) {
  .col-8, .col-6, .col-4 { grid-column: span 12; }
}
@media (max-width: 820px) {
  .sidebar { display: none; }
  .main { padding: 18px 14px 90px; }
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; inset-inline: 0; z-index: 50;
    background: rgba(11,15,26,.92); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .mobile-nav .m-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: var(--text-faint); font-size: 10px; padding: 6px 10px; cursor: pointer;
    border-radius: 10px; position: relative;
  }
  .mobile-nav .m-item.active { color: var(--primary-2); }
  .mobile-nav .m-item svg { width: 22px; height: 22px; }
  .mobile-nav .m-item .badge {
    position: absolute; top: 2px; inset-inline-end: 6px; background: var(--danger);
    color: #fff; font-size: 9px; min-width: 15px; height: 15px; border-radius: 999px;
    display: grid; place-items: center; padding: 0 3px;
  }
  .water-btns .btn { flex: 1; }
}
@media (max-width: 460px) {
  .stat-box { min-width: 70px; }
  .timer-display { font-size: 44px; }
}

/* =====================================================================
   تحسينات v2 — النوافذ المنبثقة، منتقي التركيز، والتحكم الصوتي
   ===================================================================== */

/* أمان: أي أيقونة SVG بلا حجم صريح لا تتضخّم */
.modal svg { width: 20px; height: 20px; flex-shrink: 0; }

/* زر إغلاق النافذة */
.modal { position: relative; }
.modal-close {
  position: absolute; top: 16px; inset-inline-start: 16px;
  width: 34px; height: 34px; display: grid; place-items: center;
  background: rgba(148,163,184,.08); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text-dim); cursor: pointer; transition: all .16s;
}
.modal-close:hover { background: rgba(244,63,94,.14); color: #fb7185; border-color: rgba(244,63,94,.3); }
.modal-close svg { width: 16px; height: 16px; }

.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.modal h3 { display: flex; align-items: center; gap: 10px; }
.modal h3 svg { color: var(--primary-2); }
.modal-sub { color: var(--text-dim); font-size: 13px; line-height: 1.7; margin-bottom: 16px; }

/* منتقي مهام التركيز — قائمة أنيقة */
.pick-list {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 52vh; overflow-y: auto; padding-inline-end: 4px; margin-bottom: 6px;
}
.pick-row {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: start;
  padding: 14px 16px; border-radius: var(--radius-sm); cursor: pointer;
  background: rgba(2,6,23,.4); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; transition: all .16s ease;
}
.pick-row:hover {
  border-color: var(--primary); background: rgba(99,102,241,.1);
  transform: translateX(-3px);
}
.pick-plus {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(99,102,241,.16); color: var(--primary-2);
  transition: all .16s ease;
}
.pick-row:hover .pick-plus { background: var(--primary); color: #fff; }
.pick-plus svg { width: 18px; height: 18px; }
.pick-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.pick-title { font-size: 14.5px; font-weight: 600; }
.pick-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
