@font-face {
  font-family: "Bonyad";
  src: url(./Font/BONYADEKOODAK-REGULAR.TTF);
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Bonyad";
  src: url(./Font/BONYADEKOODAK-BOLD.TTF);
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --radius: 14px;
  font-size: 15px;
}

/* ================= تم‌های رنگی ================= */

/* ۱) آسمان روز — آبی آسمانی روشن (لایت مود) */
[data-theme="sky-light"] {
  --primary: #2f8fd9;
  --primary-dark: #14497a;
  --bg: #eef5fb;
  --card: #ffffff;
  --text: #0f2b42;
  --muted: #5f7f97;
  --border: #d6e6f2;
  --danger: #d64550;
  --success: #2f9d6f;
  --shadow: 0 10px 30px rgba(15, 43, 66, 0.08);
}

/* ۲) آسمان شب — همون آبی و مشکی قبلی، اصلاح‌شده و نزدیک‌تر به رنگ واقعی آسمون شب */
[data-theme="sky-dark"] {
  --primary: #5fb8ec;
  --primary-dark: #9bd8fa;
  --bg: #0a1420;
  --card: #101f30;
  --text: #e6f1fa;
  --muted: #7f9db4;
  --border: #1e3348;
  --danger: #ef6b72;
  --success: #4bcf9a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* ۳) جنگل — تم سبز */
[data-theme="green"] {
  --primary: #2e9e5b;
  --primary-dark: #1b6b3c;
  --bg: #eef7f0;
  --card: #ffffff;
  --text: #143322;
  --muted: #5f8770;
  --border: #d3ead9;
  --danger: #d64550;
  --success: #1f7a43;
  --shadow: 0 10px 30px rgba(20, 51, 34, 0.08);
}

/* ۴) شب طلایی — مشکی و طلایی */
[data-theme="gold"] {
  --primary: #d4af37;
  --primary-dark: #f0cf6c;
  --bg: #0d0c09;
  --card: #191610;
  --text: #f5ecd7;
  --muted: #a0916b;
  --border: #362f1f;
  --danger: #e0473e;
  --success: #4bcf9a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* ۵) شب سرخ — مشکی و قرمز */
[data-theme="red"] {
  --primary: #e0473e;
  --primary-dark: #ff7d74;
  --bg: #0d0808;
  --card: #1c1213;
  --text: #f7e6e4;
  --muted: #b08682;
  --border: #3a2220;
  --danger: #ff6b61;
  --success: #4bcf9a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* ۶) کهکشان بنفش — تم اضافه به سلیقه‌ی خودم */
[data-theme="purple"] {
  --primary: #9b6bd9;
  --primary-dark: #c3a3f0;
  --bg: #130a1f;
  --card: #1e1330;
  --text: #ece6f7;
  --muted: #9a86b8;
  --border: #33234a;
  --danger: #ef6b72;
  --success: #4bcf9a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Bonyad", "Vazirmatn", "Tahoma", system-ui, sans-serif;
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

.hidden {
  display: none !important;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.82rem;
}
.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
}

/* ---------- آیکون‌های مینیمال ---------- */
.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
  flex-shrink: 0;
}
.icon-sm {
  width: 14px;
  height: 14px;
}

/* ---------- Login ---------- */
#loginScreen.screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card h1 {
  margin: 0 0 4px;
  font-size: 1.4rem;
  color: var(--primary-dark);
}
.login-card form {
  text-align: right;
  margin-top: 18px;
}

label {
  display: block;
  font-size: 0.85rem;
  margin: 12px 0 6px;
  color: var(--muted);
}
input,
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
}
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  transition:
    transform 0.05s ease,
    opacity 0.15s ease,
    background 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:active {
  transform: scale(0.97);
}
.btn.primary {
  background: var(--primary);
  color: #fff;
}
.btn.primary:hover {
  background: var(--primary-dark);
}
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn.block {
  width: 100%;
  margin-top: 18px;
  justify-content: center;
}
.btn.small {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.icon-btn-plain {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  border-radius: 8px;
}
.icon-btn-plain:hover {
  background: var(--border);
  color: var(--text);
}
/* ---------- زنگوله‌ی اعلان‌ها ---------- */
.notif-bell-btn {
  position: relative;
}
.notif-badge {
  position: absolute;
  top: 2px;
  left: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #e0473e;
  color: #fff;
  font-size: 0.62rem;
  line-height: 16px;
  text-align: center;
  font-weight: 700;
}

.notif-modal {
  max-width: 460px;
}
.notif-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.notif-modal-head h2 {
  margin: 0;
}
.notif-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  max-height: 55vh;
  overflow-y: auto;
}
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.notif-item.unread {
  border-color: var(--primary);
  background: rgba(47, 143, 217, 0.08);
}
.notif-item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 6px;
  flex-shrink: 0;
}
.notif-item.read .notif-item-dot {
  background: transparent;
}
.notif-item-body {
  flex: 1;
  min-width: 0;
}
.notif-item-text {
  font-size: 0.9rem;
  line-height: 1.5;
}
.notif-item.read .notif-item-text {
  color: var(--muted);
}
.notif-item-time {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 4px;
}
.notif-item-mark {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
  padding: 4px 6px;
}
.notif-item.read .notif-item-mark {
  visibility: hidden;
}

