/* Infinite Timeline — Styles. Plain CSS only. */

:root {
  --bg: #0f0f12;
  --surface: #18181c;
  --border: #2a2a30;
  --text: #e4e4e7;
  --text-muted: #71717a;
  --accent: #a78bfa;
  --accent-hover: #c4b5fd;
  --danger: #f87171;
  --axis: #3f3f46;
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: var(--border);
}

.btn-icon {
  width: 36px;
  padding: 8px;
  text-align: center;
  font-size: 1.1rem;
  line-height: 1;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.15);
}

/* Main layout: column with toolstrip, then row with sidebar + timeline */
.main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.main-row {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Tool strip: Add event + Edit selected, above timeline */
.toolstrip {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 24px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.toolstrip-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.add-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.edit-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-basis: 100%;
}

input[type="color"].color-pick {
  width: 40px;
  min-width: 40px;
  height: 36px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
  flex-shrink: 0;
  -webkit-appearance: none;
  appearance: none;
}

input[type="color"].color-pick::-webkit-color-swatch-wrapper {
  padding: 3px;
}

input[type="color"].color-pick::-webkit-color-swatch {
  border: none;
  border-radius: 5px;
}

input[type="color"].color-pick::-moz-color-swatch {
  border: none;
  border-radius: 5px;
}

.add-form-inline,
.edit-form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.add-form-inline select,
.add-form-inline input,
.edit-form-inline input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.add-form-inline select:focus,
.add-form-inline input:focus,
.edit-form-inline input:focus {
  outline: none;
  border-color: var(--accent);
}

.add-form-inline .add-date {
  width: 280px;
}

.add-form-inline .add-label {
  width: 160px;
}

.edit-form-inline #edit-label {
  width: 140px;
}

.edit-form-inline #edit-start,
.edit-form-inline #edit-end {
  width: 140px;
}

.edit-inline.hidden {
  visibility: hidden;
  pointer-events: none;
  /* Reserve space so toolbar height doesn’t jump when selection changes */
}

/* All events sidebar */
.events-sidebar {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.all-events-head {
  flex-shrink: 0;
  margin-bottom: 10px;
}

.all-events-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.all-events-title {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.items-list-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.items-sort {
  display: inline-flex;
  gap: 4px;
}

.items-sort-btn {
  padding: 2px 8px;
  font-size: 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.items-sort-btn-active {
  background: var(--border);
  color: var(--text);
}

.items-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  padding: 2px 0;
  flex: 1;
  min-height: 0;
}

.items-list-item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 8px;
  row-gap: 1px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  align-items: start;
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
}

.items-list-item:hover {
  background: var(--border);
}

.items-list-item.selected {
  background: rgba(167, 139, 250, 0.2);
  border-color: var(--accent);
}

.items-list-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  grid-row: 1 / 3;
  align-self: center;
  flex-shrink: 0;
}

.items-list-label {
  font-weight: 500;
  color: var(--text);
}

.items-list-date {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.items-list-mute {
  grid-column: 3;
  grid-row: 1 / 3;
  align-self: center;
  justify-self: end;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.items-list-mute .icon-eye {
  width: 18px;
  height: 18px;
}

.items-list-item:hover .items-list-mute,
.items-list-item.muted .items-list-mute {
  opacity: 1;
}

.items-list-mute:hover {
  background: var(--border);
  color: var(--text);
}

.items-list-item.muted .items-list-label,
.items-list-item.muted .items-list-date {
  opacity: 0.4;
  text-decoration: line-through;
}

/* Workspace: whole area is click-to-deselect and drag-to-pan (not just the timeline strip) */
/* Workspace: timeline area, scrolls naturally */
.workspace {
  flex: 1;
  min-width: 0;
  padding: 20px;
  position: relative;
  cursor: grab;
}
.workspace:active {
  cursor: grabbing;
}

.message {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  padding: 10px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}

.message.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.timeline-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  overflow: hidden;
  width: 100%;
  height: 560px;
  flex-shrink: 0;
}

/* Edit selected bar: below timeline */
.edit-selected-wrap {
  flex-shrink: 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.edit-selected-wrap.hidden {
  display: none;
}

.edit-selected-wrap .edit-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.edit-selected-wrap .edit-form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Eye icon button (show/hide on timeline) */
.eye-btn {
  padding: 6px;
  line-height: 0;
}
.eye-btn .eye-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.eye-btn .icon-eye {
  color: var(--text);
  vertical-align: middle;
}
.eye-btn:hover .icon-eye {
  color: var(--accent);
}
.icon-eye {
  display: block;
}

.timeline-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

.timeline-svg:active {
  cursor: grabbing;
}

/* Axis */
.timeline-axis .axis-line {
  stroke: var(--axis);
  stroke-width: 1.5;
}

.timeline-axis .axis-zoom-center {
  stroke: var(--text-muted);
  stroke-width: 1;
  stroke-dasharray: 5 5;
  opacity: 0.85;
}

.timeline-axis .axis-tick {
  stroke: var(--axis);
  stroke-width: 1;
}

.timeline-axis .axis-label {
  fill: var(--text-muted);
  font-size: 12px;
  font-family: var(--font);
}

/* Items */
.item-point {
  stroke: var(--bg);
  stroke-width: 2;
  cursor: pointer;
}

.item-point:hover,
.item-point.selected {
  opacity: 0.85;
}

.item-range {
  stroke: var(--bg);
  stroke-width: 1;
  cursor: pointer;
}

.item-range:hover,
.item-range.selected {
  opacity: 0.85;
}

.range-handle {
  stroke: var(--bg);
  stroke-width: 1;
  cursor: ew-resize;
  opacity: 0.9;
}

.range-handle:hover {
  opacity: 0.75;
}

.item-label {
  font-size: 13px;
  font-family: var(--font);
  pointer-events: none;
  /* Prevent SVG from stretching text; use consistent glyph scaling */
  font-stretch: normal;
}

.item-label.selected {
  font-weight: 600;
}

.item-date {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: var(--font);
  pointer-events: none;
}
