/* ==========================================================================
   NewspaperViewer - CSS (Namespace .npv-*)
   ========================================================================== */

:root {
  --npv-bg-main: #18191a;
  --npv-bg-stage: radial-gradient(circle at center, #38393b 0%, #222325 50%, #151617 100%);
  --npv-bg-bar: rgba(18, 19, 20, 0.95);
  --npv-border-bar: rgba(255, 255, 255, 0.09);
  --npv-text-main: #ffffff;
  --npv-text-muted: #a0a0a5;
  --npv-btn-bg: rgba(255, 255, 255, 0.12);
  --npv-btn-hover: rgba(255, 255, 255, 0.22);
  --npv-btn-active: rgba(255, 255, 255, 0.32);
  --npv-btn-text: #ffffff;
  --npv-accent: #0088ff;
  --npv-page-shadow: 0 14px 40px rgba(0, 0, 0, 0.55), 0 4px 14px rgba(0, 0, 0, 0.35);
  --npv-transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1);
}

.npv-root,
.npv-root * {
  box-sizing: border-box;
}

.npv-root {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--npv-bg-main);
  color: var(--npv-text-main);
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Topbar / Controls
   ========================================================================== */

.npv-topbar {
  flex: 0 0 auto;
  min-height: 52px;
  background: var(--npv-bg-bar);
  border-bottom: 1px solid var(--npv-border-bar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 10px;
  z-index: 50;
  backdrop-filter: blur(8px);
  width: 100%;
  box-sizing: border-box;
}

.npv-bar-left,
.npv-bar-center,
.npv-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.npv-bar-left {
  flex: 0 1 auto;
}

.npv-bar-center {
  flex: 1 1 auto;
  justify-content: center;
}

.npv-bar-right {
  flex: 0 0 auto;
  justify-content: flex-end;
}

.npv-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--npv-text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
  cursor: default;
}

.npv-btn {
  background: var(--npv-btn-bg);
  color: var(--npv-btn-text);
  border: none;
  border-radius: 6px;
  height: 36px;
  min-width: 36px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: var(--npv-transition);
  user-select: none;
  touch-action: manipulation;
  white-space: nowrap;
  flex-shrink: 0;
}

.npv-btn:hover:not(:disabled) {
  background: var(--npv-btn-hover);
}

.npv-btn:active:not(:disabled) {
  background: var(--npv-btn-active);
  transform: scale(0.97);
}

.npv-btn.npv-btn-active {
  background: rgba(0, 136, 255, 0.28);
  color: #ffffff;
  border-color: rgba(0, 136, 255, 0.6);
}

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

.npv-btn-icon {
  font-size: 16px;
  line-height: 1;
  display: inline-block;
}

/* ==========================================================================
   Mode Selector Component (Revista | Página)
   ========================================================================== */

.npv-mode-selector {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
  user-select: none;
  flex-shrink: 0;
}

.npv-btn-mode {
  background: transparent;
  border: none;
  color: var(--npv-text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 9px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
  white-space: nowrap;
}

.npv-btn-mode:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.npv-btn-mode.npv-active {
  background: var(--npv-accent);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.npv-btn-mode:focus-visible {
  outline: 2px solid var(--npv-accent);
  outline-offset: 1px;
}

.npv-page-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--npv-border-bar);
  border-radius: 6px;
  padding: 2px 8px;
  height: 36px;
  box-sizing: border-box;
}

.npv-page-input {
  width: 40px;
  height: 28px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: var(--npv-text-main);
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  outline: none;
  padding: 0;
  margin: 0;
  transition: var(--npv-transition);
}

.npv-page-input:focus {
  border-color: var(--npv-accent);
  background: rgba(255, 255, 255, 0.2);
}

.npv-page-separator {
  font-size: 13px;
  color: var(--npv-text-muted);
  user-select: none;
}

