/* ===== NexusPlayer Glassmorphism Theme ===== */
:root {
  --nx-primary: #7c3aed;
  --nx-primary-light: #a78bfa;
  --nx-primary-dark: #5b21b6;
  --nx-accent: #06b6d4;
  --nx-accent-light: #22d3ee;
  --nx-gradient: linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%);
  --nx-gradient-warm: linear-gradient(135deg, #f43f5e 0%, #7c3aed 50%, #06b6d4 100%);
  --nx-glass-bg: rgba(15, 10, 30, 0.75);
  --nx-glass-border: rgba(255, 255, 255, 0.08);
  --nx-glass-blur: 20px;
  --nx-text: #f1f5f9;
  --nx-text-muted: #94a3b8;
  --nx-radius: 12px;
  --nx-radius-sm: 8px;
  --nx-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --nx-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --nx-glow: 0 0 15px rgba(124, 58, 237, 0.3);
}

/* ===== Player Container ===== */
.nx-player {
  position: relative;
  width: 100%;
  max-width: 100%;
  background: #0a0a14;
  border-radius: var(--nx-radius);
  overflow: hidden;
  box-shadow: var(--nx-shadow);
  user-select: none;
  -webkit-user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.nx-player:focus-within {
  outline: 2px solid var(--nx-accent);
  outline-offset: 2px;
}

/* ===== Video Container ===== */
.nx-video-container {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: #000;
  overflow: hidden;
  cursor: pointer;
}

.nx-video-container video,
.nx-video-container iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: contain;
}

.nx-video-container > div:not(.nx-loading):not(.nx-play-overlay):not(.nx-subtitles-display) {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

/* ===== Loading Spinner ===== */
.nx-loading {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--nx-transition);
  z-index: 15;
}
.nx-loading.visible { opacity: 1; }

.nx-loading-spinner {
  width: 48px; height: 48px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--nx-accent);
  border-radius: 50%;
  animation: buffering 0.8s linear infinite;
}

/* ===== Play Overlay ===== */
.nx-play-overlay {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 80px; height: 80px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--nx-transition), transform var(--nx-transition);
  z-index: 10;
  filter: drop-shadow(0 0 20px rgba(124, 58, 237, 0.5));
}
.nx-play-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
.nx-play-overlay svg {
  width: 100%; height: 100%;
  transition: transform var(--nx-transition);
}
.nx-play-overlay:hover svg {
  transform: scale(1.12);
}

/* ===== Seek Indicators (±10s) ===== */
.nx-seek-indicator {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  z-index: 11;
  transition: opacity 0.15s ease;
}
.nx-seek-indicator svg {
  width: 48px; height: 48px;
  filter: drop-shadow(0 0 12px rgba(255,255,255,0.35));
}
.nx-seek-indicator span {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,0.6);
}
.nx-seek-left  { left: 15%; }
.nx-seek-right { right: 15%; }

.nx-seek-indicator.animate {
  animation: seekPulse 0.6s ease-out forwards;
}
@keyframes seekPulse {
  0%   { opacity: 0.95; transform: translateY(-50%) scale(1); }
  100% { opacity: 0;    transform: translateY(-50%) scale(1.4); }
}

/* ===== Controls Bar ===== */
.nx-controls {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 0 12px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7) 25%);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 20;
  pointer-events: none;
}

.nx-controls.visible,
.nx-player:hover .nx-controls,
.nx-player.nx-paused .nx-controls {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Always show controls when paused */
.nx-player.nx-paused .nx-controls {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ===== Progress Bar ===== */
.nx-progress-wrap {
  position: relative;
  width: 100%;
  height: 20px;
  display: flex;
  align-items: center;
  cursor: pointer;
  margin-bottom: 4px;
}

.nx-progress-bg {
  position: absolute;
  left: 0; right: 0;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.15);
  transition: height 0.15s ease;
  z-index: 1;
}

.nx-progress-buffer {
  position: absolute;
  left: 0;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.2);
  transition: width 0.3s ease, height 0.15s ease;
  pointer-events: none;
  z-index: 2;
}

