/* ============================================================
   REPOSITORIO.CSS — buscador de fotos por referencia
   Depende de los tokens de main.css y las tarjetas de grid.css.
   Movil primero.
   ============================================================ */

:root {
  --color-whatsapp: #000000;
  --color-whatsapp-hover: #2b2b2b;
  --color-mark: #fff3a3;
}

/* ── Enlace del header (copia local de la regla del parche a main.css,
      para que la pagina funcione aunque el parche no este aplicado) ── */
.header-repo-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 18px;
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  transition: background var(--transition-fast);
}

.header-repo-btn:hover,
.header-repo-btn:focus-visible {
  background: rgba(255, 255, 255, 0.15);
  outline: none;
}

@media (max-width: 479px) {
  .header-repo-btn {
    width: 36px;
    padding: 0;
    justify-content: center;
  }

  .header-repo-btn span {
    display: none;
  }
}

.site-logo {
  text-decoration: none;
}

/* ── Contenedor ── */
.repo-main {
  min-height: calc(100vh - var(--header-height));
  max-width: 1200px;
  margin: 0 auto;
}

/* ── Buscador ── */
.repo-buscador {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xl) var(--space-md) var(--space-lg);
  text-align: center;
}

.repo-titulo {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.repo-subtitulo {
  font-size: 14px;
  color: var(--color-text-muted);
}

.repo-form {
  display: flex;
  width: 100%;
  max-width: 520px;
  margin-top: var(--space-md);
  border: 2px solid var(--color-text);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg);
}

.repo-form:focus-within {
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.12);
}

.repo-input {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: none;
  outline: none;
  background: transparent;
  color: var(--color-text);
  -webkit-appearance: none;
  appearance: none;
}

.repo-input::placeholder {
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--color-text-muted);
}

.repo-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.repo-btn {
  padding: 0 20px;
  background: var(--color-text);
  color: var(--color-bg);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: opacity var(--transition-fast);
}

.repo-btn:hover {
  opacity: 0.85;
}

.repo-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Estados ── */
.repo-estado {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xl) var(--space-md);
  text-align: center;
  color: var(--color-text-muted);
  font-size: 14px;
}

.repo-estado-texto {
  max-width: 420px;
}

.repo-estado-detalle {
  font-size: 12px;
  opacity: 0.7;
}

.repo-estado--error {
  color: #b00020;
}

.repo-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-text);
  border-radius: 50%;
  animation: repo-spin 0.7s linear infinite;
}

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

/* ── Resumen ── */
.repo-resumen {
  padding: 0 var(--space-md);
  font-size: 13px;
  color: var(--color-text-muted);
  text-align: center;
}

/* ── Tarjetas ── */
.repo-card {
  cursor: default;
}

.repo-card .card-image {
  cursor: pointer;
}

/* En movil no hay hover: las flechas siempre visibles */
@media (hover: none) {
  .repo-card .card-arrow {
    opacity: 1;
  }
}

.repo-card-ref {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.repo-card-ref mark {
  background: var(--color-mark);
  color: inherit;
  padding: 0 2px;
  border-radius: var(--radius-sm);
}

.repo-card-contador {
  font-size: 12px;
  color: var(--color-text-muted);
}

.repo-card-acciones {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-xs);
  width: 100%;
  margin-top: var(--space-sm);
}

/* ── Boton WhatsApp ── */
.repo-wa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  background: var(--color-whatsapp);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast), opacity var(--transition-fast);
}

.repo-wa-btn:hover {
  background: var(--color-whatsapp-hover);
}

.repo-wa-btn:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

.repo-wa-icono {
  flex-shrink: 0;
  fill: #fff;
}

.repo-wa-btn--preparando,
.repo-wa-btn:disabled {
  opacity: 0.75;
  cursor: progress;
}

.repo-wa-btn--preparando .repo-wa-icono {
  animation: repo-pulso 1s ease-in-out infinite;
}

