/**
 * VidFlow Player Styles
 */

.vidflow-player-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin-left: auto;
  margin-right: auto;
  /* Before JS applies viewport-constrained sizing from token displayWidth/Height */
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.vidflow-player-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

/* Loading State */
.vidflow-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
  color: #fff;
  z-index: 10;
}

.vidflow-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: vidflow-spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

@keyframes vidflow-spin {
  to {
    transform: rotate(360deg);
  }
}

.vidflow-loading p {
  margin: 0;
  font-size: 14px;
  color: #9ca3af;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell,
    'Helvetica Neue', sans-serif;
}

/* Error State */
.vidflow-error {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a0a0a;
  color: #fecaca;
  z-index: 20;
  padding: 2rem;
  text-align: center;
}

.vidflow-error .vidflow-error-icon {
  width: 64px;
  height: 64px;
  stroke: #ef4444;
  margin-bottom: 1rem;
}

.vidflow-error p {
  margin: 0 0 1rem 0;
  font-size: 14px;
  line-height: 1.6;
}

.vidflow-error .vidflow-retry-btn {
  display: inline-block;
  padding: 0.625rem 1.25rem;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}

.vidflow-error .vidflow-retry-btn:hover {
  background: #2563eb;
}

.vidflow-error .vidflow-retry-btn:active {
  transform: translateY(1px);
}

