/* ============ التقويم ============ */
.cal-bar { margin-bottom: 10px; }
.cal-nav { gap: 6px; flex-wrap: wrap; }
.cal-title { font-size: 18px; font-weight: 700; min-width: 150px; text-align: center; }
/* زر الشهر السابق يشير عكس اتجاه القراءة */
.cal-prev .ic-chev { transform: scaleX(-1); }
[dir="ltr"] .cal-prev .ic-chev { transform: none; }

/* فلاتر الأنواع */
.cal-types { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.cal-type { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); padding: 5px 11px; border-radius: 20px; font-size: 12.5px; cursor: pointer; color: var(--muted); font-weight: 500; transition: background .15s, border-color .15s, opacity .15s; }
.cal-type i { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--c); background: transparent; flex: none; }
.cal-type b { font-size: 11px; font-weight: 600; color: var(--faint); }
.cal-type.on { color: var(--text); border-color: color-mix(in srgb, var(--c) 45%, var(--border)); background: color-mix(in srgb, var(--c) 10%, var(--surface)); }
.cal-type.on i { background: var(--c); }
.cal-type:not(.on) { opacity: .65; }

/* الشبكة الشهرية */
.cal { overflow: hidden; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head div { padding: 9px 10px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); text-align: start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-head .d1 { display: none; }
.cal-cell { min-width: 0; min-height: 118px; padding: 6px; display: flex; flex-direction: column; gap: 3px; border-inline-end: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.cal-cell:nth-child(7n) { border-inline-end: 0; }
.cal-grid .cal-cell:nth-last-child(-n + 7) { border-bottom: 0; }
.cal-cell.we { background: color-mix(in srgb, var(--surface-2) 70%, var(--surface)); }
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.out .cal-dn, .cal-cell.out .cal-evs { opacity: .45; }
.cal-cell.today { background: color-mix(in srgb, var(--primary-soft) 70%, var(--surface)); box-shadow: inset 0 0 0 2px var(--primary); }
.cal-dn { display: flex; align-items: center; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.cal-dn span { min-width: 24px; height: 24px; padding: 0 4px; display: grid; place-items: center; border-radius: 12px; }
.cal-cell.today .cal-dn span { background: var(--primary); color: var(--primary-ink); }
.cal-evs { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-ev { display: block; width: 100%; min-width: 0; text-align: start; border: 0; border-inline-start: 3px solid var(--c); background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--text); font-size: 11.5px; font-weight: 500; line-height: 1.55; padding: 1px 6px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal-ev:hover { background: color-mix(in srgb, var(--c) 26%, var(--surface)); }
.cal-ev .t { color: var(--muted); margin-inline-end: 4px; font-variant-numeric: tabular-nums; }
.cal-ev.done { opacity: .55; text-decoration: line-through; }
.cal-ev.late { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bad) 55%, transparent); }
.cal-ev.pend { border-inline-start-style: dashed; background: color-mix(in srgb, var(--c) 6%, var(--surface)); }
.cal-more { font-size: 11px; font-weight: 600; color: var(--muted); padding-inline-start: 4px; }
.cal-dots { display: none; gap: 3px; flex-wrap: wrap; justify-content: center; }
.cal-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }

/* عرض القائمة */
.cal-agenda { display: flex; flex-direction: column; }
.cal-ag-day { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.cal-ag-day:last-child { border-bottom: 0; }
.cal-ag-day.today { background: color-mix(in srgb, var(--primary-soft) 60%, transparent); }
.cal-ag-date { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none; cursor: pointer; padding: 4px 0 0; line-height: 1.2; color: var(--text); align-self: start; }
.cal-ag-date b { font-size: 22px; }
.cal-ag-date span { font-size: 12px; color: var(--muted); }
.cal-ag-day.today .cal-ag-date b { color: var(--primary); }
.cal-ag-list { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.cal-li { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; text-align: start; border: 0; border-inline-start: 3px solid var(--c); background: color-mix(in srgb, var(--c) 7%, var(--surface)); padding: 8px 10px; border-radius: 9px; cursor: pointer; color: var(--text); transition: background .12s; }
.cal-li:hover { background: color-mix(in srgb, var(--c) 15%, var(--surface)); }
.cal-li.done .li-title { opacity: .6; }
.cal-li .li-title { font-size: 13px; }
.cal-li .pill { font-size: 11px; padding: 0 7px; vertical-align: 1px; }
.cal-li .tag { flex: none; }

@media (max-width: 640px) {
  .cal-title { font-size: 16px; min-width: 0; }
  .cal-head div { text-align: center; padding: 8px 2px; }
  .cal-head .d0 { display: none; }
  .cal-head .d1 { display: inline; }
  .cal-cell { min-height: 54px; padding: 4px 2px; align-items: center; gap: 4px; }
  .cal-dn { justify-content: center; }
  .cal-evs { display: none; }
  .cal-dots { display: flex; }
  .cal-ag-day { grid-template-columns: 46px minmax(0, 1fr); gap: 10px; padding: 10px 12px; }
  .cal-ag-date b { font-size: 19px; }
  .cal-li .tag { display: none; }
}
