/**
 * Zone 2 : Bottom Timeline (public/studio/zones/bottom-timeline/bottom-timeline.css)
 * Style Niveau 3 spécifique à la timeline inférieure haute densité fidèles à 45de067.
 * Pur CSS Niveau 3, < 400 lignes.
 */

.timeline-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  background: rgba(10, 15, 29, 0.98);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.timeline-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.timeline-cam-icon {
  color: #38bdf8;
  flex-shrink: 0;
}

.timeline-title {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #94a3b8;
  text-transform: uppercase;
}

.timeline-video-id-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 9999px;
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.35);
  cursor: pointer;
  transition: all 0.2s ease;
}

.timeline-video-id-badge:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: #60a5fa;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

.timeline-total-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(217, 38, 248, 0.15);
  border: 1px solid rgba(217, 38, 248, 0.35);
  color: #f0abfc;
}

.timeline-view-switcher .view-tab-btn {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 23, 42, 0.6);
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.2s ease;
}

.timeline-view-switcher .view-tab-btn:hover {
  background: rgba(30, 41, 59, 0.8);
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.2);
}

.timeline-view-switcher .view-tab-btn.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(217, 38, 248, 0.3));
  border-color: #d926f8;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(217, 38, 248, 0.3);
}

/* ── Zone Principale des Pistes ── */
.timeline-tracks-area {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 0.25rem 0.5rem;
  box-sizing: border-box;
}

/* ── Ligne Règle Temporelle ── */
.timeline-ruler-track-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  height: 18px;
  margin-bottom: 1px;
}

.layer-track-header {
  width: 68px;
  min-width: 68px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.ruler-track-label {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  width: 64px;
  text-align: right;
  box-sizing: border-box;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.55rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.08rem 0.3rem;
  border-radius: 4px;
  white-space: nowrap;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  user-select: none;
  line-height: 1;
}

.timeline-time-ruler-canvas {
  position: relative;
  flex: 1;
  height: 100%;
  background: rgba(15, 23, 42, 0.75);
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.25);
  overflow: hidden;
  box-sizing: border-box;
  cursor: col-resize;
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.timeline-time-ruler-canvas:hover {
  background: rgba(15, 23, 42, 0.95);
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: inset 0 0 10px rgba(56, 189, 248, 0.2);
}

.ruler-tick {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.ruler-tick.is-start {
  transform: translateX(0);
  align-items: flex-start;
  padding-left: 2px;
}

.ruler-tick.is-end {
  transform: translateX(-100%);
  align-items: flex-end;
  padding-right: 2px;
}

.ruler-tick-mark {
  width: 1px;
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
}

.ruler-tick-mark.major {
  height: 5px;
  background: #38bdf8;
  width: 1.5px;
}

.ruler-tick-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.52rem;
  font-weight: 700;
  color: #94a3b8;
  line-height: 1;
  margin-bottom: 1px;
  white-space: nowrap;
}

.ruler-tick.major .ruler-tick-label {
  color: #93c5fd;
}

/* ── Ligne SCENE Principale ── */
.timeline-scene-track-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  height: 24px;
}

.scene-track-label {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  width: 64px;
  text-align: right;
  box-sizing: border-box;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.08rem 0.3rem;
  border-radius: 4px;
  white-space: nowrap;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  line-height: 1;
}

.scene-track-label:hover {
  background: rgba(59, 130, 246, 0.3);
  border-color: rgba(96, 165, 250, 0.7);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.scenes-row {
  position: relative;
  flex: 1;
  height: 100%;
  background: #04060b;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  box-sizing: border-box;
  padding: 0;
}

.timeline-scene-block {
  position: absolute;
  top: 1px;
  bottom: 1px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  padding: 0 4px;
  border-radius: 4px;
  border: 1px solid rgba(59, 130, 246, 0.75);
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.45) 0%, rgba(217, 38, 248, 0.45) 100%);
  box-sizing: border-box;
  overflow: hidden;
  white-space: nowrap;
  min-width: 0;
  cursor: pointer;
  transition: all 0.2s ease;
}

