/* ==========================================================================
   In-Browser EPUB Reader & Previewer Styles
   ========================================================================== */

.preview-modal-dialog {
  width: 95vw;
  max-width: 980px;
  height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.reader-toolbar {
  padding: 12px 20px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.reader-controls-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.reader-book-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.reader-tool-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.reader-tool-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

.reader-theme-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
}

.theme-pill {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition-fast);
}

.theme-pill:hover {
  transform: scale(1.15);
}

.theme-pill.active {
  border-color: var(--accent-primary);
}

.theme-pill-dark {
  background: #0f172a;
}

.theme-pill-sepia {
  background: #fbf0d9;
}

.theme-pill-light {
  background: #ffffff;
}

/* Reader Main Workspace */
.reader-workspace {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* Reader Sidebar / TOC */
.reader-toc-sidebar {
  width: 280px;
  background: var(--bg-tertiary);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}

.reader-toc-sidebar.collapsed {
  transform: translateX(-100%);
  position: absolute;
  height: 100%;
  z-index: 10;
}

.toc-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.toc-list {
  list-style: none;
  padding: 12px 0;
  margin: 0;
}

.toc-item {
  padding: 10px 20px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.toc-item.active {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-cyan);
  border-left-color: var(--accent-primary);
  font-weight: 600;
}

/* Reader Page Viewport */
.reader-viewport-container {
  flex: 1;
  overflow-y: auto;
  padding: 40px;
  display: flex;
  justify-content: center;
  transition: background-color var(--transition-normal);
}

.reader-sheet {
  max-width: 680px;
  width: 100%;
  line-height: 1.8;
  font-size: 1.05rem;
  min-height: 100%;
}

/* Reader Color Schemes */
.reader-viewport-container.theme-dark {
  background: #0b0f19;
  color: #e2e8f0;
}

.reader-viewport-container.theme-sepia {
  background: #fbf0d9;
  color: #433422;
}

.reader-viewport-container.theme-sepia .reader-sheet h1,
.reader-viewport-container.theme-sepia .reader-sheet h2,
.reader-viewport-container.theme-sepia .reader-sheet h3 {
  color: #2c2013;
}

.reader-viewport-container.theme-light {
  background: #ffffff;
  color: #1e293b;
}

.reader-viewport-container.theme-light .reader-sheet h1,
.reader-viewport-container.theme-light .reader-sheet h2,
.reader-viewport-container.theme-light .reader-sheet h3 {
  color: #0f172a;
}

/* Reader Typography elements */
.reader-sheet h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 24px;
  line-height: 1.25;
}

.reader-sheet h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 32px 0 16px;
}

.reader-sheet p {
  margin-bottom: 20px;
  text-align: justify;
}

.reader-sheet img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 20px auto;
  display: block;
}

/* Reader Footer Navigation */
.reader-footer {
  padding: 12px 24px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.reader-page-indicator {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.nav-chapter-btn {
  padding: 6px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.nav-chapter-btn:hover:not(:disabled) {
  border-color: var(--accent-primary);
  background: var(--accent-primary);
  color: #ffffff;
}

.nav-chapter-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .preview-modal-dialog {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
  .reader-viewport-container {
    padding: 24px 16px;
  }
  .reader-toc-sidebar {
    position: absolute;
    height: 100%;
    z-index: 20;
    box-shadow: var(--shadow-lg);
  }
}