.nx-progress-fill {
  position: absolute;
  left: 0;
  height: 4px;
  border-radius: 2px;
  background: var(--nx-gradient);
  transition: height 0.15s ease;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(124, 58, 237, 0.4);
  z-index: 3;
}

.nx-progress-hover {
  position: absolute;
  left: 0;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.08);
  transition: height 0.15s ease;
  pointer-events: none;
  z-index: 2;
}

.nx-progress-handle {
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--nx-accent);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.5);
  transform: translate(-50%, 0) scale(0);
  transition: transform 0.15s ease;
  pointer-events: none;
  z-index: 5;
  top: 50%;
  margin-top: -7px;
}

.nx-progress-wrap:hover .nx-progress-bg,
.nx-progress-wrap:hover .nx-progress-buffer,
.nx-progress-wrap:hover .nx-progress-fill,
.nx-progress-wrap:hover .nx-progress-hover {
  height: 6px;
}
.nx-progress-wrap:hover .nx-progress-handle {
  transform: translate(-50%, 0) scale(1);
}

/* ===== Tooltip ===== */
.nx-tooltip {
  position: absolute;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 4px 10px;
  background: var(--nx-glass-bg);
  backdrop-filter: blur(var(--nx-glass-blur));
  -webkit-backdrop-filter: blur(var(--nx-glass-blur));
  border: 1px solid var(--nx-glass-border);
  border-radius: var(--nx-radius-sm);
  color: var(--nx-text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 30;
}
.nx-tooltip.visible { opacity: 1; }

/* ===== Button Row ===== */
.nx-controls-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nx-controls-left,
.nx-controls-center,
.nx-controls-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nx-controls-left { flex: 1; min-width: 0; }
.nx-controls-center { flex: 0 0 auto; justify-content: center; }
.nx-controls-right { flex: 0 0 auto; justify-content: flex-end; }

/* ===== Buttons ===== */
.nx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: none;
  border: none;
  color: var(--nx-text);
  cursor: pointer;
  border-radius: var(--nx-radius-sm);
  transition: all var(--nx-transition);
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  flex-shrink: 0;
}

.nx-btn:hover {
  color: var(--nx-accent-light);
  background: rgba(255,255,255,0.08);
}

.nx-btn:active {
  transform: scale(0.9);
}

.nx-btn:focus-visible {
  outline: 2px solid var(--nx-accent);
  outline-offset: 1px;
}

.nx-btn svg {
  width: 22px; height: 22px;
  flex-shrink: 0;
}

.nx-btn-play {
  width: 40px; height: 40px;
}
.nx-btn-play svg {
  width: 26px; height: 26px;
}

.nx-btn.active {
  color: var(--nx-accent);
}

.nx-icon-morph {
  animation: iconMorph 0.3s ease;
}

/* ===== Time Display ===== */
.nx-time-display {
  color: var(--nx-text-muted);
  font-size: 13px;
  font-weight: 500;
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ===== Volume ===== */
.nx-volume-wrap {
  display: flex;
  align-items: center;
  position: relative;
}

.nx-volume-slider {
  width: 0;
  overflow: hidden;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
}

.nx-volume-wrap:hover .nx-volume-slider,
.nx-volume-slider.active {
  width: 80px;
}

.nx-volume-track {
  position: relative;
  width: 70px;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin: 0 6px;
  cursor: pointer;
  flex-shrink: 0;
}

.nx-volume-fill {
  position: absolute;
  left: 0; top: 0;
  height: 100%;
  border-radius: 2px;
  background: var(--nx-gradient);
  pointer-events: none;
}

.nx-volume-handle {
  position: absolute;
  top: 50%;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px rgba(0,0,0,0.3);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.15s ease;
  pointer-events: none;
}
.nx-volume-wrap:hover .nx-volume-handle {
  transform: translate(-50%, -50%) scale(1);
}

/* ===== Speed Menu ===== */
.nx-speed-wrap {
  position: relative;
}

.nx-speed-btn {
  width: auto;
  padding: 0 6px;
  gap: 2px;
  font-size: 0;
}

.nx-speed-label {
  font-size: 11px;
  font-weight: 700;
}

.nx-speed-menu {
  position: absolute;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: var(--nx-glass-bg);
  backdrop-filter: blur(var(--nx-glass-blur));
  -webkit-backdrop-filter: blur(var(--nx-glass-blur));
  border: 1px solid var(--nx-glass-border);
  border-radius: var(--nx-radius);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 40;
  box-shadow: var(--nx-shadow);
  min-width: 80px;
}

.nx-speed-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
}

