/* ======================================================
   ONE INSIDER — ULTRA-MODERN GLASSMORPHIC DOCUMENT VIEWER v5.0
   Obsidian Dark Theme, Neon Crimson Accents, Deep Blur & High-DPI
   ====================================================== */

:root {
  --cpv-bg-modal: rgba(5, 7, 13, 0.92);
  --cpv-bg-header: rgba(13, 16, 27, 0.85);
  --cpv-border-subtle: rgba(255, 255, 255, 0.12);
  --cpv-border-glow: rgba(246, 0, 0, 0.4);
  --cpv-crimson: #f60000;
  --cpv-crimson-glow: rgba(246, 0, 0, 0.35);
  --cpv-tx-primary: #ffffff;
  --cpv-tx-secondary: #cbd5e1;
  --cpv-tx-muted: #94a3b8;
  --cpv-btn-bg: rgba(255, 255, 255, 0.06);
  --cpv-btn-border: rgba(255, 255, 255, 0.12);
}

.cpv-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--cpv-bg-modal);
  z-index: 999999;
  display: none;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.cpv-modal.open {
  display: flex;
  opacity: 1;
  pointer-events: auto;
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
}

.cpv-modal:fullscreen,
.cpv-modal:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  background: #05070d;
  display: flex;
  flex-direction: column;
}

.cpv-modal:fullscreen .cpv-viewport,
.cpv-modal:-webkit-full-screen .cpv-viewport {
  padding: 20px 20px 80px;
}

/* ── Modern Glass Header Toolbar ── */
.cpv-header {
  height: 64px;
  background: var(--cpv-bg-header);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--cpv-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  z-index: 20;
  flex-shrink: 0;
  position: relative;
}

.cpv-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, #f60000 30%, #ec00ff 70%, transparent 100%);
  opacity: 0.85;
}

.cpv-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}

.cpv-title-wrap > div:last-child {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.cpv-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(246, 0, 0, 0.25), rgba(124, 58, 237, 0.25));
  border: 1px solid rgba(246, 0, 0, 0.45);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(246, 0, 0, 0.25);
}

.cpv-title {
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  font-weight: 800;
  font-size: 0.96rem;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  letter-spacing: -0.01em;
}

.cpv-meta-text {
  font-family: 'Inter', sans-serif;
  font-size: 0.76rem;
  color: var(--cpv-tx-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cpv-badge {
  font-family: 'Orbitron', monospace;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #ff4d6d;
  background: rgba(246, 0, 0, 0.12);
  border: 1px solid rgba(246, 0, 0, 0.35);
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(246, 0, 0, 0.2);
}

/* ── Modern Controls Deck ── */
.cpv-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.55);
  padding: 4px 8px;
  border-radius: 14px;
  border: 1px solid var(--cpv-border-subtle);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.cpv-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.12);
  margin: 0 4px;
}

.cpv-zoom-badge {
  font-family: 'Orbitron', monospace;
  font-size: 0.68rem;
  font-weight: 800;
  color: #ffffff;
  min-width: 44px;
  text-align: center;
}

.cpv-btn {
  background: var(--cpv-btn-bg);
  border: 1px solid var(--cpv-btn-border);
  color: var(--cpv-tx-secondary);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.cpv-btn:hover {
  background: rgba(246, 0, 0, 0.25);
  color: #ffffff;
  border-color: rgba(246, 0, 0, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 0 14px rgba(246, 0, 0, 0.35);
}

.cpv-btn:active {
  transform: scale(0.95);
}

.cpv-page-indicator {
  font-family: 'Orbitron', monospace;
  font-size: 0.74rem;
  font-weight: 700;
  color: #e2e8f0;
  padding: 0 6px;
}

.cpv-page-indicator span:first-child {
  color: #ff3366;
  font-weight: 800;
}

.cpv-close-btn {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 800;
  font-size: 1.05rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.2);
}

.cpv-close-btn:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
  transform: scale(1.06);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}