.npv-page-total {
  font-size: 13px;
  color: var(--npv-text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.npv-btn-svg {
  display: block;
  pointer-events: none;
}

/* ==========================================================================
   Viewer Body & SidePanel (Drawer / Overlay)
   ========================================================================== */

.npv-body {
  flex: 1 1 auto;
  position: relative;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.npv-sidepanel-backdrop {
  display: none;
}

.npv-sidepanel {
  position: relative;
  width: 0;
  flex: 0 0 0px;
  overflow: hidden;
  background: #1c1d1f;
  border-right: 1px solid var(--npv-border-bar);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: width 0.25s cubic-bezier(0.25, 1, 0.5, 1), flex-basis 0.25s cubic-bezier(0.25, 1, 0.5, 1);
}

.npv-sidepanel.npv-active {
  width: 250px;
  flex: 0 0 250px;
  min-width: 200px;
  max-width: 320px;
}

.npv-sidepanel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid var(--npv-border-bar);
  background: rgba(0, 0, 0, 0.25);
  flex: 0 0 auto;
  gap: 6px;
}

.npv-sidepanel-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.npv-sidepanel-tabs::-webkit-scrollbar {
  display: none;
}

.npv-sidepanel-tab {
  background: transparent;
  border: none;
  color: var(--npv-text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: var(--npv-transition);
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
}

.npv-sidepanel-tab:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.npv-sidepanel-tab.npv-active {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--npv-accent);
}

.npv-tab-icon {
  display: inline-flex;
  align-items: center;
}

.npv-sidepanel-close {
  background: transparent;
  border: none;
  color: var(--npv-text-muted);
  font-size: 15px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
  transition: var(--npv-transition);
  flex-shrink: 0;
}

.npv-sidepanel-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.npv-sidepanel-content {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  padding: 12px 10px;
}

.npv-panel-view {
  width: 100%;
}

/* ==========================================================================
   Thumbnail Panel Component
   ========================================================================== */

.npv-thumbnail-panel {
  width: 100%;
}

.npv-thumbnail-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.npv-thumb-item {
  background: transparent;
  border: none;
  padding: 6px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border-radius: 6px;
  transition: transform 0.15s ease, background 0.15s ease;
  width: 100%;
  box-sizing: border-box;
}

.npv-thumb-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.npv-thumb-item:active {
  transform: scale(0.98);
}

.npv-thumb-frame {
  background: #252628;
  border: 2px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.npv-thumb-item.npv-thumb-active .npv-thumb-frame {
  border-color: var(--npv-accent);
  box-shadow: 0 0 0 2px var(--npv-accent), 0 6px 16px rgba(0, 136, 255, 0.3);
}

.npv-thumb-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #ffffff;
}

.npv-thumb-skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #252628 25%, #35363a 50%, #252628 75%);
  background-size: 200% 100%;
  animation: npv-skeleton 1.5s infinite;
}

@keyframes npv-skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.npv-thumb-label {
  font-size: 12px;
  color: var(--npv-text-muted);
  font-weight: 500;
  transition: color 0.15s ease;
}

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

.npv-thumb-error {
  background: rgba(255, 59, 48, 0.1);
  color: #ff453a;
  border-color: rgba(255, 59, 48, 0.3);
}

.npv-thumb-error-icon {
  font-size: 20px;
}

/* ==========================================================================
   Outline Panel Component
   ========================================================================== */

.npv-outline-panel {
  width: 100%;
  color: #ffffff;
}

.npv-outline-loading,
.npv-outline-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 12px;
  text-align: center;
  color: var(--npv-text-muted);
}

.npv-outline-empty-icon {
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.6;
}

.npv-outline-empty-text {
  font-size: 13px;
  line-height: 1.45;
}

.npv-outline-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.npv-outline-children {
  list-style: none;
  margin: 0;
  padding-left: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.npv-outline-children.npv-collapsed {
  display: none;
}

.npv-outline-node {
  margin: 2px 0;
}

.npv-outline-row {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.npv-outline-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.npv-outline-row.npv-active {
  background: rgba(0, 136, 255, 0.18);
}

.npv-outline-toggle {
  background: transparent;
  border: none;
  color: var(--npv-text-muted);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 3px;
  font-size: 10px;
  padding: 0;
  flex-shrink: 0;
  transition: transform 0.2s ease, background 0.15s ease, color 0.15s ease;
}

.npv-outline-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.npv-outline-spacer {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.npv-outline-item {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  color: #dddddd;
  font-size: 13px;
  text-align: left;
  padding: 6px 8px 6px 4px;
  cursor: pointer;
  border-radius: 4px;
  min-width: 0;
}

.npv-outline-title {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.npv-outline-page {
  font-size: 11px;
  color: var(--npv-text-muted);
  margin-left: 8px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 3px;
}

.npv-outline-row.npv-active .npv-outline-item {
  color: #ffffff;
  font-weight: 600;
}

.npv-outline-row.npv-active .npv-outline-page {
  color: var(--npv-accent);
  font-weight: 600;
  background: rgba(0, 136, 255, 0.2);
}

/* ==========================================================================
   Search Panel Component
   ========================================================================== */

.npv-search-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.npv-search-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.npv-search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.npv-search-input {
  width: 100%;
  height: 36px;
  background: #151618;
  border: 1px solid var(--npv-border-bar);
  border-radius: 6px;
  color: #ffffff;
  padding: 0 34px 0 10px;
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.npv-search-input:focus {
  border-color: var(--npv-accent);
  box-shadow: 0 0 0 2px rgba(0, 136, 255, 0.25);
}

.npv-search-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--npv-text-muted);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.npv-search-clear-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
}

.npv-search-submit-btn {
  height: 34px;
  background: var(--npv-accent);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.npv-search-submit-btn:hover:not(:disabled) {
  filter: brightness(1.1);
}

.npv-search-submit-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.npv-search-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.npv-search-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--npv-text-muted);
  min-height: 20px;
  padding: 2px 0;
}

.npv-search-progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--npv-text-muted);
}

