/* Partitura — component-specific styles.
   Use CSS vars from theme.css so it adapts to dark/light × warm/neutral/cold. */

/* Root container */
.pt-root {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.pt-root.pt-embedded {
  /* When embedded in a parent card the parent provides its own border;
     keep our own border off so we don't double-border. */
  border: none;
  border-radius: 0;
  background: transparent;
}

/* Main horizontal split (timeline + right events panel) */
.pt-main {
  display: flex;
  min-height: 0;
  /* No fixed height by default — sizes to content. Override via inline style if needed. */
}

.pt-timeline-scroll {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  position: relative;
  background: var(--surface);
}

/* Ruler row sticky to top */
.pt-ruler-row {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-elev);
}
.pt-label-corner {
  width: 320px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 8px 14px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--font-mono);
  position: sticky;
  left: 0;
  z-index: 6;
  background: var(--bg-elev);
  display: flex;
  align-items: center;
}

/* Now line */
.pt-now-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
  pointer-events: none;
  z-index: 4;
}
.pt-now-line-lbl {
  position: absolute;
  top: 6px;
  left: -28px;
  padding: 2px 6px;
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 3px;
  white-space: nowrap;
}

/* ============================================================
   RIGHT EVENTS PANEL — sized by prop, sticky to viewport when embedded
   ============================================================ */
.pt-panel {
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 240px;
  max-width: 640px;
  /* sticky positioning enabled by inline style (top + max-height) */
  position: sticky;
  align-self: flex-start;
  overflow: hidden;
}

/* Resize handle */
.pt-resize-handle {
  flex: 0 0 6px;
  cursor: col-resize;
  position: relative;
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  transition: background 0.12s, border-color 0.12s;
  user-select: none;
}
.pt-resize-handle:hover,
.pt-resize-handle:active {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.pt-resize-handle::before {
  content: "";
  position: absolute;
  inset: 0 -3px;
}
.pt-resize-handle-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 32px;
  transform: translate(-50%, -50%);
  background: var(--text-faint);
  border-radius: 1px;
  box-shadow: 4px 0 0 var(--text-faint), -4px 0 0 var(--text-faint);
}
.pt-resize-handle:hover .pt-resize-handle-grip {
  background: var(--accent);
  box-shadow: 4px 0 0 var(--accent), -4px 0 0 var(--accent);
}

.pt-panel-hd {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
}
.pt-panel-title { position: relative; padding-right: 24px; }
.pt-panel-selected {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pt-panel-selected > div:nth-child(2) { flex: 1; min-width: 0; }
.pt-panel-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pt-panel-sub {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.pt-clear-btn {
  position: absolute;
  top: 0;
  right: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.pt-clear-btn:hover { background: var(--surface-hi); color: var(--text); }
.pt-clear-btn.pt-clear-btn-sm { position: static; }

.pt-panel-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
}
.pt-window { font-family: var(--font-mono); }
.pt-count strong {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
  margin-right: 4px;
}
.pt-count-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Tiny breakdown by event kind */
.pt-breakdown {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-soft);
}
.pt-breakdown-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 5px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 3px;
  font-size: 10px;
  color: var(--text-dim);
}
.pt-breakdown-item .mono { color: var(--text); font-weight: 600; }

/* Selected segment block — small card at top of list */
.pt-seg-card {
  padding: 10px 14px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--accent-line);
  border-left: 3px solid var(--accent);
}
.pt-seg-card-hd {
  display: flex; align-items: center; justify-content: space-between;
}
.pt-seg-card-lbl {
  font-size: 9px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 600;
}
.pt-seg-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-top: 6px;
  line-height: 1.3;
}
.pt-seg-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.pt-sep { padding: 0 6px; color: var(--text-faint); }

/* Events list */
.pt-panel-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.pt-ev-row {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.08s;
}
.pt-ev-row:hover { background: var(--surface-hi); }
.pt-ev-row.is-highlight {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding-left: 11px;
}

.pt-ev-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 1px;
}
.pt-ev-bd { min-width: 0; }
.pt-ev-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
  flex-wrap: wrap;
}
.pt-ev-time { font-size: 11px; color: var(--text-muted); }
.pt-ev-seq  { font-size: 11px; color: var(--accent); font-weight: 600; }
.pt-ev-agent {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-dim);
}
.pt-ev-avatar {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border);
}
.pt-ev-sev {
  font-size: 9px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border-radius: 2px;
  font-weight: 600;
}
.pt-ev-sev-critical { background: var(--crit-soft); color: var(--crit); }
.pt-ev-sev-warning  { background: var(--warn-soft); color: var(--warn); }
.pt-ev-sev-info     { background: var(--info-soft); color: var(--info); }

