/* --- Base / Layout --- */
:root {
  --toolbar-height: 56px;
  --thumb-width: 200px;
  --bg: #121212;
  --panel: #2a2a2a;
  --accent: #007bff;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: Arial, sans-serif;
  background-color: #1e1e1e;
  color: #fff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: auto; /* permitimos scroll si es necesario */
}

/* Contenedor principal ocupa la ventana */
.viewer-container {
  display: flex;
  width: 100%;
  min-height: 100vh;
  height: 100vh; /* usamos 100vh en el contenedor, pero manejamos el scroll en el visor */
  box-sizing: border-box;
}

/* --- Thumbnails (sidebar) --- */
.thumbnails {
  width: var(--thumb-width);
  background-color: var(--panel);
  overflow-y: auto;
  padding: 12px;
  box-sizing: border-box;
  border-right: 1px solid rgba(255,255,255,0.04);
}

.thumbnails img {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  margin-bottom: 12px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.82;
  transition: transform .15s ease, opacity .15s ease;
  display: block;
}

.thumbnails img:hover { opacity: 1; transform: translateY(-3px); }

.thumbnails img.active {
  opacity: 1;
  transform: scale(1.02);
  border: 2px solid var(--accent);
  box-sizing: border-box;
}

/* --- Área principal --- */
.main-view {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  min-height: 0; /* importante para que los hijos con overflow funcionen */
}

/* --- Toolbar fija arriba --- */
.toolbar {
  height: var(--toolbar-height);
  min-height: var(--toolbar-height);
  background-color: var(--panel);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  box-sizing: border-box;
  position: sticky;
  top: 0;
  z-index: 50; /* por encima de las imágenes */
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

/* Botones visibles y accesibles */
.toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  transition: background .12s ease, transform .08s ease;
}

.toolbar button:hover {
  background: rgba(255,255,255,0.06);
  transform: translateY(-1px);
}

/* indicador de página a la derecha */
#pageIndicator {
  margin-left: auto;
  font-weight: 600;
  font-size: 14px;
  opacity: 0.95;
}

/* --- Viewer: aquí se hace el scroll principal del contenido --- */
.image-viewer {
  flex: 1 1 auto;
  width: 100%;
  overflow-y: auto;    /* <-- el scroll debe funcionar aquí */
  overflow-x: hidden;
  padding: 18px 20px 40px 20px;
  box-sizing: border-box;
  scroll-behavior: smooth;

  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Cada imagen/página */
.viewer-page {
  display: block;
  width: 90%;
  max-width: 900px;      /* limita el ancho para que no se desborde */
  height: auto;
  max-height: calc(100vh - var(--toolbar-height) - 60px); /* evita que sea mayor que la pantalla */
  margin: 28px 0;
  border-radius: 6px;
  object-fit: contain;
  transition: transform 0.18s ease;
  box-shadow: 0 6px 20px rgba(0,0,0,0.6);
  background: #222; /* si la imagen tiene transparencia */
}

/* --- Manejo del zoom: solo transform en la imagen actual --- */
.viewer-page[style] {
  will-change: transform;
}

/* =================
   RESPONSIVE RULES
   ================= */
@media (max-width: 1024px) {
  :root { --thumb-width: 160px; }
  .viewer-page { max-width: 900px; }
}

@media (max-width: 768px) {
  :root { --thumb-width: 120px; }
  .thumbnails { width: var(--thumb-width); }
  .viewer-page { width: 95%; max-width: 95%; margin: 22px 0; }
}

@media (max-width: 480px) {
  /* En móviles ocultamos el sidebar para mejorar espacio */
  .thumbnails {
    display: none;
  }
  .viewer-container { height: 100%; min-height: 100vh; }
  .image-viewer { padding: 12px; }
  .viewer-page {
    width: 100%;
    margin: 18px 0;
    max-height: none; /* permitir scroll vertical si la imagen es muy alta */
  }
}

/* =================
   UTILS (opcional)
   ================= */

/* Asegurar que el toolbar siempre se vea sobre overlays */
.toolbar {
  box-shadow: 0 1px 0 rgba(255,255,255,0.02);
}

/* Si quieres forzar botones grandes en móvil */
@media (max-width:480px) {
  .toolbar button { padding: 8px 12px; font-size: 16px; }
}