.npv-search-cancel-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--npv-text-muted);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.npv-search-cancel-btn:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.08);
}

.npv-search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.npv-search-item {
  background: #252628;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  width: 100%;
  box-sizing: border-box;
}

.npv-search-item:hover {
  background: #2e3034;
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.npv-search-item:active {
  transform: translateY(0);
}

.npv-search-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.npv-search-item-page {
  font-size: 12px;
  font-weight: 700;
  color: var(--npv-accent);
}

.npv-search-item-count {
  font-size: 11px;
  color: var(--npv-text-muted);
}

.npv-search-item-snippet {
  font-size: 12px;
  line-height: 1.45;
  color: #cccccc;
  word-break: break-word;
}

.npv-search-mark {
  background: rgba(255, 214, 10, 0.35);
  color: #fff37a;
  font-weight: 600;
  padding: 1px 3px;
  border-radius: 2px;
}

.npv-spinner-sm {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--npv-accent);
  border-radius: 50%;
  animation: npv-spin 0.8s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

.npv-search-empty {
  text-align: center;
  padding: 24px 10px;
  color: var(--npv-text-muted);
}

.npv-search-empty-icon {
  font-size: 24px;
  margin-bottom: 6px;
  opacity: 0.6;
}

.npv-search-empty-text {
  font-size: 12px;
  line-height: 1.4;
}

/* ==========================================================================
   Viewer Stage (Workspace)
   ========================================================================== */

.npv-stage {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  background: var(--npv-bg-stage);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Arrow Navigators on Desktop Stage */
.npv-stage-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 64px;
  background: rgba(0, 0, 0, 0.45);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  z-index: 30;
  transition: var(--npv-transition);
  border-radius: 6px;
}

.npv-stage-nav:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.75);
  transform: translateY(-50%) scale(1.05);
}

.npv-stage-nav:disabled {
  opacity: 0;
  pointer-events: none;
}

.npv-stage-nav.npv-prev {
  left: 16px;
}

.npv-stage-nav.npv-next {
  right: 16px;
}

/* ==========================================================================
   Slider Mode Layout
   ========================================================================== */

.npv-slider-viewport {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  touch-action: pan-y pinch-zoom;
}

.npv-slider-track {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  transform-origin: center center;
}

.npv-slide-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  box-shadow: var(--npv-page-shadow);
  border-radius: 4px;
  overflow: hidden;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.npv-canvas-wrapper {
  position: relative;
  display: block;
  line-height: 0;
}

.npv-canvas-wrapper canvas {
  display: block;
  max-width: none;
  background: #ffffff;
}

/* ==========================================================================
   Magazine Mode Layout
   ========================================================================== */

.npv-magazine-viewport {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  touch-action: pan-y pinch-zoom;
  perspective: 2000px;
  -webkit-perspective: 2000px;
}

.npv-magazine-container {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: auto;
  transform-origin: center center;
  transform-style: preserve-3d;
}

.npv-magazine-spread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: transparent;
  transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1);
  transform-style: preserve-3d;
}

/* Dupla página (Double-page) */
.npv-magazine-spread.npv-spread-double {
  background: #ffffff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), 0 6px 18px rgba(0, 0, 0, 0.4);
  border-radius: 4px;
}

/* Página isolada (Capa, contracapa ou single-page) */
.npv-magazine-spread.npv-spread-single {
  background: #ffffff;
  box-shadow: var(--npv-page-shadow);
  border-radius: 4px;
}

.npv-magazine-page {
  position: relative;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  overflow: hidden;
}

