/* =============================================
   MANGA READER — reader.css (refactored)
   ============================================= */

/* ── Base wrapper ────────────────────────────── */
.reader-wrapper {
  min-height: 100vh;
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Top navigation bar ──────────────────────── */
.reader-nav {
  background: rgba(10, 10, 10, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255, 107, 53, 0.25);
}

.reader-nav-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.reader-info h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

.reader-info p {
  color: #ff6b35;
  font-size: 0.8rem;
}

.reader-nav-links {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.reader-nav-links a {
  padding: 0.4rem 0.85rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  font-size: 0.82rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.reader-nav-links a:hover {
  background: #ff6b35;
  color: white;
}

/* ── Controls bar (below nav) ────────────────── */
.reader-controls-bar {
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 0.5rem 1rem;
  position: sticky;
  top: 56px;
  z-index: 99;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.controls-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.3rem 0.75rem;
  border-radius: 50px;
  border: 1px solid rgba(255,255,255,0.07);
}

.control-group label {
  font-size: 0.78rem;
  color: #aaa;
  white-space: nowrap;
}

.control-group select,
.control-group input[type="number"] {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
  padding: 0.2rem 0.4rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.82rem;
}

.control-group select:focus,
.control-group input:focus {
  outline: none;
  border-color: #ff6b35;
}

.control-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: white;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  line-height: 1;
}

.control-btn:hover {
  background: #ff6b35;
  transform: scale(1.05);
}

.control-btn:active {
  transform: scale(0.95);
}

.page-indicator-text {
  font-size: 0.85rem;
  color: #ff6b35;
  font-weight: 600;
  min-width: 50px;
  text-align: center;
}

.zoom-level {
  font-size: 0.82rem;
  color: #ccc;
  min-width: 38px;
  text-align: center;
}

/* ── Main image viewer ───────────────────────── */
.viewer-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1rem 1rem 5rem; /* bottom padding so fixed nav-bar doesn't cover image */
  min-height: calc(100vh - 108px);
  /* Allow left/right click areas */
  position: relative;
}

.image-viewer {
  text-align: center;
  position: relative;
  width: 100%;
  max-width: 900px; /* cap comfortable reading width */
  user-select: none;
  -webkit-user-select: none;
}

.image-loader {
  position: relative;
  display: inline-block;
  width: 100%;
}

.image-viewer img#pageImage {
  width: 100%;
  max-width: 100%;
  height: auto;          /* never clip height — scroll naturally */
  object-fit: contain;
  display: block;
  margin: 0 auto;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
  border-radius: 4px;
  transition: opacity 0.2s ease;
}

/* Webtoon / scroll mode — images stack vertically */
.image-viewer.webtoon-mode {
  max-width: 800px;
}

.image-viewer.webtoon-mode img#pageImage {
  border-radius: 0;
  box-shadow: none;
  margin-bottom: 2px;
}

/* Double-page mode */
.image-viewer.double-page-mode {
  max-width: 1400px;
}