/* Player Container */
.vidflow-player {
  width: 100%;
  height: 100%;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .vidflow-loading .vidflow-spinner {
    width: 40px;
    height: 40px;
    border-width: 3px;
  }

  .vidflow-loading p {
    font-size: 12px;
  }

  .vidflow-error {
    padding: 1.5rem;
  }

  .vidflow-error .vidflow-error-icon {
    width: 48px;
    height: 48px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .vidflow-player-container {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  }
}

/* Accessibility */
.vidflow-player-container:focus-within {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.vidflow-player-container[tabindex='0']:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Print styles */
@media print {
  .vidflow-player-container {
    border: 1px solid #000;
  }

  .vidflow-loading,
  .vidflow-error {
    display: none;
  }
}

/**
 * Watermark layers (v1.4.0)
 *
 * Defense-in-depth baseline (§9.4 of WATERMARK_DISPLAY_MODES_PROPOSAL.md).
 * The inline `!important` rules applied by the JS still take precedence, but
 * this stylesheet also forces pointer-events off and never matches the
 * `.vf-wm-*` (random class-name suffix) selectors, so attackers cannot
 * pre-empt the watermark with a generic `[class*="watermark"]` selector.
 */
.vidflow-player-wrapper [data-watermark] {
  pointer-events: none !important;
  -webkit-user-select: none;
  user-select: none;
}

.vidflow-player-wrapper [data-watermark] * {
  pointer-events: none !important;
}

/* Reduced-motion users get a fully static watermark (also handled in JS). */
@media (prefers-reduced-motion: reduce) {
  .vidflow-player-wrapper [data-watermark],
  .vidflow-player-wrapper [data-watermark] * {
    animation: none !important;
    transition: none !important;
  }
}

/* Safari/older browsers fallback when `offset-path` is unavailable —
   orbiter degrades to a slower (still looping) translate via the same animName. */
@supports not (offset-path: rect(0% 0% 0% 0%)) {
  .vidflow-player-wrapper [data-wm-mode='orbiter'] {
    will-change: left, top;
  }
}

/* ==========================================================================
 * v2.1.0 — Custom control bar (port web app vidflow.bluez.vn)
 * Native controls tắt (iOS giữ native) — watermark luôn hiện khi fullscreen
 * vì fullscreen target .vidflow-player-wrapper.
 * ========================================================================== */


/* --------------------------------------------------------------------------
 * Theme-isolation reset — WordPress themes/plugins đè style lên button
 * (MasterStudy/Woo theme hay có `button[type=...]` specificity > .vfc-btn).
 * Reset kiểu embed-widget: specificity 3 lớp + !important cho thuộc tính
 * nhận diện. Giữ hover/focus/active của riêng player.
 * -------------------------------------------------------------------------- */
.vidflow-player-wrapper .vfc-root button.vfc-btn,
.vidflow-player-wrapper .vfc-root button.vfc-center-play {
  appearance: none !important;
  -webkit-appearance: none !important;
  background: transparent !important;
  border: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
  text-shadow: none !important;
  color: rgba(255, 255, 255, 0.92) !important;
  line-height: 1 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  font-family: inherit !important;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease !important;
}
.vidflow-player-wrapper .vfc-root button.vfc-btn:hover,
.vidflow-player-wrapper .vfc-root button.vfc-btn:focus-visible {
  background: rgba(255, 255, 255, 0.16) !important;
  color: #fff !important;
}
.vidflow-player-wrapper .vfc-root button.vfc-btn:active {
  background: rgba(255, 255, 255, 0.24) !important;
  transform: scale(0.94);
}
.vidflow-player-wrapper .vfc-root button.vfc-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.45) !important;
  outline-offset: 1px;
}
.vidflow-player-wrapper .vfc-root button.vfc-center-play {
  background: rgba(15, 15, 15, 0.62) !important;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff !important;
}
.vidflow-player-wrapper .vfc-root button.vfc-center-play:hover {
  background: rgba(15, 15, 15, 0.78) !important;
  transform: scale(1.06);
}
/* Icon svg + số "10" của nút ±10s luôn trắng, không bị theme nhuộm */
.vidflow-player-wrapper .vfc-root .vfc-btn svg,
.vidflow-player-wrapper .vfc-root .vfc-center-play svg {
  fill: currentColor;
  stroke: currentColor;
  color: inherit !important;
  pointer-events: none;
}
.vidflow-player-wrapper .vfc-root .vfc-skipnum {
  color: #fff !important;
  background: transparent !important;
}
/* Range inputs (seek + volume) — theme không được chạm vào */
.vidflow-player-wrapper .vfc-root input[type='range'] {
  appearance: none !important;
  -webkit-appearance: none !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  margin: 0 !important;
}
.vidflow-player-wrapper .vfc-root .vfc-volgroup input[type='range'] {
  background: rgba(255, 255, 255, 0.25) !important;
  border-radius: 99px !important;
}
.vidflow-player-wrapper .vfc-root input[type='range']::-webkit-slider-thumb {
  appearance: none !important;
  -webkit-appearance: none !important;
  border: none !important;
}
.vidflow-player-wrapper .vfc-root input[type='range']::-moz-range-thumb {
  border: none !important;
}
/* Panel menu + time: nền tối đồng nhất, không bị theme đổ màu */
.vidflow-player-wrapper .vfc-root .vfc-menu {
  background: rgba(18, 18, 20, 0.95) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.vidflow-player-wrapper .vfc-root .vfc-menu-item {
  color: rgba(255, 255, 255, 0.88) !important;
}
.vidflow-player-wrapper .vfc-root .vfc-menu-item.vfc-active {
  color: #4da3ff !important;
}
.vidflow-player-wrapper .vfc-root .vfc-time,
.vidflow-player-wrapper .vfc-root .vfc-time .vfc-dur {
  color: #fff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.vfc-root {
  position: absolute;
  inset: 0;
  z-index: 20;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.vfc-root.vfc-hidden .vfc-bottom,
.vfc-root.vfc-hidden .vfc-center {
  opacity: 0;
  pointer-events: none !important;
}
.vfc-surface {
  position: absolute;
  inset: 0;
  cursor: pointer;
  /* iOS: chặn double-tap zoom + text-selection/callout khi long-press (2×) */
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* Center: big play + spinner */
.vfc-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  pointer-events: none;
}
.vfc-center-play {
  pointer-events: auto;
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
}
.vfc-center-play svg { width: 28px; height: 28px; margin-left: 3px; }
.vfc-center-play:hover { background: rgba(0, 0, 0, 0.7); transform: scale(1.05); }
.vfc-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: vfc-spin 0.8s linear infinite;
}
@keyframes vfc-spin { to { transform: rotate(360deg); } }

/* Bottom bar */
.vfc-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 40px 12px 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.4) 60%, transparent);
  transition: opacity 0.2s;
}

