/* ==========================================================================
   LEITOR DE LIVRO INTERATIVO DE ALTO LUXO - BOOK READER ENGINE
   Padrão Mariana Dayrell • Coleção Jurídica de Excelência
   Cores Oficiais: Azul Petróleo Noturno (#07141A), Ouro Nobre (#C59B58), Marfim (#FAF8F3)
   ========================================================================== */

:root {
  --color-petrol-dark: #07141A;
  --color-petrol-medium: #0D222D;
  --color-petrol-light: #1C475C;
  --color-gold: #C59B58;
  --color-gold-bright: #D4AF37;
  --color-gold-light: #E6CA92;
  --color-paper: #FAF8F3;
  --color-text-dark: #1A242B;
  --color-text-main: #1A242B;
  --color-text-muted: #6B7B83;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-cinzel: 'Cinzel', serif;
  --page-scale: 0.70;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: #030a0f;
  background-image: 
    radial-gradient(circle at 50% 50%, #071a24 0%, #030a0f 90%),
    linear-gradient(rgba(197, 155, 88, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(197, 155, 88, 0.03) 1px, transparent 1px);
  background-size: 100% 100%, 60px 60px, 60px 60px;
  font-family: var(--font-sans);
  color: var(--color-paper);
  -webkit-font-smoothing: antialiased;
}

/* APP SHELL CONTAINER */
.reader-app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   HEADER & TOOLBAR
   -------------------------------------------------------------------------- */
.app-header {
  height: 60px;
  background: rgba(7, 20, 26, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(197, 155, 88, 0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  z-index: 100;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-emblem {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--color-gold);
  background: rgba(197, 155, 88, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-emblem svg {
  width: 18px;
  height: 18px;
  fill: var(--color-gold);
}

.brand-text h1 {
  font-family: var(--font-cinzel);
  font-size: 14px;
  font-weight: 700;
  color: var(--color-paper);
  letter-spacing: 1.5px;
  margin: 0;
  line-height: 1.2;
}

.brand-text p {
  font-size: 11px;
  color: var(--color-gold-light);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin: 0;
}

.controls-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(197, 155, 88, 0.28);
  color: var(--color-paper);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-sans);
  text-decoration: none;
}

.tool-btn:hover {
  background: rgba(197, 155, 88, 0.25);
  border-color: var(--color-gold-bright);
  color: #FFF;
  transform: translateY(-1px);
}

.tool-btn.active {
  background: var(--color-gold);
  color: #07141A;
  border-color: var(--color-gold-bright);
  font-weight: 700;
}

.tool-btn svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

/* FREQUÊNCIAS DE FOCO BINAURAIS */
.freq-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(197, 155, 88, 0.2);
  border-radius: 20px;
  padding: 3px 6px;
}

.freq-label-tag {
  font-size: 11px;
  color: var(--color-gold-light);
  padding: 0 4px;
}

.freq-pill-group {
  display: flex;
  gap: 3px;
}

.freq-btn {
  background: transparent;
  border: 1px solid transparent;
  color: rgba(250, 248, 243, 0.7);
  border-radius: 12px;
  padding: 3px 8px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.freq-btn:hover {
  color: #FFF;
  border-color: rgba(197, 155, 88, 0.4);
}

.freq-btn.active {
  background: var(--color-gold);
  color: #07141A;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(197, 155, 88, 0.5);
}

/* --------------------------------------------------------------------------
   EBOOK STAGE & FLIPBOOK CANVAS
   -------------------------------------------------------------------------- */
.ebook-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  position: relative;
  overflow: hidden !important;
  touch-action: pan-x pinch-zoom;
}

.flipbook-container {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 30px rgba(197, 155, 88, 0.15);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  max-height: 100%;
  max-width: 100%;
}

.stf__parent,
.stf__wrapper {
  overflow: hidden !important;
}

/* PAGE FRAME NO MOTOR FLIPBOOK */
.page {
  width: 100%;
  height: 100%;
  background-color: var(--color-paper);
  color: var(--color-text-dark);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

/* Escalonador proporcional de A4 para o Flipbook */
.page-scaler {
  width: 210mm;
  height: 297mm;
  color: var(--color-text-dark);
  transform-origin: 0 0;
  transform: scale(var(--page-scale, 0.7));
  box-sizing: border-box;
  overflow: hidden;
}

/* Pranchas 1:1 Autênticas do Documento Original com Espaços em Branco Preservados */
.page-original-wrapper {
  width: 210mm;
  height: 297mm;
  position: relative;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
}

.page[id="page-1"] .page-original-wrapper {
  background: transparent;
}

.page-original-img {
  width: 210mm;
  height: 297mm;
  object-fit: fill;
  display: block;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

/* Sombras de espinha central do livro */
.page.--left {
  border-radius: 4px 0 0 4px;
  box-shadow: inset -15px 0 25px -10px rgba(0, 0, 0, 0.25);
}

.page.--right {
  border-radius: 0 4px 4px 0;
  box-shadow: inset 15px 0 25px -10px rgba(0, 0, 0, 0.25);
}

.page.--left::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 6px;
  background: linear-gradient(to right, rgba(0,0,0,0.1), transparent);
  pointer-events: none;
}

.page.--right::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 6px;
  background: linear-gradient(to left, rgba(0,0,0,0.1), transparent);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   PÁGINA FINAL: MAPA MENTAL 16K INTERATIVO (CHAPTER FINALE)
   -------------------------------------------------------------------------- */
.page-mindmap-finale,
.pdf-page.page-mindmap-finale {
  width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
  max-height: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
  background: #030a0f !important;
  color: #FAF8F3 !important;
  position: relative !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

.mindmap-page-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 68px;
  background: rgba(7, 20, 26, 0.96);
  border-bottom: 1px solid rgba(197, 155, 88, 0.4);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 5px 10px;
  gap: 5px;
  z-index: 20;
  box-sizing: border-box;
}

.mindmap-page-title {
  font-family: var(--font-cinzel);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--color-gold);
  letter-spacing: 1.2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.mindmap-controls-group {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
}

.mm-ctrl-btn {
  background: rgba(197, 155, 88, 0.15);
  border: 1px solid rgba(197, 155, 88, 0.4);
  color: #FAF8F3;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mm-ctrl-btn svg {
  width: 11px;
  height: 11px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.mm-ctrl-btn:hover {
  background: var(--color-gold);
  color: #07141A;
}

.mindmap-deepzoom-viewport {
  position: absolute !important;
  top: 68px !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: calc(100% - 68px) !important;
  overflow: hidden !important;
  cursor: grab;
  user-select: none;
  touch-action: none;
  background: #030a0f;
}

.mindmap-deepzoom-viewport:active {
  cursor: grabbing;
}

.mindmap-deepzoom-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 15360px;
  height: 8640px;
  border: none;
  transform-origin: 0 0;
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
   FOOTER CONTROLS & NAVIGATION SLIDER
   -------------------------------------------------------------------------- */
.app-footer {
  height: 56px;
  background: rgba(7, 20, 26, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid rgba(197, 155, 88, 0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  z-index: 100;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.nav-arrow-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(197, 155, 88, 0.3);
  color: #FFF;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-arrow-btn:hover {
  background: var(--color-gold);
  color: #07141A;
  border-color: var(--color-gold-bright);
  transform: scale(1.08);
}

.nav-arrow-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.nav-progress-wrapper {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  max-width: 520px;
  margin: 0 20px;
}

.page-indicator-text {
  font-size: 13px;
  color: var(--color-gold-light);
  white-space: nowrap;
  font-weight: 600;
  font-family: var(--font-cinzel);
}

.slider-track {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.slider-track::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-gold);
  border: 2px solid #FFF;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(197, 155, 88, 0.7);
  transition: transform 0.15s ease;
}

.slider-track::-webkit-slider-thumb:hover {
  transform: scale(1.3);
}

/* --------------------------------------------------------------------------
   SUMÁRIO DRAWER (TOC)
   -------------------------------------------------------------------------- */
.drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(3, 10, 15, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.drawer-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.toc-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 380px;
  max-width: 85vw;
  background: #071720;
  border-right: 1px solid rgba(197, 155, 88, 0.4);
  box-shadow: 10px 0 50px rgba(0, 0, 0, 0.8);
  z-index: 250;
  transform: translateX(-100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.toc-drawer.active {
  transform: translateX(0);
}

.drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(197, 155, 88, 0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-header h2 {
  font-family: var(--font-cinzel);
  font-size: 16px;
  color: var(--color-gold);
  letter-spacing: 2px;
  margin: 0;
}

.close-drawer-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(197, 155, 88, 0.3);
  color: #FFF;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.toc-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  list-style: none;
  margin: 0;
}

.toc-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 13px;
  color: rgba(250, 248, 243, 0.85);
  margin-bottom: 4px;
}

.toc-item:hover {
  background: rgba(197, 155, 88, 0.15);
  color: #FFF;
}

.toc-item-major {
  font-weight: 700;
  color: var(--color-gold);
  font-family: var(--font-cinzel);
}

.toc-item-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-item-dots {
  flex: 1;
  border-bottom: 1px dotted rgba(197, 155, 88, 0.4);
  margin: 0 8px;
  min-width: 15px;
}

.toc-item-page {
  font-weight: 700;
  color: var(--color-gold);
}

/* --------------------------------------------------------------------------
   MODO ROLAGEM CONTÍNUA (CONTINUOUS SCROLL MODE)
   -------------------------------------------------------------------------- */
body.mode-scroll .ebook-stage {
  display: none !important;
}

#scrollContainer {
  display: none;
}

body.mode-scroll #scrollContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
  padding: 30px 16px;
  overflow-y: auto;
  height: calc(100vh - 116px);
  -webkit-overflow-scrolling: touch;
}

body.mode-scroll .scroll-page-wrap {
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(197, 155, 88, 0.3);
  border-radius: 4px;
  background: var(--color-paper);
}

/* --------------------------------------------------------------------------
   MODO IMERSIVO (OCULTAR HUD)
   -------------------------------------------------------------------------- */
body.hud-hidden .app-header {
  transform: translateY(-100%);
}

body.hud-hidden .app-footer {
  transform: translateY(100%);
}

.hud-floating-trigger {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 999;
  background: rgba(7, 20, 26, 0.85);
  border: 1px solid rgba(197, 155, 88, 0.4);
  color: var(--color-gold);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0,0,0,0.6);
}

body.hud-hidden .hud-floating-trigger {
  display: flex;
}

/* --------------------------------------------------------------------------
   RESPONSIVIDADE MOBILE
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .app-header {
    height: 52px;
    padding: 0 12px;
  }
  .brand-text h1 {
    font-size: 12px;
  }
  .brand-text p {
    display: none;
  }
  .freq-selector-wrapper {
    display: none;
  }
  .tool-btn span {
    display: none;
  }
  .tool-btn {
    padding: 6px 8px;
  }
  .mindmap-page-title {
    font-size: 9px;
    letter-spacing: 0.6px;
  }
  .app-footer {
    height: 50px;
    padding: 0 10px;
  }
  .nav-arrow-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }
  .nav-progress-wrapper {
    margin: 0 8px;
    gap: 8px;
    min-width: 0;
  }
  .page-indicator-text {
    font-size: 10px;
  }
  .slider-track {
    min-width: 60px;
  }
}
