/* 基本スタイル */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: #000;
  color: #fff;
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
}

.fullscreen-app {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* ヘッダーコントロール */
.header-controls {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

body:not(:hover) .header-controls {
  transform: translateY(-100%);
  opacity: 0;
}

.left-controls,
.right-controls {
  display: flex;
  align-items: center;
  gap: 12px; /* 要素間のスペースを追加 */
}

.center-controls {
  display: flex;
  justify-content: center;
  align-items: center; /* 要素を垂直方向中央揃えに追加 */
  flex-grow: 1;
  gap: 16px; /* モードトグルと音声選択の間のスペース */
}

.exit-fullscreen {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
  transition: background 0.2s ease;
}

.exit-fullscreen:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* モードトグル */
.mode-toggle {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 24px;
  overflow: hidden;
  padding: 4px;
}

.mode-option {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 20px;
}

.mode-option.active {
  background: #1976d2;
  color: white;
}

/* 音量コントロール */
.volume-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 音声読み上げ切り替えボタン */
.voice-playback-toggle {
  display: flex;
  align-items: center;
}

.voice-playback-checkbox {
  display: none;
}

.voice-playback-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 0.2s ease;
  color: white;
}

.voice-playback-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.voice-playback-checkbox:checked + .voice-playback-button {
  background: #1976d2;
  color: white;
}

.voice-playback-checkbox:not(:checked) + .voice-playback-button {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.5);
}

.voice-playback-button .material-icons {
  font-size: 20px;
}

/* 字幕エリア */
.subtitle-container {
  display: flex;
  flex-direction: column;
  justify-content: center; /* flex-end から center に変更 */
  align-items: center;
  width: 100%;
  height: 100%;
  padding-bottom: 0; /* 100px から 0 に変更、または削除 */
}

.caption-area {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* 音声波形 */
.audio-waveform {
  width: 80px; /* ヘッダー用に幅を調整 */
  height: 16px; /* ヘッダー用に高さを調整 */
  margin-bottom: 0; /* ヘッダー内なのでマージンボトムは不要 */
}

.waveform-container {
  width: 100%;
  height: 100%; /* 親要素の高さに合わせる */
  background: rgba(255, 255, 255, 0.1); /* 背景を少し明るく */
  border-radius: 3px; /* 角丸を調整 */
  overflow: hidden;
}

.waveform-visualizer {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, #66bb6a, #ffee58, #ef5350); /* 少し落ち着いた色合いに */
  transition: width 0.1s ease;
  border-radius: 3px; /* 角丸を調整 */
}

/* 字幕テキスト */
.caption {
  margin-bottom: 16px;
}

.caption-label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 4px;
}

.caption-text {
  font-size: 24px;
  line-height: 1.4;
  padding: 8px 0;
  word-wrap: break-word;
  overflow-y: auto;
  scroll-behavior: smooth;
  white-space: pre-wrap; /* 連続する空白を保持するように変更 */
}

/* 字幕色分け */
.original .caption-text {
  color: #ffffff;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
  max-height: 180px; /* originalの高さを180pxに設定 */
}

.translation .caption-text {
  color: #00d1ff;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
  max-height: 175px; /* translationの高さを175pxに設定 */
}

/* フローティングコントロール */
.floating-controls {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
}

.control-panel {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  border-radius: 30px;
  padding: 6px 10px; /* パディングを少し調整 */
  gap: 8px; /* 要素間のギャップを少し調整 */
}

.status-indicator {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
}

.control-button {
  background: #1976d2;
  border: none;
  border-radius: 20px;
  color: white;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.control-button:hover {
  background: #1565c0;
}

.control-button.recording {
  background: #d32f2f;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(211, 47, 47, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(211, 47, 47, 0);
  }
}

.settings-button {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.settings-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ヘッダー内音声選択コントロール */
.header-voice-selector {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-inline-label {
  font-size: 13px; /* フォントサイズ調整 */
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
}

.header-inline-select {
  background: rgba(0, 0, 0, 0.3); /* mode-toggle と同様の背景 */
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px; /* mode-option と同様の角丸 */
  padding: 6px 10px; /* パディング調整 */
  font-size: 13px; /* フォントサイズ調整 */
  -webkit-appearance: none; /* Safari/Chromeでのデフォルトスタイル解除 */
  -moz-appearance: none; /* Firefoxでのデフォルトスタイル解除 */
  appearance: none;
  background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 8px 8px;
  padding-right: 24px; /* アイコンのためのスペース */
}

.header-inline-select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.5);
}


/* インライン設定コントロール */
.inline-settings-controls {
  display: flex;
  align-items: center;
  gap: 10px; /* 各設定グループ間のギャップ */
}

.inline-setting {
  display: flex;
  align-items: center;
  gap: 4px; /* ラベルとセレクト間のギャップ */
}

.inline-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
}

.inline-select {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 12px;
  max-width: 120px; /* セレクトボックスの最大幅 */
}

.inline-select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.5);
}


/* 設定モーダル */
.settings-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000; /* z-indexを高く設定 */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.settings-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.settings-content {
  background: #1f1f1f;
  width: 90%;
  max-width: 500px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 85vh; /* 80vhから85vhに変更し、表示領域を少し拡大 */
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px; /* パディングを少し削減 (元は16px 20px) */
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0; /* ヘッダーが縮まないように */
}

.settings-header h3 {
  font-size: 18px;
  font-weight: 500;
  margin: 0;
}

