/* ==========================================================================
   Video a Addon
   Reutiliza el editor de tres paneles del HUD Generator (hud.css) y añade
   la pantalla 16:9, la caja del video, la lista de videos y los ajustes.
   ========================================================================== */

.vx-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4) 0;
}

.vx-toolbar .chip-row { flex: 1; min-width: 0; }
.vx-toolbar .icon-btn { flex-shrink: 0; background: var(--surface-high); }

/* La pantalla de Minecraft siempre es 16:9 para que los % coincidan */
.vx-screen,
.canvas-container.vx-screen { aspect-ratio: 16 / 9; }

.vx-caption {
  padding: 0 var(--sp-4) var(--sp-4);
  text-align: center;
  font-size: var(--t-label);
  color: var(--on-surface-var);
  font-family: var(--font-mono);
}

/* Barra de objetos de referencia (solo guía visual) */
.vx-hotbar {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 1.2%;
  transform: translateX(-50%);
  display: flex;
  gap: 0;
  width: 42.2%;
  aspect-ratio: 182 / 22;
  pointer-events: none;
  border: 2px solid rgba(0, 0, 0, .55);
  background: rgba(0, 0, 0, .28);
}

.vx-hotbar span { flex: 1; border-right: 1px solid rgba(255, 255, 255, .12); }
.vx-hotbar span:last-child { border-right: none; }

/* Guías de centrado */
.vx-guide {
  position: absolute;
  z-index: 8;
  background: var(--ember-70);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-1, 90ms) linear;
}

.vx-guide.on { opacity: .9; }
.vx-guide-v { top: 0; bottom: 0; left: 50%; width: 1px; }
.vx-guide-h { left: 0; right: 0; top: 50%; height: 1px; }

/* Caja del video en el lienzo */
.vx-box {
  position: absolute;
  z-index: 10;
  cursor: move;
  user-select: none;
  touch-action: none;
  outline: 2px solid transparent;
  outline-offset: 0;
  background: #000;
  transition: outline-color var(--dur-2) var(--ease-standard);
}

.vx-box video,
.vx-box img,
.vx-box canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.vx-box:hover { outline-color: color-mix(in srgb, var(--primary) 55%, transparent); }
.vx-box.selected { outline-color: var(--primary); }
.vx-box .el-handles { position: absolute; inset: 2px; display: none; z-index: 15; pointer-events: none; }
.vx-box.selected .el-handles { display: block; }
.vx-box .r-handle { pointer-events: auto; }

.vx-box-label {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 12;
  max-width: 100%;
  padding: 2px 6px;
  border-bottom-right-radius: 6px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.vx-box.dim { opacity: .45; }

/* Lista de videos */
#videoList { display: flex; flex-direction: column; gap: var(--sp-2); }

.el-thumb canvas { width: 100%; height: 100%; object-fit: cover; }

.vx-warn { color: var(--error, #d33); }

/* Interruptor con texto */
.vx-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: 48px;
  margin-bottom: var(--sp-4);
  font-size: var(--t-body-sm);
  font-weight: 500;
  cursor: pointer;
}

.range-num.mono { display: inline-grid; place-items: center; }

/* Estadísticas de salida */
.vx-stats {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--shape-md);
  background: var(--surface-high);
  font-size: var(--t-label);
}

.vx-stats dt { color: var(--on-surface-var); }
.vx-stats dd { margin: 0; font-family: var(--font-mono); text-align: right; }
.vx-stats .vx-note { grid-column: 1 / -1; margin-top: 4px; line-height: var(--lh-snug); }

#exportBtn { margin-top: var(--sp-2); }
.vx-cancel { margin-top: var(--sp-2); }
.progress-wrap { margin-bottom: var(--sp-3); }

.vx-help { margin-top: var(--sp-5); font-size: var(--t-body-sm); line-height: var(--lh-snug); }
.vx-help ol { margin: var(--sp-2) 0; padding-left: 1.2em; display: grid; gap: 4px; }
.vx-help p + p { margin-top: var(--sp-2); }
.vx-help p:last-child { color: var(--on-surface-var); font-size: var(--t-label); }

#panel-config .drop-zone { margin-bottom: var(--sp-2); }

#propsPanel .field-row > .field { margin-bottom: var(--sp-3); }

@media (max-width: 1099px) {
  #panel-canvas .canvas-wrap { align-items: flex-start; }
}


/* ══ Pantalla de carga al generar ══════════════════════════════════════════ */

.vx-loading {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: var(--sp-6);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity .25s ease;
}

.vx-loading.is-open { opacity: 1; }

/* Cerrada no ocupa nada: sin esto la capa invisible tapaba toda la página */
.vx-loading[hidden] { display: none !important; }

.vx-loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  width: min(520px, 100%);
  text-align: center;
}

.vx-loading-box .rdx-loader { margin-bottom: var(--sp-4); }
.vx-loading-done { font-size: 64px !important; color: var(--success); margin-bottom: var(--sp-2); font-variation-settings: 'FILL' 1; }
.vx-loading-title { font-size: var(--t-title-lg); font-weight: 800; letter-spacing: -.01em; }
.vx-loading-pct { font-size: 2.75rem; font-weight: 800; line-height: 1.1; color: var(--primary); font-variant-numeric: tabular-nums; }

