/* ============================== AGENDA OVERLAYS + PANELS ==============================
   Styles shared across the agenda tab that aren't in the main styles.css bundle
   (overlay shell sizing, notes tabs, md toolbar, habits table, habit notes, quick
   note panel). Ported verbatim from the v2 habits.css + courses.css + agenda.css
   and adjusted for the v3 dark surface where v2 assumed a light background. */

/* ─── Agenda-specific modal sizing — v3 styles.css sets .omodal to 480px,
   but the session overlay needs the wider v2 layout (820px). ─────── */
#session-overlay .omodal { max-width: 820px; max-height: 90vh; }
#category-overlay .omodal { max-width: 380px; }
#columns-overlay .omodal { max-width: 450px; }
#calendar-overlay .omodal { max-width: 520px; }
#notes-habit-overlay .omodal-body { padding: 0; }

@keyframes fs { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.overlay .omodal { animation: fs .2s ease; }
.overlay .omodal-head button {
  width: 26px; height: 26px; border: none; background: var(--bg);
  border-radius: 5px; cursor: pointer; font-size: 13px;
}
.overlay .omodal-head button:hover { background: var(--border); }
.overlay .omodal-body { padding: 12px 16px; overflow-y: auto; }

/* ─── ht-btn (used by habits table toolbar AND quick-note panel AND
   session overlay actions) ──────────────────────────────────────── */
.ht-btn {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 5px;
  background: var(--surface); cursor: pointer; font-size: 11px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 4px; transition: all .12s;
  color: var(--text);
}
.ht-btn:hover { border-color: var(--primary); }
.ht-btn.p { background: var(--primary); color: #fff; border-color: var(--primary); }
.ht-btn.p:hover { background: var(--primary-dark); }

/* ─── Habits table toolbar + container ────────────────────────────── */
.ht-toolbar {
  display: flex; align-items: center; gap: 6px; margin: 8px 0; flex-wrap: wrap;
}
.ht-toolbar .ht-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .3px; }

.ht-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow-x: auto;
}
.ht-wrap table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 700px; }
.ht-wrap th {
  background: var(--bg); padding: 6px 6px; text-align: center;
  font-weight: 600; font-size: 10px; color: var(--text-muted);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.ht-wrap th:first-child { width: 36px; }
.ht-wrap th:nth-child(2) { text-align: left; }
.ht-wrap td {
  padding: 4px 5px; border-bottom: 1px solid var(--border-light);
  text-align: center; vertical-align: middle;
}
.ht-wrap td input[type="text"] {
  width: 100%; padding: 3px 5px; border: 1px solid transparent; border-radius: 3px;
  font-size: 12px; background: transparent; font-family: var(--font); outline: none; transition: all .12s;
  color: var(--text);
}
.ht-wrap td input[type="text"]:focus { border-color: var(--primary); background: var(--primary-light); }
.ht-wrap td input[type="text"]:hover { border-color: var(--border); }
.ht-wrap td input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }
.ht-wrap .pbar { width: 100%; height: 5px; background: var(--bg); border-radius: 3px; overflow: hidden; min-width: 50px; }
.ht-wrap .pbar .fill { height: 100%; background: var(--green); border-radius: 3px; transition: width .2s; }
.pct-label { font-size: 10px; font-weight: 600; color: var(--text-muted); white-space: nowrap; min-width: 28px; text-align: right; }
.ht-wrap .note-trigger {
  display: block; padding: 2px 5px; border: 1px solid transparent; border-radius: 3px;
  font-size: 11px; cursor: pointer; color: var(--text-muted); text-align: left;
  max-width: 90px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: transparent;
}
.ht-wrap .note-trigger:hover { border-color: var(--border); background: var(--bg); }

/* ─── Quick-note panel + status indicator ────────────────────────── */
.panel { background: var(--bg); border-radius: var(--radius-sm); padding: 10px; }
.panel-title {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .4px; color: var(--text-muted);
  margin-bottom: 6px; display: flex; align-items: center; justify-content: space-between;
}
.panel-title .pa {
  font-size: 13px; cursor: pointer; opacity: .4; transition: opacity .12s;
}
.panel-title .pa:hover { opacity: 1; }
.note-status { font-size: 11px; transition: color .2s; }
.note-status.saving { color: var(--amber); }
.note-status.ok     { color: var(--green); }
.note-status.err    { color: var(--red);   }

