/* =========================================================
   أهدافي اليومية — نظام تصميم Dark Premium / RTL / Mobile-First
   لوحة الألوان:
   --bg (خلفية أساسية داكنة) #10121A
   --surface (بطاقات) #191C26
   --surface-2 (بطاقات مرتفعة) #212536
   --gold (شارة الإنجاز/النار) #E8A93B
   --teal (التقدم/النجاح) #2FD8C4
   --coral (الخطر/الحذف) #EF6461
   --text (نص أساسي) #F1F0EC
   --muted (نص ثانوي) #8B90A3
========================================================= */

:root{
  --bg:#0F111A;
  --surface:#191C29;
  --surface-2:#20243570;
  --surface-solid:#20243A;
  --border:#2A2F45;
  --gold:#E8A93B;
  --gold-dim:#8a6a2c;
  --teal:#2FD8C4;
  --coral:#EF6461;
  --text:#F1F0EC;
  --muted:#8B90A3;
  --radius-lg:26px;
  --radius-md:18px;
  --radius-sm:12px;
  --font: -apple-system, "SF Arabic", "Segoe UI", Tahoma, Geneva, "Cairo", Arial, sans-serif;
}

*{ box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body{ height:100%; }
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:var(--font);
  direction:rtl;
  overflow-x:hidden;
  -webkit-font-smoothing:antialiased;
}
button, input, textarea{ font-family:inherit; color:inherit; }
button{ cursor:pointer; border:none; background:none; }
.hidden{ display:none !important; }
img{ max-width:100%; display:block; }

/* ===================== شاشة البداية ===================== */
.splash{
  position:fixed; inset:0; background:var(--bg);
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:14px; z-index:999;
}
.splash-ring{ position:relative; width:96px; height:96px; }
.splash-svg{ width:100%; height:100%; transform:rotate(-90deg); }
.splash-track{ fill:none; stroke:var(--border); stroke-width:6; }
.splash-arc{
  fill:none; stroke:var(--gold); stroke-width:6; stroke-linecap:round;
  stroke-dasharray:264; stroke-dashoffset:264;
  animation:splashSpin 1.1s ease-in-out infinite;
}
@keyframes splashSpin{
  0%{ stroke-dashoffset:264; }
  50%{ stroke-dashoffset:60; }
  100%{ stroke-dashoffset:264; transform-origin:center; }
}
.splash-emoji{ position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-size:32px; }
.splash-title{ font-size:19px; font-weight:700; margin:0; }
.splash-sub{ font-size:13px; color:var(--muted); margin:0; }

/* ===================== الهيكل العام ===================== */
.app{ min-height:100%; padding-bottom:96px; }

