/* ============================================================
   TaskModule CSS — هم‌شکل با بقیه‌ی ماژول‌ها. پیشوند tm-.
   ============================================================ */

.task-module {
  --tm-c-bg: #f5f5f3;
  --tm-c-surface: #ffffff;
  --tm-c-border: rgba(0,0,0,0.08);
  --tm-c-border-strong: rgba(0,0,0,0.14);
  --tm-c-text: #1a1a18;
  --tm-c-text-2: #5a5a56;
  --tm-c-text-3: #9a9994;
  --tm-c-accent: #2563eb;
  --tm-c-accent-bg: #eff6ff;
  --tm-c-accent-text: #1d4ed8;
  --tm-c-accent-border: #bfdbfe;
  --tm-c-success: #16a34a;
  --tm-c-success-bg: #f0fdf4;
  --tm-c-success-text: #15803d;
  --tm-c-success-border: #bbf7d0;
  --tm-c-warning: #d97706;
  --tm-c-warning-bg: #fffbeb;
  --tm-c-warning-text: #b45309;
  --tm-c-warning-border: #fde68a;
  --tm-c-danger: #dc2626;
  --tm-c-danger-bg: #fef2f2;
  --tm-c-danger-text: #b91c1c;
  --tm-c-danger-border: #fecaca;
  --tm-radius-sm: 6px;
  --tm-radius: 10px;
  --tm-radius-lg: 14px;
  --tm-transition: 0.15s ease;

  font-family: 'Vazirmatn', system-ui, sans-serif;
  color: var(--tm-c-text);
  font-size: 13px;
  line-height: 1.5;
  position: relative;
}

[data-theme="dark"] .task-module {
  --tm-c-bg: #15161a;
  --tm-c-surface: #1c1d22;
  --tm-c-border: rgba(255,255,255,0.08);
  --tm-c-border-strong: rgba(255,255,255,0.14);
  --tm-c-text: #f1f1ef;
  --tm-c-text-2: #b3b3ad;
  --tm-c-text-3: #76766f;
  --tm-c-accent-bg: rgba(37,99,235,0.14);
  --tm-c-success-bg: rgba(22,163,74,0.14);
  --tm-c-warning-bg: rgba(217,119,6,0.14);
  --tm-c-danger-bg: rgba(220,38,38,0.14);
}

.task-module * { box-sizing: border-box; }

/* ── Page header ── */
.tm-page-hdr { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.tm-page-title { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.tm-page-desc { font-size: 13px; color: var(--tm-c-text-3); margin-top: 3px; }

/* ── Buttons ── */
.tm-btn { display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; height: 34px; border-radius: var(--tm-radius-sm); border: 1px solid var(--tm-c-border-strong); background: var(--tm-c-surface); color: var(--tm-c-text); font-size: 12px; font-weight: 500; cursor: pointer; font-family: inherit; transition: background var(--tm-transition), border-color var(--tm-transition); white-space: nowrap; }
.tm-btn:hover { background: var(--tm-c-bg); }
.tm-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.tm-btn i { font-size: 14px; }
.tm-btn-primary { background: var(--tm-c-accent); border-color: var(--tm-c-accent); color: #fff; }
.tm-btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }

/* ── Card / table ── */
.tm-card { background: var(--tm-c-surface); border: 1px solid var(--tm-c-border); border-radius: var(--tm-radius-lg); overflow: hidden; }
.tm-tbl-wrap { overflow-x: auto; }
table.tm-tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
table.tm-tbl th { text-align: right; padding: 10px 14px; color: var(--tm-c-text-3); font-weight: 600; font-size: 11px; border-bottom: 1px solid var(--tm-c-border); background: var(--tm-c-bg); }
table.tm-tbl td { padding: 11px 14px; border-bottom: 1px solid var(--tm-c-border); vertical-align: middle; }
table.tm-tbl tr:hover td { background: var(--tm-c-bg); }
.tm-mono { font-family: 'Courier New', monospace; }
td.tm-row-actions { white-space: nowrap; }
.tm-row-act-btn { width: 27px; height: 27px; border: 1px solid var(--tm-c-border); background: var(--tm-c-surface); border-radius: var(--tm-radius-sm); display: inline-flex; align-items: center; justify-content: center; color: var(--tm-c-text-2); cursor: pointer; margin-inline-start: 4px; }
.tm-row-act-btn:hover { background: var(--tm-c-accent-bg); border-color: var(--tm-c-accent-border); color: var(--tm-c-accent); }
.tm-row-act-btn.danger:hover { background: var(--tm-c-danger-bg); border-color: var(--tm-c-danger-border); color: var(--tm-c-danger); }

/* ── Badge ── */
.tm-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; background: var(--tm-c-accent-bg); color: var(--tm-c-accent-text); border: 1px solid var(--tm-c-accent-border); }
.tm-b-warning { background: var(--tm-c-warning-bg); color: var(--tm-c-warning-text); border-color: var(--tm-c-warning-border); }

/* ── Toolbar / search / filter ── */
.tm-toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--tm-c-border); flex-wrap: wrap; }
.tm-search-box { display: flex; align-items: center; gap: 8px; background: var(--tm-c-bg); border: 1px solid var(--tm-c-border); border-radius: var(--tm-radius-sm); padding: 0 10px; height: 34px; flex: 1; min-width: 180px; }
.tm-search-box input { border: none; outline: none; background: transparent; font-family: inherit; font-size: 12.5px; color: var(--tm-c-text); width: 100%; height: 100%; }
.tm-filter-select { height: 34px; border: 1px solid var(--tm-c-border-strong); border-radius: var(--tm-radius-sm); padding: 0 10px; font-size: 12px; background: var(--tm-c-surface); color: var(--tm-c-text); font-family: inherit; }