.npv-magazine-page-left {
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

.npv-magazine-page-right {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

.npv-magazine-page-center {
  border-radius: 4px;
}

/* Vinco / Lombada central entre páginas esquerda e direita */
.npv-magazine-seam {
  width: 20px;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.08) 0%,
    rgba(0, 0, 0, 0.24) 45%,
    rgba(0, 0, 0, 0.35) 50%,
    rgba(0, 0, 0, 0.24) 55%,
    rgba(0, 0, 0, 0.08) 100%
  );
  pointer-events: none;
  z-index: 10;
}

/* ==========================================================================
   Page Flip 3D Animation & Shadows (Fase 4B)
   ========================================================================== */

.npv-flip-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  perspective: 2000px;
  -webkit-perspective: 2000px;
  transform-style: preserve-3d;
}

.npv-flip-sheet {
  position: absolute;
  top: 0;
  bottom: 0;
  transform-style: preserve-3d;
  will-change: transform;
  pointer-events: none;
}

/* Folha da direita virando para a esquerda (Next) */
.npv-flip-sheet.npv-flip-right {
  left: 50%;
  width: 50%;
  transform-origin: left center;
}

/* Folha da esquerda virando para a direita (Prev) */
.npv-flip-sheet.npv-flip-left {
  left: 0;
  width: 50%;
  transform-origin: right center;
}

/* Modo Single-page (Capa, contracapa ou smartphone) */
.npv-flip-sheet.npv-flip-single {
  left: 0 !important;
  width: 100% !important;
}

.npv-flip-sheet.npv-flip-single.npv-flip-right {
  transform-origin: left center;
}

.npv-flip-sheet.npv-flip-single.npv-flip-left {
  transform-origin: right center;
}

/* Faces 3D da folha (Frente e Verso) */
.npv-flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.npv-flip-face-front {
  transform: rotateY(0deg);
  z-index: 2;
}

.npv-flip-face-back {
  transform: rotateY(180deg);
  z-index: 1;
  background: #f7f7f8;
}

.npv-flip-face canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Sombra na própria página curvada */
.npv-flip-shadow-page {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 3;
  transition: opacity 0.04s ease;
}

.npv-flip-right .npv-flip-shadow-page {
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.45) 0%,
    rgba(0, 0, 0, 0.18) 35%,
    rgba(0, 0, 0, 0) 100%
  );
}

.npv-flip-left .npv-flip-shadow-page {
  background: linear-gradient(
    to left,
    rgba(0, 0, 0, 0.45) 0%,
    rgba(0, 0, 0, 0.18) 35%,
    rgba(0, 0, 0, 0) 100%
  );
}

/* Sombra projetada na página subjacente */
.npv-flip-shadow-cast {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  pointer-events: none;
  opacity: 0;
  z-index: 15;
  transition: opacity 0.04s ease;
}

.npv-flip-shadow-cast.npv-shadow-left {
  left: 0;
  background: linear-gradient(
    to left,
    rgba(0, 0, 0, 0.55) 0%,
    rgba(0, 0, 0, 0.22) 25%,
    rgba(0, 0, 0, 0) 75%
  );
}

.npv-flip-shadow-cast.npv-shadow-right {
  left: 50%;
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.55) 0%,
    rgba(0, 0, 0, 0.22) 25%,
    rgba(0, 0, 0, 0) 75%
  );
}

/* Respeito a prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .npv-flip-overlay,
  .npv-flip-sheet {
    display: none !important;
    transition: none !important;
    transform: none !important;
  }

  .npv-magazine-spread {
    transition: none !important;
  }
}

/* ==========================================================================
   Annotation Layer (Links & Interactive elements)
   ========================================================================== */

.npv-annotation-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  line-height: 1;
}

.npv-annotation-layer a {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  background: rgba(0, 136, 255, 0.08);
  border-bottom: 1px dashed rgba(0, 136, 255, 0.4);
  transition: background 0.15s ease;
}

.npv-annotation-layer a:hover {
  background: rgba(0, 136, 255, 0.22);
  border-bottom-color: rgba(0, 136, 255, 0.9);
}

/* ==========================================================================
   Loading and Error Overlays
   ========================================================================== */

.npv-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 16, 17, 0.78);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.npv-overlay.npv-active {
  display: flex;
}

.npv-overlay-box {
  background: rgba(26, 27, 30, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 24px 30px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
}

.npv-spinner {
  width: 38px;
  height: 38px;
  margin: 0 auto 16px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--npv-accent);
  border-radius: 50%;
  animation: npv-spin 0.8s linear infinite;
}

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

.npv-overlay-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #ffffff;
}

