.fm-document-preview {
  position: relative;
  width: 100%;
  min-width: 0;
}

.fm-document-preview-tools {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.fm-document-preview-expand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.fm-document-preview-frame {
  display: block;
  width: 100%;
  height: 360px;
  max-height: 65vh;
  border: 0;
  border-radius: 12px;
  background: #fff;
}

.fm-document-preview.is-loading .fm-document-preview-frame {
  visibility: hidden;
}

.fm-document-preview.is-loading .fm-document-preview-fallback,
.fm-document-preview.is-ready .fm-document-preview-fallback {
  display: none;
}

.fm-document-preview-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  color: #69768a;
  font-size: 0.875rem;
  text-align: center;
}

.fm-document-preview.is-loading .fm-document-preview-status {
  position: absolute;
  inset: 0;
}

.fm-document-preview.is-ready .fm-document-preview-status {
  display: none;
}

.fm-document-preview-fallback > a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.fm-embed-document-modal .modal-body {
  min-width: 0;
}

.fm-embed-document-modal .modal-title {
  min-width: 0;
  overflow-wrap: anywhere;
}

.fm-embed-document-modal .fm-document-preview-frame {
  height: 420px;
}

html[data-bs-theme="dark"] .fm-document-preview-status {
  color: #b5c1d4;
}

body.fm-document-lightbox-open {
  overflow: hidden !important;
}

.fm-document-lightbox {
  width: calc(100vw - 48px);
  height: calc(100vh - 48px);
  height: calc(100dvh - 48px);
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  background: #f4f6fa;
  color: #002058;
  box-shadow: 0 24px 80px rgba(0, 15, 42, 0.3);
}

.fm-document-lightbox[open] {
  display: flex;
  flex-direction: column;
}

.fm-document-lightbox::backdrop {
  background: rgba(9, 20, 39, 0.72);
}

.fm-document-lightbox-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: #fff;
}

.fm-document-lightbox-header h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fm-document-lightbox-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
}

.fm-document-lightbox-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.fm-document-lightbox-actions .btn-close {
  flex-shrink: 0;
  margin-left: 8px;
}

.fm-document-lightbox-body {
  flex: 1;
  min-height: 0;
  padding: 16px;
  overflow: hidden;
}

.fm-document-lightbox-body > .fm-document-preview,
.fm-document-lightbox .fm-document-preview .fm-document-preview-frame {
  height: 100%;
  max-height: none;
}

.fm-document-lightbox .fm-document-preview-fallback {
  padding: 24px;
}

html[data-bs-theme="dark"] .fm-document-lightbox {
  background: #161e2b;
  color: #e2e8f1;
  color-scheme: dark;
}

html[data-bs-theme="dark"] .fm-document-lightbox-header {
  background: #202a3b;
}

html[data-bs-theme="dark"] .fm-document-lightbox-actions .btn-outline-primary {
  color: #a7c8ff;
  border-color: #597fb8;
}

html[data-bs-theme="dark"] .fm-document-lightbox-actions .btn-outline-secondary {
  color: #d0d9e6;
  border-color: #718096;
}

html[data-bs-theme="dark"] .fm-document-lightbox-actions .btn-close {
  filter: invert(1) grayscale(100%) brightness(200%);
}

@media (max-width: 575.98px) {
  .fm-document-preview-frame,
  .fm-embed-document-modal .fm-document-preview-frame {
    height: 320px;
  }

  .fm-document-lightbox {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }

  .fm-document-lightbox-header {
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px;
  }

  .fm-document-lightbox-header h2 {
    flex-basis: 100%;
  }

  .fm-document-lightbox-actions {
    width: 100%;
  }

  .fm-document-lightbox-actions .btn-close {
    margin-left: auto;
  }

  .fm-document-lightbox-body {
    padding: 8px;
  }
}