.timeline-scene-block:hover {
  filter: brightness(1.2);
  border-color: rgba(255, 255, 255, 0.45);
  z-index: 10;
}

.timeline-scene-block.is-active-scene {
  border-color: #d926f8 !important;
  box-shadow: 0 0 12px rgba(217, 38, 248, 0.6) !important;
  filter: brightness(1.2) !important;
  z-index: 5 !important;
}

.timeline-scene-block>* {
  pointer-events: none;
}

.scene-block-label {
  font-family: 'JetBrains Mono', monospace, sans-serif;
  font-size: 0.65rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  line-height: 1;
  min-width: 0;
  width: 100%;
  user-select: none;
}

.scene-time-text {
  color: #93c5fd;
  font-weight: 800;
  flex-shrink: 0;
}

.scene-sep-text {
  color: rgba(103, 232, 249, 0.65);
  font-weight: 700;
  flex-shrink: 0;
  margin: 0 1px;
}

.scene-id-text {
  color: #67e8f9;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ── Poignées d'insertion de scène ── */
.timeline-scene-insert-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  cursor: pointer;
  pointer-events: auto;
  background: transparent;
  user-select: none;
}

.timeline-scene-insert-handle .insert-handle-guide {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-50%);
  background: #d926f8;
  opacity: 0;
  box-shadow: 0 0 8px #d926f8, 0 0 14px rgba(217, 38, 248, 0.8);
  transition: opacity 0.16s ease;
  pointer-events: none;
}

.timeline-scene-insert-handle .insert-handle-btn {
  position: relative;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #3b82f6;
  color: #ffffff;
  border: 1.5px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  opacity: 0;
  transform: scale(0.6);
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.9), 0 2px 5px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  cursor: pointer;
  box-sizing: border-box;
}

.timeline-scene-insert-handle:hover .insert-handle-guide {
  opacity: 1;
}

