/**
 * 오디오 내비게이션 스타일
 * OpenAI 음성 내비게이션 디자인을 참고하여 제작
 */

.audio-navigation {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  width: 200px;
  height: 48px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 8px;
  cursor: pointer;
  pointer-events: auto;
  /* 임시 숨김 */
  display: none;

  transition: bottom 0.4s, opacity 0.4s;
}
html.popup-open .audio-navigation {
  bottom: -70px;
  opacity: 0;
  pointer-events: none;
}

.audio-navigation.expanded {
  width: 355px;
}

.audio-navigation:hover {
  transform: translateX(-50%) scale(1.05);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.audio-navigation.hidden {
  transform: translateX(-50%) translateY(100px);
  opacity: 0;
  pointer-events: none;
}

.audio-navigation .play-button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  font-size: 14px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.audio-navigation .play-button:hover {
  background: #f0f0f0;
  transform: scale(1.05);
}

.audio-navigation .play-button.playing {
  background: linear-gradient(135deg, #ff5600 0%, #ee5a24 100%);
}

.audio-navigation .play-button.playing:hover {
  background: linear-gradient(135deg, #ff5252 0%, #e74c3c 100%);
}

.audio-navigation .intro-text {
  flex: 1;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.7);
  font-weight: 500;
  text-align: left;
  margin-left: 8px;
  line-height: 20px;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  height: 20px;
}

.audio-navigation .intro-text-content {
  display: inline-block;
  animation: scroll-text 15s linear infinite;
}

.audio-navigation .intro-text-content::after {
  content: "요약 내용을 음성으로 들을 수 있어요. 자막 옵션도 제공됩니다.";
}

@keyframes scroll-text {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-100%);
  }
}

.audio-navigation .progress-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  pointer-events: auto;
}

.audio-navigation .progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
  pointer-events: auto;
}

.audio-navigation .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-purple) 0%, #764ba2 100%);
  border-radius: 2px;
  transition: width 0.1s ease;
  position: relative;
}

