/* Calendar widget (cal2-): header rows, linked table, derived hours chart, add form with Jalali picker. */
.cal2-h1, .cal2-h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 0; }
.cal2-h1 .btn.add { order: 3; margin-inline-start: auto; }
.cal2-search { display: flex; align-items: center; gap: 8px; flex: 1 1 220px; max-width: 360px; }
.cal2-q { flex: 1; min-width: 0; height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--foreground); font: inherit; font-size: 13px; }
.cal2-q:focus { outline: 2px solid var(--ring); outline-offset: 1px; }
.cal2-cnt { white-space: nowrap; font-size: 12px; color: var(--muted-foreground); }
.cal2-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.cal2-views button[disabled] { opacity: .45; cursor: not-allowed; }
.cal2-h2 { justify-content: space-between; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.cal2-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }
.cal2-range { font-family: Morabba, inherit; font-size: 16px; font-weight: 500; margin-inline-start: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.cal2-tools { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.cal2-tools .btn.on { background: var(--muted); }
.cal2-extra:empty { display: none; }
/* «تبدیل به جدول» card: table on the right/left, chart side panel beside it (same look as the table widget) */
.cal2-tblgrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
.cal2-tblcard.has-side .cal2-tblgrid { grid-template-columns: minmax(0, 1fr); }
.cal2-tblgrid .tc-side:empty { display: none; }
.cal2-tblgrid .tc-side { min-width: 0; width: 100%; }
/* widget body scrolls vertically so the table and chart below the calendar stay reachable */
.cal-root .w-body { overflow-y: auto; overflow-x: hidden; }
.cal-root .w-body > * { flex-shrink: 0; }
.cal-root .cal-scroll { flex: none; }
/* table (and its chart side panel) sit BELOW the calendar, full width */
.cal-root .cal2-extra { order: 5; }
.cal-root .cal2-extra:not(:empty) { padding-bottom: 4px; }
.cal2-extra { display: flex; flex-direction: column; gap: 10px; padding: 8px 0; }
.cal2-card { border: 1px solid var(--border); border-radius: 10px; background: var(--card); padding: 10px 12px; min-width: 0; }
.cal2-card > header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cal2-card > header b { font-weight: 600; font-size: 14px; }
.cal2-sync { font-size: 12px; color: var(--muted-foreground); margin-inline-start: auto; white-space: nowrap; }
.cal2-x { border: 0; background: transparent; color: var(--muted-foreground); cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 6px; }
.cal2-x:hover { color: var(--foreground); background: var(--muted); }
.cal2-tblwrap { overflow-x: auto; max-width: 100%; }
.cal2-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.cal2-tbl th, .cal2-tbl td { text-align: start; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.cal2-tbl th { color: var(--muted-foreground); font-weight: 500; font-size: 12px; }
.cal2-bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding-top: 6px; }
.cal2-bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; }
.cal2-bar i { display: block; width: 100%; max-width: 36px; min-height: 2px; border-radius: 6px 6px 2px 2px; background: var(--chart-1); }
.cal2-bar.today i { background: var(--primary); }
.cal2-bar em { font-style: normal; font-size: 12px; color: var(--muted-foreground); margin-top: 4px; }
.cal2-bar:hover::after { content: attr(title); position: absolute; bottom: calc(100% + 4px); inset-inline-start: 50%; transform: translateX(50%); background: var(--foreground); color: var(--card); font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; z-index: 2; pointer-events: none; }

/* add form */
.cal2-form { display: flex; flex-direction: column; gap: 10px; }
.cal2-form .req { color: var(--primary); }
.cal2-in { width: 100%; min-height: 34px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--foreground); font: inherit; font-size: 13px; text-align: start; }
.cal2-in:focus { outline: 2px solid var(--ring); outline-offset: 1px; }
.cal2-date { cursor: pointer; }
.cal2-picker { margin-top: 6px; border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: var(--card); }
.cal2-picker[hidden] { display: none; }
.cal2-pk-h { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.cal2-pk-h b { font-size: 13px; font-weight: 600; }
.cal2-pk-w, .cal2-pk-g { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal2-pk-w span { font-size: 11px; color: var(--muted-foreground); padding: 2px 0; }
.cal2-dd { height: 30px; border: 0; border-radius: 6px; background: transparent; color: var(--foreground); font: inherit; font-size: 13px; cursor: pointer; }
.cal2-dd:hover { background: var(--muted); }
.cal2-dd.out { color: var(--muted-foreground); opacity: .55; }
.cal2-dd.today { box-shadow: inset 0 0 0 1px var(--primary); }
.cal2-dd.sel { background: var(--primary); color: var(--primary-foreground); }
.cal2-times { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cal2-err { min-height: 18px; font-size: 12px; color: var(--destructive, #d64545); }
.cal2-err:empty { display: none; }
.cal2-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ── week-count geometry (day view = 1 column, week = 7) ── */
.cal-root { --nc: 7; }
.cal-root .cal-days { grid-template-columns: repeat(var(--nc), 1fr); }
.cal-root .cal-col-bg, .cal-root .cal-now { width: calc(100% / var(--nc)); }
.cal-root .ev { inset-inline-start: calc(var(--col) * (100% / var(--nc)) + 3px + var(--lane) * ((100% / var(--nc) - 6px) / var(--lanes))); width: calc((100% / var(--nc) - 6px) / var(--lanes) - 2px); }
.cal2-hide, [hidden] { display: none !important; }

/* ── month / season / year grids ── */
.cal2-months { display: grid; gap: 14px; }
.cal2-months.year { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.cal2-month h6 { font-size: 14px; font-weight: 600; margin: 4px 0 6px; }
.cal2-mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal2-mc { min-height: 66px; border: 1px solid var(--border); border-radius: 6px; padding: 3px 4px; overflow: hidden; cursor: pointer; min-width: 0; }
.cal2-mc:hover { background: var(--muted); }
.cal2-mc.out { opacity: .4; }
.cal2-mc.today b { color: var(--primary); }
.cal2-mc b { font-size: 12px; font-weight: 600; }
.cal2-mgrid.compact .cal2-mc { min-height: 34px; }
.cal2-mgrid.compact .cal2-mc em { font-size: 10px; }
.cal2-chipev { display: block; font-size: 10.5px; line-height: 1.5; border-inline-start: 3px solid var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); border-radius: 4px; padding: 0 4px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal2-mc em { display: block; font-style: normal; font-size: 10.5px; color: var(--muted-foreground); }

/* ── combo box (person) ── */
.cal2-combo { position: relative; }
.cal2-opts { position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 5; max-height: 200px; overflow: auto; background: var(--card); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-pop); padding: 4px; }
.cal2-opt { padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.cal2-opt:hover, .cal2-opt.hl { background: var(--muted); }

/* ── tag chips (status, builder options) ── */
.cal2-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.cal2-tag { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; width: auto; border: 1px solid var(--border); background: transparent; color: var(--foreground); font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.cal2-tag .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted-foreground)); }
.cal2-tag[aria-pressed="true"] { background: color-mix(in srgb, var(--c, var(--primary)) 16%, transparent); border-color: var(--c, var(--primary)); font-weight: 600; }

/* ── derived cards + chart ── */
.cal2-derived .cal2-chartbox, .cal2-derived .cal2-tblwrap { min-width: 0; }
.cal2-svg { width: 100%; height: auto; display: block; }
.cal2-hit { cursor: default; }
.cal2-empty { display: grid; place-items: center; font-size: 13px; }
.cal2-pv { min-width: 0; }
.cal2-tblwrap { overflow-x: auto; }

/* ── hover tooltip (shared, follows [data-tip]) ── */
.cal2-tip { position: fixed; z-index: 9999; transform: translate(-50%, -100%); background: var(--foreground); color: var(--card); font-size: 12px; padding: 5px 9px; border-radius: 6px; white-space: nowrap; pointer-events: none; box-shadow: var(--shadow-pop); }

/* resize handles on both edges; the built table is the table widget itself */
.cal-root .ev .grab.top { top: 0; bottom: auto; place-items: start center; }
.cal-root .ev .grab.top::after { margin: 2px 0 0; }
.cal2-tblwrap { min-width: 0; }
.cal2-tblwrap .w { margin: 0; border: 0; box-shadow: none; padding: 0; }
.cal2-tblwrap [data-act=add] { display: none; }