@keyframes repo-pulso {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Boton secundario: copiar enlaces ── */
.repo-copiar-btn {
  width: 100%;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 12px;
  letter-spacing: 0.02em;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.repo-copiar-btn:hover {
  background: var(--color-hover);
}

.repo-copiar-btn--ok {
  border-color: var(--color-whatsapp);
  color: var(--color-whatsapp-hover);
}

/* ── Aviso bajo los botones ── */
.repo-aviso {
  font-size: 12px;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: var(--space-xs);
}

/* ── Escritorio ── */
@media (min-width: 640px) {
  .repo-titulo {
    font-size: 22px;
  }

  .repo-input {
    font-size: 24px;
    padding: 16px 20px;
  }

  .repo-btn {
    padding: 0 28px;
  }

  .repo-card-acciones {
    flex-direction: row;
  }

  .repo-wa-btn {
    flex: 2;
  }

  .repo-copiar-btn {
    flex: 1;
    min-height: 44px;
  }
}

/* ── Referencia y contador en una fila ── */
.repo-card-fila {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.repo-card-fila .repo-card-ref,
.repo-card-fila .repo-card-contador {
  margin: 0;
  text-align: left;
}
.repo-card-fila .repo-card-contador {
  text-align: right;
  white-space: nowrap;
}

/* ── PC: fotos descargadas, listas para WhatsApp Web ── */
.repo-wa-btn.repo-wa-btn--listo,
.repo-wa-btn.repo-wa-btn--listo:hover {
  background: #25D366;
  color: #fff;
}
.repo-wa-btn--listo .repo-wa-texto {
  font-size: 13px;
  line-height: 1.25;
  text-align: center;
}

/* ── Encabezado fijo con buscador compacto ── */
/* overflow-x:hidden en html y body anula position:sticky; clip recorta igual sin romperlo. */
html, body { overflow-x: clip; }

.repo-form-mini {
  display: none;
  flex: 1;
  max-width: 520px;
  margin: 0 auto;
  height: 38px;
  background: #fff;
  border-radius: var(--radius-md);
  overflow: hidden;
}
.site-header.con-buscador .repo-form-mini { display: flex; }
.site-header.con-buscador .site-tagline { display: none; }

.repo-input-mini {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #000;
  background: #fff;
}
.repo-input-mini:focus { outline: none; }
.repo-form-mini:focus-within { box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(255,255,255,.35); }

.repo-btn-mini {
  padding: 0 14px;
  border: 0;
  border-left: 1px solid #e5e5e5;
  background: #fff;
  color: #000;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.repo-btn-mini:hover { background: #f2f2f2; }

@media (max-width: 600px) {
  .site-header.con-buscador .site-logo { display: none; }
  .repo-form-mini { max-width: none; }
  .site-header.con-buscador .header-repo-btn span { display: none; }
  .repo-form-mini { height: 34px; }
  .repo-btn-mini { padding: 0 10px; }
}

/* ── Contador con iconos (fotos y videos) ── */
.repo-card-contador { display: inline-flex; align-items: center; gap: 10px; line-height: 1; }
.repo-cont-item svg { display: block; }
.repo-cont-item { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.repo-cont-item svg { flex: none; }

/* ── Visor: la miniatura del video (al final) se distingue de las fotos ── */
.lightbox-thumb--video { outline: 2px solid #fff; outline-offset: -2px; filter: brightness(0.75); }

/* ── Boton Compartir dentro del visor ── */
/* El visor es una columna (foto, puntos, miniaturas, boton). El boton tiene alto fijo y,
   cuando esta visible, la foto se achica para que nada se monte. */
.lightbox-accion.repo-wa-btn {
  flex: 0 0 auto;
  align-self: center;
  width: min(360px, 100%);
  height: 48px;
  min-height: 48px;
  margin: 0;
  padding: 0 20px;
  border-radius: var(--radius-md);
  background: #fff;
  color: #000;
}
.lightbox-accion.repo-wa-btn:hover { background: #e9e9e9; }
.lightbox-accion.repo-wa-btn.repo-wa-btn--listo { background: #25D366; color: #fff; }
.lightbox-accion[hidden] { display: none !important; }
.lightbox:has(.lightbox-accion:not([hidden])) .lightbox-stage { max-height: calc(100vh - 230px); }
.lightbox:has(.lightbox-accion:not([hidden])) .lightbox-image { max-height: calc(100vh - 230px); }
@media (max-width: 600px) {
  .lightbox:has(.lightbox-accion:not([hidden])) .lightbox-stage,
  .lightbox:has(.lightbox-accion:not([hidden])) .lightbox-image { max-height: calc(100vh - 210px); }
}
/* Icono de WhatsApp del boton del visor: negro sobre blanco; blanco cuando el boton pasa a verde. */
.lightbox-accion.repo-wa-btn .repo-wa-icono { fill: #000; }
.lightbox-accion.repo-wa-btn.repo-wa-btn--listo .repo-wa-icono { fill: #fff; }

/* ── Celular: X con su propio espacio y Compartir como icono redondo abajo a la derecha ── */
@media (max-width: 600px) {
  .lightbox:has(.lightbox-accion:not([hidden])) {
    padding-top: calc(64px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }
  .lightbox:has(.lightbox-accion:not([hidden])) .lightbox-close {
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: 12px;
    background: rgba(0, 0, 0, 0.55);
  }
  .lightbox:has(.lightbox-accion:not([hidden])) .lightbox-stage,
  .lightbox:has(.lightbox-accion:not([hidden])) .lightbox-image {
    max-height: calc(100vh - 64px - 84px - 150px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
  .lightbox-accion.repo-wa-btn {
    position: absolute;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    width: 52px;
    height: 52px;
    min-height: 52px;
    padding: 0;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  }
  .lightbox-accion.repo-wa-btn .repo-wa-texto {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .lightbox-accion.repo-wa-btn .repo-wa-icono { width: 24px; height: 24px; }
}

/* ── Visor (PC y celular igual): Compartir como icono redondo abajo a la derecha ── */
.lightbox-accion.repo-wa-btn {
  position: absolute;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: 52px;
  height: 52px;
  min-height: 52px;
  padding: 0;
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}
.lightbox-accion.repo-wa-btn .repo-wa-texto {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.lightbox-accion.repo-wa-btn .repo-wa-icono { width: 24px; height: 24px; }
/* Cargando: el icono se cambia por un circulo que gira. */
.lightbox-accion.repo-wa-btn--preparando .repo-wa-icono { display: none; }
.lightbox-accion.repo-wa-btn--preparando::after {
  content: "";
  width: 22px;
  height: 22px;
  border: 3px solid #d0d0d0;
  border-top-color: #000;
  border-radius: 50%;
  animation: repo-giro 0.8s linear infinite;
}
@keyframes repo-giro { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .lightbox-accion.repo-wa-btn--preparando::after { animation-duration: 2.4s; }
}

/* ── Aviso de ventana privada ── */
#repo-aviso-privado {
  position: sticky;
  top: var(--header-height, 60px);
  z-index: 90;
  background: #b3261e;
  color: #fff;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
}
#repo-aviso-privado strong { font-weight: 700; }

/* ── Boton de la tarjeta: circulo de carga mientras prepara las fotos ── */
.repo-card .repo-wa-btn--preparando .repo-wa-icono { display: none; }
.repo-card .repo-wa-btn--preparando::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: repo-giro 0.8s linear infinite;
  flex: none;
}
@keyframes repo-giro { to { transform: rotate(360deg); } }

/* ── Estados del boton Compartir: cargando (verde oscuro + reloj) y listo (verde + pulso) ── */
.repo-wa-btn.repo-wa-btn--cargando,
.repo-wa-btn.repo-wa-btn--cargando:hover {
  background: #128C7E;
  color: #fff;
}
.repo-icono-tiempo {
  fill: none !important;
  stroke: #fff;
  animation: repo-arena 1.4s ease-in-out infinite;
}
@keyframes repo-arena {
  0%, 35% { transform: rotate(0deg); }
  50%, 85% { transform: rotate(180deg); }
  100% { transform: rotate(360deg); }
}
.repo-wa-btn.repo-wa-btn--listo {
  background: #25D366;
  color: #fff;
  animation: repo-pulso-listo 1.6s ease-in-out infinite;
}
@keyframes repo-pulso-listo {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.55); }
  50% { box-shadow: 0 0 0 7px rgba(37, 211, 102, 0); }
}
.repo-wa-btn--cargando .repo-wa-texto { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) {
  .repo-icono-tiempo, .repo-wa-btn.repo-wa-btn--listo { animation: none; }
}

.repo-version { text-align: center; font-size: 11px; color: #9a9a9a; margin: 24px 0 8px; }
