/* ==========================================================================
   Civilanka - "Design a Perfect Home" Online Booklet Viewer
   Premium Architectural Reader (View-Only / No Download)
   ========================================================================== */

:root {
  --bv-bg: #0b0d11;
  --bv-surface: #13171f;
  --bv-surface-card: #1a1f29;
  --bv-border: rgba(255, 255, 255, 0.08);
  --bv-border-active: #c5a880;
  --bv-accent: #c5a880;
  --bv-accent-hover: #dfc49e;
  --bv-text-primary: #f0f2f5;
  --bv-text-muted: #8a92a0;
  --bv-font-heading: 'Jost', -apple-system, BlinkMacSystemFont, sans-serif;
  --bv-font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --bv-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

/* Modal Overlay Wrapper */
.booklet-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(8, 10, 14, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s ease;
  user-select: none;
  -webkit-user-select: none;
}

.booklet-modal.bv-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Dedicated standalone page */
body.booklet-standalone-page {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bv-bg);
  font-family: var(--bv-font-body);
  user-select: none;
  -webkit-user-select: none;
}

.booklet-viewer-app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bv-bg);
  position: relative;
  overflow: hidden;
}

/* ── Top Header Toolbar ── */
.bv-toolbar {
  height: 60px;
  min-height: 60px;
  background: rgba(15, 18, 24, 0.96);
  border-bottom: 1px solid var(--bv-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 30;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* Left: Branding & Title */
.bv-toolbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 260px;
}

.bv-brand-link {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.bv-brand-logo {
  height: 26px;
  width: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.bv-doc-info {
  display: flex;
  flex-direction: column;
}

.bv-doc-title {
  font-family: var(--bv-font-heading);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--bv-text-primary);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.bv-doc-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--bv-accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.bv-doc-badge::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--bv-accent);
}

/* Center: Page Navigation Controls */
.bv-toolbar-center {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bv-surface);
  border: 1px solid var(--bv-border);
  border-radius: 30px;
  padding: 4px 10px;
}

.bv-nav-btn {
  background: transparent;
  border: none;
  color: var(--bv-text-primary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.85rem;
}

.bv-nav-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: var(--bv-accent);
  transform: translateY(-1px);
}

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

.bv-page-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--bv-text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0 4px;
}

.bv-page-input {
  width: 44px;
  height: 26px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--bv-border);
  border-radius: 4px;
  color: var(--bv-text-primary);
  text-align: center;
  font-family: var(--bv-font-body);
  font-size: 0.82rem;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s ease;
}

.bv-page-input:focus {
  border-color: var(--bv-accent);
}

/* Hide spin buttons */
.bv-page-input::-webkit-outer-spin-button,
.bv-page-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.bv-page-input[type=number] {
  -moz-appearance: textfield;
}

/* Right: Tools & Actions */
.bv-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bv-tool-group {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bv-surface);
  border: 1px solid var(--bv-border);
  border-radius: 8px;
  padding: 3px;
}

.bv-btn {
  background: transparent;
  border: none;
  color: var(--bv-text-primary);
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.85rem;
  font-family: var(--bv-font-body);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.bv-btn-icon {
  width: 32px;
  padding: 0;
}

.bv-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--bv-accent);
}

.bv-btn.active {
  background: rgba(197, 168, 128, 0.16);
  color: var(--bv-accent);
}

.bv-zoom-level {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--bv-text-muted);
  min-width: 44px;
  text-align: center;
}

.bv-close-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--bv-border);
  color: var(--bv-text-primary);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: 6px;
  font-size: 1.1rem;
  transition: all 0.2s ease;
}

.bv-close-btn:hover {
  background: #e74c3c;
  border-color: #e74c3c;
  color: #fff;
  transform: rotate(90deg);
}

/* ── Main Viewport Layout ── */
.bv-main-stage {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* ── Thumbnails Sidebar Drawer ── */
.bv-thumbnails-sidebar {
  width: 250px;
  min-width: 250px;
  background: var(--bv-surface);
  border-right: 1px solid var(--bv-border);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), margin-left 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 20;
}