.timeline-scene-insert-handle:hover .insert-handle-btn {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.timeline-scene-insert-handle:active .insert-handle-btn {
  transform: scale(0.85);
  background: #0369a1;
}

/* ── Conteneur des Calques Multi-Pistes ── */
.timeline-layers-rows {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  max-height: clamp(190px, 28vh, 260px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.timeline-layer-track-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  height: 20px;
  position: relative;
}

.z-label,
.audio-label {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  width: 64px;
  text-align: right;
  box-sizing: border-box;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.08rem 0.3rem;
  border-radius: 4px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  line-height: 1;
}

.z-label {
  color: #f0abfc;
  background: rgba(217, 38, 248, 0.15);
  border: 1px solid rgba(217, 38, 248, 0.35);
}

.z-label:hover {
  background: rgba(217, 38, 248, 0.3);
  border-color: rgba(217, 38, 248, 0.7);
  box-shadow: 0 0 10px rgba(217, 38, 248, 0.4);
  transform: translateY(-1px);
}

.audio-label {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.audio-label:hover {
  background: rgba(59, 130, 246, 0.3);
  border-color: rgba(96, 165, 250, 0.7);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.layer-track-canvas {
  position: relative;
  flex: 1;
  height: 100%;
  background: rgba(4, 6, 11, 0.6);
  border-radius: 4px;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  overflow: hidden;
  box-sizing: border-box;
  padding: 0;
}

.layer-element-block {
  position: absolute;
  top: 1px;
  bottom: 1px;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0 4px;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  box-sizing: border-box;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
  min-width: 0;
  transition: all 0.2s ease;
}

.layer-element-block:hover {
  filter: brightness(1.25);
  border-color: rgba(255, 255, 255, 0.45);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.layer-element-block.layer-element-block--inherited {
  background: rgba(30, 58, 138, 0.4);
  border: 1px solid rgba(96, 165, 250, 0.4);
}

.layer-element-block.layer-element-block--inherited:hover {
  border-color: #60a5fa;
  box-shadow: 0 0 12px rgba(96, 165, 250, 0.35);
}

.layer-element-block>* {
  pointer-events: none;
}

.layer-element-block.layer-element-block-empty {
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.45);
  justify-content: center;
  align-items: center;
  display: flex;
  padding: 0;
  margin: 0;
  line-height: 0;
  opacity: 0.45;
  box-shadow: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  box-sizing: border-box;
}

.layer-element-block.layer-element-block-empty:hover {
  opacity: 1;
  transform: none;
  z-index: 10;
}

.layer-element-block.layer-element-block-empty.layer-empty-image:hover,
.layer-element-block.layer-element-block-empty.layer-empty-audio:hover {
  background: rgba(56, 189, 248, 0.14);
  border: 1.5px dashed #38bdf8;
  color: #38bdf8;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.28);
}

.layer-element-block.layer-element-block-empty.layer-empty-subtitle:hover {
  background: rgba(192, 132, 252, 0.14);
  border: 1.5px dashed #c084fc;
  color: #c084fc;
  box-shadow: 0 0 16px rgba(192, 132, 252, 0.28);
}

.empty-part-plus-icon {
  width: 14px;
  height: 14px;
  display: block;
  opacity: 0;
  transform: scale(0.7);
  transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  user-select: none;
  flex-shrink: 0;
  margin: auto;
}

.layer-element-block.layer-element-block-empty:hover .empty-part-plus-icon {
  opacity: 1;
  transform: scale(1);
}

/* ── Poignées Flottantes d'Insertion de Piste ── */
.timeline-track-insert-handle {
  position: absolute;
  left: 0;
  right: 0;
  height: 16px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  z-index: 35;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
}

.timeline-track-insert-handle.track-insert-top {
  top: -9px;
}

.timeline-track-insert-handle.track-insert-bottom {
  bottom: -9px;
}

.btn-add-track-floating {
  width: 64px;
  min-width: 64px;
  height: 18px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 4px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  margin-left: 2px;
  flex-shrink: 0;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  line-height: 1;
}

.timeline-track-insert-handle:hover .btn-add-track-floating {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.btn-add-track-floating.btn-add-image-track {
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.95), rgba(168, 85, 247, 0.95));
  border: 1.5px solid #e9d5ff;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.7), 0 2px 6px rgba(0, 0, 0, 0.6);
}

.btn-add-track-floating.btn-add-audio-track {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.95), rgba(59, 130, 246, 0.95));
  border: 1.5px solid #93c5fd;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.7), 0 2px 6px rgba(0, 0, 0, 0.6);
}

.track-insert-guide-line {
  flex: 1;
  height: 2px;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.16s ease;
  pointer-events: none;
}

.timeline-track-insert-handle:hover .track-insert-guide-line {
  opacity: 1;
}

.track-insert-guide-line.track-guide-image {
  background: #c084fc;
  box-shadow: 0 0 8px #c084fc, 0 0 14px rgba(192, 132, 252, 0.8);
}

.track-insert-guide-line.track-guide-audio {
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8, 0 0 14px rgba(56, 189, 248, 0.8);
}

.track-insert-guide-text {
  background: #0f172a;
  padding: 0.1rem 0.6rem;
  border-radius: 4px;
  font-size: 0.60rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}

.track-guide-image .track-insert-guide-text {
  color: #f5d0fe;
  border-color: rgba(192, 132, 252, 0.6);
}

.track-guide-audio .track-insert-guide-text {
  color: #93c5fd;
  border-color: rgba(56, 189, 248, 0.6);
}

/* ── Playhead Globale Lumineuse ── */
.timeline-global-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #d926f8;
  box-shadow: 0 0 8px #d926f8, 0 0 16px rgba(59, 130, 246, 0.6);
  z-index: 40;
  pointer-events: none;
  transition: none;
}

.global-playhead-knob {
  position: absolute;
  top: -5px;
  left: -4px;
  width: 10px;
  height: 10px;
  background: #d926f8;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

.global-playhead-line {
  position: absolute;
  top: 5px;
  bottom: 0;
  left: 0;
  width: 2px;
  background: #d926f8;
}

.timeline-empty-state {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #64748b);
  font-size: 0.75rem;
  font-style: italic;
  height: 100%;
}