.pt-ev-text {
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

/* Empty state */
.pt-empty {
  padding: 40px 24px;
  text-align: center;
}
.pt-empty-glyph {
  font-size: 32px;
  color: var(--text-faint);
  margin-bottom: 8px;
  font-family: var(--font-mono);
}
.pt-empty-msg {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ============================================================
   RICH TRACK LABELS
   ============================================================ */
.pt-tl {
  padding: 10px 14px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  min-width: 0;
}
.pt-tl-mono { font-family: var(--font-mono); }
.pt-tl-crit { color: var(--crit); }

.pt-tl-row1 {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.pt-tl-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.pt-tl-avatar.is-lead {
  box-shadow: 0 0 0 2px var(--accent);
  border-color: var(--bg-elev);
}
.pt-tl-mod-icon {
  width: 38px;
  height: 38px;
  border-radius: 5px;
  border: 1.5px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}
.pt-tl-id { flex: 1; min-width: 0; }
.pt-tl-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pt-tl-role {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pt-tl-alert {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  background: var(--crit-soft);
  color: var(--crit);
  border: 1px solid var(--crit);
  flex-shrink: 0;
}

.pt-tl-watcher {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
}
.pt-tl-watcher .dot { flex-shrink: 0; }
.pt-tl-watcher .pt-tl-mono {
  color: var(--text);
  font-weight: 500;
}

.pt-tl-task {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  min-width: 0;
}
.pt-tl-seq {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}
.pt-tl-title {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.pt-tl-free {
  color: var(--text-muted);
  font-style: italic;
}

.pt-tl-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 4px;
  font-size: 10px;
  color: var(--text-dim);
}
.pt-tl-foot-pair {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pt-tl-foot-lbl {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.pt-tl-pct {
  font-size: 12px;
  font-weight: 600;
}
.pt-tl-load { margin-left: auto; flex-shrink: 0; }

/* Module label specifics */
.pt-tl-mod-agents {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.pt-tl-mini-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border);
}

/* Range slider */
input[type="range"].pt-slider {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  height: 22px;
}
input[type="range"].pt-slider::-webkit-slider-runnable-track {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  height: 6px;
}
input[type="range"].pt-slider::-moz-range-track {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  height: 6px;
}
input[type="range"].pt-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  background: var(--accent);
  border: 2px solid var(--surface);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  margin-top: -6px;
}
input[type="range"].pt-slider::-moz-range-thumb {
  background: var(--accent);
  border: 2px solid var(--surface);
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

/* ============================================================
   CONTROLS (header bar)
   ============================================================ */
.pt-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.pt-ctl-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.pt-ctl-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
}
.pt-ctl-lbl {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Segmented control (period / mode) */
.pt-segctl {
  display: inline-flex;
  padding: 2px;
  background: var(--bg-elev);
  border-radius: 6px;
  border: 1px solid var(--border);
  gap: 1px;
}
.pt-segctl-btn {
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 500;
  background: transparent;
  color: var(--text-dim);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
}
.pt-segctl-btn:hover { color: var(--text); }
.pt-segctl-btn.is-on { background: var(--accent); color: var(--surface); }
:root[data-theme="dark"] .pt-segctl-btn.is-on { color: #fff; }

/* Select dropdown */
.pt-select {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
}
.pt-select:focus { outline: none; border-color: var(--accent); }

.pt-ctl-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Zoom preset buttons */
.pt-preset {
  padding: 4px 10px;
  font-size: 12px;
  font-family: var(--font-sans);
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s;
}
.pt-preset:hover { color: var(--text); border-color: var(--text-faint); }
.pt-preset.is-on {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.pt-numinput {
  width: 64px;
  padding: 4px 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  text-align: right;
}

/* Filter chip — already styled via inline; ensure class works */
.pt-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  font-size: 11px;
  font-family: var(--font-sans);
  background: var(--bg-elev);
  color: var(--text-muted);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.12s, color 0.12s, background 0.12s, border-color 0.12s;
}
.pt-filter-chip.is-on {
  background: var(--surface-hi);
  color: var(--text);
  border-color: var(--border);
  opacity: 1;
}

/* ============================================================
   SUB-AGENT LABEL (inside module group)
   ============================================================ */
.pt-sl {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 10px 22px;
  height: 100%;
  min-width: 0;
  position: relative;
}
.pt-sl-prong {
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border-soft);
}
.pt-sl-prong::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 8px;
  height: 1px;
  background: var(--border-soft);
}
.pt-sl-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.pt-sl-avatar.is-lead { box-shadow: 0 0 0 1.5px var(--accent); border-color: var(--bg-elev); }
.pt-sl-id { flex: 1; min-width: 0; }
.pt-sl-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pt-sl-role {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}
.pt-sl-stat { text-align: right; flex-shrink: 0; }
.pt-sl-stat-num {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}
.pt-sl-stat-unit { color: var(--text-muted); font-size: 11px; font-weight: 400; margin-left: 1px; }
.pt-sl-stat-lbl {
  font-size: 9px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Module head row — accent stripe top */
.pt-track.pt-head .pt-track-label { background: var(--surface); }
.pt-track.pt-sub .pt-track-label { background: var(--bg-elev); }

/* ============================================================
   STATS ROW
   ============================================================ */
.pt-stat-numbers {
  display: flex;
  gap: 18px;
  flex-shrink: 0;
}

/* ============================================================
   PANEL — additional bits
   ============================================================ */
.pt-panel-mod-badge {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 1.5px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.pt-panel-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
