/* Trakk - Timeline Editor Styles */

/* CSS Custom Properties - Override these to customize Trakk */
.timeline-editor {
  /* Core colors */
  --trakk-bg: #191b1d;
  --trakk-text: #ffffff;
  --trakk-accent: #5297FF;

  /* Block colors */
  --trakk-block-bg: #2f3134;
  --trakk-block-bg-hover: #3a3d40;
  --trakk-block-bg-selected: #4a7ba7;

  /* Border & subtle elements */
  --trakk-border: rgba(255, 255, 255, 0.1);
  --trakk-border-strong: rgba(255, 255, 255, 0.3);

  /* Text variations */
  --trakk-text-muted: rgba(255, 255, 255, 0.6);
  --trakk-text-subtle: rgba(255, 255, 255, 0.4);

  /* State colors */
  --trakk-danger: #ff6464;
  --trakk-disabled-opacity: 0.6;
  --trakk-locked-opacity: 0.7;

  /* Base styles */
  height: 100%;
  width: 100%;
  min-height: 100px;
  position: relative;
  font-size: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--trakk-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--trakk-text);
  box-sizing: border-box;
  user-select: none;
}

/* Time Area */
.timeline-editor-time-area {
  position: relative;
  height: 32px;
  flex: 0 0 auto;
  background-color: var(--trakk-bg);
  overflow: hidden;
  z-index: 150;
}

.timeline-editor-time-area-wrapper {
  position: relative;
  height: 100%;
}

.timeline-editor-time-area-interact {
  position: absolute;
  cursor: pointer;
  left: 0;
  top: 0;
  height: 100%;
  display: flex;
  align-items: flex-end;
}

.timeline-editor-time-unit {
  border-right: 1px solid var(--trakk-border);
  position: relative;
  box-sizing: border-box;
  height: 6px;
  bottom: 0;
  flex-shrink: 0;
}

.timeline-editor-time-unit-big {
  height: 12px;
  border-right: 1px solid var(--trakk-border-strong);
}

.timeline-editor-time-unit-scale {
  color: var(--trakk-text-muted);
  position: absolute;
  right: 0;
  top: 0;
  transform: translate(50%, -100%);
  padding-bottom: 4px;
  font-size: 11px;
}

/* Edit Area */
.timeline-editor-edit-area {
  flex: 1 1 0;
  margin-top: 0;
  overflow-x: scroll;
  overflow-y: auto;
  position: relative;
  min-height: 48px; /* Ensure horizontal scrollbar is always visible (row height + scrollbar) */
  min-width: 0;
  height: 100%;
  width: 0;
}

.timeline-editor-rows {
  position: relative;
  z-index: 1;
}

/* Scrollbar - Firefox fallback */
.timeline-editor-edit-area {
  scrollbar-color: var(--trakk-border-strong) rgba(0, 0, 0, 0.2);
  scrollbar-width: auto;
}

/* Scrollbar - Webkit browsers */
.timeline-editor-edit-area::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

.timeline-editor-edit-area::-webkit-scrollbar-track {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}

.timeline-editor-edit-area::-webkit-scrollbar-thumb {
  background-color: var(--trakk-border-strong);
  border-radius: 10px;
}

.timeline-editor-edit-area::-webkit-scrollbar-thumb:hover {
  background-color: var(--trakk-text-subtle);
}

.timeline-editor-edit-area::-webkit-scrollbar-corner {
  background-color: rgba(0, 0, 0, 0.2);
}

/* Edit Row */
.timeline-editor-edit-row {
  --timeline-scale-width: 160px; /* fallback, overridden by JS */
  background-repeat: no-repeat, repeat;
  background-image: linear-gradient(var(--trakk-bg), var(--trakk-bg)), linear-gradient(90deg, var(--trakk-border) 1px, transparent 0);
  background-size: var(--timeline-scale-width) 100%;
  display: flex;
  flex-direction: row;
  box-sizing: border-box;
  position: relative;
  border-bottom: 1px solid var(--trakk-border);
  min-height: 32px;
}

.timeline-editor-edit-row:first-child {
  border-top: 1px solid var(--trakk-border);
}

.timeline-editor-edit-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: transparent;
  pointer-events: none;
  transition: background-color 0.1s;
}

.timeline-editor-edit-row:hover::before {
  background-color: rgba(255, 255, 255, 0.02);
}

.timeline-editor-row-label {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 8px;
  color: var(--trakk-text-muted);
  font-size: 12px;
  font-weight: 500;
  background-color: var(--trakk-bg);
  border-right: 1px solid var(--trakk-border);
  z-index: 2;
  pointer-events: auto;
}

.timeline-editor-row-label:hover {
  color: var(--trakk-text);
}

.timeline-editor-row-label-locked::after {
  content: '';
  margin-left: 6px;
  width: 10px;
  height: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='rgba(255,255,255,0.4)'%3E%3Cpath d='M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  flex-shrink: 0;
}

.timeline-editor-row-label-input {
  user-select: text;
}