/* ---------- App shell ---------- */
#appScreen.screen {
  max-width: 640px;
  margin: 0 auto;
  padding-bottom: 90px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar-title {
  display: flex;
  flex-direction: column;
}
.topbar-title strong {
  font-size: 1.05rem;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.owner-toggle {
  display: flex;
  gap: 8px;
  padding: 12px 16px 0;
}
.owner-btn {
  flex: 1;
  padding: 9px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
}
.owner-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 14px 16px 6px;
  overflow-x: auto;
}
.tab-btn {
  flex: 1;
  padding: 9px 4px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  white-space: nowrap;
}
.tab-btn.active {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
  font-weight: 700;
}
[data-mode="dark"] .tab-btn.active {
  color: var(--primary);
}

main {
  padding: 10px 16px 20px;
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

/* ---------- Task cards ---------- */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.task-card.done {
  opacity: 0.55;
}
.task-card.done .task-title {
  text-decoration: line-through;
}

.task-check {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.task-check.checked {
  background: var(--success);
  border-color: var(--success);
}
.task-check.readonly {
  cursor: default;
}

.task-body {
  flex: 1;
  min-width: 0;
}
.task-title {
  font-weight: 700;
  font-size: 1rem;
}
.task-desc {
  color: var(--muted);
  font-size: 0.87rem;
  margin-top: 3px;
}
.task-desc.history-date {
  font-size: 0.78rem;
  margin-top: 6px;
  opacity: 0.85;
}
.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.badge {
  font-size: 0.76rem;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--bg);
  color: var(--primary-dark);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
[data-mode="dark"] .badge {
  color: var(--primary);
}

.task-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.icon-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
}
.icon-btn:hover {
  color: var(--primary);
}
.icon-btn.danger-hover:hover {
  color: var(--danger);
}

.day-section {
  margin-bottom: 18px;
  border-bottom: 1px #14497a;
}
.day-section h3 {
  font-size: 0.95rem;
  margin: 0 0 8px;
  color: var(--primary-dark);
}
[data-mode="dark"] .day-section h3 {
  color: var(--primary);
}
.day-section .date-sub {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.8rem;
}

.empty-hint {
  color: var(--muted);
  text-align: center;
  padding: 30px 10px;
  font-size: 0.9rem;
}

/* ---------- تب در حال انجام ---------- */
.progress-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.progress-card.active {
  border-color: var(--primary);
}
.progress-label {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 8px;
}
.progress-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 3px;
}
.progress-desc {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 10px;
}
.progress-countdown {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--primary-dark);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 20px;
  line-height: 1.4;
  white-space: nowrap;
}
.progress-countdown .icon {
  width: 13px;
  height: 13px;
}
[data-mode="dark"] .progress-countdown {
  color: var(--primary);
}
.progress-next {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(47, 143, 217, 0.4);
  cursor: pointer;
  z-index: 20;
}
.fab .icon {
  width: 26px;
  height: 26px;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 34, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
  }
}
.modal {
  background: var(--card);
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  padding: 20px;
}
@media (min-width: 640px) {
  .modal {
    border-radius: 18px;
  }
}
.modal h2 {
  margin-top: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.repeat-type-toggle {
  margin-top: 6px;
}
.repeat-type-hint {
  margin-top: 6px;
  margin-bottom: 4px;
}
.badge.badge-once {
  background: rgba(224, 71, 62, 0.12);
  color: #e0473e;
}
[data-mode="dark"] .badge.badge-once {
  background: rgba(224, 71, 62, 0.22);
  color: #ff9d97;
}

.time-row {
  display: flex;
  gap: 10px;
}
.time-row > div {
  flex: 1;
}
.time-hint {
  margin-top: 6px;
}
.hint-red {
  color: var(--danger);
  font-size: 0.5rem;
  margin: 6px 0 0;
}

.days-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
#allDaysBtn {
  margin-top: 10px;
}

.day-chip {
  padding: 7px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
}
.day-chip.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  justify-content: flex-end;
}

.history-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.history-controls label {
  font-size: 0.8rem;
  margin: 0;
}
.history-controls input {
  padding: 7px 9px;
}
.jalali-range {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.jalali-date-group {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
}
.jalali-date-group select {
  padding: 6px 4px;
  font-size: 0.82rem;
  width: auto;
  min-width: 56px;
}

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 0.9rem;
  z-index: 100;
  min-width: 260px;
  max-width: 90vw;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(47, 143, 217, 0.08),
    0 10px 30px rgba(47, 143, 217, 0.35);
  animation: toast-pop-in 0.22s ease;
}
@keyframes toast-pop-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}
.toast-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
}

.toast-text {
  flex: 1;
  line-height: 1.4;
  color: var(--text);
}
.toast-undo {
  color: var(--muted);
  background: transparent;
  border: none;
  font-weight: 700;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  padding: 4px 2px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.toast-undo:hover {
  color: var(--primary);
}
.toast-undo:active {
  opacity: 0.7;
}
.toast-bar {
  height: 3px;
  background: var(--primary);
  width: 100%;
  transform-origin: right;
}
.toast-bar.animate {
  transition: transform linear;
  transform: scaleX(0);
}

/* ---------- انتخاب تم ---------- */
.theme-modal {
  max-width: 420px;
}
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 16px;
}
.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  text-align: right;
}
.theme-option.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.03) inset;
}
.theme-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: conic-gradient(
    var(--sw-primary) 0deg 180deg,
    var(--sw-bg) 180deg 360deg
  );
}
.theme-option-label {
  font-size: 0.88rem;
  font-weight: 600;
  flex: 1;
}
.theme-option-check {
  display: none;
  color: var(--primary);
}
.theme-option.active .theme-option-check {
  display: flex;
}
#themeModal.first-run #themeCloseBtn {
  display: none;
}

/* ---------- کارت در حالت در انتظار تایید (قبل از قطعی شدن) ---------- */
.task-card.pending {
  opacity: 0.5;
}
.task-card.pending .task-check {
  pointer-events: none;
}