.close-button {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.close-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.settings-body {
  padding: 18px; /* パディングを少し削減 (元は20px) */
  max-height: calc(85vh - 110px); /* 親の高さからヘッダーとフッターのおおよその高さを引いた値に調整 (元は60vh) */
  overflow-y: auto;
  flex-grow: 1;
}

.setting-group {
  margin-bottom: 16px; /* マージンを少し削減 (元は20px) */
}

.setting-group label {
  display: block;
  margin-bottom: 6px; /* マージンを少し削減 (元は8px) */
  color: rgba(255, 255, 255, 0.8);
}

.source-select,
.voice-select {
  width: 100%;
  padding: 9px; /* パディングを少し削減 (元は10px) */
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 14px;
  margin-bottom: 8px; /* マージンを少し削減 (元は10px) */
}

.vad-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px; /* 要素間のギャップを少し削減 (元は10px) */
  padding: 8px; /* パディングを少し削減 (元は10px) */
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  margin-top: 8px;
}

.vad-panel label {
  display: flex;
  align-items: center;
  margin-bottom: 0;
}

.vad-panel input {
  width: 70px;
  padding: 5px; /* パディングを少し削減 (元は6px) */
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  margin-left: 8px;
}

.settings-footer {
  padding: 14px 18px; /* パディングを少し削減 (元は16px 20px) */
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: right;
}

.apply-button {
  background: #1976d2;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.apply-button:hover {
  background: #1565c0;
}

/* スマホ用コントロール */
.mobile-controls {
  display: none;
}

/* 横向きレイアウト (サイド-バイ-サイド) */
@media (orientation: landscape) and (min-width: 1024px) {
  .caption-area {
    display: flex;
    flex-direction: column;
  }

  .captions-row {
    display: flex;
    gap: 20px;
  }

  .original,
  .translation {
    flex: 1;
  }
}

/* タブレット表示調整 */
@media (max-width: 1023px) {
  .caption-text {
    font-size: 20px;
  }
}

/* モバイル表示 */
@media (max-width: 767px) {
  .caption-text {
    font-size: 18px;
  }

  .mobile-controls {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 110;
  }

  /* モバイルではインライン設定を非表示 */
  .inline-settings-controls {
    display: none;
  }

  .mobile-toggle-button {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 24px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 12px 12px 0 0;
    cursor: pointer;
  }

  .mobile-panel {
    background: rgba(0, 0, 0, 0.8);
    padding: 16px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
  }

  .mobile-panel.active {
    transform: translateY(0);
  }

  .mobile-settings {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .subtitle-container {
    padding-bottom: 60px; /* モバイルでは下部コントロールがあるため維持、または調整 */
  }
}

/* ダークモード用特別調整 */
@media (prefers-color-scheme: dark) {
  .settings-modal {
    background: rgba(0, 0, 0, 0.9);
  }

  .settings-content {
    background: #121212;
  }
}

/* プッシュトゥートーク説明（全画面モード・洗練されたUI） */
.ptt-instructions-elegant-fullscreen {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(100, 181, 246, 0.3);
  border-radius: 8px;
  backdrop-filter: blur(15px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  max-width: 400px;
  width: auto;
  opacity: 1;
  animation: pttSlideInFullscreen 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ptt-instructions-elegant-fullscreen.fade-out {
  opacity: 0;
  transform: translate(-50%, -15px) scale(0.95);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.ptt-instructions-elegant-fullscreen:hover {
  border-color: rgba(100, 181, 246, 0.5);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

@keyframes pttSlideInFullscreen {
  0% {
    opacity: 0;
    transform: translate(-50%, -25px) scale(0.9);
    filter: blur(5px);
  }
  50% {
    opacity: 0.8;
    transform: translate(-50%, -5px) scale(1.02);
    filter: blur(1px);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
    filter: blur(0);
  }
}

@keyframes pttPulseGlow {
  0%, 100% {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(100, 181, 246, 0);
  }
  50% {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 0 20px 5px rgba(100, 181, 246, 0.2);
  }
}

.ptt-instructions-elegant-fullscreen .ptt-elegant-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.ptt-instructions-elegant-fullscreen .ptt-elegant-label {
  font-size: 13px;
  color: #b3e5fc;
  font-weight: 500;
  letter-spacing: 0.4px;
  opacity: 0.9;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.ptt-instructions-elegant-fullscreen .ptt-elegant-keys {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.ptt-instructions-elegant-fullscreen .ptt-key-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #e1f5fe;
  font-weight: 400;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.ptt-instructions-elegant-fullscreen .ptt-key-item kbd {
  background: linear-gradient(135deg, #1976d2, #1565c0);
  color: white;
  padding: 3px 7px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  border: none;
  min-width: 18px;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  transition: all 0.2s ease;
}

.ptt-instructions-elegant-fullscreen .ptt-key-item:hover kbd {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
}

/* レスポンシブ対応（全画面モード） */
@media (max-width: 768px) {
  .ptt-instructions-elegant-fullscreen {
    padding: 10px 16px;
    top: 80px;
    max-width: 350px;
    width: 90%;
  }
  
  .ptt-instructions-elegant-fullscreen .ptt-elegant-label {
    font-size: 12px;
  }
  
  .ptt-instructions-elegant-fullscreen .ptt-elegant-keys {
    gap: 12px;
  }
  
  .ptt-instructions-elegant-fullscreen .ptt-key-item {
    font-size: 11px;
  }
  
  .ptt-instructions-elegant-fullscreen .ptt-key-item kbd {
    padding: 2px 5px;
    font-size: 10px;
  }
}
