/* UFY Phone — Editor oscuro de fotos y videos: la pantalla y el paso de una a otra.
 *
 * Qué hace: da el aspecto de la imagen de referencia del dueño al diálogo del
 * editor (media-composer.js) mientras está abierto el editor oscuro (clase
 * is-editing, que pone media-editor-screens.js): fondo negro, la cabecera
 * con × título ✓, la foto en medio y los botones de abajo (Cancelar / Listo
 * o Guardar / Cancelar). También la pantalla de entrada (fila de
 * herramientas y «Previsualizar»), la rejilla con esquinas y el botón de
 * reproducir.
 * Quién lo usa: media-editor-screens.js. Lo de cada herramienta (Recortar,
 * Formato, Ajustar, Mover, Zoom, Recortar video, Portada) está en
 * media-editor-tools.css. Cuando NO está abierto manda media-upload-screen.css
 * (la pantalla blanca).
 *
 * root.dataset.editorScreen dice qué pantalla se ve: hub, crop, format,
 * adjust, move, zoom, trim, cover, filters, text o preview.
 */

/* ---------- La página ---------- */

.ufy-media-editor.is-editing {
  padding: 0;
  overflow: hidden;
  background: #000;
  color: #fff;
}

/* Lo de la pantalla blanca y del editor antiguo que aquí no se usa. */
.ufy-media-editor.is-editing > .ufy-upload-heading,
.ufy-media-editor.is-editing > .ufy-upload-edit,
.ufy-media-editor.is-editing > .ufy-upload-progress,
.ufy-media-editor.is-editing > .ufy-editor-playback,
.ufy-media-editor.is-editing > .ufy-editor-footer,
.ufy-media-editor.is-editing .ufy-editor-frame > .ufy-editor-header,
.ufy-media-editor.is-editing .ufy-editor-mode,
.ufy-media-editor.is-editing .ufy-upload-preview-play,
.ufy-media-editor.is-editing .ufy-publish-hint {
  display: none !important;
}

/* Filtros: la tira de siempre (del pie) sola, encima de Cancelar / Listo. */
.ufy-media-editor.is-editing[data-editor-screen="filters"]:not(.is-text-editing) > .ufy-editor-footer {
  display: block !important;
  padding: 6px 16px 0;
  border: 0;
  background: #000;
}

.ufy-media-editor.is-editing[data-editor-screen="filters"] > .ufy-editor-footer > :not(.ufy-editor-filters) {
  display: none !important;
}

.ufy-media-editor.is-editing .ufy-editor-filters button {
  color: #d6d6db;
  font-size: 11px;
}

.ufy-media-editor.is-editing .ufy-editor-filters button[aria-pressed=true] {
  color: #fff;
  font-weight: 700;
}

.ufy-media-editor.is-editing .ufy-editor-filters button[aria-pressed=true] .ufy-filter-preview {
  border-color: #fff;
  box-shadow: none;
}

.ufy-media-editor.is-editing :is(button, input, [tabindex="0"]):focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* ---------- Cabecera: × título ✓ ---------- */

.ufy-editor-screen-header {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  flex: none;
  padding: max(8px, env(safe-area-inset-top)) 8px 6px;
}

.ufy-editor-screen-header h2 {
  grid-column: 2;
  margin: 0;
  overflow: hidden;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  outline: none;
}

.ufy-editor-top-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: #fff;
}

.ufy-editor-top-button:first-child {
  grid-column: 1;
}

.ufy-editor-top-button:last-child {
  grid-column: 3;
  justify-self: end;
}

.ufy-editor-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
}

.ufy-editor-icon svg {
  width: 24px;
  height: 24px;
}

/* ---------- La foto ---------- */

.ufy-media-editor.is-editing > .ufy-editor-workspace {
  flex: 1;
  width: 100%;
  height: auto;
  min-height: 120px;
  margin: 0;
  padding: 8px 16px;
}

.ufy-media-editor.is-editing .ufy-editor-frame {
  border-radius: 0;
  background: #111;
  touch-action: none;
}

/* Las pantallas que enseñan el resultado van con las esquinas redondas. */
.ufy-media-editor.is-editing:is([data-editor-screen="hub"], [data-editor-screen="trim"],
  [data-editor-screen="cover"], [data-editor-screen="preview"], [data-editor-screen="zoom"],
  [data-editor-screen="filters"], [data-editor-screen="text"]) .ufy-editor-frame {
  border-radius: 14px;
}

/* Rejilla de tercios y esquinas (Ajustar, Formato y Mover). */
.ufy-editor-guides {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  pointer-events: none;
}

.ufy-media-editor.is-editing:is([data-editor-screen="adjust"], [data-editor-screen="format"],
  [data-editor-screen="move"]) .ufy-editor-guides {
  display: block;
}

