/* ============================================ */
/* ============ RESET E VARIÁVEIS ============== */
/* ============================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --jf-purple: #aa5cc3;
  --jf-blue:   #00a4dc;
  --jf-bg:     #101010;
  --jf-bg-2:   #181818;
  --jf-bg-3:   #202020;
  --jf-text:   #ffffff;
  --jf-dim:    #b3b3b3;
  --jf-border: #2a2a2a;
  --radius:    8px;
}

html, body {
  height: 100%;
  background: var(--jf-bg);
  color: var(--jf-text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  user-select: none;
}

/* ============================================ */
/* ============ TEMA CLARO ===================== */
/* ============================================ */
body.theme-light {
  --jf-bg:     #f0f0f0;
  --jf-bg-2:   #ffffff;
  --jf-bg-3:   #e0e0e0;
  --jf-text:   #1a1a1a;
  --jf-dim:    #666666;
  --jf-border: #d0d0d0;
}

body.theme-light #welcome {
  background: radial-gradient(circle at center, #ffffff 0%, #e8e8e8 100%);
}

body.theme-light .reader-topbar {
  background: linear-gradient(to bottom, rgba(255,255,255,.95) 0%, rgba(255,255,255,.85) 100%);
}

body.theme-light .reader-bottombar {
  background: linear-gradient(to top, rgba(255,255,255,.95) 0%, rgba(255,255,255,.85) 100%);
}

body.theme-light .topbar-btn { color: #333; }
body.theme-light .topbar-btn:hover { background: rgba(0,0,0,.08); }

body.theme-light .welcome-hint { color: #888; }
body.theme-light .welcome-hint b { color: #555; }

body.theme-light #reader-bg {
  filter: blur(60px) brightness(1.6) saturate(1.2);
}

body.theme-light #reader-bg::after {
  background: rgba(255, 255, 255, 0.55);
}

body.theme-light .welcome-shortcuts { color: #888; }
body.theme-light .welcome-shortcuts b { color: #666; }
body.theme-light .welcome-shortcuts kbd { background: #e0e0e0; color: #333; border-color: #c0c0c0; }

/* ============================================ */
/* ============ TELA INICIAL =================== */
/* ============================================ */
#welcome {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #1a1a1a 0%, #0a0a0a 100%);
  z-index: 1000;
  transition: opacity .4s;
  padding: 24px 20px;
  overflow-y: auto;
  text-align: center;
}

#welcome.hidden { opacity: 0; pointer-events: none; }

.welcome-logo {
  font-size: 64px;
  margin-bottom: 20px;
  filter: drop-shadow(0 0 20px rgba(170, 92, 195, .4));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

.welcome-title {
  font-size: 44px;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 14px;
  letter-spacing: -1px;
  color: var(--jf-text);
  max-width: 90vw;
  text-align: center;
}

.welcome-title br {
  display: block;
  content: "";
  margin: 4px 0;
}

.title-books {
  background: linear-gradient(135deg, #aa5cc3 0%, #c77ed8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.title-comics {
  background: linear-gradient(135deg, #00a4dc 0%, #4dc3e8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-sub {
  font-size: 15px;
  color: var(--jf-dim);
  margin-bottom: 40px;
  text-align: center;
  max-width: 90vw;
}

.welcome-btn {
  background: linear-gradient(135deg, #aa5cc3 0%, #00a4dc 100%);
  color: #fff;
  border: none;
  padding: 16px 40px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 8px 24px rgba(0, 164, 220, .3);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.welcome-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 164, 220, .5);
}

.welcome-btn:active { transform: translateY(0); }

.welcome-formats {
  margin-top: 24px;
  font-size: 13px;
  color: #555;
  letter-spacing: .5px;
}

.welcome-formats span {
  display: inline-block;
  padding: 4px 10px;
  margin: 0 4px;
  background: var(--jf-bg-2);
  border-radius: 4px;
  border: 1px solid var(--jf-border);
}

.welcome-hint {
  margin-top: 32px;
  font-size: 12px;
  color: #444;
  max-width: 420px;
  text-align: center;
  line-height: 1.6;
}

.welcome-hint b { color: #666; }

.welcome-shortcuts {
  margin-top: 20px;
  font-size: 11px;
  color: #555;
  text-align: center;
  line-height: 2;
  max-width: 500px;
}

.welcome-shortcuts b { color: #777; display: block; margin-bottom: 6px; }

.welcome-shortcuts span {
  display: inline-block;
  margin: 0 6px;
  white-space: nowrap;
}

.welcome-shortcuts kbd {
  display: inline-block;
  padding: 1px 6px;
  background: var(--jf-bg-2);
  border: 1px solid var(--jf-border);
  border-radius: 3px;
  font-family: monospace;
  font-size: 10px;
  color: var(--jf-text);
  margin: 0 1px;
}

/* ============================================ */
/* ============ LEITOR ========================= */
/* ============================================ */
#reader {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  background: transparent;
}

#reader.active { display: flex; }

/* ---- Fundo com capa desfocada ---- */
#reader-bg {
  position: absolute;
  inset: 0;
  background-color: #0a0a0a;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(50px) brightness(0.5) saturate(1.3);   /* mais claro */
  transform: scale(1.2);
  z-index: 0;
  transition: background-image .5s;
  pointer-events: none;
  will-change: background-image;
}

#reader-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);   /* menos escuro */
}

/* ---- Barra superior ---- */
.reader-topbar {
  height: 52px;
  background: linear-gradient(to bottom, rgba(0,0,0,.95) 0%, rgba(0,0,0,.7) 100%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  z-index: 10;
  transition: transform .3s, opacity .3s;
  flex-shrink: 0;
  backdrop-filter: blur(8px);
  position: relative;
}

.reader-topbar.hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.topbar-btn {
  background: transparent;
  border: none;
  color: var(--jf-text);
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 18px;
  transition: background .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  font-family: inherit;
}

.topbar-btn:hover { background: rgba(255,255,255,.1); }

#btn-bookmark.active {
  color: var(--jf-blue);
  background: rgba(0, 164, 220, .15);
}

.topbar-title {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: .9;
}

/* ---- Área central ---- */
.reader-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  padding: 20px;
  perspective: 2500px;
  z-index: 1;
  background: transparent;
  cursor: grab;
}

.reader-stage.zoomed { cursor: grab; }
.reader-stage.panning { cursor: grabbing; }

.reader-stage.panning #flipbook { transition: none; }

#flipbook {
  box-shadow: 0 30px 80px rgba(0,0,0,.9);
  transition: transform .15s ease-out;
  will-change: transform;
  transform-origin: center center;
}

#flipbook .page {
  background: #fff;
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(0,0,0,.05);
}

#flipbook .page img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  -webkit-user-drag: none;
  pointer-events: none;
  background: #1a1a1a;
}

/* ---- Zonas clicáveis ---- */
.click-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 25%;
  cursor: pointer;
  z-index: 5;
  transition: background .15s;
}

