/* ===== Reader View Styles ===== */

/* Reader Mode Toggle Buttons */
.reader-mode-btn { color: #64748b; background: transparent; }
.reader-mode-btn:hover { background: rgba(241, 245, 249, 0.8); color: #334155; }
.reader-mode-btn.is-active {
  background: #ffffff;
  color: #0f766e;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* TOC Nodes & Nesting */
.toc-node {
  display: flex;
  flex-direction: column;
}
.toc-children {
  margin-top: 2px;
  border-left: 1.5px solid rgba(241, 245, 249, 0.9);
  margin-left: 20px;
  padding-left: 2px;
}
.toc-children.hidden {
  display: none;
}

/* TOC Items */
.toc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 2px;
  border: 1px solid transparent;
}
.toc-item:hover {
  background: #f8fafc;
}
.toc-item.is-active {
  background: #f0fdfa;
  border-color: #99f6e4;
}

.toc-item-label {
  font-size: 13px;
  font-weight: 500;
  color: #334155;
  line-height: 1.4;
}
.toc-item.is-active .toc-item-label {
  color: #0f766e;
  font-weight: 600;
}

.toc-item-subtitle {
  font-size: 11px;
  font-weight: 500;
  color: #94a3b8;
}
.toc-item.is-active .toc-item-subtitle {
  color: #2dd4bf;
}

.toc-item-page {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  flex-shrink: 0;
  margin-left: 8px;
}
.toc-item.is-active .toc-item-page {
  color: #0d9488;
}

/* Chevron button on TOC */
.toc-chevron-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 3px;
  border-radius: 6px;
  transition: background 0.15s;
}
.toc-chevron-btn:hover {
  background: #e2e8f0;
}
.toc-chevron-btn svg {
  transition: transform 0.2s ease;
}

/* Book Page Spread */
.reader-book-spread {
  display: flex;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.12), 0 4px 20px rgba(0, 0, 0, 0.06);
  border-radius: 4px;
  overflow: hidden;
}
.reader-page {
  width: 300px;
  min-height: 400px;
  padding: 28px;
  position: relative;
}
.reader-page-left {
  border-right: 1px solid #e2e0d8;
  background: linear-gradient(to right, #f5f3ed, #fffef9 60%);
}
.reader-page-right {
  background: linear-gradient(to left, #f5f3ed, #fffef9 60%);
}

/* Page Thumbnails */
.page-thumb { flex-shrink: 0; cursor: pointer; }
.page-thumb-inner {
  width: 52px;
  height: 38px;
  border-radius: 7px;
  border: 1.5px solid #e2e8f0;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  transition: all 0.15s;
}
.page-thumb-inner:hover { border-color: #94a3b8; color: #64748b; }
.page-thumb-inner.is-active {
  border-color: #14b8a6;
  background: #f0fdfa;
  color: #0d9488;
  box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.15);
}

/* Reader Toolbar Buttons */
.reader-toolbar-btn {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.reader-toolbar-btn:hover { background: #f1f5f9; color: #334155; }
.reader-toolbar-btn.is-active {
  background: #f0fdfa;
  color: #0d9488;
  border-color: #ccfbf1;
}

/* Zoom Slider */
.zoom-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  outline: none;
}
.zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2px solid #14b8a6;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* TOC Sidebar Collapse */
#tocSidebar {
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s, padding 0.25s;
}
#tocSidebar.is-collapsed {
  width: 0 !important;
  padding: 0;
  opacity: 0;
  overflow: hidden;
  border-right: none;
}

/* TOC Scrollbar */
.toc-scroll::-webkit-scrollbar { width: 5px; }
.toc-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.toc-scroll::-webkit-scrollbar-track { background: transparent; }

/* Thumbnail strip scrollbar */
.thumbnail-strip {
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.thumbnail-strip:active {
  cursor: grabbing;
}
.thumbnail-strip::-webkit-scrollbar { height: 4px; }
.thumbnail-strip::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }
.thumbnail-strip::-webkit-scrollbar-track { background: transparent; }

/* ===== Flipbook Engine Styles ===== */

/* Vùng bao quanh sách – tạo độ sâu 3D */
.book-wrapper {
  perspective: 2000px;
}

/* Container sách: kích thước đôi, ẩn cho đến khi load xong */
#book-container {
  display: none;
  position: relative;
  transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
  will-change: transform;
}

/* 3 trạng thái dịch chuyển để sách luôn cân giữa màn hình */
#book-container.state-cover { transform: translateX(-25%); }
#book-container.state-open  { transform: translateX(0); }
#book-container.state-back  { transform: translateX(25%); }

/* Trang sách */
.page {
  background-color: #ffffff;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.page canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Hiệu ứng gáy sách (bóng rìa) */
.page-shadow {
  position: absolute;
  top: 0;
  width: 20px;
  height: 100%;
  z-index: 10;
  pointer-events: none;
}
.shadow-left  { right: 0; background: linear-gradient(to left,  rgba(0,0,0,0.15), transparent); }
.shadow-right { left:  0; background: linear-gradient(to right, rgba(0,0,0,0.15), transparent); }

/* Con trỏ chuột bàn tay trên vùng lật */
.st-page-flip-client-layer { cursor: pointer !important; }

/* Loading spinner */
.flipbook-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e2e8f0;
  border-top-color: #14b8a6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Scroll Mode Styles */
#scroll-container {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
#scroll-container::-webkit-scrollbar {
  width: 6px;
}
#scroll-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
.scroll-page {
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  background: #ffffff;
  transition: width 0.2s ease, height 0.2s ease;
}