.nx-speed-item {
  background: none;
  border: none;
  color: var(--nx-text-muted);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: all var(--nx-transition);
  font-family: inherit;
}

.nx-speed-item:hover {
  background: rgba(255,255,255,0.08);
  color: var(--nx-text);
}

.nx-speed-item.active {
  color: var(--nx-accent);
  font-weight: 700;
  background: rgba(6, 182, 212, 0.1);
}

/* ===== Subtitles Display ===== */
.nx-subtitles-display {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  z-index: 18;
  max-width: 80%;
  display: none;
}

.nx-subtitle-cue {
  display: inline-block;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: clamp(14px, 2.5vw, 20px);
  font-weight: 500;
  line-height: 1.5;
  padding: 4px 12px;
  border-radius: 6px;
  margin: 2px 0;
}

/* ===== Thumbnail Preview ===== */
.nx-thumbnail-preview {
  position: absolute;
  bottom: 28px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 25;
}

.nx-thumbnail-preview.visible {
  opacity: 1;
}

.nx-thumbnail-canvas {
  width: 160px;
  height: 90px;
  border-radius: 6px;
  border: 2px solid rgba(255,255,255,0.15);
  background: #000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.nx-thumbnail-time {
  margin-top: 4px;
  padding: 2px 8px;
  background: var(--nx-glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--nx-glass-border);
  border-radius: 4px;
  color: var(--nx-text);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ===== Playlist Panel ===== */
.nx-playlist-panel {
  position: absolute;
  top: 0; right: 0;
  width: 320px;
  height: 100%;
  background: var(--nx-glass-bg);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-left: 1px solid var(--nx-glass-border);
  display: flex;
  flex-direction: column;
  z-index: 25;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.nx-playlist-panel.open {
  transform: translateX(0);
}

.nx-playlist-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--nx-glass-border);
  gap: 10px;
}

.nx-playlist-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--nx-text);
  margin: 0;
  flex: 1;
}

.nx-playlist-count {
  font-size: 12px;
  color: var(--nx-text-muted);
  font-weight: 500;
}

.nx-playlist-close {
  background: none;
  border: none;
  color: var(--nx-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  transition: all var(--nx-transition);
}
.nx-playlist-close:hover {
  color: var(--nx-text);
  background: rgba(255,255,255,0.08);
}
.nx-playlist-close svg { width: 18px; height: 18px; }

.nx-playlist-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.nx-playlist-list::-webkit-scrollbar { width: 6px; }
.nx-playlist-list::-webkit-scrollbar-track { background: transparent; }
.nx-playlist-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
}

.nx-playlist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--nx-radius-sm);
  cursor: pointer;
  transition: background var(--nx-transition);
  border: 1px solid transparent;
}
.nx-playlist-item:hover {
  background: rgba(255,255,255,0.06);
}
.nx-playlist-item.active {
  background: rgba(124, 58, 237, 0.15);
  border-color: rgba(124, 58, 237, 0.3);
}

.nx-playlist-thumb {
  width: 80px;
  height: 45px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nx-playlist-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.nx-playlist-thumb svg {
  width: 24px; height: 24px;
  color: var(--nx-text-muted);
}

.nx-playlist-info {
  flex: 1;
  min-width: 0;
}

.nx-playlist-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--nx-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}