/* Loading overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 4px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  z-index: 10;
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ── Click navigation zones ──────────────────── */
.click-zone {
  position: fixed;
  top: 108px;
  bottom: 60px;
  width: 20%;
  z-index: 50;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.click-zone:hover {
  opacity: 1;
}

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

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

.click-zone-icon {
  font-size: 2rem;
  color: rgba(255,255,255,0.7);
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

/* ── Bottom page navigation (always visible) ─── */
.page-navigation {
  background: rgba(12, 12, 12, 0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.75rem 1.5rem;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 98;
  border-top: 1px solid rgba(255, 107, 53, 0.2);
  /* FIXED: always visible — removed transform hide */
}

.nav-container {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.nav-btn {
  background: #ff6b35;
  border: none;
  color: white;
  padding: 0.55rem 1.25rem;
  border-radius: 50px;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  white-space: nowrap;
}

.nav-btn:hover:not(:disabled) {
  background: #ff8c5a;
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(255, 107, 53, 0.35);
}

.nav-btn:disabled {
  background: #444;
  cursor: not-allowed;
  opacity: 0.5;
}

.page-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.07);
  padding: 0.4rem 1rem;
  border-radius: 50px;
}

.page-indicator select {
  background: #222;
  border: 1px solid #ff6b35;
  color: white;
  padding: 0.3rem 0.6rem;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.85rem;
}

.page-indicator > span {
  color: #ff6b35;
  font-weight: 700;
  font-size: 0.85rem;
}

/* ── Floating side tools ─────────────────────── */
.view-tools {
  position: fixed;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(10px);
  border-radius: 50px;
  padding: 0.75rem 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 97;
  border: 1px solid rgba(255, 107, 53, 0.2);
}

.tool-btn {
  background: transparent;
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool-btn:hover {
  background: #ff6b35;
  transform: scale(1.1);
}

.tool-btn.active {
  background: #ff6b35;
}

/* ── Settings panel ──────────────────────────── */
.settings-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  background: #181818;
  border-radius: 16px;
  padding: 1.75rem;
  max-width: 460px;
  width: 90%;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255,107,53,0.4);
}

.settings-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-header h3 {
  color: #ff6b35;
  font-size: 1.05rem;
}

.close-settings {
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.3rem;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.close-settings:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.setting-item {
  margin-bottom: 1.25rem;
}

.setting-item label {
  display: block;
  margin-bottom: 0.4rem;
  color: #bbb;
  font-size: 0.9rem;
  font-weight: 500;
}

.setting-item select,
.setting-item input[type="range"] {
  width: 100%;
  padding: 0.5rem;
  background: #2a2a2a;
  border: 1px solid #444;
  color: white;
  border-radius: 8px;
  font-size: 0.9rem;
}

.theme-preview {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.4rem;
}

.theme-option {
  flex: 1;
  padding: 0.45rem;
  text-align: center;
  background: #2a2a2a;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  font-size: 0.82rem;
}

.theme-option:hover {
  transform: translateY(-2px);
}

.theme-option.active {
  border-color: #ff6b35;
  background: rgba(255, 107, 53, 0.15);
}

/* Mode options (webtoon etc) */
.mode-options {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mode-option {
  flex: 1;
  min-width: 80px;
  padding: 0.4rem 0.5rem;
  text-align: center;
  background: #2a2a2a;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  font-size: 0.78rem;
  color: #ccc;
}

.mode-option:hover { transform: translateY(-1px); }

.mode-option.active {
  border-color: #ff6b35;
  background: rgba(255,107,53,0.15);
  color: white;
}

/* ── Overlay (behind settings/etc) ───────────── */
.reader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 199;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.reader-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ── Keyboard hint ───────────────────────────── */
.keyboard-hint {
  position: fixed;
  bottom: 62px;
  left: 16px;
  background: rgba(0, 0, 0, 0.7);
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  font-size: 0.7rem;
  color: #666;
  pointer-events: none;
  z-index: 96;
  font-family: monospace;
}

/* ── Reading progress bar (top) ──────────────── */
.progress-indicator {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  z-index: 102;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff6b35, #ffb347);
  width: 0%;
  transition: width 0.3s ease;
}

/* ── Chapter selector panel ──────────────────── */
.chapter-selector {
  position: fixed;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  background: rgba(12, 12, 12, 0.96);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 1rem;
  z-index: 97;
  max-height: 420px;
  overflow-y: auto;
  width: 220px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  border: 1px solid rgba(255, 107, 53, 0.25);
}

.chapter-selector.active {
  opacity: 1;
  visibility: visible;
}

.chapter-selector h4 {
  margin-bottom: 0.75rem;
  color: #ff6b35;
  text-align: center;
  font-size: 0.9rem;
}

.chapter-list {
  list-style: none;
}

.chapter-list li {
  margin-bottom: 0.35rem;
}

.chapter-list a {
  display: block;
  padding: 0.4rem 0.6rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  transition: all 0.2s ease;
  font-size: 0.82rem;
  color: #ccc;
}

.chapter-list a:hover,
.chapter-list a.active {
  background: #ff6b35;
  color: white;
}

.chapter-list small {
  display: block;
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 2px;
}

/* ── Toggle chapter list button ──────────────── */
.toggle-chapter-list {
  position: fixed;
  left: 12px;
  bottom: 68px;
  background: rgba(10, 10, 10, 0.88);
  border: 1px solid rgba(255,107,53,0.3);
  color: white;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 98;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.toggle-chapter-list:hover {
  background: #ff6b35;
}

/* ── Themes ──────────────────────────────────── */
body.reader-light {
  background: #f0f0f0;
}
body.reader-light .reader-wrapper {
  background: #f0f0f0;
}
body.reader-light .reader-nav,
body.reader-light .reader-controls-bar,
body.reader-light .page-navigation,
body.reader-light .view-tools,
body.reader-light .settings-panel,
body.reader-light .chapter-selector,
body.reader-light .toggle-chapter-list {
  background: rgba(255, 255, 255, 0.97);
  border-color: #ddd;
}
body.reader-light .reader-info h2,
body.reader-light .control-group label,
body.reader-light .control-btn,
body.reader-light .tool-btn,
body.reader-light .keyboard-hint {
  color: #333;
}
body.reader-light .control-btn:hover,
body.reader-light .tool-btn:hover {
  background: #ff6b35;
  color: white;
}
body.reader-light .chapter-list a { color: #333; }
body.reader-light .chapter-list a:hover,
body.reader-light .chapter-list a.active { background: #ff6b35; color: white; }
body.reader-light .image-viewer img#pageImage {
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

body.reader-sepia { background: #f4ecd8; }
body.reader-sepia .reader-wrapper { background: #f4ecd8; }
body.reader-sepia .reader-nav,
body.reader-sepia .reader-controls-bar,
body.reader-sepia .page-navigation,
body.reader-sepia .view-tools,
body.reader-sepia .settings-panel,
body.reader-sepia .chapter-selector {
  background: rgba(244, 236, 216, 0.97);
  border-color: #c4a882;
}
body.reader-sepia .reader-info h2,
body.reader-sepia .control-group label,
body.reader-sepia .control-btn,
body.reader-sepia .tool-btn { color: #5b4636; }
body.reader-sepia .control-btn:hover,
body.reader-sepia .tool-btn:hover { background: #ff6b35; color: white; }
body.reader-sepia .chapter-list a { color: #5b4636; }
body.reader-sepia .chapter-list a:hover,
body.reader-sepia .chapter-list a.active { background: #ff6b35; color: white; }
body.reader-sepia .image-viewer img#pageImage {
  box-shadow: 0 4px 20px rgba(91,70,54,0.2);
}

/* ── Fullscreen mode ─────────────────────────── */
.fullscreen-mode .reader-nav,
.fullscreen-mode .reader-controls-bar {
  display: none;
}
.fullscreen-mode .viewer-container {
  padding-top: 0.5rem;
}
.fullscreen-mode .image-viewer img#pageImage {
  max-height: 92vh;
  width: auto;
}

/* ── Spinner ─────────────────────────────────── */
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: #ff6b35;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Mobile ──────────────────────────────────── */
@media (max-width: 768px) {
  .reader-nav {
    padding: 0.6rem 1rem;
  }

  .reader-info h2 {
    font-size: 0.88rem;
    max-width: 180px;
  }

  .reader-info p {
    font-size: 0.72rem;
  }

  .reader-nav-links a {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
  }

  .reader-controls-bar {
    top: 52px;
    padding: 0.4rem 0.5rem;
  }

  .controls-container {
    gap: 0.4rem;
  }

  .control-group {
    padding: 0.25rem 0.5rem;
    font-size: 0.78rem;
  }

  .viewer-container {
    padding: 0.5rem 0.25rem 4.5rem;
    align-items: flex-start;
  }

  .image-viewer {
    max-width: 100%;
  }

  .image-viewer img#pageImage {
    border-radius: 2px;
  }

  .view-tools {
    right: 6px;
    gap: 0.4rem;
    padding: 0.6rem 0.3rem;
  }

  .tool-btn {
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
  }

  .chapter-selector {
    left: 8px;
    width: 190px;
  }

  .toggle-chapter-list {
    left: 8px;
    width: 34px;
    height: 34px;
    font-size: 0.9rem;
  }

  .keyboard-hint {
    display: none;
  }

  .nav-btn {
    padding: 0.5rem 0.9rem;
    font-size: 0.82rem;
  }

  .page-navigation {
    padding: 0.6rem 1rem;
  }

  /* hide zoom controls on tiny screens */
  .control-group:has(.zoom-out) { display: none; }
}

@media (max-width: 480px) {
  .reader-nav-links a:not(.prev-chapter):not(.next-chapter) {
    display: none; /* hide "Manga Info" link — save space */
  }

  .controls-container {
    justify-content: center;
  }

  /* Only keep page nav group and mode group on xs */
  .control-group:has(#gotoPage) { display: none; }

  .nav-container {
    gap: 0.5rem;
  }
}

/* ── Comments section ────────────────────────── */
.comments-section {
  user-select: text;
  -webkit-user-select: text;
}

.comment-form {
  margin-bottom: 1.5rem;
}

.comment-form textarea {
  width: 100%;
  padding: 0.75rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  color: white;
  resize: vertical;
  margin-bottom: 0.5rem;
  font-family: inherit;
  font-size: 0.9rem;
}

.comment-form textarea:focus {
  outline: none;
  border-color: #ff6b35;
}

.comment-item, .reply-item {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 1rem;
  border-radius: 10px;
  margin-bottom: 0.85rem;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.comment-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.comment-avatar,
.comment-avatar-placeholder {
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

.comment-avatar-placeholder {
  background: #ff6b35;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.comment-username {
  font-weight: 600;
  font-size: 0.88rem;
}

.comment-date {
  font-size: 0.7rem;
  color: #666;
}

.comment-text {
  margin-bottom: 0.5rem;
  line-height: 1.55;
  font-size: 0.9rem;
  color: #ddd;
}

.reply-btn, .delete-comment-btn {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: all 0.15s;
}

.reply-btn:hover { color: #ff6b35; background: rgba(255,107,53,0.1); }
.delete-comment-btn:hover { color: #ef4444; }

.replies-list {
  margin-left: 1.5rem;
  margin-top: 0.5rem;
  padding-left: 0.85rem;
  border-left: 2px solid rgba(255,107,53,0.3);
}

.reply-item {
  margin-bottom: 0.4rem;
}

.login-to-comment {
  text-align: center;
  padding: 1rem;
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
}

.login-to-comment a { color: #ff6b35; }

/* ── Reader toast notifications ──────────────── */
.reader-notification {
  animation: toastFade 2.5s ease forwards;
}

@keyframes toastFade {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0); }
  70%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(16px); }
}