.ufy-editor-guide-grid {
  position: absolute;
  inset: 0;
  border: 1px solid #ffffffb3;
  background:
    linear-gradient(90deg, transparent calc(33.333% - .5px), #ffffff73 calc(33.333% - .5px), #ffffff73 calc(33.333% + .5px), transparent calc(33.333% + .5px),
      transparent calc(66.666% - .5px), #ffffff73 calc(66.666% - .5px), #ffffff73 calc(66.666% + .5px), transparent calc(66.666% + .5px)),
    linear-gradient(180deg, transparent calc(33.333% - .5px), #ffffff73 calc(33.333% - .5px), #ffffff73 calc(33.333% + .5px), transparent calc(33.333% + .5px),
      transparent calc(66.666% - .5px), #ffffff73 calc(66.666% - .5px), #ffffff73 calc(66.666% + .5px), transparent calc(66.666% + .5px));
}

.ufy-editor-guide-corner {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 3px solid #fff;
}

.ufy-editor-guide-corner.is-nw { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.ufy-editor-guide-corner.is-ne { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.ufy-editor-guide-corner.is-sw { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.ufy-editor-guide-corner.is-se { bottom: 0; right: 0; border-left: 0; border-top: 0; }

/* Botón redondo de reproducir / pausar en medio del video. */
.ufy-editor-play {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #00000073;
  backdrop-filter: blur(6px);
  color: #fff;
  transform: translate(-50%, -50%);
}

.ufy-editor-play svg {
  width: 28px;
  height: 28px;
}

.ufy-editor-play:not(.is-playing) svg {
  margin-left: 3px;
}

/* Mientras se reproduce, el botón casi no se ve (sigue ahí para pausar). */
.ufy-editor-play.is-playing {
  opacity: 0;
}

.ufy-editor-play.is-playing:focus-visible,
.ufy-editor-play.is-playing:hover {
  opacity: 1;
}

/* ---------- Lo de abajo ---------- */

.ufy-editor-screen-panel {
  flex: none;
  max-height: 46%;
  overflow-y: auto;
  padding: 10px 16px max(16px, env(safe-area-inset-bottom));
  background: #000;
  scrollbar-width: none;
}

/* El texto tiene su propio panel con «Listo». */
.ufy-media-editor[data-editor-screen="text"] .ufy-editor-screen-panel {
  display: none;
}

.ufy-editor-hint {
  margin: 12px 0 0;
  color: #d4d4d9;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
}

/* Cancelar (gris) a la izquierda y Listo (blanco) a la derecha. */
.ufy-editor-pills {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.ufy-editor-pill {
  min-width: 96px;
  min-height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: 22px;
  background: #2b2b30;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.ufy-editor-pill.is-primary,
.ufy-editor-wide.is-primary {
  background: #fff;
  color: #000 !important;
}

/* Botones anchos: Previsualizar, Guardar y Cancelar. */
.ufy-editor-wide {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  padding: 0 18px;
  border: 0;
  border-radius: 25px;
  background: #1f1f23;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.ufy-editor-preview-actions {
  display: grid;
  gap: 12px;
  padding-top: 6px;
}

/* ---------- Pantalla de entrada: herramientas y Previsualizar ---------- */

.ufy-editor-hub {
  display: grid;
  gap: 16px;
}

.ufy-editor-tool-row {
  display: flex;
  gap: 4px;
  margin: 0 -16px;
  padding: 2px 16px 4px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}

.ufy-editor-tool-row::-webkit-scrollbar {
  display: none;
}

.ufy-editor-tool {
  display: flex;
  flex: 0 0 68px;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  scroll-snap-align: start;
}

.ufy-editor-tool > .ufy-editor-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: #1f1f23;
}

.ufy-editor-tool.is-active > .ufy-editor-icon {
  background: #fff;
  color: #000;
}

/* ---------- Ordenador: la mitad derecha, como la pantalla blanca ---------- */

@media (min-width: 900px) and (min-height: 500px) {
  .ufy-media-editor.is-editing {
    left: 50%;
    right: 0;
    width: 50%;
    transform: none;
    box-shadow: -50vw 0 0 0 #000000a6;
  }

  .ufy-editor-tool-row {
    justify-content: center;
    flex-wrap: wrap;
    row-gap: 12px;
  }
}

/* ---------- Pantallas bajas (horizontal): todo cabe o se desplaza ---------- */

@media (max-height: 560px) {
  .ufy-editor-screen-header {
    padding-top: max(4px, env(safe-area-inset-top));
    padding-bottom: 2px;
  }

  .ufy-media-editor.is-editing > .ufy-editor-workspace {
    min-height: 90px;
    padding-top: 4px;
    padding-bottom: 4px;
  }

  .ufy-editor-screen-panel {
    max-height: 58%;
    padding-top: 6px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .ufy-editor-hub {
    gap: 10px;
  }

  .ufy-editor-pills {
    margin-top: 10px;
  }

  .ufy-editor-wide {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ufy-editor-tool-row {
    scroll-behavior: auto;
  }
}
