/**
 * Shared FlmvrDocPreviewer modal styling. Used across customer/signup/user details, signup
 * step8 agreement view, control/agreements PDF view, and messaging chat (via
 * site/scripts/messaging/attachment-viewer.js adapter).
 *
 * Theming notes:
 *  - The header/footer match Bootstrap defaults so the modal inherits whatever Bootstrap theme
 *    the host page already loads (control panels, signup wizard, public site).
 *  - `.flmvr-doc-preview-pdf-iframe` uses a dark background so an unset PDF render time looks
 *    intentional rather than blank.
 *  - The PDF.js fallback canvas-stack also uses the dark background for visual parity.
 */

.flmvr-doc-preview-root.modal {
  z-index: 10080;
}

body.modal-open .modal-backdrop.flmvr-doc-preview-backdrop {
  z-index: 10070 !important;
}

#flmvrDocPreviewModal .modal-content {
  background: #ffffff;
  box-shadow: 0 10px 40px rgb(0 0 0 / 30%);
}

#flmvrDocPreviewModal .modal-header {
  background: #ffffff;
  border-bottom: 1px solid #dee2e6;
  padding: 1rem 1.25rem;
}

#flmvrDocPreviewModal .modal-title {
  color: #1a1a1a;
  font-weight: 600;
}

#flmvrDocPreviewModal .modal-footer {
  background: #ffffff;
  border-top: 1px solid #dee2e6;
}

#flmvrDocPreviewModal .modal-body {
  background: #ffffff;
  min-height: 360px;
}

.flmvr-doc-preview-spinner {
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ------------------------------- Image ---------------------------------- */
.flmvr-doc-preview-image-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  background: #f6f7f9;
}

.flmvr-doc-preview-image {
  max-width: 100%;
  max-height: 78vh;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 1px 6px rgb(0 0 0 / 12%);
}

/* -------------------------------- PDF ----------------------------------- */
.flmvr-doc-preview-pdf-iframe {
  display: block;
  width: 100%;
  height: 80vh;
  border: 0;
  background: #525659;
}

/** PDF.js canvas-stack fallback (used only when bytes can't be served via cookie-auth URL). */
.flmvr-doc-preview-pdf-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: #525659;
  padding: 12px;
  border-radius: 0;
  max-height: 80vh;
  overflow-y: auto;
}

.flmvr-doc-preview-pdf-page {
  display: block;
  background: #ffffff;
  box-shadow: 0 2px 6px rgb(0 0 0 / 35%);
  max-width: 100%;
  height: auto;
}

/* ------------------------------- Audio ---------------------------------- */
.flmvr-doc-preview-audio-wrap {
  background: #f6f7f9;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ------------------------------- Video ---------------------------------- */
.flmvr-doc-preview-video-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
  min-height: 360px;
}

.flmvr-doc-preview-video {
  display: block;
  max-width: 100%;
  max-height: 80vh;
  width: auto;
  height: auto;
  background: #000000;
}

/* -------------------------------- DOCX ---------------------------------- */
.flmvr-doc-preview-docx {
  background: #ffffff;
  font-family: Calibri, "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: #1a1a1a;
  text-align: left;
  max-height: 80vh;
  overflow: auto;
}

.flmvr-doc-preview-docx p { margin: 0 0 0.5em 0; }
.flmvr-doc-preview-docx h1, .flmvr-doc-preview-docx h2, .flmvr-doc-preview-docx h3 { color: #1a1a1a; }
.flmvr-doc-preview-docx table { border-collapse: collapse; margin: 0.5em 0; }
.flmvr-doc-preview-docx td, .flmvr-doc-preview-docx th { border: 1px solid #dee2e6; padding: 4px 8px; }

/* ------------------------------- Sheet ---------------------------------- */
.flmvr-doc-preview-sheet-tabs {
  border-bottom: 1px solid #dee2e6;
  padding: 0 1rem;
  flex-wrap: wrap;
}

.flmvr-doc-preview-sheet-tabs .nav-link {
  font-size: 13px;
  padding: 0.4rem 0.8rem;
}

.flmvr-doc-preview-sheet-pane {
  max-height: 78vh;
  overflow: auto;
  text-align: left;
}

.flmvr-doc-preview-sheet-pane table {
  border-collapse: collapse;
  font-size: 13px;
  width: max-content;
  min-width: 100%;
}

.flmvr-doc-preview-sheet-pane th,
.flmvr-doc-preview-sheet-pane td {
  border: 1px solid #dee2e6;
  padding: 4px 8px;
  text-align: left;
  white-space: nowrap;
}

.flmvr-doc-preview-sheet-pane tr:nth-child(even) td { background: #fafbfc; }

/* -------------------------------- Text ---------------------------------- */
.flmvr-doc-preview-text {
  background: #ffffff;
  margin: 0;
  padding: 1rem 1.25rem;
  text-align: left;
  font-family: Menlo, Consolas, "Courier New", monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 80vh;
  overflow: auto;
}
