/*
 * RAYAN LOGISTICS — Discreet Book Controls, TOC Modal & Navigation
 */

/* =====================================================================
   TOP FLOATING UTILITY BAR
   ===================================================================== */
.book-top-bar {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 8px 18px;
  border-radius: 30px;
  border: 1px solid rgba(218, 221, 216, 0.9);
  box-shadow: 0 4px 16px rgba(24, 44, 62, 0.08);
  z-index: 100;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.book-brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--color-navy-primary);
  text-transform: uppercase;
}

.brand-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-teal-accent);
}

.divider-vert {
  width: 1px;
  height: 14px;
  background-color: var(--color-divider-grey);
}

/* Control Buttons */
.ctrl-btn {
  background: transparent;
  border: none;
  color: var(--color-slate-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.ctrl-btn:hover {
  background: var(--color-bg-warm-grey);
  color: var(--color-navy-primary);
}

.ctrl-btn:active {
  transform: scale(0.96);
}

.ctrl-btn.active {
  background: var(--color-navy-primary);
  color: #FFFFFF;
}

.ctrl-icon {
  width: 15px;
  height: 15px;
}

/* Bilingual Switcher Pill */
.lang-switcher-pill {
  display: flex;
  align-items: center;
  background: var(--color-bg-warm-grey);
  border-radius: 20px;
  padding: 3px;
  border: 1px solid var(--color-divider-grey);
}

.lang-btn {
  background: transparent;
  border: none;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 16px;
  cursor: pointer;
  color: var(--color-slate-muted);
  transition: all 0.2s ease;
}

.lang-btn.active {
  background: var(--color-navy-primary);
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(24, 44, 62, 0.2);
}

/* =====================================================================
   BOTTOM FLOATING NAVIGATION BAR
   ===================================================================== */
.book-bottom-bar {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 8px 18px;
  border-radius: 30px;
  border: 1px solid rgba(218, 221, 216, 0.9);
  box-shadow: 0 6px 20px rgba(24, 44, 62, 0.1);
  z-index: 100;
}

.nav-arrow-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--color-divider-grey);
  background: #FFFFFF;
  color: var(--color-navy-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-arrow-btn:hover:not(:disabled) {
  background: var(--color-teal-accent);
  color: #FFFFFF;
  border-color: var(--color-teal-accent);
  transform: scale(1.05);
}

.nav-arrow-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-indicator-pill {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-navy-primary);
  letter-spacing: 0.04em;
  padding: 4px 12px;
  background: var(--color-bg-warm-grey);
  border-radius: 14px;
  min-width: 90px;
  text-align: center;
}

/* Top Subtle Reading Progress Bar */
.reading-progress-track {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(218, 221, 216, 0.5);
  z-index: 150;
}

.reading-progress-fill {
  height: 100%;
  background: linear-gradient(to right, var(--color-teal-accent), var(--color-navy-primary));
  width: 10%;
  transition: width 0.4s ease;
}

/* =====================================================================
   SIDE FLOATING ARROWS (DESKTOP)
   ===================================================================== */
.side-nav-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(218, 221, 216, 0.8);
  box-shadow: 0 4px 12px rgba(24, 44, 62, 0.08);
  color: var(--color-navy-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 80;
  transition: all 0.25s ease;
}

.side-nav-btn:hover:not(:disabled) {
  background: var(--color-navy-primary);
  color: #FFFFFF;
  transform: translateY(-50%) scale(1.08);
}

.side-nav-btn:disabled {
  opacity: 0;
  pointer-events: none;
}

.side-prev { left: 24px; }
.side-next { right: 24px; }

/* In RTL, swap visual arrows */
[data-lang="ar"] .side-prev { right: 24px; left: auto; }
[data-lang="ar"] .side-next { left: 24px; right: auto; }

/* =====================================================================
   TABLE OF CONTENTS MODAL / DRAWER
   ===================================================================== */
.toc-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(24, 44, 62, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.toc-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.toc-drawer {
  background: var(--color-paper-white);
  border-radius: 8px;
  width: min(92vw, 760px);
  max-height: 85vh;
  padding: 32px 36px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.98);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
}

.toc-overlay.open .toc-drawer {
  transform: translateY(0) scale(1);
}

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-divider-grey);
  margin-bottom: 20px;
}

.toc-title {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-navy-primary);
  margin: 0;
}

.toc-close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--color-slate-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.toc-close-btn:hover {
  background: var(--color-bg-warm-grey);
  color: var(--color-navy-primary);
}

.toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  overflow-y: auto;
  padding-right: 6px;
}

.toc-item-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--color-bg-ivory);
  border: 1px solid var(--color-divider-grey);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

[data-lang="ar"] .toc-item-card {
  text-align: right;
}

.toc-item-card:hover {
  background: var(--color-bg-warm-grey);
  border-color: var(--color-teal-accent);
  transform: translateY(-2px);
}

.toc-item-card.current-active {
  background: rgba(100, 140, 135, 0.12);
  border-color: var(--color-teal-accent);
}

.toc-thumb-num {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--color-navy-primary);
  color: #FFFFFF;
  font-size: var(--text-xs);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toc-item-info {
  display: flex;
  flex-direction: column;
}

.toc-item-category {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--color-teal-accent);
  text-transform: uppercase;
}

.toc-item-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-navy-primary);
  line-height: 1.3;
}

/* =====================================================================
   ZOOM / ENLARGEMENT MODE
   ===================================================================== */
.rayan-book-stage.mode-zoomed {
  overflow: auto !important;
  cursor: grab;
}

.rayan-book-stage.mode-zoomed .rayan-book {
  transform: scale(1.4) !important;
  transition: transform 0.3s ease;
}

/* Mobile Controls Adjustments */
@media (max-width: 860px) {
  .book-top-bar {
    top: max(8px, env(safe-area-inset-top));
    padding: 5px 12px;
    gap: 8px;
    max-width: calc(100vw - 20px);
    width: auto;
    justify-content: center;
    box-sizing: border-box;
  }

  .book-brand-badge span {
    display: none;
  }

  .book-bottom-bar {
    bottom: max(10px, env(safe-area-inset-bottom));
    padding: 5px 14px;
    max-width: calc(100vw - 20px);
    box-sizing: border-box;
  }

  .side-nav-btn {
    display: none;
  }

  .toc-drawer {
    width: 94vw;
    padding: 20px 16px;
    max-height: 80vh;
  }

  .toc-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