/* Seek bar */
.vfc-seek {
  position: relative;
  height: 12px;
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}
.vfc-seek-track {
  position: absolute;
  left: 0; right: 0;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.25);
}
.vfc-seek-buffered {
  position: absolute;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.4);
  width: 0;
}
.vfc-seek-progress {
  position: absolute;
  height: 4px;
  border-radius: 99px;
  background: #007aff;
  width: 0;
}
.vfc-seek-thumb {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.vfc-seek:hover .vfc-seek-thumb { opacity: 1; }
.vfc-seek:hover .vfc-seek-track,
.vfc-seek:hover .vfc-seek-buffered,
.vfc-seek:hover .vfc-seek-progress { height: 6px; }
.vfc-seek input[type='range'] {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 12px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}
.vfc-seek input[type='range']::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: transparent;
}
.vfc-seek input[type='range']::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: none;
  border-radius: 50%;
  background: transparent;
}
.vfc-seek-tip {
  position: absolute;
  bottom: 100%;
  margin-bottom: 8px;
  width: 40px;
  text-align: center;
  font-size: 11px;
  color: #fff;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 4px;
  padding: 2px 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s;
  font-variant-numeric: tabular-nums;
}

/* Button row */
.vfc-row {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fff;
}
.vfc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
  flex: none;
}
.vfc-btn:hover { background: rgba(255, 255, 255, 0.15); }
.vfc-btn svg { width: 19px; height: 19px; pointer-events: none; }
.vfc-skipnum {
  position: absolute;
  top: 1px; right: 1px;
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
}

/* Volume: slider nở ra khi hover group */
.vfc-volgroup { display: flex; align-items: center; gap: 0; }
.vfc-volgroup input[type='range'] {
  width: 0;
  opacity: 0;
  transition: width 0.2s, opacity 0.2s;
  appearance: none;
  -webkit-appearance: none;
  height: 3px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.25);
  cursor: pointer;
}
.vfc-volgroup:hover input[type='range'],
.vfc-volgroup input[type='range']:focus { width: 64px; opacity: 1; }
.vfc-volgroup input[type='range']::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #fff;
}
.vfc-volgroup input[type='range']::-moz-range-thumb {
  width: 10px; height: 10px;
  border: none; border-radius: 50%;
  background: #fff;
}

.vfc-time {
  margin-left: 4px;
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  user-select: none;
}
.vfc-time .vfc-dur { color: rgba(255, 255, 255, 0.6); }
.vfc-spacer { flex: 1; }

/* Menus */
.vfc-menuwrap { position: relative; }
.vfc-menu {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 10px;
  min-width: 96px;
  background: rgba(0, 0, 0, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 4px;
  z-index: 30;
}
.vfc-menu-item {
  padding: 6px 10px;
  font-size: 12px;
  color: #fff;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.vfc-menu-item:hover { background: rgba(255, 255, 255, 0.12); }
.vfc-menu-item.vfc-active { color: #4da3ff; font-weight: 600; }

/* Quality badge (top-left) */
.vfc-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 18;
  padding: 3px 8px;
  font-size: 11px;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Fullscreen: wrapper fullscreen — bar + watermark đều con của wrapper */
.vidflow-player-wrapper:fullscreen { width: 100%; height: 100%; }
.vidflow-player-wrapper:-webkit-full-screen { width: 100%; height: 100%; }

/* Mobile: nút to hơn, time ẩn bớt phần duration */
@media (max-width: 640px) {
  .vfc-btn { width: 36px; height: 36px; }
  .vfc-btn svg { width: 22px; height: 22px; }
  .vfc-time .vfc-dur { display: none; }
  .vfc-center-play { width: 56px; height: 56px; }
  .vfc-center-play svg { width: 24px; height: 24px; }
  .vfc-bottom { padding: 32px 8px 6px; }
}