/* ── Form ── */
.tm-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tm-field { display: flex; flex-direction: column; gap: 5px; }
.tm-field-check { display: flex; align-items: center; font-size: 13px; font-weight: 500; color: var(--tm-c-text); cursor: pointer; margin-top: 22px; }
.tm-field label { font-size: 11px; font-weight: 600; color: var(--tm-c-text-2); }
.tm-field input, .tm-field select, .tm-field textarea { border: 1px solid var(--tm-c-border-strong); border-radius: var(--tm-radius-sm); padding: 8px 11px; font-size: 13px; background: var(--tm-c-surface); color: var(--tm-c-text); font-family: inherit; outline: none; }
.tm-field input:focus, .tm-field select:focus { border-color: var(--tm-c-accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.tm-form-actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--tm-c-border); }
.tm-persian-date-input { width: 100%; height: 36px; border: 1px solid var(--tm-c-border-strong); border-radius: var(--tm-radius-sm); padding: 0 11px; font-size: 13px; font-family: inherit; }

/* ── Chapter picker (dual list) ── */
.tm-picker-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tm-picker-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tm-picker-col-title { font-size: 11px; font-weight: 600; color: var(--tm-c-text-2); }
.tm-picker-toolbar { margin-bottom: 4px; }
.tm-picker-list { border: 1px solid var(--tm-c-border); border-radius: var(--tm-radius); max-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding: 6px; }
.tm-picker-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--tm-radius-sm); cursor: pointer; }
.tm-picker-item:hover { background: var(--tm-c-bg); }
.tm-picker-item.selected { background: var(--tm-c-accent-bg); }
.tm-picker-item i { font-size: 16px; color: var(--tm-c-text-3); flex-shrink: 0; }
.tm-picker-item.selected i { color: var(--tm-c-accent); }
.tm-picker-item-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.tm-picker-item-info strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-picker-item-info span { font-size: 10.5px; color: var(--tm-c-text-3); }

/* ── Modal ── */
.tm-modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,15,14,0.5); z-index: 10000; align-items: center; justify-content: center; padding: 20px; }
.tm-modal-backdrop.open { display: flex; }
.tm-modal-box { width: 100%; max-width: 680px; background: var(--tm-c-surface); border-radius: var(--tm-radius-lg); border: 1px solid var(--tm-c-border); box-shadow: 0 24px 64px rgba(0,0,0,0.32); max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; }
.tm-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--tm-c-border); }
.tm-modal-title { font-size: 14px; font-weight: 600; }
.tm-modal-close { width: 30px; height: 30px; border: none; background: var(--tm-c-bg); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--tm-c-text-2); cursor: pointer; }
.tm-modal-close:hover { background: var(--tm-c-border); }
.tm-modal-body { padding: 20px; overflow-y: auto; }
.tm-modal-actions { display: flex; gap: 8px; margin-top: 20px; }
.tm-modal-actions .tm-btn { flex: 1; justify-content: center; }
.tm-confirm-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--tm-c-danger-bg); color: var(--tm-c-danger); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; font-size: 26px; }
.tm-confirm-text { text-align: center; font-size: 13px; color: var(--tm-c-text-2); line-height: 1.7; }