/* ── Viewer Workspace Viewport ── */
.cpv-viewport {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  padding: 36px 20px 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  background-color: #04060b;
  background-image: 
    radial-gradient(circle at 50% -5%, rgba(246, 0, 0, 0.45) 0%, rgba(236, 0, 255, 0.15) 30%, transparent 60%),
    radial-gradient(circle at 10% 20%, rgba(124, 58, 237, 0.35) 0%, transparent 45%),
    radial-gradient(circle at 90% 30%, rgba(236, 0, 255, 0.32) 0%, transparent 48%),
    radial-gradient(circle at 15% 75%, rgba(0, 240, 255, 0.25) 0%, transparent 42%),
    radial-gradient(circle at 85% 80%, rgba(246, 0, 0, 0.35) 0%, transparent 48%),
    radial-gradient(circle at 50% 50%, rgba(124, 58, 237, 0.18) 0%, transparent 65%);
  background-attachment: fixed;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

/* High-Intensity Floating Radiant Aurora Lights */
.cpv-viewport::before {
  content: '';
  position: fixed;
  top: 8%;
  left: 4%;
  width: 550px;
  height: 550px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(246, 0, 0, 0.32) 0%, rgba(236, 0, 255, 0.18) 40%, transparent 70%);
  filter: blur(65px);
  pointer-events: none;
  z-index: 0;
  animation: cpvGlowFloat1 12s ease-in-out infinite alternate;
}

.cpv-viewport::after {
  content: '';
  position: fixed;
  bottom: 8%;
  right: 4%;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.32) 0%, rgba(0, 240, 255, 0.18) 45%, transparent 70%);
  filter: blur(75px);
  pointer-events: none;
  z-index: 0;
  animation: cpvGlowFloat2 14s ease-in-out infinite alternate;
}

@keyframes cpvGlowFloat1 {
  0% { transform: translate(0, 0) scale(1); opacity: 0.85; }
  50% { transform: translate(60px, 45px) scale(1.22); opacity: 1; }
  100% { transform: translate(-40px, 70px) scale(0.95); opacity: 0.9; }
}

@keyframes cpvGlowFloat2 {
  0% { transform: translate(0, 0) scale(1); opacity: 0.8; }
  50% { transform: translate(-60px, -45px) scale(1.25); opacity: 1; }
  100% { transform: translate(40px, -60px) scale(0.92); opacity: 0.85; }
}

/* Document Page Card Container */
.cpv-page-wrapper {
  position: relative;
  z-index: 2;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.88), 0 0 0 1px rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
  box-sizing: border-box;
  margin: 0 auto;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cpv-page-wrapper:hover {
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(246, 0, 0, 0.4), 0 0 35px rgba(246, 0, 0, 0.2);
}

/* Page Skeleton */
.cpv-page-skeleton {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 520px;
  background: rgba(15, 23, 42, 0.6);
}

/* Canvas Element */
.cpv-page-canvas {
  display: block;
  pointer-events: none;
  image-rendering: -webkit-optimize-contrast;
}

/* Dynamic Watermark Canvas Overlay */
.cpv-watermark-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* Loading State */
.cpv-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #cbd5e1;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  margin: auto;
  padding: 50px 30px;
  background: rgba(14, 16, 26, 0.85);
  border: 1px solid var(--cpv-border-subtle);
  border-radius: 20px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
  animation: cpvFadeIn 0.2s ease;
}

@keyframes cpvFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.cpv-spinner {
  width: 44px;
  height: 44px;
  border: 3.5px solid rgba(246, 0, 0, 0.15);
  border-top-color: #f60000;
  border-right-color: #ec00ff;
  border-radius: 50%;
  animation: cpvSpin 0.75s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
  box-shadow: 0 0 16px rgba(246, 0, 0, 0.35);
}

@keyframes cpvSpin {
  to { transform: rotate(360deg); }
}

/* ── Responsive Mobile Styling ── */
@media (max-width: 768px) {
  .cpv-header {
    height: auto;
    min-height: 56px;
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .cpv-title-wrap {
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(100% - 48px);
    gap: 8px;
  }

  .cpv-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
    border-radius: 10px;
  }

  .cpv-title {
    font-size: 0.86rem;
  }

  .cpv-badge {
    font-size: 0.56rem;
    padding: 2px 6px;
  }

  .cpv-close-btn {
    order: 2;
    width: 34px;
    height: 34px;
  }

  .cpv-controls {
    order: 3;
    width: 100%;
    justify-content: space-between;
    padding: 6px 8px;
    gap: 4px;
    overflow-x: auto;
  }

  .cpv-btn {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
    flex-shrink: 0;
  }

  .cpv-page-indicator {
    font-size: 0.72rem;
    padding: 0 4px;
  }

  .cpv-viewport {
    padding: 18px 10px 140px;
    gap: 16px;
  }

  .cpv-page-wrapper {
    max-width: 100% !important;
  }

  .cpv-page-canvas {
    max-width: 100% !important;
    height: auto !important;
  }
}

/* Strict Print Suppression */
@media print {
  body, html, .cpv-modal {
    display: none !important;
    visibility: hidden !important;
  }
}