.bv-thumbnails-sidebar.collapsed {
  margin-left: -250px;
  pointer-events: none;
}

.bv-sidebar-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--bv-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bv-sidebar-title {
  font-family: var(--bv-font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--bv-text-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.bv-thumbnails-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Custom scrollbar */
.bv-thumbnails-list::-webkit-scrollbar,
.bv-canvas-scroller::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.bv-thumbnails-list::-webkit-scrollbar-thumb,
.bv-canvas-scroller::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 4px;
}
.bv-thumbnails-list::-webkit-scrollbar-track,
.bv-canvas-scroller::-webkit-scrollbar-track {
  background: transparent;
}

.bv-thumb-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.bv-thumb-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.bv-thumb-item.active {
  border-color: var(--bv-border-active);
  background: rgba(197, 168, 128, 0.1);
}

.bv-thumb-canvas-wrap {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.bv-thumb-canvas-wrap img,
.bv-thumb-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.bv-thumb-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--bv-text-muted);
}

.bv-thumb-item.active .bv-thumb-label {
  color: var(--bv-accent);
  font-weight: 600;
}

/* ── Central Canvas Stage ── */
.bv-canvas-scroller {
  flex: 1;
  overflow: auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  background: radial-gradient(circle at center, #151922 0%, #0b0d11 100%);
  outline: none;
}

.bv-page-container {
  position: relative;
  display: inline-block;
  margin: auto;
  box-shadow: var(--bv-shadow);
  border-radius: 2px;
  background: #111;
  transition: transform 0.15s ease-out;
}

.bv-main-canvas {
  display: block;
  background: #fff;
  border-radius: 2px;
  max-width: 100%;
  height: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
  pointer-events: none; /* Disables drag / save */
}

/* ── Prev / Next floating overlay controls on viewport edges ── */
.bv-edge-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 64px;
  background: rgba(18, 22, 30, 0.85);
  border: 1px solid var(--bv-border);
  color: var(--bv-text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
  z-index: 10;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 1.1rem;
}

.bv-edge-prev {
  left: 20px;
}

.bv-edge-next {
  right: 20px;
}

.bv-edge-nav:hover:not(:disabled) {
  background: var(--bv-accent);
  border-color: var(--bv-accent);
  color: #111;
  transform: translateY(-50%) scale(1.06);
}

.bv-edge-nav:disabled {
  opacity: 0.15;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Loading Overlay ── */
.bv-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 13, 17, 0.82);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 50;
  transition: opacity 0.25s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.bv-spinner {
  width: 46px;
  height: 46px;
  border: 3px solid rgba(197, 168, 128, 0.2);
  border-top-color: var(--bv-accent);
  border-radius: 50%;
  animation: bv-spin 0.8s linear infinite;
}

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

.bv-loading-text {
  font-family: var(--bv-font-heading);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  color: var(--bv-text-primary);
}

/* ── Security / Watermark bar ── */
.bv-security-bar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 18, 24, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--bv-border);
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 0.72rem;
  color: var(--bv-text-muted);
  letter-spacing: 0.04em;
  pointer-events: none;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bv-security-bar i {
  color: var(--bv-accent);
}

/* ── Print Protection ── */
@media print {
  body, .booklet-modal, .booklet-viewer-app, canvas {
    display: none !important;
    visibility: hidden !important;
  }
}

/* ── Responsive adjustments ── */
@media (max-width: 900px) {
  .bv-doc-title {
    max-width: 160px;
  }
  .bv-toolbar {
    padding: 0 12px;
  }
  .bv-btn span.bv-btn-label {
    display: none;
  }
}

@media (max-width: 680px) {
  .bv-toolbar {
    height: 52px;
    min-height: 52px;
  }
  .bv-brand-link {
    display: none;
  }
  .bv-doc-info {
    display: none;
  }
  .bv-edge-nav {
    width: 38px;
    height: 48px;
    font-size: 0.95rem;
  }
  .bv-edge-prev {
    left: 8px;
  }
  .bv-edge-next {
    right: 8px;
  }
  .bv-canvas-scroller {
    padding: 12px;
  }
  .bv-thumbnails-sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.6);
  }
}