.vx-runner {
  width: 240px;
  height: 211px;
  margin-bottom: var(--sp-3);
  border-radius: var(--shape-lg);
  image-rendering: pixelated;
  /* Cielo de Minecraft detrás: la cara blanca del panda no se pierde en el fondo */
  background: linear-gradient(180deg, #8fc3ff 0%, #c7e2ff 70%, #dcecff 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}

[data-theme="dark"] .vx-runner { background: linear-gradient(180deg, #0f1a33 0%, #1d2f55 70%, #26406e 100%); }

/* Barra de progreso con efecto de agua: superficie con olas que se mueven,
   frente ondulado que avanza y burbujas que suben. */
.vx-loading-bar {
  position: relative;
  width: 100%;
  height: 22px;
  margin: var(--sp-2) 0;
  border-radius: var(--shape-full);
  background: var(--surface-highest);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .14);
  overflow: hidden;
}

.vx-water {
  --water-top: color-mix(in srgb, var(--primary) 62%, #ffffff);
  --water-bottom: var(--primary);
  position: relative;
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(180deg, var(--water-top), var(--water-bottom));
  transition: width .45s cubic-bezier(.2, 0, 0, 1);
}

/* Olas en la superficie: dos capas en sentidos contrarios */
.vx-water::before,
.vx-bubbles::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='22'%3E%3Cpath d='M0 7 Q12 1 24 7 T48 7 V0 H0Z' fill='white' fill-opacity='.45'/%3E%3C/svg%3E") repeat-x 0 0 / 48px 100%;
  animation: vx-wave 1.8s linear infinite;
  pointer-events: none;
}

.vx-bubbles::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='22'%3E%3Cpath d='M0 9 Q16 3 32 9 T64 9 V0 H0Z' fill='white' fill-opacity='.22'/%3E%3C/svg%3E");
  background-size: 64px 100%;
  animation: vx-wave-back 2.6s linear infinite;
}

/* Frente ondulado: el agua avanza con borde de ola, no con un corte recto */
.vx-water::after {
  content: "";
  position: absolute;
  top: 0;
  right: -9px;
  width: 10px;
  height: 100%;
  background: linear-gradient(180deg, var(--water-top), var(--water-bottom));
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='16'%3E%3Cpath d='M0 0 H4 Q10 4 4 8 T4 16 H0Z'/%3E%3C/svg%3E") repeat-y 0 0 / 10px 16px;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='16'%3E%3Cpath d='M0 0 H4 Q10 4 4 8 T4 16 H0Z'/%3E%3C/svg%3E") repeat-y 0 0 / 10px 16px;
  animation: vx-front 1.1s linear infinite;
}

.vx-bubbles { position: absolute; inset: 0; overflow: hidden; }

.vx-bubbles i {
  position: absolute;
  bottom: -6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .75);
  background: rgba(255, 255, 255, .25);
  animation: vx-bubble 2.4s ease-in infinite;
}

.vx-bubbles i:nth-child(1) { right: 12%; animation-delay: 0s; }
.vx-bubbles i:nth-child(2) { right: 30%; animation-delay: .7s; width: 4px; height: 4px; }
.vx-bubbles i:nth-child(3) { right: 52%; animation-delay: 1.3s; }
.vx-bubbles i:nth-child(4) { right: 70%; animation-delay: .35s; width: 3px; height: 3px; }
.vx-bubbles i:nth-child(5) { right: 88%; animation-delay: 1.8s; width: 4px; height: 4px; }

@keyframes vx-wave { to { background-position: 48px 0; } }
@keyframes vx-wave-back { to { background-position: -64px 0; } }
@keyframes vx-front {
  to { -webkit-mask-position: 0 16px; mask-position: 0 16px; }
}
@keyframes vx-bubble {
  0% { transform: translate(0, 0) scale(.6); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(-6px, -26px) scale(1.1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .vx-water::before, .vx-bubbles::before, .vx-water::after, .vx-bubbles i { animation: none; }
}

.vx-loading.is-done .vx-water { --water-top: color-mix(in srgb, var(--success) 60%, #ffffff); --water-bottom: var(--success); }
.vx-loading.is-done .vx-water::after { display: none; }
.vx-loading-status { min-height: 1.5em; font-size: var(--t-body-sm); color: var(--on-surface-var); overflow-wrap: anywhere; }
.vx-loading-note { font-size: var(--t-label); color: var(--on-surface-dim); margin-bottom: var(--sp-4); }
.vx-loading [hidden] { display: none !important; }
.vx-loading.is-done .vx-loading-warn { display: none; }

.vx-loading-warn {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  width: 100%;
  margin: var(--sp-2) 0 var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--shape-md);
  background: var(--warning-container);
  color: var(--on-warning-container);
  font-size: var(--t-body-sm);
  line-height: 1.45;
  text-align: left;
}

.vx-loading-warn b { color: inherit; }
.vx-loading-warn .material-icons { font-size: 22px; margin-top: 1px; }
