/* ============================== AGENDA TIMELINE VIEWS ============================== */
/* CSS for Day / Week / Month timeline grids (sub-phase C port of v2 agenda.css
   lines 193-387). Lives in its own file so the session-card + habit CSS stays
   focused in agenda.css and we can load the timeline CSS lazily once the user
   picks a timeline view if we ever need to. Classes mirror v2 exactly:
   .tl-* day grid, .tlw-* week grid, .tlm-* month grid. Dark-theme overrides at
   the bottom flip the few v2 light-bg tints that would be invisible on #16213e.
   (Single-user mode → no per-user theme variant.) */

/* ─── DAY TIMELINE ──────────────────────────────────────────────── */
.tl-container { margin-top: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }

.tl-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); font-size: 12px; }
.tl-header-title { font-weight: 600; color: var(--text); }
.tl-header-count { font-size: 10px; color: var(--text-muted); }

/* No max-height and no overflow-y here on purpose. Capping the timeline at
     60vh put a second scroll box inside the page's own scroll, which showed
     only 8.6 of the 24 hours: every session from 09:00 onwards sat below the
     visible edge, crammed against the bottom, and the hour gutter — pinned
     to the capped height — stopped at 08. Letting the grid take its natural
     height (24 x 40px) means the page scrolls once, the hour labels stay
     aligned with their rows by construction, and the whole day is visible. */
.tl-body { display: flex; position: relative; }
.tl-gutter { flex-shrink: 0; width: 44px; background: var(--surface); border-right: 1px solid var(--border); z-index: 1; }
.tl-hour { display: flex; align-items: flex-start; justify-content: center; font-size: 10px; color: var(--text-muted); padding-top: 1px; border-bottom: 1px solid var(--border); }

.tl-grid { flex: 1; position: relative; background: var(--bg); }
.tl-row { border-bottom: 1px solid var(--border); }
/* Even-row tint overridden in dark-theme block at bottom of file */