/* ─── Markdown toolbar (session overlay notes edit tab) ──────────── */
.md-toolbar {
  display: flex; gap: 1px; flex-wrap: wrap; padding: 3px 4px;
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 4px 4px 0 0; background: var(--bg);
  width: 100%; box-sizing: border-box;
}
.md-tb-btn {
  background: transparent; border: 1px solid transparent; border-radius: 3px;
  cursor: pointer; padding: 2px 6px; font-size: 11px; line-height: 1.4;
  color: var(--text); white-space: nowrap; transition: background .15s, border-color .15s;
}
.md-tb-btn:hover { background: var(--surface-hover); border-color: var(--border); }
.md-tb-btn:active { background: var(--primary); color: #fff; }
.md-tb-sep { width: 1px; background: var(--border); margin: 2px 3px; }

/* ─── Session overlay notes: View / Edit tabs + rendered preview ── */
.so-notes-tabs {
  display: flex; gap: 0; margin-bottom: 0;
}
.so-ntab {
  padding: 5px 14px; border: 1px solid var(--border); border-bottom: none;
  background: var(--bg); cursor: pointer; font-size: 12px; font-weight: 500;
  border-radius: 4px 4px 0 0; color: var(--text-muted);
  margin-bottom: -1px; transition: background .15s, color .15s;
}
.so-ntab.active { background: var(--surface); color: var(--text); border-bottom-color: var(--surface); }
.so-ntab:hover:not(.active) { background: var(--surface-hover); }
.so-notes-panel { display: none; }
.so-notes-panel.active { display: block; }
.so-notes-rendered {
  min-height: 320px; max-height: 55vh; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 0 4px 4px 4px;
  font-size: 14px; line-height: 1.7; background: var(--bg);
  overflow-y: auto; color: var(--text);
}
.so-notes-rendered p { margin: 0 0 8px; }
.so-notes-rendered ul, .so-notes-rendered ol { margin: 4px 0; padding-left: 20px; }
.so-notes-rendered code { background: var(--surface); padding: 1px 4px; border-radius: 3px; font-size: 13px; }
.so-notes-rendered pre { background: var(--surface); padding: 10px; border-radius: 4px; overflow-x: auto; font-size: 13px; }
.so-notes-rendered h1, .so-notes-rendered h2, .so-notes-rendered h3 { margin: 12px 0 6px; }
.so-notes-rendered blockquote { border-left: 3px solid var(--border); padding-left: 10px; margin: 8px 0; color: var(--text-muted); }

/* ─── Habit notes inside the agenda (rendered in center column) ── */
.hn-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-top: 20px; box-shadow: var(--shadow);
}
.hn-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border-light);
}
.hn-head-left { display: flex; align-items: center; gap: 8px; }
.hn-icon { font-size: 16px; line-height: 1; }
.hn-title { font-size: 13px; font-weight: 600; color: var(--text); }
.hn-day-badge {
  font-size: 11px; font-weight: 500; color: var(--text-secondary);
  background: var(--primary-light); padding: 3px 10px; border-radius: 20px;
  border: 1px solid var(--primary); line-height: 1.4;
}
.hn-body {
  padding: 8px 16px 12px; display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; max-height: 420px; overflow-y: auto;
}
.hn-row {
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  padding: 8px 10px; background: var(--bg); transition: border-color .15s, box-shadow .15s, background .15s;
}
.hn-row:hover { border-color: var(--border); background: var(--surface-hover); }
.hn-row:focus-within { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.hn-row-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.hn-row-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.hn-row-dot { font-size: 10px; color: var(--primary); opacity: .7; line-height: 1; }
.hn-ta {
  width: 100%; padding: 4px 6px; border: 1px solid transparent;
  border-radius: var(--radius-xs); background: var(--surface);
  font-family: var(--font); font-size: 12px; color: var(--text);
  resize: vertical; outline: none; line-height: 1.4;
  transition: background .12s; min-height: 32px; box-sizing: border-box;
}
.hn-ta:focus { background: var(--surface); border-color: var(--primary); }
.hn-ta::placeholder { color: var(--text-muted); font-size: 11px; opacity: .7; }
.hn-empty { grid-column: 1 / -1; text-align: center; padding: 20px 16px; font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* ─── Empty state (rendered when no sessions) ───────────────────── */
.empty-state {
  text-align: center; padding: 32px 16px;
  color: var(--text-muted); font-size: 13px;
}
.empty-state .big { font-size: 48px; display: block; margin-bottom: 8px; opacity: .6; }
.empty-state .ht-btn { margin: 4px 0; }

/* ─── Sessions scroll wrapper (v2 styles not in agenda.css) ─────── */
.sessions-scroll-wrapper { max-height: 50vh; overflow-y: auto; margin-bottom: 12px; }
.sessions-scroll-wrapper::-webkit-scrollbar { width: 3px; }
.sessions-scroll-wrapper::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── Move session modal clickable days (v2 overlay helper) ────── */
.mc-grid .mc-day.mc-day-pending { background: rgba(249, 115, 22, 0.18); }
.mc-grid .mc-day.mc-day-done    { background: rgba(34, 197, 94, 0.18); }
.ms-clickable { cursor: pointer; transition: all .12s; }
.ms-clickable:hover { background: var(--primary-light) !important; transform: scale(1.08); z-index: 1; }
.ms-clickable:hover .mc-day-num { font-weight: 700; color: var(--primary); }
.mc-grid .mc-day.ms-origin { outline: 2px solid var(--primary); outline-offset: -2px; }
.mc-grid .mc-day.ms-origin .mc-day-num { font-weight: 700; color: var(--primary); }
.ms-row:hover { border-color: var(--primary) !important; }
#ms-session-list { max-height: 180px; overflow-y: auto; margin-bottom: 4px; }
