/* === ModulHub File Preview – shared plattformkomponent === */

.mh-file-preview {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

/* Toolbar */
.mh-fp-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.mh-fp-toolbar-left,
.mh-fp-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mh-fp-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
  line-height: 1;
}

.mh-fp-btn:hover:not(:disabled) {
  background: var(--surface-soft);
  border-color: var(--primary);
  color: var(--primary);
}

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

.mh-fp-page-info {
  font-size: 13px;
  color: var(--muted);
  min-width: 60px;
  text-align: center;
  user-select: none;
}

.mh-fp-zoom-info {
  font-size: 12px;
  color: var(--muted);
  min-width: 44px;
  text-align: center;
  user-select: none;
}

/* Viewport.
   Bruker block + margin:auto paa child istedenfor flex-center fordi
   flex + overflow:auto hindrer native touch-pan paa mobile nettlesere
   naar innholdet er bredere enn viewport (zoomet PDF). touch-action
   og -webkit-overflow-scrolling er eksplisitt for iOS/Android. */
.mh-fp-viewport {
  flex: 1;
  overflow: auto;
  padding: 4px;
  background: #f0f0f0;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}

/* Placeholder */
.mh-fp-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 200px;
  color: var(--muted);
  user-select: none;
}

.mh-fp-placeholder-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.mh-fp-placeholder-text {
  font-size: 14px;
}

/* Canvas (PDF).
   display:block + margin:auto sentrerer horisontalt naar canvas er
   smalere enn viewport. Naar zoomet bredere, havner canvas left-
   forankret og overflow:auto tillater horisontal scroll/pan. */
.mh-fp-canvas {
  display: block;
  margin: 0 auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  background: #fff;
}

/* Image */
.mh-fp-image {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  border-radius: 4px;
}

/* Expand button */
.mh-fp-expand-btn {
  margin-left: 4px;
}

/* Expanded mode — fullskjerm-modus. Vidars feedback 2026-04-25:
   tidligere 70%-floating-vindu opplevdes som "PDF forsvinner" naar
   man brukte den i en modal. Full skjerm gir tydelig fokus paa
   filen, og lukk-knappen er klart synlig. */
.mh-fp-expanded {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  z-index: 9999;
  border-radius: 0;
  border: none;
  box-shadow: none;
  background: var(--surface, #fff);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Resize-håndtak: 4 sider + 4 hjørner */
.mh-fp-resize-handle {
  position: absolute;
  z-index: 10;
  background: transparent;
}
.mh-file-preview:not(.mh-fp-expanded) .mh-fp-resize-handle { display: none; }

/* Sider */
.mh-fp-resize-n { top: -3px; left: 12px; right: 12px; height: 6px; cursor: ns-resize; }
.mh-fp-resize-s { bottom: -3px; left: 12px; right: 12px; height: 6px; cursor: ns-resize; }
.mh-fp-resize-e { right: -3px; top: 12px; bottom: 12px; width: 6px; cursor: ew-resize; }
.mh-fp-resize-w { left: -3px; top: 12px; bottom: 12px; width: 6px; cursor: ew-resize; }

/* Hjørner */
.mh-fp-resize-ne { top: 0; right: 0; width: 14px; height: 14px; cursor: nesw-resize; }
.mh-fp-resize-nw { top: 0; left: 0; width: 14px; height: 14px; cursor: nwse-resize; }
.mh-fp-resize-se { bottom: 0; right: 0; width: 14px; height: 14px; cursor: nwse-resize; }
.mh-fp-resize-sw { bottom: 0; left: 0; width: 14px; height: 14px; cursor: nesw-resize; }

/* Visuelt ikon på NE-hjørnet (alltid synlig) */
.mh-fp-resize-ne::after {
  content: "";
  position: absolute;
  top: 2px; right: 2px;
  width: 10px; height: 10px;
  background: linear-gradient(135deg, transparent 50%, var(--primary, #E8541A) 50%, var(--primary, #E8541A) 70%, transparent 70%);
  opacity: 0.5;
  border-radius: 2px;
}
.mh-fp-resize-ne:hover::after { opacity: 1; }

.mh-fp-expanded .mh-fp-toolbar {
  cursor: move;
  user-select: none;
}

.mh-fp-expanded .mh-fp-viewport {
  padding: 10px;
  flex: 1;
  min-height: 0;
}

.mh-fp-expanded.mh-fp-dragging {
  opacity: 0.92;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.35);
}

/* Mobile bruker samme fullskjerm-CSS som desktop — ingen overstyring noedvendig */

/* Skjul resize-haandtak i fullskjerm-modus — meningsloest naar PDF
   allerede dekker hele skjermen */
.mh-fp-expanded .mh-fp-resize-handle { display: none; }

/* === Utskrift: kun fil-innholdet skrives ut === */
@media print {
  .platform-topbar,
  .platform-topbar-spacer,
  .mh-module-toolbar {
    display: none !important;
  }

  .mh-fp-toolbar {
    display: none !important;
  }

  .mh-file-preview {
    border: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
  }

  .mh-fp-viewport {
    background: white !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  .mh-fp-canvas {
    box-shadow: none !important;
    width: 100% !important;
    height: auto !important;
  }

  .mh-fp-image {
    box-shadow: none !important;
    width: 100% !important;
    height: auto !important;
  }

  body {
    background: white !important;
  }
}