.topbar{
  position:sticky; top:0; z-index:40;
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 16px; background:rgba(15,17,26,0.85); backdrop-filter:blur(10px);
  border-bottom:1px solid var(--border);
}
.page-title{ font-size:17px; font-weight:800; margin:0; }
.icon-btn{
  width:38px; height:38px; border-radius:50%; display:flex; align-items:center; justify-content:center;
  background:var(--surface-solid); color:var(--text);
}
.icon-btn svg{ width:19px; height:19px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; }
.icon-btn.small{ width:32px; height:32px; }
.avatar-btn{ width:38px; height:38px; border-radius:50%; overflow:hidden; background:linear-gradient(135deg, var(--gold), #c67c1e); display:flex; align-items:center; justify-content:center; }
.avatar-img{ width:100%; height:100%; object-fit:cover; }
.avatar-initial{ font-weight:800; color:#10121a; font-size:15px; }

.views{ padding:16px; max-width:520px; margin:0 auto; }
.view{ display:none; animation:fadeUp .25s ease; }
.view.active{ display:block; }
@keyframes fadeUp{ from{ opacity:0; transform:translateY(6px);} to{ opacity:1; transform:translateY(0);} }

/* ===================== بطاقة Dashboard الرئيسية ===================== */
.hero-card{
  background:linear-gradient(160deg, #1B1F30, #14161F 70%);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:22px 20px 18px;
  margin-bottom:16px;
  position:relative;
  overflow:hidden;
}
.hero-card::before{
  content:""; position:absolute; top:-60px; left:-40px; width:180px; height:180px;
  background:radial-gradient(circle, rgba(232,169,59,0.18), transparent 70%);
}
.hero-top{ display:flex; align-items:flex-start; justify-content:space-between; margin-bottom:14px; position:relative; z-index:1; }
.hero-greeting{ margin:0; font-size:13px; color:var(--muted); }
.hero-name{ margin:2px 0 0; font-size:20px; font-weight:800; }
.hero-date{ font-size:12px; color:var(--muted); background:var(--surface-solid); padding:6px 10px; border-radius:20px; }

.hero-ring-wrap{ position:relative; width:150px; height:150px; margin:6px auto 14px; }
.ring-svg{ width:100%; height:100%; transform:rotate(-90deg); }
.ring-track{ fill:none; stroke:var(--border); stroke-width:10; }
.ring-progress{
  fill:none; stroke:var(--teal); stroke-width:10; stroke-linecap:round;
  stroke-dasharray:377; stroke-dashoffset:377;
  transition:stroke-dashoffset .8s cubic-bezier(.4,0,.2,1);
}
.ring-center{ position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; }
.ring-percent{ font-size:30px; font-weight:800; }
.ring-label{ font-size:12px; color:var(--muted); margin-top:2px; }

.hero-stats{ display:flex; justify-content:space-around; position:relative; z-index:1; }
.hero-stat{ display:flex; flex-direction:column; align-items:center; gap:2px; }
.hero-stat-num{ font-size:18px; font-weight:800; }
.hero-stat-label{ font-size:11.5px; color:var(--muted); }

/* ===================== بطاقات مصغرة (Streak/إنجاز) ===================== */
.mini-cards-row{ display:flex; gap:12px; margin-bottom:22px; }
.mini-card{
  flex:1; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-md);
  padding:14px 10px; display:flex; flex-direction:column; align-items:center; gap:2px;
}
.mini-card.streak-card{ background:linear-gradient(160deg, #2a2013, var(--surface)); border-color:var(--gold-dim); }
.mini-emoji{ font-size:22px; }
.mini-num{ font-size:17px; font-weight:800; margin-top:2px; }
.mini-label{ font-size:11.5px; color:var(--muted); }

/* ===================== عناوين الأقسام ===================== */
.section-row{ display:flex; align-items:center; justify-content:space-between; margin:6px 0 12px; }
.section-title{ font-size:15.5px; font-weight:800; margin:0; }
.link-btn{ font-size:12.5px; color:var(--teal); font-weight:700; }
.muted-line{ color:var(--muted); font-size:13px; text-align:center; padding:12px 0; }

/* ===================== قائمة الأهداف / بطاقة الهدف ===================== */
.goals-list{ display:flex; flex-direction:column; gap:12px; margin-bottom:8px; }
.goal-card{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-md);
  padding:14px; position:relative;
}
.goal-card.completed{ opacity:0.62; }
.goal-card-top{ display:flex; justify-content:space-between; align-items:flex-start; gap:10px; }
.goal-cat-badge{ font-size:11px; background:var(--surface-solid); padding:3px 9px; border-radius:20px; color:var(--muted); white-space:nowrap; }
.goal-title-row{ display:flex; align-items:center; gap:6px; flex:1; min-width:0; }
.goal-title{ font-size:15px; font-weight:700; margin:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.goal-star{ color:var(--gold); font-size:14px; flex-shrink:0; }
.goal-desc{ font-size:12.5px; color:var(--muted); margin:6px 0 0; line-height:1.5; }
.goal-meta-row{ display:flex; gap:10px; margin-top:10px; flex-wrap:wrap; }
.goal-meta{ font-size:11.5px; color:var(--muted); display:flex; align-items:center; gap:4px; }
.priority-dot{ width:7px; height:7px; border-radius:50%; display:inline-block; }
.priority-low{ background:#5FA8D3; }
.priority-medium{ background:var(--gold); }
.priority-high{ background:var(--coral); }
.goal-progress-bar{ height:6px; background:var(--surface-solid); border-radius:10px; margin-top:10px; overflow:hidden; }
.goal-progress-fill{ height:100%; background:linear-gradient(90deg, var(--teal), #1fa896); border-radius:10px; transition:width .5s ease; }
.goal-progress-text{ font-size:11px; color:var(--muted); margin-top:4px; text-align:left; }
.goal-images-strip{ display:flex; gap:6px; margin-top:10px; overflow-x:auto; }
.goal-images-strip img{ width:52px; height:52px; object-fit:cover; border-radius:10px; flex-shrink:0; }
.goal-actions-row{ display:flex; gap:8px; margin-top:12px; }
.goal-action-btn{
  flex:1; padding:9px 0; border-radius:12px; font-size:12.5px; font-weight:700; text-align:center;
  background:var(--surface-solid); color:var(--text);
}
.goal-action-btn.complete{ background:linear-gradient(135deg, var(--teal), #16a394); color:#06231f; }
.goal-action-btn.done-tag{ background:transparent; color:var(--teal); }
.goal-action-btn.edit{ flex:0 0 44px; }
.goal-action-btn.delete{ flex:0 0 44px; color:var(--coral); }
.status-pill{ position:absolute; top:12px; left:12px; font-size:10.5px; padding:3px 9px; border-radius:20px; font-weight:700; }
.status-pill.late{ background:rgba(239,100,97,0.15); color:var(--coral); }
.status-pill.completed{ background:rgba(47,216,196,0.15); color:var(--teal); }

/* ===================== حالة فارغة ===================== */
.empty-state{ text-align:center; padding:40px 20px; }
.empty-emoji{ font-size:44px; display:block; margin-bottom:10px; }
.empty-title{ font-weight:800; font-size:15px; margin:0 0 4px; }
.empty-sub{ color:var(--muted); font-size:13px; margin:0 0 16px; }

/* ===================== أزرار عامة ===================== */
.btn-primary, .btn-secondary, .btn-danger{
  padding:13px 18px; border-radius:14px; font-size:14px; font-weight:700; text-align:center;
}
.btn-primary{ background:linear-gradient(135deg, var(--teal), #17a695); color:#06231f; }
.btn-secondary{ background:var(--surface-solid); color:var(--text); border:1px solid var(--border); margin-top:8px; }
.btn-danger{ background:rgba(239,100,97,0.12); color:var(--coral); margin-top:8px; }
.full{ width:100%; display:block; }
.tiny-btn{ font-size:12px; color:var(--teal); font-weight:700; padding:6px 10px; }

/* ===================== الفلاتر (Chips) ===================== */
.filters-bar{ margin-bottom:16px; }
.chip-scroll{ display:flex; gap:8px; overflow-x:auto; padding:2px 0 10px; scrollbar-width:none; }
.chip-scroll::-webkit-scrollbar{ display:none; }
.chip{
  flex-shrink:0; padding:8px 14px; border-radius:20px; font-size:12.5px; font-weight:600;
  background:var(--surface); border:1px solid var(--border); color:var(--muted); white-space:nowrap;
}
.chip.active{ background:var(--teal); color:#06231f; border-color:var(--teal); font-weight:800; }

/* ===================== التقويم ===================== */
.cal-header{ display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
.cal-month-label{ font-weight:800; font-size:16px; }
.cal-weekdays{ display:grid; grid-template-columns:repeat(7,1fr); text-align:center; font-size:11px; color:var(--muted); margin-bottom:6px; }
.cal-grid{ display:grid; grid-template-columns:repeat(7,1fr); gap:5px; }
.cal-day{
  aspect-ratio:1; border-radius:12px; background:var(--surface); border:1px solid var(--border);
  display:flex; flex-direction:column; align-items:center; justify-content:center; font-size:12.5px; gap:3px; position:relative;
}
.cal-day.empty{ background:transparent; border-color:transparent; }
.cal-day.today{ border-color:var(--teal); }
.cal-day.selected{ background:var(--teal); color:#06231f; font-weight:800; }
.cal-dot{ width:5px; height:5px; border-radius:50%; background:var(--gold); position:absolute; bottom:6px; }
.cal-day.selected .cal-dot{ background:#06231f; }

/* ===================== الإحصائيات ===================== */
.stats-grid{ display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:22px; }
.stat-box{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-md); padding:16px 12px; text-align:center; }
.stat-box-num{ display:block; font-size:21px; font-weight:800; color:var(--teal); }
.stat-box-label{ display:block; font-size:11.5px; color:var(--muted); margin-top:4px; }
.chart-card{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-md); padding:14px; margin-bottom:22px; }
.chart-card canvas{ width:100%; height:auto; display:block; }

/* ===================== معرض الإنجازات ===================== */
.gallery-grid{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.gallery-item{ position:relative; border-radius:var(--radius-md); overflow:hidden; aspect-ratio:1; background:var(--surface); border:1px solid var(--border); }
.gallery-item img{ width:100%; height:100%; object-fit:cover; }
.gallery-caption{ position:absolute; bottom:0; right:0; left:0; padding:8px; background:linear-gradient(to top, rgba(0,0,0,0.75), transparent); font-size:11px; }
.gallery-caption b{ display:block; font-size:12px; }

/* ===================== الشارات ===================== */
.badges-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:10px; }
.badge-item{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-md); padding:14px 8px; text-align:center; }
.badge-item.locked{ opacity:0.35; }
.badge-emoji{ font-size:26px; display:block; margin-bottom:6px; }
.badge-name{ font-size:11px; color:var(--muted); }

/* ===================== المذكرات ===================== */
.card{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-md); padding:16px; margin-bottom:14px; }
.card-title{ font-size:14px; font-weight:800; margin:0 0 12px; }
.field-label{ display:block; font-size:12.5px; color:var(--muted); margin:12px 0 6px; font-weight:600; }
.field-label:first-child{ margin-top:0; }
.field-input{
  width:100%; background:var(--surface-solid); border:1px solid var(--border); border-radius:12px;
  padding:11px 13px; font-size:14px; color:var(--text); resize:vertical;
}
.field-input:focus{ outline:none; border-color:var(--teal); }
.field-row{ display:flex; gap:10px; }
.field-half{ flex:1; }
.journal-history{ display:flex; flex-direction:column; gap:10px; }
.journal-entry{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-md); padding:14px; }
.journal-entry-date{ font-size:12px; font-weight:800; color:var(--teal); margin-bottom:8px; }
.journal-entry-block{ font-size:12.5px; margin-bottom:6px; }
.journal-entry-block b{ color:var(--muted); font-weight:600; }

/* ===================== نموذج إضافة الهدف ===================== */
.segmented{ display:flex; gap:6px; background:var(--surface-solid); padding:4px; border-radius:14px; }
.seg-btn{ flex:1; padding:9px 0; border-radius:10px; font-size:12.5px; font-weight:700; color:var(--muted); }
.seg-btn.active{ background:var(--teal); color:#06231f; }
.cat-grid{ display:grid; grid-template-columns:repeat(2,1fr); gap:8px; }
.cat-btn{ padding:10px 6px; border-radius:12px; background:var(--surface-solid); border:1px solid var(--border); font-size:12.5px; color:var(--muted); }
.cat-btn.active{ background:rgba(47,216,196,0.15); border-color:var(--teal); color:var(--teal); font-weight:700; }
.range-input{ width:100%; accent-color:var(--teal); }
.image-preview-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-bottom:8px; }
.image-preview-item{ position:relative; aspect-ratio:1; border-radius:12px; overflow:hidden; background:var(--surface-solid); }
.image-preview-item img{ width:100%; height:100%; object-fit:cover; }
.image-preview-remove{
  position:absolute; top:4px; left:4px; width:22px; height:22px; border-radius:50%;
  background:rgba(0,0,0,0.6); color:#fff; display:flex; align-items:center; justify-content:center; font-size:13px;
}
.important-toggle{ margin-top:14px; cursor:pointer; }
.form-actions{ display:flex; gap:10px; margin-top:18px; }
.form-actions .full{ margin-top:0; }

.toggle-row{ display:flex; align-items:center; justify-content:space-between; padding:10px 0; font-size:14px; }
.switch{ position:relative; display:inline-block; width:44px; height:26px; flex-shrink:0; }
.switch input{ opacity:0; width:0; height:0; }
.slider{ position:absolute; inset:0; background:var(--surface-solid); border:1px solid var(--border); border-radius:20px; transition:.2s; }
.slider::before{ content:""; position:absolute; width:18px; height:18px; right:4px; top:3px; background:var(--muted); border-radius:50%; transition:.2s; }
.switch input:checked + .slider{ background:var(--teal); border-color:var(--teal); }
.switch input:checked + .slider::before{ transform:translateX(-18px); background:#06231f; }

/* ===================== الإعدادات ===================== */
.settings-profile{ text-align:center; }
.settings-avatar-wrap{ display:flex; flex-direction:column; align-items:center; gap:8px; margin-bottom:6px; }
.settings-avatar, .settings-avatar-initial{
  width:76px; height:76px; border-radius:50%; object-fit:cover;
  background:linear-gradient(135deg, var(--gold), #c67c1e); display:flex; align-items:center; justify-content:center;
  font-size:28px; font-weight:800; color:#10121a;
}
.app-version{ text-align:center; font-size:11.5px; color:var(--muted); margin-top:20px; }

/* ===================== تفاصيل الهدف ===================== */
.detail-header-card{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); padding:20px; margin-bottom:16px; }
.detail-title{ font-size:19px; font-weight:800; margin:0 0 6px; }
.detail-desc{ font-size:13.5px; color:var(--muted); line-height:1.6; margin:0 0 14px; }
.detail-meta-grid{ display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:14px; }
.detail-meta-item{ background:var(--surface-solid); border-radius:12px; padding:10px; text-align:center; }
.detail-meta-item span{ display:block; }
.detail-meta-item .dm-label{ font-size:10.5px; color:var(--muted); margin-bottom:3px; }
.detail-meta-item .dm-val{ font-size:13px; font-weight:700; }
.timeline{ display:flex; flex-direction:column; gap:0; margin:18px 0; }
.timeline-item{ display:flex; gap:12px; position:relative; padding-bottom:22px; }
.timeline-item:last-child{ padding-bottom:0; }
.timeline-dot{ width:12px; height:12px; border-radius:50%; background:var(--border); flex-shrink:0; margin-top:3px; position:relative; z-index:1; }
.timeline-item.done .timeline-dot{ background:var(--teal); }
.timeline-item::before{
  content:""; position:absolute; top:15px; bottom:0; right:5.5px; width:1px; background:var(--border);
}
.timeline-item:last-child::before{ display:none; }
.timeline-text b{ display:block; font-size:13px; }
.timeline-text span{ font-size:11.5px; color:var(--muted); }
.detail-images-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-bottom:14px; }
.detail-images-grid img{ aspect-ratio:1; object-fit:cover; border-radius:12px; }
.detail-notes-box{ background:var(--surface-solid); border-radius:12px; padding:12px; font-size:13px; color:var(--muted); line-height:1.6; }

/* ===================== شريط التنقل السفلي ===================== */
.bottom-nav{
  position:fixed; bottom:0; right:0; left:0; height:78px; z-index:50;
  background:rgba(20,22,32,0.92); backdrop-filter:blur(14px);
  border-top:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-around;
  padding-bottom:env(safe-area-inset-bottom);
}
.nav-btn{ display:flex; flex-direction:column; align-items:center; gap:3px; color:var(--muted); font-size:10.5px; flex:1; padding:6px 0; }
.nav-btn svg{ width:21px; height:21px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.nav-btn.active{ color:var(--teal); }
.nav-fab{
  width:56px; height:56px; border-radius:50%; background:linear-gradient(135deg, var(--gold), #c67c1e);
  display:flex; align-items:center; justify-content:center; margin-top:-26px; box-shadow:0 8px 20px rgba(232,169,59,0.35);
  flex-shrink:0;
}
.nav-fab svg{ width:24px; height:24px; fill:none; stroke:#10121a; stroke-width:2.4; stroke-linecap:round; }

/* ===================== النوافذ المنبثقة العامة ===================== */
.overlay{
  position:fixed; inset:0; background:rgba(8,9,14,0.72); z-index:200;
  display:flex; align-items:flex-end; justify-content:center;
  animation:overlayFade .2s ease;
}
@keyframes overlayFade{ from{ opacity:0; } to{ opacity:1; } }
.modal-box{
  background:var(--surface-solid); border:1px solid var(--border); border-radius:22px 22px 0 0;
  padding:22px; width:100%; max-width:520px; animation:modalUp .25s ease;
}
@keyframes modalUp{ from{ transform:translateY(30px); opacity:0;} to{ transform:translateY(0); opacity:1;} }
.modal-message{ font-size:14.5px; text-align:center; margin:0 0 18px; line-height:1.6; }
.modal-actions{ display:flex; gap:10px; }
.modal-actions .full{ margin-top:0; }

.search-panel{ background:var(--surface-solid); border-radius:22px 22px 0 0; padding:18px; width:100%; max-width:520px; max-height:80vh; overflow-y:auto; animation:modalUp .25s ease; }
.search-input-row{ display:flex; gap:10px; align-items:center; margin-bottom:14px; }
.search-input-row .field-input{ flex:1; }

.viewer-close{ position:absolute; top:20px; left:20px; background:rgba(255,255,255,0.15); color:#fff; z-index:2; }
#imageViewer{ align-items:center; }
#imageViewer img{ max-width:92vw; max-height:80vh; border-radius:16px; object-fit:contain; }

.profile-menu{
  position:fixed; top:60px; left:16px; z-index:60; background:var(--surface-solid); border:1px solid var(--border);
  border-radius:16px; padding:8px; display:flex; flex-direction:column; min-width:170px; box-shadow:0 10px 30px rgba(0,0,0,0.4);
}
.profile-menu button{ text-align:right; padding:11px 12px; border-radius:10px; font-size:13.5px; }
.profile-menu button:active{ background:var(--surface); }

/* ===================== Toasts ===================== */
.toast-container{ position:fixed; bottom:100px; right:0; left:0; display:flex; flex-direction:column; align-items:center; gap:8px; z-index:300; pointer-events:none; }
.toast{
  background:var(--surface-solid); border:1px solid var(--border); color:var(--text);
  padding:12px 20px; border-radius:30px; font-size:13.5px; font-weight:600;
  box-shadow:0 8px 24px rgba(0,0,0,0.35); animation:toastIn .25s ease, toastOut .25s ease 2.3s forwards;
  max-width:90%;
}
@keyframes toastIn{ from{ opacity:0; transform:translateY(10px);} to{ opacity:1; transform:translateY(0);} }
@keyframes toastOut{ to{ opacity:0; transform:translateY(-6px);} }

/* ===================== Light mode (اختياري) ===================== */
body.light{
  --bg:#F6F5F1;
  --surface:#FFFFFF;
  --surface-2:#FFFFFF70;
  --surface-solid:#EFEDE6;
  --border:#E3E0D6;
  --text:#1B1C22;
  --muted:#6B6E7D;
}

/* ===================== استجابة أكبر للشاشات الأوسع ===================== */
@media (min-width:600px){
  .views{ padding:20px; }
}