.click-zone.left  { left: 0; }
.click-zone.right { right: 0; }

.click-zone.left:hover  { background: linear-gradient(to right, rgba(0,164,220,.06), transparent); }
.click-zone.right:hover { background: linear-gradient(to left,  rgba(0,164,220,.06), transparent); }

/* ---- Barra inferior ---- */
.reader-bottombar {
  height: 64px;
  background: linear-gradient(to top, rgba(0,0,0,.95) 0%, rgba(0,0,0,.7) 100%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  z-index: 10;
  transition: transform .3s, opacity .3s;
  flex-shrink: 0;
  backdrop-filter: blur(8px);
  position: relative;
}

.reader-bottombar.hidden {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

.page-info {
  font-size: 13px;
  color: var(--jf-dim);
  font-variant-numeric: tabular-nums;
  min-width: 90px;
  text-align: center;
  font-weight: 500;
}

.page-info b { color: var(--jf-text); font-weight: 600; }

.slider {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: #2a2a2a;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--jf-blue);
  cursor: pointer;
  box-shadow: 0 0 12px rgba(0,164,220,.6);
  transition: transform .15s;
  border: 2px solid #fff;
}

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

.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--jf-blue);
  cursor: pointer;
  border: 2px solid #fff;
}

/* ---- Indicador de zoom ---- */
.zoom-indicator {
  font-size: 12px;
  color: var(--jf-dim);
  font-variant-numeric: tabular-nums;
  min-width: 50px;
  text-align: center;
  font-weight: 600;
  padding: 0 6px;
  user-select: none;
}

