/**
 * 리플레이 타임라인 스타일
 * TrackQueryTimeline 디자인 참조 (다크 테마)
 */

.replay-timeline {
  background: rgba(30, 35, 55, 0.95);
  border-radius: 6px;
  overflow: visible;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  min-width: 400px;

  &.playing {
    .play-btn {
      animation: pulse-glow 1.5s infinite;
    }
  }

  &.dragging {
    cursor: grabbing;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    opacity: 0.95;
  }
}

// 드래그 가능한 헤더
.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(79, 195, 247, 0.3), rgba(41, 182, 246, 0.2));
  border-bottom: 1px solid rgba(79, 195, 247, 0.3);
  border-radius: 6px 6px 0 0;
  cursor: grab;
  user-select: none;

  &:active {
    cursor: grabbing;
  }

  .header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
  }

  .header-title {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.5px;
  }

  .header-date-range {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    font-weight: 500;
    color: #4fc3f7;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 8px;
    border-radius: 4px;
  }

  .header-close-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
    line-height: 1;

    &:hover {
      background: rgba(244, 67, 54, 0.3);
      color: #fff;
    }
  }
}

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

// 배속 선택기
.speed-selector {
  position: relative;
  z-index: 100;

  .speed-btn {
    background: rgba(79, 195, 247, 0.2);
    border: 1px solid rgba(79, 195, 247, 0.4);
    border-radius: 4px;
    color: #4fc3f7;
    font-size: 11px;
    font-weight: 600;
    padding: 5px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 50px;

    &:hover:not(:disabled) {
      background: rgba(79, 195, 247, 0.3);
      border-color: #4fc3f7;
    }

    &:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }
  }

  .speed-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 4px;
    background: rgba(40, 45, 70, 0.98);
    border: 1px solid rgba(79, 195, 247, 0.4);
    border-radius: 6px;
    padding: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 180px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
    z-index: 101;

    .speed-option {
      flex: 0 0 calc(33.333% - 4px);
      background: rgba(255, 255, 255, 0.1);
      border: 1px solid transparent;
      border-radius: 4px;
      color: #fff;
      font-size: 11px;
      font-weight: 500;
      padding: 6px 8px;
      cursor: pointer;
      transition: all 0.2s ease;
      text-align: center;

      &:hover {
        background: rgba(79, 195, 247, 0.3);
        border-color: rgba(79, 195, 247, 0.5);
      }

      &.active {
        background: rgba(79, 195, 247, 0.5);
        border-color: #4fc3f7;
        color: #fff;
      }
    }
  }
}

// 컨트롤 버튼
.control-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.2s ease;

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  &.play-btn {
    background: linear-gradient(135deg, #4caf50, #45a049);
    color: #fff;

    &:hover:not(:disabled) {
      transform: scale(1.1);
      box-shadow: 0 0 12px rgba(76, 175, 80, 0.5);
    }

    &.playing {
      background: linear-gradient(135deg, #ffc107, #ffb300);
    }
  }

  &.stop-btn {
    background: rgba(244, 67, 54, 0.8);
    color: #fff;

    &:hover:not(:disabled) {
      background: rgba(244, 67, 54, 1);
      transform: scale(1.1);
    }
  }
}

// 슬라이더 컨테이너
.timeline-slider-container {
  flex: 1;
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
  min-width: 100px;

  .timeline-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    z-index: 2;

    &::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 14px;
      height: 14px;
      background: #fff;
      border: 2px solid #4fc3f7;
      border-radius: 50%;
      cursor: grab;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
      transition: transform 0.1s ease;

      &:hover {
        transform: scale(1.2);
      }

      &:active {
        cursor: grabbing;
      }
    }

    &::-moz-range-thumb {
      width: 14px;
      height: 14px;
      background: #fff;
      border: 2px solid #4fc3f7;
      border-radius: 50%;
      cursor: grab;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }

    &:disabled {
      opacity: 0.5;
      cursor: not-allowed;

      &::-webkit-slider-thumb {
        cursor: not-allowed;
      }
    }
  }

  .slider-progress {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 6px;
    background: linear-gradient(90deg, #4fc3f7, #29b6f6);
    border-radius: 3px;
    pointer-events: none;
    z-index: 1;
    transition: width 0.05s ease-out;
  }
}

// 현재 시간 표시
.current-time-display {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 11px;
  font-weight: 500;
  color: #4fc3f7;
  min-width: 130px;
  text-align: center;
  white-space: nowrap;
}

// 토글 스타일 공통
.loop-toggle,
.trail-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;

  input[type='checkbox'] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: #4fc3f7;

    &:disabled {
      cursor: not-allowed;
    }
  }

  &:hover {
    color: #fff;
  }
}

// 항적표시 토글 (액센트 색상)
.trail-toggle {
  input[type='checkbox'] {
    accent-color: #ff9800;
  }
}

// 재생 중 글로우 애니메이션
@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.4);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(255, 193, 7, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 193, 7, 0);
  }
}

// 반응형 대응
@media (max-width: 768px) {
  .replay-timeline {
    padding: 6px 8px;

    .control-btn {
      width: 28px;
      height: 28px;
      font-size: 10px;
    }

    .speed-btn {
      font-size: 10px;
      padding: 4px 8px;
    }

    .current-time-display {
      font-size: 10px;
      min-width: 100px;
    }
  }
}
