/* In-app docx viewer modal — used from chat View Inputs, fraud source pills,
   and the dashboard documents list. The styling stays neutral so the
   docx-preview output (which carries the original Word formatting) can
   shine through without our shell coloring its own ink. */

body.docx-viewer-locked { overflow: hidden; }

.docx-viewer-modal {
  position: fixed;
  inset: 0;
  /* Sit above the dashboard's documents modal (z-index 1000), the agent
     page's drawers, and any toast layer so the viewer always lands on top
     of whatever surface launched it. */
  z-index: 2000;
  display: flex;
  align-items: stretch;
  justify-content: center;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
}
.docx-viewer-modal[hidden] { display: none; }

.docx-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 10, 28, 0.58);
}

.docx-viewer-panel {
  position: relative;
  margin: 4vh auto;
  width: min(1080px, calc(100vw - 32px));
  max-height: 92vh;
  background: #f3f4f6;
  border-radius: 12px;
  border: 1px solid #d1d5db;
  box-shadow: 0 24px 60px rgba(5, 10, 28, .35);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.docx-viewer-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: linear-gradient(180deg, #ffffff, #f9fafb);
  border-bottom: 1px solid #e5e7eb;
}
.docx-viewer-head-main {
  flex: 1;
  min-width: 0;
}
.docx-viewer-eyebrow {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: #0352CC;
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 2px;
}
.docx-viewer-title {
  font-family: "Manrope", "Inter", sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: #0D1526;
  margin: 0;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.docx-viewer-sub {
  font-size: 11.5px;
  color: #6b7280;
  margin: 4px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.docx-viewer-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.docx-viewer-download,
.docx-viewer-close {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #1f2937;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease;
}
.docx-viewer-download:hover,
.docx-viewer-close:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #1e3a8a;
}
.docx-viewer-close {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
}

.docx-viewer-body {
  overflow: auto;
  background: #e5e7eb;
  padding: 24px;
  display: flex;
  justify-content: center;
}

.docx-viewer-surface {
  width: 100%;
  max-width: 880px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
}

/* PDF rendering uses a same-origin blob: URL inside an iframe so the
   browser's native PDF viewer (built-in pagination, zoom, search) takes
   over without the loanops modal having to ship its own renderer. */
.docx-viewer-pdf-frame {
  width: 100%;
  max-width: 100%;
  height: calc(92vh - 80px);
  min-height: 480px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 2px 12px rgba(15, 23, 42, .08);
}

.docx-viewer-loading,
.docx-viewer-error {
  margin: 64px auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13.5px;
  color: #4b5563;
  align-self: center;
}
.docx-viewer-error {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
}

/* docx-preview output uses .docx-wrapper around each document, with each
   page inside .docx. We keep the page surface white with a subtle shadow
   so it reads like a Word document rather than an inline panel. */
.docx-viewer-surface .docx-wrapper {
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: transparent;
  padding: 0;
}
.docx-viewer-surface .docx-wrapper > section.docx,
.docx-viewer-surface .docx-wrapper .docx {
  background: #ffffff;
  box-shadow: 0 2px 12px rgba(15, 23, 42, .08);
  border: 1px solid #d1d5db;
  border-radius: 4px;
  overflow: hidden;
  margin: 0 auto;
}

/* The library injects sizes from the source document; let it. We just
   guard against horizontal overflow on small screens. */
@media (max-width: 880px) {
  .docx-viewer-surface .docx-wrapper > section.docx,
  .docx-viewer-surface .docx-wrapper .docx {
    transform-origin: top center;
  }
}
