*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: #f0f0f0;
  color: #222;
}

/* ── APP SHELL ─────────────────────────────────────────── */
.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── HEADER ─────────────────────────────────────────────── */
.header {
  flex: 0 0 auto;
  background: #fff;
  border-bottom: 1px solid #ddd;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}

.header-logo img {
  height: 44px;
  width: auto;
  display: block;
}
.logo-text {
  font-size: 28px;
  font-style: italic;
  font-weight: 800;
  color: #003087;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.3;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s;
  color: #fff;
}
.btn-action:hover { opacity: .88; }
.btn-action svg { width: 26px; height: 26px; flex-shrink: 0; }
.btn-action span { color: #fff; }
.btn-action strong { display: block; font-size: 15px; }

.btn-web {
  background: #003087;
  border: 2px solid #003087;
  color: #fff;
}
.btn-web svg { stroke: #fff; }

.btn-whatsapp {
  background: #25D366;
  border: 2px solid #25D366;
  color: #fff;
}

/* ── VIEWER ─────────────────────────────────────────────── */
.viewer {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: #e8e8e8;
  overflow: hidden;
}

.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 48px;
  height: 80px;
  background: rgba(0,0,0,.18);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 48px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  padding: 0;
}
.nav-btn:hover { background: rgba(0,0,0,.35); }
.nav-left  { left: 12px; }
.nav-right { right: 12px; }

.book-wrap {
  width: calc(100% - 130px);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* PageFlip container */
.book-container { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.book-container[hidden] { display: none !important; }
.book-el { display: block; }
.book-el[hidden] { display: none !important; }

.stf__item { background: #fff !important; overflow: hidden; }
.stf__item img { width: 100%; height: 100%; object-fit: fill; display: block; }
.book-page { background: #fff; overflow: hidden; box-shadow: 0 0 8px rgba(0,0,0,.15); }
.book-page img { width: 100%; height: 100%; object-fit: fill; display: block; user-select: none; -webkit-user-drag: none; }

/* Fallback */
.fallback-book { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.fallback-book[hidden] { display: none !important; }
.fallback-book img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 4px 20px rgba(0,0,0,.25); }

/* ── FOOTER ─────────────────────────────────────────────── */
.footer {
  flex: 0 0 auto;
  background: #fff;
  border-top: 1px solid #ddd;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.page-info { font-size: 14px; font-weight: 600; white-space: nowrap; min-width: 110px; }
.page-info .sep { color: #888; font-weight: 400; margin-left: 4px; }

.slider { flex: 1; accent-color: #003087; height: 4px; cursor: pointer; }

.footer-btns { display: flex; gap: 8px; }
.footer-btns button {
  background: #003087;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.footer-btns button:hover { background: #002070; }

/* ── THUMBS ─────────────────────────────────────────────── */
.thumbs-bar {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 6px 12px;
  background: #f8f8f8;
  border-top: 1px solid #e0e0e0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.thumb {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border: 2px solid transparent;
  border-radius: 5px;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  background: #ddd;
  transition: border-color .15s;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.active { border-color: #003087; }
.thumb:hover { border-color: #0050c8; }

/* ── TABLET ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .book-wrap { width: 100%; }
  .nav-btn { width: 38px; height: 64px; font-size: 38px; background: rgba(0,0,0,.25); }
  .nav-left  { left: 4px; }
  .nav-right { right: 4px; }
}

/* ── MÓVIL ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  .header { padding: 8px 10px; gap: 6px; }
  .header-logo { flex-shrink: 0; }
  .header-logo img { height: 32px; }
  .logo-text { font-size: 18px; }
  .header-actions { flex: 1; gap: 5px; justify-content: flex-end; overflow: hidden; }
  .btn-action { padding: 6px 8px; gap: 5px; font-size: 10px; border-radius: 7px; flex: 1; min-width: 0; }
  .btn-action svg { width: 16px; height: 16px; flex-shrink: 0; }
  .btn-action span { overflow: hidden; }
  .btn-action strong { font-size: 11px; }
  .nav-btn { width: 32px; height: 52px; font-size: 32px; }
  .footer { padding: 6px 10px; gap: 8px; }
  .page-info { font-size: 12px; min-width: 80px; }
  .footer-btns button { padding: 6px 10px; font-size: 12px; }
  .thumb { width: 42px; height: 42px; }
}