.zoom-indicator.active { color: var(--jf-blue); }

/* ---- Loading ---- */
.loading {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10,10,10,.95);
  z-index: 100;
  gap: 20px;
  backdrop-filter: blur(4px);
}

.loading.active { display: flex; }

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,.1);
  border-top-color: var(--jf-blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

.loading-text {
  font-size: 14px;
  color: var(--jf-dim);
  font-weight: 500;
}

.loading-progress {
  width: 240px;
  height: 4px;
  background: var(--jf-border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

.loading-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #aa5cc3, #00a4dc);
  border-radius: 2px;
  transition: width .2s;
  width: 0%;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30,30,30,.95);
  color: var(--jf-text);
  padding: 12px 20px;
  border-radius: 8px;
  border: 1px solid var(--jf-border);
  font-size: 13px;
  opacity: 0;
  transition: opacity .3s, transform .3s;
  z-index: 200;
  pointer-events: none;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  max-width: 90%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast b { color: var(--jf-blue); }

/* ============================================ */
/* ============ BOOKMARKS (painel) ============= */
/* ============================================ */
.bookmarks-panel {
  position: fixed;
  top: 52px;
  right: 0;
  bottom: 64px;
  width: 320px;
  background: rgba(20, 20, 20, 0.97);
  border-left: 1px solid var(--jf-border);
  backdrop-filter: blur(12px);
  z-index: 20;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4, 0, .2, 1);
  display: flex;
  flex-direction: column;
}

.bookmarks-panel.open { transform: translateX(0); }

body.theme-light .bookmarks-panel {
  background: rgba(255, 255, 255, 0.98);
}

.bookmarks-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--jf-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bookmarks-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .3px;
}

.bookmarks-count {
  font-size: 11px;
  color: var(--jf-dim);
  background: var(--jf-bg-3);
  padding: 2px 8px;
  border-radius: 10px;
}

.bookmarks-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.bookmarks-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--jf-dim);
  font-size: 13px;
  line-height: 1.6;
}

.bookmarks-empty-icon {
  font-size: 42px;
  margin-bottom: 12px;
  opacity: .3;
}

.bookmark-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
  position: relative;
}

.bookmark-item:hover { background: var(--jf-bg-3); }

.bookmark-thumb {
  width: 44px;
  height: 60px;
  border-radius: 4px;
  object-fit: cover;
  background: #222;
  flex-shrink: 0;
  border: 1px solid var(--jf-border);
}

.bookmark-info { flex: 1; min-width: 0; }

.bookmark-page {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}

.bookmark-date {
  font-size: 11px;
  color: var(--jf-dim);
}

.bookmark-note {
  font-size: 11px;
  color: var(--jf-dim);
  margin-top: 4px;
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bookmark-delete {
  background: transparent;
  border: none;
  color: var(--jf-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  font-size: 14px;
  opacity: 0;
  transition: opacity .15s, color .15s;
}

.bookmark-item:hover .bookmark-delete { opacity: 1; }

.bookmark-delete:hover { color: #ff6b6b; background: rgba(255,107,107,.1); }

/* ============================================ */
/* ============ RESPONSIVO ===================== */
/* ============================================ */
@media (max-width: 768px) {
  .welcome-title { font-size: 32px; letter-spacing: -0.5px; }
  .welcome-logo  { font-size: 52px; }
  .welcome-sub   { font-size: 14px; margin-bottom: 32px; }
  .welcome-btn   { padding: 14px 28px; font-size: 15px; }
  .reader-bottombar { gap: 4px; padding: 0 8px; }
  .page-info { min-width: 55px; font-size: 12px; }
  .zoom-indicator { min-width: 40px; font-size: 11px; }
  .topbar-btn { min-width: 34px; height: 34px; padding: 6px; font-size: 16px; }
  .reader-stage { padding: 10px; }
  .bookmarks-panel { width: 90%; }
  .reader-topbar { gap: 4px; padding: 0 8px; }
}

@media (max-width: 500px) {
  .welcome-title { font-size: 26px; }
  .welcome-logo  { font-size: 44px; }
  .welcome-shortcuts { font-size: 10px; }
  .welcome-shortcuts span { margin: 0 3px; }
}