/* =========================================================
   دستیار هوشمند کارها — استایل اصلی
   ========================================================= */

:root {
  --bg: #0f0f1a;
  --bg-elev1: #171726;
  --bg-elev2: #1e1e30;
  --bg-elev3: #262640;
  --card-border: rgba(255,255,255,0.06);
  --text: #f2f2f7;
  --text-dim: #9a9ab0;
  --text-faint: #6c6c86;
  --accent: #7c5cfc;
  --accent-2: #5b8cff;
  --accent-soft: rgba(124,92,252,0.16);
  --green: #34d399;
  --green-soft: rgba(52,211,153,0.16);
  --yellow: #fbbf24;
  --yellow-soft: rgba(251,191,36,0.16);
  --red: #f87171;
  --red-soft: rgba(248,113,113,0.16);
  --blue: #60a5fa;
  --blue-soft: rgba(96,165,250,0.16);
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f4f9;
  --bg-elev1: #ffffff;
  --bg-elev2: #f0f0f7;
  --bg-elev3: #e9e9f5;
  --card-border: rgba(20,20,40,0.06);
  --text: #17172b;
  --text-dim: #5c5c74;
  --text-faint: #8a8aa0;
  --accent: #6b46f0;
  --shadow: 0 8px 24px rgba(30,30,60,0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", "IRANSans", "Tahoma", "Segoe UI", -apple-system, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body { direction: rtl; }
* { -webkit-user-select: none; user-select: none; }
input, textarea { -webkit-user-select: text; user-select: text; }

h1,h2,h3,h4,p { margin: 0; }
button { font-family: inherit; }
ul { list-style: none; margin: 0; padding: 0; }

::-webkit-scrollbar { width: 0; height: 0; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.app-header {
  padding: calc(16px + var(--safe-top)) 18px 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.app-header .greet h1 { font-size: 19px; font-weight: 700; }
.app-header .greet p { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }
.header-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--bg-elev2); border: 1px solid var(--card-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text); cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Main scroll area ---------- */
.view {
  display: none;
  padding: 4px 16px calc(96px + var(--safe-bottom));
  flex: 1;
  overflow-y: auto;
}
.view.active { display: block; animation: fadein .18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px);} to {opacity:1; transform:none;} }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-elev1);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 14px; font-weight: 700; margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.card-title .more { font-size: 12px; color: var(--accent); font-weight: 600; cursor: pointer; }
.muted { color: var(--text-dim); }
.section-label { font-size: 13px; color: var(--text-dim); margin: 18px 2px 8px; font-weight: 600; }