.tl-blocks { position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; }
.tl-block {
  /* left/width are set inline by the lane packer. Do not hard-code
     left/right here or the lanes get overridden. */
  position: absolute; left: 4px; width: calc(100% - 8px); border-radius: 5px; cursor: grab; user-select: none;
  border-left: 3px solid; pointer-events: auto; transition: box-shadow .12s; overflow: hidden;
  display: flex; align-items: stretch; min-height: 18px;
}
.tl-block:hover { box-shadow: 0 2px 8px rgba(0,0,0,.12); z-index: 2; }
.tl-block-dragging { cursor: grabbing; opacity: .85; z-index: 10; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.tl-block-done { opacity: .55; }
.tl-block-done .tl-block-title { text-decoration: line-through; }
.tl-block-running { border-left-color: var(--green) !important; }
.tl-block-paused { border-left-color: var(--amber) !important; }

.tl-block-bar { width: 3px; flex-shrink: 0; border-radius: 2px 0 0 2px; }
.tl-block-body { flex: 1; padding: 2px 6px; overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
.tl-block-title { font-size: 11px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.tl-block-time { font-size: 9px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Day timeline drag floating clone + tooltip */
.tl-block-floating {
  opacity: .9; box-shadow: 0 4px 20px rgba(0,0,0,.25); border-radius: 3px;
  pointer-events: none; transition: none !important;
}
.tl-drag-tip {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 4px; white-space: nowrap;
  margin-bottom: 4px; pointer-events: none;
}

/* Day unscheduled section */
.tl-unscheduled { border-top: 1px solid var(--border); padding: 8px 12px; background: var(--surface); }
.tl-unscheduled-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.tl-unscheduled-list { display: flex; flex-direction: column; gap: 4px; }
.tl-unsched-item { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 4px; cursor: default; }
.tl-unsched-item:hover { background: var(--surface-hover); }
.tl-unsched-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* ─── WEEK TIMELINE ─────────────────────────────────────────────── */
.tlw-container { margin-top: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }

.tlw-header { display: flex; border-bottom: 1px solid var(--border); background: var(--surface); }
.tlw-gutter-spacer { flex-shrink: 0; width: 44px; border-right: 1px solid var(--border); }
.tlw-day-header {
  flex: 1; text-align: center; padding: 6px 2px; font-size: 10px;
  border-right: 1px solid var(--border); min-width: 0;
}
.tlw-day-header:last-child { border-right: none; }
.tlw-day-header.today { background: var(--primary-light); }
.tlw-day-name { display: block; font-weight: 600; color: var(--text); }
.tlw-day-num { display: block; font-size: 9px; color: var(--text-muted); margin-top: 1px; }
.tlw-day-header.today .tlw-day-name { color: var(--primary); }

/* Same reasoning as .tl-body above: a 60vh cap nested a second scroll box
   inside the page's own scroll, cropping the day columns and squeezing the
   hour gutter. .tlw-gutter already carries flex-shrink:0, so the labels now
   stretch to the full week height instead of stopping mid-grid. */
.tlw-body { display: flex; position: relative; }
.tlw-gutter { flex-shrink: 0; width: 44px; background: var(--surface); border-right: 1px solid var(--border); z-index: 1; }

.tlw-col { flex: 1; position: relative; min-width: 0; }
.tlw-col.today { background: rgba(79,70,229,.03); }
.tlw-col-highlight { background: var(--primary-light) !important; }

.tlw-grid { position: relative; background: var(--bg); border-right: 1px solid var(--border); }
.tlw-col:last-child .tlw-grid { border-right: none; }
.tlw-row { border-bottom: 1px solid var(--border); }
/* Even-row tint overridden in dark-theme block at bottom of file */

.tlw-blocks { position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; }

.tlw-block {
  /* left/width come inline from the lane packer (shared/lane-packer.js):
     left = index/total, width = 1/total. This used to be `left:1px;
     right:1px`, which is full column width for every block, so two
     sessions in the same hour occupied the identical rectangle and only
     the last one in DOM order was visible. Do not reintroduce a static
     left/width here — it would override the lanes. */
  position: absolute; left: 1px; width: calc(100% - 2px); border-radius: 3px;
  cursor: grab; user-select: none;
  border-left: 3px solid; pointer-events: auto; transition: box-shadow .12s; overflow: hidden;
  display: flex; align-items: stretch; min-height: 14px;
}
.tlw-block:hover { box-shadow: 0 1px 6px rgba(0,0,0,.12); z-index: 2; }
.tlw-block-dragging { cursor: grabbing; opacity: .7; z-index: 10; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.tlw-block-done { opacity: .55; }
.tlw-block-done .tlw-block-title { text-decoration: line-through; }
.tlw-block-running { border-left-color: var(--green) !important; }
.tlw-block-paused { border-left-color: var(--amber) !important; }

.tlw-block-bar { width: 3px; flex-shrink: 0; border-radius: 2px 0 0 2px; }
.tlw-block-body { flex: 1; padding: 1px 3px; overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
.tlw-block-title { font-size: 9px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.tlw-block-time { font-size: 8px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tlw-block-floating {
  opacity: .9; box-shadow: 0 4px 20px rgba(0,0,0,.25); border-radius: 3px;
  pointer-events: none; transition: none !important;
}
.tlw-drag-tip {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 4px; white-space: nowrap;
  margin-bottom: 4px; pointer-events: none;
}

.tlw-unscheduled { border-top: 1px solid var(--border); padding: 8px 12px; background: var(--surface); }
.tlw-unscheduled-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.tlw-unscheduled-days { display: flex; gap: 8px; flex-wrap: wrap; }
.tlw-unsched-day { flex: 1; min-width: 100px; }
.tlw-unsched-day.today { background: var(--primary-light); border-radius: 4px; padding: 0 4px; }
.tlw-unsched-day-label { font-size: 10px; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; }
.tlw-unsched-item { font-size: 11px; color: var(--text-secondary); display: flex; align-items: center; gap: 4px; padding: 2px 4px; border-radius: 3px; cursor: default; }
.tlw-unsched-item:hover { background: var(--surface-hover); }
.tlw-unsched-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }

/* ─── MONTH TIMELINE ────────────────────────────────────────────── */
.tlm-container { margin-top: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }

.tlm-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.tlm-head .tlm-nav { cursor: pointer; font-size: 13px; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 50%; user-select: none; transition: background .12s; }
.tlm-head .tlm-nav:hover { background: var(--bg); }
.tlm-head .tlm-title { font-size: 13px; font-weight: 600; color: var(--text); }

.tlm-dow-row { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--surface); border-bottom: 1px solid var(--border); }
.tlm-dow { text-align: center; font-size: 9px; font-weight: 600; color: var(--text-muted); padding: 4px 0; text-transform: uppercase; letter-spacing: .5px; }

.tlm-body { background: var(--bg); }
.tlm-week { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); }
.tlm-week:last-child { border-bottom: none; }

.tlm-cell {
    min-height: 110px; padding: 3px 4px; cursor: pointer; position: relative;
    border-right: 1px solid var(--border); background: var(--surface);
    transition: background .12s; display: flex; flex-direction: column;
    overflow: hidden;
  }
.tlm-cell:last-child { border-right: none; }
.tlm-cell:hover { background: var(--surface-hover); }
.tlm-cell.tlm-empty { cursor: default; background: var(--bg); }
.tlm-cell.tlm-today { background: rgba(79,70,229,.04); }
.tlm-cell.tlm-today .tlm-day-num { background: var(--primary); color: #fff; border-radius: 50%; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.tlm-cell.tlm-cell-highlight { background: var(--primary-light) !important; outline: 2px solid var(--primary); outline-offset: -2px; z-index: 1; }

.tlm-day-num { font-size: 11px; font-weight: 500; color: var(--text-secondary); line-height: 1; margin-bottom: 2px; }

/* Days with more sessions than fit get their own scrollbar rather than
     silently clipping — that was why a busy day looked empty. Auto (not
     always-visible) so quiet cells show no scrollbar at all. */
  .tlm-sessions {
    display: flex; flex-direction: column; gap: 1px; flex: 1;
    overflow-y: auto; overflow-x: hidden;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
    overscroll-behavior: contain;
  }
  .tlm-sessions::-webkit-scrollbar { width: 5px; }
  .tlm-sessions::-webkit-scrollbar-track { background: transparent; }
  .tlm-sessions::-webkit-scrollbar-thumb {
    background: var(--border); border-radius: 3px;
  }
  .tlm-sessions::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.tlm-session {
  display: flex; align-items: center; gap: 3px; padding: 1px 3px; border-radius: 2px;
  cursor: grab; user-select: none; font-size: 9px; line-height: 1.3;
  min-height: 14px; transition: background .12s;
}
/* Hover overridden in dark-theme block below — rgba(0,0,0,.04) is invisible on dark */
.tlm-session.tlm-s-done { opacity: .5; }
.tlm-session.tlm-s-done .tlm-s-title { text-decoration: line-through; }
.tlm-session.tlm-s-dragging { opacity: .4; }

.tlm-s-bar { width: 3px; height: 10px; border-radius: 1px; flex-shrink: 0; }
.tlm-s-time { color: var(--text-muted); flex-shrink: 0; font-size: 8px; }
.tlm-s-title { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.tlm-overflow { font-size: 9px; color: var(--text-muted); text-align: center; padding: 1px 0; font-weight: 600; cursor: default; }

.tlm-s-floating {
  opacity: .9; box-shadow: 0 4px 20px rgba(0,0,0,.25); border-radius: 3px;
  pointer-events: none; transition: none !important;
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 3px; padding: 2px 6px; font-size: 9px; line-height: 1.3;
}

.tlm-drag-tip {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 4px; white-space: nowrap;
  margin-bottom: 4px; pointer-events: none;
}

/* ─── DARK THEME OVERRIDES ──────────────────────────────────────── */
/* v2 designed these for a light surface; a few tints that disappear on
   the v3 dark surface (#16213e) are flipped here. rgba shadow values
   (.12 / .20 / .25) still produce visible drop-shadows on dark and are
   kept as-is — they read as depth, not noise. */
.tl-row:nth-child(even),
.tlw-row:nth-child(even) { background: rgba(255, 255, 255, 0.02); }
.tlm-session:hover { background: var(--surface-hover); }
.tl-unsched-item:hover,
.tlw-unsched-item:hover { background: var(--surface-hover); }