.npv-overlay-msg {
  font-size: 13px;
  color: var(--npv-text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

.npv-overlay-retry {
  background: var(--npv-accent);
  color: #ffffff;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--npv-transition);
}

.npv-overlay-retry:hover {
  filter: brightness(1.15);
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

/* Telas médias e Tablets (<= 768px) */
@media (max-width: 768px) {
  .npv-stage-nav {
    display: none; /* Prioriza gestos de toque / swipe */
  }

  .npv-slider-viewport {
    padding: 10px;
  }

  .npv-sidepanel {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    max-width: 80vw;
    flex: none !important;
    z-index: 80;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.6);
    transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1);
  }

  .npv-sidepanel.npv-active {
    transform: translateX(0);
    width: 260px;
  }

  .npv-sidepanel-backdrop {
    display: block;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 75;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    backdrop-filter: blur(2px);
  }

  .npv-sidepanel-backdrop.npv-active {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Modo Smartphone em Orientação Retrato (Portrait) ou telas estreitas */
@media (max-width: 640px), (max-width: 768px) and (orientation: portrait) {
  .npv-topbar {
    height: auto;
    min-height: auto;
    padding: 6px 10px 8px;
    flex-wrap: wrap;
    row-gap: 6px;
    column-gap: 8px;
  }

  /* Linha 1: Título e Controles de Zoom/Fullscreen */
  .npv-bar-left {
    order: 1;
    flex: 1 1 0%;
    min-width: 0;
  }

  .npv-bar-right {
    order: 2;
    flex: 0 0 auto;
    margin-left: auto;
    gap: 4px;
  }

  .npv-title {
    font-size: 12px;
    max-width: 100%;
  }

  .npv-mode-selector {
    padding: 1px;
    border-radius: 5px;
    gap: 1px;
  }

  .npv-btn-mode {
    font-size: 11px;
    padding: 3px 6px;
  }

  .npv-bar-right .npv-btn {
    height: 32px;
    min-width: 32px;
    padding: 0 6px;
    font-size: 12px;
  }

  .npv-bar-right .npv-btn-fit {
    font-size: 11px;
    padding: 0 5px;
  }

  /* Linha 2: Navegação de Páginas com layout fluído e centralizado */
  .npv-bar-center {
    order: 3;
    width: 100%;
    flex: 1 0 100%;
    justify-content: space-between;
    padding-top: 5px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    margin-top: 2px;
  }

  .npv-bar-center .npv-btn-nav {
    height: 34px;
    min-width: 34px;
    padding: 0 8px;
  }

  .npv-page-nav {
    height: 32px;
    padding: 1px 6px;
  }

  .npv-page-input {
    width: 36px;
    height: 26px;
    font-size: 12px;
  }

  .npv-page-total,
  .npv-page-separator {
    font-size: 12px;
  }
}

/* Telas estreitas (<= 480px): Oculta texto "Anterior/Próxima" mantendo ícones ‹ e › com aria-label */
@media (max-width: 480px) {
  .npv-btn-label {
    display: none !important;
  }

  .npv-bar-center .npv-btn-nav {
    min-width: 38px;
    padding: 0 10px;
    font-size: 18px;
  }
}

/* Dispositivos Móveis em Orientação Paisagem (Landscape) */
@media (max-width: 900px) and (orientation: landscape) {
  .npv-topbar {
    height: 44px;
    min-height: 44px;
    padding: 2px 10px;
    gap: 8px;
  }

  .npv-title {
    max-width: 160px;
    font-size: 12px;
  }

  .npv-btn {
    height: 30px;
    min-width: 30px;
    padding: 0 6px;
    font-size: 12px;
  }

  .npv-btn-label {
    display: none !important;
  }

  .npv-page-nav {
    height: 30px;
    padding: 1px 6px;
  }

  .npv-page-input {
    width: 34px;
    height: 24px;
    font-size: 12px;
  }

  .npv-slider-viewport {
    padding: 6px;
  }
}

/* Telas Ultra-estreitas (<= 360px) */
@media (max-width: 360px) {
  .npv-btn-mode {
    font-size: 10px;
    padding: 2px 5px;
  }

  .npv-title {
    max-width: 75px;
  }

  .npv-bar-right .npv-btn-fit {
    display: none !important;
  }
}

/* Telas Mínimas Suportadas (<= 320px) */
@media (max-width: 320px) {
  .npv-topbar {
    padding: 4px 6px;
  }

  .npv-title {
    display: none !important;
  }

  .npv-btn-mode {
    font-size: 9px;
    padding: 2px 4px;
  }
}