/* ── Toast ── */
.tm-toast-wrap { position: fixed; bottom: 24px; left: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.tm-toast { display: flex; align-items: center; gap: 10px; background: var(--tm-c-text); color: #fff; padding: 12px 16px; border-radius: var(--tm-radius); font-size: 13px; font-weight: 500; cursor: pointer; }

/* ── Loading / empty ── */
.tm-loading { display: flex; justify-content: center; padding: 30px 0; }
.tm-spinner { width: 14px; height: 14px; border: 2px solid var(--tm-c-border-strong); border-top-color: var(--tm-c-text-2); border-radius: 50%; display: inline-block; animation: tmSpin 0.7s linear infinite; }
.tm-spinner.large { width: 26px; height: 26px; border-width: 3px; }
@keyframes tmSpin { to { transform: rotate(360deg); } }
.tm-empty { text-align: center; padding: 30px 20px; color: var(--tm-c-text-3); }
.tm-empty i { font-size: 28px; margin-bottom: 8px; display: block; opacity: 0.4; }

/* ══════════════════════════════════════════
   زیرفاز ۲: ویزارد برنامه‌ریزی، فهرست تسک دانش‌آموز، تقویم
   ══════════════════════════════════════════ */

/* ── View toggle (فهرست تسک) ── */
.tm-view-toggle { display: flex; border: 1px solid var(--tm-c-border-strong); border-radius: 20px; overflow: hidden; }
.tm-view-toggle button { border: none; background: var(--tm-c-surface); padding: 8px 16px; font-size: 12px; cursor: pointer; font-family: inherit; color: var(--tm-c-text-2); }
.tm-view-toggle button.active { background: var(--tm-c-accent); color: #fff; }

/* ── Wizard ── */
.tm-wizard-card { max-width: 640px; margin: 0 auto; background: var(--tm-c-surface); border: 1px solid var(--tm-c-border); border-radius: var(--tm-radius-lg); padding: 24px; }
.tm-wizard-timeline { display: flex; justify-content: space-between; margin-bottom: 28px; gap: 6px; }
.tm-wizard-step { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; text-align: center; opacity: 0.5; }
.tm-wizard-step.active, .tm-wizard-step.done { opacity: 1; }
.tm-wizard-step-circle { width: 36px; height: 36px; border-radius: 50%; background: var(--tm-c-bg); border: 2px solid var(--tm-c-border-strong); display: flex; align-items: center; justify-content: center; font-size: 16px; color: var(--tm-c-text-3); }
.tm-wizard-step.active .tm-wizard-step-circle { background: var(--tm-c-accent); border-color: var(--tm-c-accent); color: #fff; }
.tm-wizard-step.done .tm-wizard-step-circle { background: var(--tm-c-success); border-color: var(--tm-c-success); color: #fff; }
.tm-wizard-step-text { display: flex; flex-direction: column; }
.tm-wizard-step-text strong { font-size: 10.5px; }
.tm-wizard-step-text span { font-size: 9.5px; color: var(--tm-c-text-3); }

.tm-wizard-step-panel { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.tm-wizard-img { max-width: 220px; width: 100%; border-radius: var(--tm-radius); }
.tm-wizard-step-body p { font-size: 13px; color: var(--tm-c-text-2); line-height: 1.9; }
.tm-wizard-quote { font-size: 13px; color: var(--tm-c-text-2); font-weight: 600; }
.tm-wizard-quote.success { color: var(--tm-c-success-text); }

/* ── Progress ring ── */
.tm-progress-ring { position: relative; width: 160px; height: 160px; margin: 8px auto; }
.tm-progress-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.tm-ring-bg { fill: none; stroke: var(--tm-c-bg); stroke-width: 10; }
.tm-ring-fg { fill: none; stroke: var(--tm-c-accent); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 0.1s linear; }
.tm-ring-value { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.tm-ring-value strong { font-size: 22px; font-weight: 700; }
.tm-ring-value span { font-size: 11px; color: var(--tm-c-text-3); }

/* ── Upload zone (CSV import) ── */
.tm-upload-zone { border: 1.5px dashed var(--tm-c-border-strong); border-radius: var(--tm-radius-lg); padding: 32px 16px; text-align: center; color: var(--tm-c-text-3); cursor: pointer; transition: border-color var(--tm-transition), background var(--tm-transition); }
.tm-upload-zone:hover, .tm-upload-zone.drag { border-color: var(--tm-c-accent); background: var(--tm-c-accent-bg); color: var(--tm-c-accent-text); }
.tm-upload-zone i { font-size: 30px; display: block; margin-bottom: 10px; }
.tm-upload-zone .tm-uz-sub { font-size: 11px; margin-top: 4px; }

/* ── Calendar ── */
#tmCalendar { max-width: 900px; margin: 0 auto; }
.fc { direction: rtl; font-family: 'Vazirmatn', sans-serif; }

@media (max-width: 720px) {
  .tm-form-grid, .tm-picker-grid { grid-template-columns: 1fr; }
  .tm-modal-backdrop { padding: 0; align-items: flex-end; }
  .tm-modal-box { max-width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; }
  td.tm-row-actions { display: flex !important; gap: 6px; }
  .tm-toast-wrap { bottom: 12px; left: 12px; right: 12px; }
  .tm-toast { width: 100%; }
}
