/*
 * RAYAN LOGISTICS — Layout, Controls, Navigation & Modals
 */

/* Fullscreen Application Stage */
.rayan-stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.75) 0%, rgba(247, 246, 241, 0.95) 70%, rgba(236, 237, 233, 1) 100%);
  user-select: none;
  -webkit-user-select: none;
}

/* Reading Progress Bar */
.reading-progress-track {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 3px;
  background: rgba(24, 44, 62, 0.08);
  z-index: 200;
}

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

/* Top Floating Utility Bar */
.book-top-bar {
  position: fixed;
  top: 18px;
  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 var(--color-divider-grey);
  box-shadow: 0 4px 18px rgba(24, 44, 62, 0.08);
  z-index: 100;
  transition: opacity 0.3s ease;
}

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

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

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

/* 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 12px;
  border-radius: 16px;
  color: var(--color-slate-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-btn:hover {
  color: var(--color-navy-primary);
}

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

/* Control Buttons */
.ctrl-btn {
  background: transparent;
  border: none;
  color: var(--color-slate-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 6px 12px;
  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 {
  background: var(--color-navy-primary);
  color: #FFFFFF;
}

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

/* Side Floating Desktop Arrows */
.side-nav-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--color-divider-grey);
  box-shadow: 0 4px 16px rgba(24, 44, 62, 0.1);
  color: var(--color-navy-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 90;
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.side-nav-btn:hover:not(:disabled) {
  background: #FFFFFF;
  box-shadow: 0 6px 22px rgba(24, 44, 62, 0.16);
  transform: translateY(-50%) scale(1.08);
}

.side-nav-btn:active:not(:disabled) {
  transform: translateY(-50%) scale(0.96);
}

.side-nav-btn:disabled {
  opacity: 0.22;
  cursor: not-allowed;
  pointer-events: none;
}

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

/* Bottom Floating Navigation Bar */
.book-bottom-bar {
  position: fixed;
  bottom: 18px;
  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: 6px 14px;
  border-radius: 30px;
  border: 1px solid var(--color-divider-grey);
  box-shadow: 0 4px 18px rgba(24, 44, 62, 0.08);
  z-index: 100;
}

.nav-arrow-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: none;
  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-bg-warm-grey);
}

.nav-arrow-btn:active:not(:disabled) {
  transform: scale(0.92);
}

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

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

/* Table of Contents Modal Drawer */
.toc-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(24, 44, 62, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.toc-overlay.open {
  opacity: 1;
  visibility: visible;
}

.toc-drawer {
  background: #FFFFFF;
  border-radius: 12px;
  width: min(90vw, 760px);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(24, 44, 62, 0.25);
  padding: 24px 28px;
  box-sizing: border-box;
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.toc-overlay.open .toc-drawer {
  transform: 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: 18px;
}

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

.toc-close-btn {
  background: transparent;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: var(--color-slate-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.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(210px, 1fr));
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
}

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

[dir="rtl"] .toc-item-card {
  text-align: right;
}

.toc-item-card:hover {
  background: #FFFFFF;
  border-color: var(--color-teal-accent);
  box-shadow: 0 4px 12px rgba(24, 44, 62, 0.08);
  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: 32px;
  height: 32px;
  border-radius: 6px;
  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;
  letter-spacing: 0.06em;
}

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

/* Zoom / Enlargement Mode */
.rayan-stage.mode-zoomed {
  overflow: auto !important;
}

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

/* Responsive Overrides for Controls */
@media (max-width: 899px) {
  .book-top-bar {
    top: max(8px, env(safe-area-inset-top));
    padding: 5px 12px;
    gap: 8px;
    max-width: calc(100vw - 16px);
  }

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

  .ctrl-btn span {
    display: none;
  }

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

  .book-bottom-bar {
    bottom: max(10px, env(safe-area-inset-bottom));
    padding: 4px 12px;
    max-width: calc(100vw - 20px);
  }

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

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