/* ========================================================================== */
/* Media Player Styles                                                        */
/* ========================================================================== */

/* ---- Shared progress bar ---- */

.media-player-progress {
  width: 100%;
  cursor: pointer;
  padding: 6px 0;
  position: relative;
}

.media-player-progress:focus {
  outline: 2px solid rgba(99, 102, 241, 0.5);
  outline-offset: 2px;
  border-radius: 2px;
}

.media-player-progress-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
  transition: height 0.15s ease;
}

.media-player-progress:hover .media-player-progress-bar {
  height: 6px;
}

.media-player-progress-buffered {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.media-player-progress-filled {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: #6366f1;
  border-radius: 2px;
}

/* ---- Shared time text ---- */

.media-player-time {
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  gap: 4px;
  user-select: none;
}

/* ---- Shared volume slider ---- */

.media-player-volume-slider {
  width: 60px;
  height: 4px;
  appearance: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.media-player-volume-slider::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  cursor: pointer;
}

.media-player-volume-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

/* ---- Shared error state ---- */

.media-player-error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
}

.media-player-error-text {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
}

/* ========================================================================== */
/* Audio Player                                                               */
/* ========================================================================== */

.media-player-audio {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px;
  user-select: none;
}

.media-player-audio-play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.media-player-audio-play-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.media-player-audio-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.media-player-audio-filename {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-player-audio-controls {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.media-player-audio-controls .media-player-time {
  justify-content: space-between;
  padding: 0 2px;
}

.media-player-audio-volume {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.media-player-audio-volume-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  color: inherit;
  line-height: 1;
}

/* ========================================================================== */
/* Video Player                                                               */
/* ========================================================================== */

.media-player-video {
  position: relative;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  user-select: none;
}

.media-player-video video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.media-player-video-overlay {
  position: absolute;
  inset: 0;
  cursor: pointer;
  z-index: 1;
}

.media-player-video-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  padding: 24px 12px 8px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.media-player-video:hover .media-player-video-controls,
.media-player-video-controls-visible .media-player-video-controls {
  opacity: 1;
  pointer-events: auto;
}

.media-player-video-progress-row {
  margin-bottom: 6px;
}

.media-player-video-controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.media-player-video-btn {
  background: none;
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.media-player-video-btn:hover {
  opacity: 0.8;
}

.media-player-video-fullscreen-btn {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.media-player-video-fullscreen-btn:hover {
  opacity: 0.8;
}

.media-player-video-filename {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

.media-player-video-controls-spacer {
  flex: 1;
}

.media-player-video-error-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  width: 100%;
}

/* ---- Fullscreen adjustments ---- */

.media-player-video:fullscreen {
  border-radius: 0;
}

.media-player-video:-webkit-full-screen {
  border-radius: 0;
}

.media-player-video:fullscreen video {
  height: 100vh;
}

.media-player-video:-webkit-full-screen video {
  height: 100vh;
}

/* ========================================================================== */
/* Light Theme                                                                */
/* ========================================================================== */

[data-theme="light"] .media-player-audio {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .media-player-audio-play-btn {
  background: rgba(0, 0, 0, 0.08);
  color: #334155;
}

[data-theme="light"] .media-player-audio-play-btn:hover {
  background: rgba(0, 0, 0, 0.14);
}

[data-theme="light"] .media-player-audio-filename {
  color: rgba(0, 0, 0, 0.6);
}

[data-theme="light"] .media-player-time {
  color: rgba(0, 0, 0, 0.45);
}

[data-theme="light"] .media-player-progress-bar {
  background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .media-player-progress-buffered {
  background: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .media-player-progress-filled {
  background: #6366f1;
}

[data-theme="light"] .media-player-volume-slider {
  background: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .media-player-volume-slider::-webkit-slider-thumb {
  background: #334155;
}

[data-theme="light"] .media-player-volume-slider::-moz-range-thumb {
  background: #334155;
}

[data-theme="light"] .media-player-audio-volume-btn {
  color: #334155;
}

[data-theme="light"] .media-player-error-text {
  color: rgba(0, 0, 0, 0.45);
}

/* ========================================================================== */
/* Playback Rate Selector                                                     */
/* ========================================================================== */

.media-player-rate-selector {
  position: relative;
  flex-shrink: 0;
}

.media-player-rate-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.8);
  font-size: 11px;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1;
  white-space: nowrap;
}

.media-player-rate-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.35);
}

.media-player-rate-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: rgba(30, 30, 30, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 4px;
  min-width: 100px;
  z-index: 10;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.media-player-rate-option {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}

.media-player-rate-option:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.media-player-rate-option-active {
  color: #6366f1;
  font-weight: 600;
}

.media-player-rate-option-active:hover {
  color: #818cf8;
}

/* Light theme rate selector */
[data-theme="light"] .media-player-rate-btn {
  color: rgba(0, 0, 0, 0.65);
  border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .media-player-rate-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .media-player-rate-menu {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .media-player-rate-option {
  color: rgba(0, 0, 0, 0.65);
}

[data-theme="light"] .media-player-rate-option:hover {
  background: rgba(0, 0, 0, 0.05);
  color: rgba(0, 0, 0, 0.9);
}

[data-theme="light"] .media-player-rate-option-active {
  color: #6366f1;
}

/* ========================================================================== */
/* Progress Bar Drag State                                                    */
/* ========================================================================== */

.media-player-progress-dragging {
  cursor: grabbing;
}

.media-player-progress-dragging .media-player-progress-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
}

.media-player-progress-dragging .media-player-progress-filled {
  background: #818cf8;
}

[data-theme="light"] .media-player-progress-dragging .media-player-progress-bar {
  background: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .media-player-progress-dragging .media-player-progress-filled {
  background: #818cf8;
}

/* Drag tooltip */
.media-player-progress-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: rgba(30, 30, 30, 0.95);
  color: white;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .media-player-progress-tooltip {
  background: rgba(30, 30, 30, 0.9);
  color: white;
}

/* ========================================================================== */
/* Audio Player Extra Controls Row                                            */
/* ========================================================================== */

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

/* ========================================================================== */
/* Keyboard Help Panel                                                        */
/* ========================================================================== */

.keyboard-help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.keyboard-help-panel {
  background: rgba(30, 30, 35, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 0;
  min-width: 380px;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  color: rgba(255, 255, 255, 0.85);
}

[data-theme="light"] .keyboard-help-panel {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
  color: rgba(0, 0, 0, 0.8);
}

.keyboard-help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.keyboard-help-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.keyboard-help-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s;
}

.keyboard-help-close-btn:hover {
  color: rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .keyboard-help-close-btn {
  color: rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .keyboard-help-close-btn:hover {
  color: rgba(0, 0, 0, 0.8);
}

.keyboard-help-body {
  padding: 12px 20px;
}

.keyboard-help-group {
  margin-bottom: 16px;
}

.keyboard-help-group:last-child {
  margin-bottom: 0;
}

.keyboard-help-group-title {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.4);
}

[data-theme="light"] .keyboard-help-group-title {
  color: rgba(0, 0, 0, 0.35);
}

.keyboard-help-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.keyboard-help-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.keyboard-help-key {
  display: inline-block;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 12px;
  min-width: 36px;
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
}

[data-theme="light"] .keyboard-help-key {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
  color: rgba(0, 0, 0, 0.7);
}

.keyboard-help-desc {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
}

[data-theme="light"] .keyboard-help-desc {
  color: rgba(0, 0, 0, 0.55);
}

.keyboard-help-footer {
  padding: 10px 20px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}

.keyboard-help-hint {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
}

.keyboard-help-hint kbd {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 10px;
}

[data-theme="light"] .keyboard-help-footer {
  border-top-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .keyboard-help-hint {
  color: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .keyboard-help-hint kbd {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.08);
}