.timeline-editor-row-delete {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='rgba(255,255,255,0.5)'%3E%3Cpath d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

.timeline-editor-row-label:hover .timeline-editor-row-delete,
.timeline-editor-label-row:hover .timeline-editor-row-delete {
  opacity: 1;
}

.timeline-editor-label-row:hover .timeline-editor-lock-icon {
  opacity: 0;
}

.timeline-editor-row-delete:hover {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ff6464'%3E%3Cpath d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/%3E%3C/svg%3E");
}

.timeline-editor-action-locked {
  opacity: var(--trakk-locked-opacity);
}

.timeline-editor-action-delete {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='rgba(255,255,255,0.5)'%3E%3Cpath d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  z-index: 2;
}

.timeline-editor-action:hover .timeline-editor-action-delete {
  opacity: 1;
}

.timeline-editor-action-delete:hover {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ff6464'%3E%3Cpath d='M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'/%3E%3C/svg%3E");
}

/* Action Block */
.timeline-editor-action {
  position: absolute;
  left: 0;
  top: 4px;
  background-color: var(--trakk-block-bg);
  border-radius: 4px;
  cursor: move;
  user-select: none;
  height: calc(100% - 8px);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--trakk-border);
  box-sizing: border-box;
  transition: background-color 0.2s;
}

.timeline-editor-action:hover {
  background-color: var(--trakk-block-bg-hover);
}

.timeline-editor-action.selected {
  background-color: var(--trakk-block-bg-selected);
  border-color: var(--trakk-accent);
}

.timeline-editor-action-left-stretch,
.timeline-editor-action-right-stretch {
  position: absolute;
  top: 0;
  width: 10px;
  border-radius: 4px;
  height: 100%;
  overflow: hidden;
  cursor: ew-resize;
  z-index: 1;
}

.timeline-editor-action-left-stretch::after,
.timeline-editor-action-right-stretch::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  margin: auto;
  border-radius: 4px;
  border-top: 14px solid transparent;
  border-bottom: 14px solid transparent;
}

.timeline-editor-action-left-stretch {
  left: 0;
}

.timeline-editor-action-left-stretch::after {
  left: 0;
  border-left: 7px solid var(--trakk-border);
  border-right: 7px solid transparent;
}

.timeline-editor-action-right-stretch {
  right: 0;
}

.timeline-editor-action-right-stretch::after {
  right: 0;
  border-right: 7px solid var(--trakk-border);
  border-left: 7px solid transparent;
}

/* Cursor */
.timeline-editor-cursor {
  cursor: ew-resize;
  position: absolute;
  top: 32px;
  height: calc(100% - 32px);
  box-sizing: border-box;
  border-left: 1px solid var(--trakk-accent);
  border-right: 1px solid var(--trakk-accent);
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 100;
  will-change: left;
}

.timeline-editor-cursor-top {
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 12px;
  pointer-events: none;
}

.timeline-editor-cursor-top::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 8px;
  height: 12px;
  background: var(--trakk-accent);
  clip-path: polygon(0 0, 100% 0, 100% 60%, 50% 100%, 0 60%);
}

.timeline-editor-cursor-area {
  width: 16px;
  height: 100%;
  cursor: ew-resize;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: all;
}

/* Disabled state */
.timeline-editor-disable .timeline-editor-action {
  cursor: not-allowed;
  opacity: var(--trakk-disabled-opacity);
}

.timeline-editor-disable .timeline-editor-cursor {
  cursor: not-allowed;
}

/* Utility classes */
.timeline-editor-action-content {
  padding: 0 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  width: 100%;
  text-align: center;
}

/* Spacer (covers cursor line between time area and content) */
.timeline-editor-spacer {
  height: 10px;
  width: var(--timeline-start-left);
  background-color: var(--trakk-bg);
  flex-shrink: 0;
  position: relative;
  z-index: 101;
}

/* Content wrapper */
.timeline-editor-content {
  display: flex;
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  height: 0;
  overflow: hidden;
  position: relative;
}

/* Label column (frozen left side) */
.timeline-editor-label-column {
  width: var(--timeline-start-left);
  flex-shrink: 0;
  overflow: hidden;
  background-color: var(--trakk-bg);
  border-right: 1px solid var(--trakk-border);
  z-index: 200;
  position: relative;
}

/* Label row */
.timeline-editor-label-row {
  display: flex;
  align-items: center;
  padding: 0 8px;
  color: var(--trakk-text-muted);
  font-size: 12px;
  font-weight: 500;
  border-bottom: 1px solid var(--trakk-border);
  box-sizing: border-box;
  position: relative;
}

.timeline-editor-label-row:first-child {
  border-top: 1px solid var(--trakk-border);
}

.timeline-editor-label-row:hover {
  color: var(--trakk-text);
}

/* Label text */
.timeline-editor-label-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Lock icon in label */
.timeline-editor-lock-icon {
  width: 12px;
  height: 12px;
  margin-left: 4px;
  flex-shrink: 0;
  background-size: contain;
  background-repeat: no-repeat;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='rgba(255,255,255,0.4)'%3E%3Cpath d='M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z'/%3E%3C/svg%3E");
}

/* Input fields for editing names */
.timeline-editor-row-label-input,
.timeline-editor-block-name-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--trakk-border-strong);
  color: inherit;
  font: inherit;
  outline: none;
  padding: 0;
  margin: 0;
  user-select: text;
  box-sizing: border-box;
}

.timeline-editor-block-name-input {
  width: 100%;
  text-align: center;
}