.nx-playlist-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.nx-playlist-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--nx-gradient);
  color: #fff;
  letter-spacing: 0.5px;
}

.nx-playlist-duration {
  font-size: 11px;
  color: var(--nx-text-muted);
}

/* ===== Fullscreen ===== */
.nx-player.nx-fullscreen,
.nx-player:fullscreen,
.nx-player:-webkit-full-screen {
  max-width: none;
  border-radius: 0;
}

.nx-player.nx-fullscreen .nx-video-container,
.nx-player:fullscreen .nx-video-container,
.nx-player:-webkit-full-screen .nx-video-container {
  padding-top: 0;
  width: 100vw;
  height: 100vh;
}

.nx-player.nx-fullscreen .nx-playlist-panel,
.nx-player:fullscreen .nx-playlist-panel,
.nx-player:-webkit-full-screen .nx-playlist-panel {
  height: 100vh;
}

/* ===== Theater Mode ===== */
.nx-body-theater {
  overflow: hidden;
}

.nx-mode-theater .nx-video-container {
  padding-top: 0;
  height: 70vh;
}

/* ===== Cinema Mode ===== */
.nx-body-cinema {
  overflow: hidden;
}

.nx-cinema-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.nx-cinema-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.nx-mode-cinema {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  width: 90vw;
  max-width: 1200px;
  border-radius: var(--nx-radius);
  box-shadow: 0 0 60px rgba(124, 58, 237, 0.3), var(--nx-shadow);
  border: 1px solid var(--nx-glass-border);
}

.nx-mode-cinema .nx-video-container {
  padding-top: 0;
  height: 75vh;
}

/* ===== Buffering State ===== */
.nx-buffering .nx-loading { opacity: 1; }

/* ===== Responsive: Tablet ===== */
@media (max-width: 768px) {
  .nx-controls {
    padding: 0 8px 8px;
  }

  .nx-btn {
    width: 32px; height: 32px;
  }
  .nx-btn svg { width: 20px; height: 20px; }
  .nx-btn-play {
    width: 36px; height: 36px;
  }
  .nx-btn-play svg { width: 24px; height: 24px; }

  .nx-time-display { font-size: 11px; margin-left: 2px; }

  .nx-volume-wrap:hover .nx-volume-slider { width: 60px; }
  .nx-volume-track { width: 50px; }

  .nx-progress-handle { width: 12px; height: 12px; margin-top: -6px; }

  .nx-playlist-panel { width: 280px; }

  .nx-subtitle-cue { font-size: clamp(12px, 3vw, 16px); }
  .nx-subtitles-display { bottom: 50px; }

  .nx-thumbnail-canvas { width: 120px; height: 68px; }

  .nx-mode-cinema { width: 95vw; }
  .nx-mode-cinema .nx-video-container { height: 60vh; }
}

/* ===== Responsive: Mobile ===== */
@media (max-width: 480px) {
  .nx-controls-left .nx-btn-icon:not(.nx-btn-play),
  .nx-controls-center .nx-btn-icon:not(.nx-btn-play) {
    width: 28px; height: 28px;
  }
  .nx-controls-left .nx-btn-icon:not(.nx-btn-play) svg,
  .nx-controls-center .nx-btn-icon:not(.nx-btn-play) svg {
    width: 18px; height: 18px;
  }

  .nx-playlist-panel { width: 100%; }

  .nx-btn-play {
    width: 34px; height: 34px;
  }
  .nx-btn-play svg { width: 22px; height: 22px; }

  .nx-mode-cinema .nx-video-container { height: 50vh; }
}

/* ===== Responsive: Large screens ===== */
@media (min-width: 1200px) {
  .nx-player {
    border-radius: 16px;
  }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Print ===== */
@media print {
  .nx-controls, .nx-playlist-panel, .nx-loading { display: none !important; }
}