/* ---------- Stat pills (dashboard) ---------- */
.stat-row { display: flex; gap: 10px; margin-top: 12px; }
.stat-pill {
  flex: 1; background: var(--bg-elev2); border-radius: var(--radius-md);
  padding: 12px 6px; text-align: center; border: 1px solid var(--card-border);
}
.stat-pill .num { font-size: 20px; font-weight: 800; color: var(--accent); }
.stat-pill .lbl { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: var(--radius-md);
  padding: 13px 16px; font-size: 14.5px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn-secondary { background: var(--bg-elev2); color: var(--text); border: 1px solid var(--card-border); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-sm { padding: 9px 12px; font-size: 13px; width: auto; }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: .5; pointer-events: none; }

.fab {
  position: fixed; bottom: calc(84px + var(--safe-bottom)); left: 50%;
  transform: translateX(-50%);
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: none; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px rgba(124,92,252,.45);
  border: 4px solid var(--bg); cursor: pointer; z-index: 40;
  max-width: 480px;
}
.fab svg { width: 24px; height: 24px; color: #fff; }

/* ---------- Bottom Nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: var(--bg-elev1); border-top: 1px solid var(--card-border);
  display: flex; padding: 8px 6px calc(8px + var(--safe-bottom));
  z-index: 30;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; color: var(--text-faint); padding: 6px 2px; cursor: pointer;
  font-size: 10.5px;
}
.nav-btn svg { width: 21px; height: 21px; }
.nav-btn.active { color: var(--accent); }

/* ---------- Task list ---------- */
.task-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-elev1); border: 1px solid var(--card-border);
  border-radius: var(--radius-md); padding: 12px; margin-bottom: 9px;
}
.task-check {
  width: 24px; height: 24px; min-width: 24px; border-radius: 50%;
  border: 2px solid var(--text-faint); display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.task-check.done { background: var(--green); border-color: var(--green); }
.task-check.done svg { width: 13px; height: 13px; color: #06281c; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 14px; font-weight: 600; }
.task-title.done { text-decoration: line-through; color: var(--text-faint); }
.task-meta { display: flex; gap: 6px; margin-top: 5px; flex-wrap: wrap; align-items: center; }
.chip { font-size: 10.5px; padding: 3px 8px; border-radius: 20px; font-weight: 700; white-space: nowrap; }
.chip-high { background: var(--red-soft); color: var(--red); }
.chip-med { background: var(--yellow-soft); color: var(--yellow); }
.chip-low { background: var(--green-soft); color: var(--green); }
.chip-time { background: var(--bg-elev3); color: var(--text-dim); font-weight: 600; }
.chip-cat { background: var(--accent-soft); color: var(--accent); }
.task-drag { color: var(--text-faint); font-size: 18px; padding: 2px 4px; cursor: grab; }

.filter-tabs { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; padding-bottom: 2px; }
.filter-tab {
  padding: 7px 14px; border-radius: 20px; font-size: 12.5px; font-weight: 600;
  background: var(--bg-elev2); color: var(--text-dim); border: 1px solid var(--card-border);
  white-space: nowrap; cursor: pointer;
}
.filter-tab.active { background: var(--accent); color: #fff; border-color: transparent; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
.field input[type=text], .field input[type=number], .field input[type=password],
.field input[type=time], .field input[type=date],
.field textarea, .field select {
  width: 100%; background: var(--bg-elev2); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 12px; color: var(--text); font-size: 14px;
  font-family: inherit;
  color-scheme: dark;
}
:root[data-theme="light"] .field input[type=time], :root[data-theme="light"] .field input[type=date] { color-scheme: light; }
.field textarea { resize: vertical; min-height: 70px; }
.seg-group { display: flex; gap: 8px; }
.seg-btn {
  flex: 1; text-align: center; padding: 10px 4px; border-radius: var(--radius-sm);
  background: var(--bg-elev2); border: 1px solid var(--card-border); color: var(--text-dim);
  font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.seg-btn.active.prio-high { background: var(--red-soft); color: var(--red); border-color: var(--red); }
.seg-btn.active.prio-med { background: var(--yellow-soft); color: var(--yellow); border-color: var(--yellow); }
.seg-btn.active.prio-low { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.seg-btn.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.row2 { display: flex; gap: 10px; }
.row2 > * { flex: 1; }

.toggle { position: relative; width: 46px; height: 26px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .track {
  position: absolute; inset: 0; background: var(--bg-elev3); border-radius: 20px;
  transition: .2s; cursor: pointer;
}
.toggle .track::before {
  content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::before { transform: translateX(-20px); }

/* ---------- Voice / Mic ---------- */
.mic-hero { display: flex; flex-direction: column; align-items: center; padding: 30px 10px 10px; }
.mic-btn {
  width: 92px; height: 92px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 0 rgba(124,92,252,.5);
  color: #fff;
}
.mic-btn svg { width: 34px; height: 34px; }
.mic-btn.listening { animation: pulse 1.4s infinite; background: linear-gradient(135deg, var(--red), #ff8a8a); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(248,113,113,.5); }
  70% { box-shadow: 0 0 0 22px rgba(248,113,113,0); }
  100% { box-shadow: 0 0 0 0 rgba(248,113,113,0); }
}
.mic-status { margin-top: 14px; font-size: 13px; color: var(--text-dim); text-align: center; min-height: 18px; }
.mic-transcript {
  margin-top: 14px; width: 100%; min-height: 54px; background: var(--bg-elev2);
  border-radius: var(--radius-md); padding: 12px; font-size: 14px; color: var(--text);
  border: 1px solid var(--card-border);
}
.voice-preview-list { margin-top: 14px; }
.vp-row { display: flex; justify-content: space-between; padding: 9px 4px; border-bottom: 1px dashed var(--card-border); font-size: 13px; }
.vp-row:last-child { border-bottom: none; }
.vp-label { color: var(--text-dim); }
.vp-val { font-weight: 700; }

/* ---------- Add task quick tabs ---------- */
.add-type-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.add-type-tab { flex: 1; text-align: center; padding: 10px 4px; border-radius: var(--radius-sm);
  background: var(--bg-elev2); font-size: 12px; font-weight: 700; color: var(--text-dim); cursor: pointer; }
.add-type-tab.active { background: var(--accent-soft); color: var(--accent); }

/* ---------- Calendar ---------- */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-header .cal-title { font-size: 15px; font-weight: 800; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-wd { font-size: 11px; color: var(--text-faint); padding: 4px 0; font-weight: 700; }
.cal-day {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 10px; font-size: 12.5px; cursor: pointer; position: relative; color: var(--text);
  background: var(--bg-elev1); border: 1px solid transparent;
}
.cal-day.other { color: var(--text-faint); opacity: .35; }
.cal-day.today { border-color: var(--accent); font-weight: 800; }
.cal-day.selected { background: var(--accent); color: #fff; }
.cal-day .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); margin-top: 3px; }
.cal-day.selected .dot { background: #fff; }

/* ---------- Goals / Habits ---------- */
.progress-bar { height: 8px; background: var(--bg-elev3); border-radius: 10px; overflow: hidden; margin-top: 8px; }
.progress-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 10px; }
.goal-card .goal-top { display: flex; justify-content: space-between; align-items: center; }
.goal-card .goal-frac { font-size: 12px; color: var(--text-dim); font-weight: 700; }
.habit-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.habit-card { background: var(--bg-elev1); border: 1px solid var(--card-border); border-radius: var(--radius-md); padding: 12px; }
.habit-card .h-title { font-size: 13px; font-weight: 700; display:flex; align-items:center; gap:6px;}
.habit-card .h-streak { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.week-dots { display: flex; gap: 4px; margin-top: 8px; justify-content: space-between; }
.week-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--bg-elev3); font-size: 9px;
  display:flex; align-items:center; justify-content:center; color: var(--text-faint); }
.week-dot.on { background: var(--green); color: #06281c; }

/* ---------- Focus timer ---------- */
.focus-wrap { display: flex; flex-direction: column; align-items: center; padding-top: 10px; }
.timer-ring { position: relative; width: 220px; height: 220px; }
.timer-ring svg { transform: rotate(-90deg); }
.timer-ring .bg { stroke: var(--bg-elev3); }
.timer-ring .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.timer-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.timer-center .t { font-size: 38px; font-weight: 800; letter-spacing: 1px; }
.timer-center .l { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.timer-controls { display: flex; gap: 12px; margin-top: 22px; }
.timer-controls .icon-btn { width: 52px; height: 52px; border-radius: 50%; }
.timer-controls .icon-btn.play { background: var(--accent); color: #fff; }
.chip-row { display:flex; gap:8px; margin-top:18px; flex-wrap:wrap; justify-content:center; }

/* ---------- Reports ---------- */
.donut-wrap { display: flex; align-items: center; gap: 16px; }
canvas { max-width: 100%; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin-top: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }

/* ---------- Notes / shopping ---------- */
.note-card { background: var(--bg-elev1); border:1px solid var(--card-border); border-radius: var(--radius-md); padding: 12px; margin-bottom: 9px; }
.note-card .n-text { font-size: 13.5px; white-space: pre-wrap; }
.note-card .n-meta { font-size: 11px; color: var(--text-faint); margin-top: 6px; }
.shop-item, .sub-row { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px dashed var(--card-border); }
.shop-item:last-child, .sub-row:last-child { border-bottom: none; }
.shop-item .s-title.done, .sub-row .s-title.done { text-decoration: line-through; color: var(--text-faint); }

/* ---------- Modal / bottom sheet ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none;
  align-items: flex-end; justify-content: center; z-index: 100;
}
.overlay.show { display: flex; }
.sheet {
  background: var(--bg-elev1); width: 100%; max-width: 480px;
  border-radius: 22px 22px 0 0; padding: 18px 18px calc(24px + var(--safe-bottom));
  max-height: 88vh; overflow-y: auto;
  animation: sheetup .22s ease;
}
@keyframes sheetup { from { transform: translateY(30px); opacity:.4;} to { transform:none; opacity:1;} }
.sheet-handle { width: 40px; height: 4px; background: var(--bg-elev3); border-radius: 4px; margin: 0 auto 14px; }
.sheet-title { font-size: 16px; font-weight: 800; margin-bottom: 14px; }

/* ---------- PIN lock ---------- */
#pinLockScreen {
  position: fixed; inset: 0; background: var(--bg); z-index: 500;
  display: none; flex-direction: column; align-items: center; justify-content: center; padding: 20px;
}
#pinLockScreen.show { display: flex; }
.pin-dots { display: flex; gap: 14px; margin: 22px 0; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--text-faint); }
.pin-dot.filled { background: var(--accent); border-color: var(--accent); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 64px); gap: 16px; }
.pin-key {
  width: 64px; height: 64px; border-radius: 50%; background: var(--bg-elev2); border: 1px solid var(--card-border);
  color: var(--text); font-size: 20px; font-weight: 700; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.pin-key.empty { background: transparent; border: none; }

/* ---------- Toast ---------- */
#toastHost { position: fixed; bottom: calc(150px + var(--safe-bottom)); left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; width: calc(100% - 40px); max-width: 440px; align-items:center;}
.toast {
  background: var(--bg-elev3); color: var(--text); padding: 11px 16px; border-radius: 12px;
  font-size: 13px; box-shadow: var(--shadow); animation: toastin .2s ease; text-align:center;
  border: 1px solid var(--card-border);
}
@keyframes toastin { from { opacity:0; transform: translateY(10px);} to {opacity:1; transform:none;} }

/* ---------- Settings list ---------- */
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 2px; border-bottom: 1px solid var(--card-border); }
.settings-row:last-child { border-bottom: none; }
.settings-row .sr-label { font-size: 13.5px; font-weight: 600; }
.settings-row .sr-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.settings-row .sr-left { display:flex; gap:10px; align-items:center; }
.settings-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent);
  display:flex; align-items:center; justify-content:center; }
.settings-icon svg { width:17px; height:17px; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 40px 10px; color: var(--text-dim); }
.empty-state svg { width: 46px; height: 46px; color: var(--text-faint); margin-bottom: 10px; }
.empty-state p { font-size: 13px; }

/* ---------- Energy mode ---------- */
.energy-row { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; }
.energy-opt { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 2px;
  border-radius: var(--radius-md); cursor: pointer; font-size: 22px; background: var(--bg-elev2); border: 2px solid transparent; }
.energy-opt.active { border-color: var(--accent); background: var(--accent-soft); }
.energy-opt .el { font-size: 10.5px; color: var(--text-dim); font-weight: 600; }

/* ---------- misc ---------- */
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.hidden { display: none !important; }
.center-text { text-align: center; }
.small { font-size: 11.5px; color: var(--text-dim); }
.link-text { color: var(--accent); font-weight: 700; cursor: pointer; font-size: 13px; }
.badge { display:inline-flex; align-items:center; justify-content:center; min-width:18px; height:18px; border-radius:9px;
  background: var(--red); color:#fff; font-size:10px; font-weight:800; padding:0 5px; }

@media (max-width: 360px) {
  .pin-pad { grid-template-columns: repeat(3, 56px); }
  .pin-key { width: 56px; height: 56px; }
}