.audio-navigation .progress-fill::after {
  content: '';
  position: absolute;
  right: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.audio-navigation:hover .progress-fill::after {
  opacity: 1;
}

.audio-navigation .time-display {
  font-size: 11px;
  color: rgba(0, 0, 0, 0.6);
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.audio-navigation .current-time,
.audio-navigation .total-time {
  font-variant-numeric: tabular-nums;
}

.audio-navigation .controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.audio-navigation .control-button {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(0, 0, 0, 0.6);
  font-size: 12px;
  transition: all 0.2s ease;
}

.audio-navigation .control-button:hover {
  background: rgba(0, 0, 0, 0.05);
  color: rgba(0, 0, 0, 0.8);
}

.audio-navigation .control-button.active {
  background: rgba(102, 126, 234, 0.1);
  color: var(--color-purple);
}

.audio-navigation .control-button.subtitle-toggle,
.audio-navigation .control-button.semantic-toggle {
  width: 24px;
  height: 24px;
  font-size: 11px;
  border: 2.5px solid var(--color-purple);
  background: var(--color-purple);
  color: #222;
  box-shadow: 0 2px 8px rgba(102,126,234,0.08);
  z-index: 2;
  transition: all 0.2s;
}
.audio-navigation .control-button.subtitle-toggle:active,
.audio-navigation .control-button.semantic-toggle:active {
  background: #f5f5f5;
}

.audio-navigation .subtitle-toggle.active,
.audio-navigation .semantic-toggle.active {
  background: rgba(102, 126, 234, 0.2);
  color: var(--color-purple);
}

.audio-navigation .speed-control {
  font-size: 10px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}

.audio-navigation .subtitle-display {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  background: none;
  box-shadow: none;
  z-index: 1000;
  /* pointer-events: none; */
  display: flex;
  justify-content: center;
  align-items: center;
}

.audio-navigation .subtitle-text {
  display: inline-block;
  max-width: 95vw;
  min-width: 40px;
  padding: 10px 12px;
  font-size: 15px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  text-align: center;
  margin: 0 auto;
  word-break: break-all;
  white-space: nowrap;
  overflow-x: auto;
  transition: width 0.2s, max-width 0.2s, min-width 0.2s;
}

.audio-navigation .subtitle-text:empty {
  display: none;
}

.audio-navigation .subtitle-text.speaker-1 {
  color: #fff;
}
.audio-navigation .subtitle-text.speaker-2 {
  color: #a0d9f7;
}
.audio-navigation .subtitle-text.speaker-3 {
  color: #d6a0f7;
}
.audio-navigation .subtitle-text.speaker-4 {
  color: #bcf7a0;
}

/* 다크 모드 지원 */
@media (prefers-color-scheme: dark) {
  .audio-navigation {
    background: rgba(30, 30, 30, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
  }
  
  .audio-navigation .intro-text {
    color: rgba(255, 255, 255, 0.7);
  }
  
  .audio-navigation .time-display {
    color: rgba(255, 255, 255, 0.6);
  }
  
  .audio-navigation .control-button {
    color: rgba(255, 255, 255, 0.6);
  }
  
  .audio-navigation .control-button:hover {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.8);
  }
  
  .audio-navigation .control-button.active {
    background: rgba(102, 126, 234, 0.2);
  }
}

/* 모바일 반응형 */
@media (max-width: 768px) {
  .audio-navigation {
    width: calc(100vw - 32px);
    max-width: 300px;
    bottom: 1rem;
  }
  
  .audio-navigation:focus-within {
    width: calc(100vw - 32px);
    max-width: 300px;
  }
  
  .audio-navigation .controls {
    gap: 4px;
  }
  
  .audio-navigation .control-button {
    width: 20px;
    height: 20px;
    font-size: 10px;
  }
}

/* 접근성 개선 */
.audio-navigation:focus-visible {
  outline: 2px solid var(--color-purple);
  outline-offset: 2px;
}

.audio-navigation .play-button:focus-visible,
.audio-navigation .control-button:focus-visible {
  outline: 2px solid var(--color-purple);
  outline-offset: 2px;
}

/* 로딩 상태 */
.audio-navigation.loading .play-button {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* 오디오 없음 상태 */
.audio-navigation.no-audio {
  opacity: 0.5;
  pointer-events: none;
}

.audio-navigation.no-audio .play-button {
  background: rgba(0, 0, 0, 0.2);
  cursor: not-allowed;
}

.semantic-highlight {
  background: linear-gradient(90deg, rgba(255, 193, 7, 0.1) 0%, rgba(255, 152, 0, 0.1) 100%);
  
  transition: all 0.3s ease;
}

/* 키워드 하이라이트 스타일 */

.highlight {
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}


.keyword-highlight {
  /* 기본적으로는 배경색 없이 표시 */
  background: transparent;
  transition: background 0.3s ease;
}

.keyword-highlight.active {
  /* 활성화 시에만 배경색 적용 */
  background: linear-gradient(90deg, rgba(255, 235, 59, 0.6) 0%, rgba(255, 193, 7, 0.35) 100%) !important;
  border-radius: 0.2em;
}

.phrase-highlight {
  /* 기본적으로는 배경색 없이 표시 */
  background: transparent;
  transition: background 0.3s ease;
  cursor: pointer;
  border-bottom: 1px solid var(--color-purple);
  position: relative;
}

.phrase-highlight i {
  position: relative;
}

.phrase-highlight i::before {
  color: var(--color-purple);
  font-size: 0.65rem;
  vertical-align: super;
  width: 14px;
  height: 14px;
  line-height: 13px;
  text-align: center;
  display: inline-block;
  /* background: rgb(102 126 234 / 25%); */
  /* padding: 3px; */
  border-radius: 50%;
}


.phrase-highlight.active {
  /* 활성화 시에만 배경색 적용 */
  background: linear-gradient(90deg, rgba(33, 150, 243, 0.18) 0%, rgb(3, 169, 244, 0.22) 100%) !important;
}


/* 툴팁 스타일 */
.phrase-highlight[data-multiple-segments]:hover::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 1000;
  margin-bottom: 5px;
  pointer-events: none;
}

.phrase-highlight[data-multiple-segments]:hover::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #333;
  z-index: 1000;
  margin-bottom: -5px;
  pointer-events: none;
}

/* 재생 옵션 UI 스타일 */
.phrase-play-options {
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 12px;
  min-width: 200px;
  font-size: 14px;
  position: absolute;
  z-index: 1000;
}

.options-header {
  font-weight: 600;
  margin-bottom: 8px;
  color: #333;
  border-bottom: 1px solid #eee;
  padding-bottom: 6px;
}

.play-option, .play-all-option {
  display: block;
  width: 100%;
  padding: 8px 12px;
  margin: 4px 0;
  border: none;
  background: #f8f9fa;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s;
  font-size: 13px;
}

.play-option:hover, .play-all-option:hover {
  background: #e9ecef;
}

.play-all-option {
  background: #007bff;
  color: white;
  font-weight: 600;
  margin-top: 8px;
  border-top: 1px solid #eee;
  padding-top: 10px;
}

.play-all-option:hover {
  background: #0056b3;
}