/**
 * 리플레이 v2 컴포넌트 스타일 - 충돌 방지 버전
 * 기존 tracking 컴포넌트 스타일과 충돌하지 않도록 네임스페이스 사용
 */

@keyframes replay-slideUpFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

// ReplayV2 전용 컨테이너 (네임스페이스로 스타일 격리)
.replay-v2-container-new {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  width: 700px;
  max-width: 95vw;
  max-height: 40vh;
  z-index: 1060;
  //background: #ffffff;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2), 0 8px 16px rgba(0, 0, 0, 0.1);
  //border: 1px solid rgba(33, 48, 121, 0.2);
  //backdrop-filter: blur(10px);
  animation: replay-slideUpFadeIn 0.3s ease-out;
  overflow: visible; // 드롭다운이 잘리지 않도록 변경

  // 네임스페이스 내에서만 적용되는 스타일
  > .card {
    border: none;
    background: transparent;
    height: 100%;
    overflow: visible; // 드롭다운이 잘리지 않도록
  }

  > .card > .card-header {
    background: linear-gradient(135deg, #213079 0%, #1a2660 100%);
    color: #ffffff;
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    padding: 6px 10px;
    overflow: hidden; // 헤더 내부 요소는 border-radius 안에 유지

    h5 {
      font-weight: 600;
      font-size: 13px;
      margin-bottom: 0;
      letter-spacing: -0.02em;
    }

    .btn {
      border-radius: 5px;
      font-size: 11px;
      padding: 2px 5px;
      transition: all 0.2s ease;

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

  > .card > .card-body.compact-layout {
    //padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    overflow: visible; // 드롭다운이 잘리지 않도록
  }

  // 타임라인 섹션 (항상 상단에 표시)
  .replay-timeline-section {
    flex-shrink: 0; // 축소되지 않도록
    overflow: visible; // 드롭다운이 잘리지 않도록
    border-radius: 10px;
  }

  // 접을 수 있는 필터 컨트롤
  .replay-filter-collapse {
    flex-shrink: 0;

    &[open] {
      .replay-filter-toggle {
        span:first-child {
          transform: rotate(90deg);
        }
      }
    }

    .replay-filter-toggle {
      list-style: none;
      outline: none;
      transition: all 0.2s ease;

      &::-webkit-details-marker {
        display: none;
      }

      span:first-child {
        transition: transform 0.2s ease;
        display: inline-block;
      }

      &:hover {
        background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
      }
    }

    .replay-filter-content {
      animation: slideDown 0.2s ease-out;
    }
  }

  @keyframes slideDown {
    from {
      opacity: 0;
      transform: translateY(-8px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  // 컴팩트 컨트롤 패널 - 고유한 클래스명 사용
  .replay-compact-control-panel {
    // 첫 번째 행 - Flexbox로 수평 배치
    .replay-control-row {
      display: flex;
      gap: 6px;
      margin-bottom: 5px;

      // 각 섹션을 동일한 너비로 배치
      .replay-info-section,
      .replay-timeline-section,
      .replay-params-section {
        flex: 1;
        min-width: 0; // flexbox 오버플로우 방지
      }
    }

    // 정보 섹션
    .replay-info-section {
      .replay-info-box {
        background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
        border: 1px solid #2196f3;
        border-radius: 6px;
        padding: 5px;
        height: 56px;
        display: flex;
        align-items: center;
        justify-content: center;

        // TrackingStats를 안전하게 래핑
        .tracking-stats {
          width: 100%;
          text-align: center;

          .stat-card {
            background: transparent !important;
            border: none !important;
            padding: 2px !important;
            margin: 0 !important;

            .stat-value {
              font-size: 0.9rem !important;
              margin-bottom: 1px !important;
            }

            .stat-label {
              font-size: 0.6rem !important;
            }
          }
        }
      }
    }

    // 타임라인 섹션 (드래그 가능한 영역)
    .replay-timeline-section {
      position: relative;

      // ReplayTimeline 스타일 조정
      .replay-timeline {
        .timeline-header {
          .header-title {
            font-size: 12px;
          }

          .header-date-range {
            font-size: 10px;
          }
        }

        .timeline-controls {
          gap: 6px;
          padding: 6px 10px;

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

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

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

    // 파라미터 섹션
    .replay-params-section {
      .replay-params-box {
        background: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%);
        border: 1px solid #9c27b0;
        border-radius: 6px;
        padding: 5px;
        height: 56px;

        .replay-section-title {
          font-size: 10px;
          font-weight: 600;
          color: #7b1fa2;
          margin-bottom: 4px;
          display: flex;
          align-items: center;

          i {
            margin-right: 2px;
            font-size: 8px;
          }
        }

        .replay-param-item {
          margin-bottom: 2px;

          .replay-param-label {
            font-size: 8px;
            color: #7b1fa2;
            font-weight: 600;
            margin-right: 4px;
          }

          .replay-param-value {
            font-size: 8px;
            color: #4a148c;
            font-weight: 500;
          }

          .badge {
            font-size: 7px;
            padding: 1px 3px;
          }
        }
      }
    }

    // 고급 설정 (접힌 상태)
    .replay-advanced-control {
      margin-top: 5px;

      .replay-advanced-summary {
        list-style: none;
        outline: none;
        cursor: pointer;
        font-size: 10px;
        font-weight: 600;
        color: #495057;
        padding: 4px 0;
        border-bottom: 1px solid #dee2e6;
        background: none;
        border: none;
        display: flex;
        align-items: center;

        &::before {
          content: '▶';
          margin-right: 4px;
          transition: transform 0.2s;
          font-size: 8px;
        }

        i {
          margin-right: 4px;
          font-size: 8px;
        }
      }

      &[open] .replay-advanced-summary::before {
        transform: rotate(90deg);
      }

      .replay-advanced-content {
        max-height: 150px;
        overflow-y: auto;
        margin-top: 4px;

        // TrackingControl 내부 스타일 최소한 조정
        .tracking-control {
          .card {
            font-size: 9px !important;

            .card-header {
              padding: 4px 6px !important;

              h5 {
                font-size: 9px !important;
                margin: 0 !important;
              }
            }

            .card-body {
              padding: 6px !important;

              .form-label {
                font-size: 8px !important;
                margin-bottom: 1px !important;
              }

              .form-control,
              .form-select {
                font-size: 8px !important;
                padding: 1px 3px !important;
                height: auto !important;
              }

              .btn {
                font-size: 8px !important;
                padding: 1px 3px !important;
              }

              .btn-group .btn {
                font-size: 7px !important;
                padding: 1px 2px !important;
              }

              .mb-3 {
                margin-bottom: 0.25rem !important;
              }
            }
          }
        }
      }
    }
  }

  // 알림 메시지
  .replay-compact-alert {
    padding: 3px 5px;
    font-size: 9px;
    border-radius: 5px;
    margin-bottom: 5px;
  }

  // 반응형 조정
  @media (max-width: 1200px) {
    width: 95vw;

    .replay-compact-control-panel .replay-control-row {
      flex-direction: column;
      gap: 6px;
    }

    .replay-info-box,
    .replay-timeline-box,
    .replay-params-box {
      height: 48px !important;
    }
  }

  @media (max-width: 768px) {
    width: 98vw;
    bottom: 10px;

    > .card > .card-header {
      padding: 5px 8px;

      h5 {
        font-size: 12px;
      }

      .btn {
        font-size: 9px;
        padding: 2px 4px;
      }
    }

    > .card > .card-body.compact-layout {
      padding: 4px;
    }

    .replay-info-box,
    .replay-timeline-box,
    .replay-params-box {
      height: 40px !important;
      padding: 3px !important;
    }
  }

  @media (max-width: 480px) {
    width: 99vw;
    bottom: 5px;

    .replay-info-box,
    .replay-timeline-box,
    .replay-params-box {
      height: 32px !important;
    }
  }
}

// 기존 컨테이너 숨김
.replay-v2-container {
  display: none !important;
}

// QueryProgressPanel 위치 조정 (ReplayV2와 독립적으로 표시)
.query-progress-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 500px;
  max-width: 95vw;
  z-index: 1059; // ReplayV2보다 약간 낮은 z-index

  @media (max-width: 1200px) {
    width: 95vw;
    bottom: 260px;
  }

  @media (max-width: 768px) {
    width: 98vw;
    bottom: 240px;
  }

  @media (max-width: 480px) {
    width: 99vw;
    bottom: 220px;
  }
}