/* Fullscreen overlay - now supports multiple instances */
.text-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: none;
  /* z-index is set dynamically via JS */
}

.modal-visible { display: block; }
.modal-hidden { display: none; }

/* Dialog - now uses class instead of ID */
.text-modal {
  position: absolute;
  top: 5%;
  left: 50%;
  transform: translateX(-50%);
  width: min(900px, 92vw);
  height: 85vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.text-modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid #eee;
}

.text-modal header h3 {
  margin: 0;
  font: 600 1rem/1.2 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.text-modal header .actions {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}

.text-modal a.text-modal-download {
  font: 500 .95rem/1 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  text-decoration: none;
  padding: .4rem .6rem;
  background: #eef2ff;
  border-radius: .5rem;
}

.text-modal button {
  border: none;
  background: #f2f2f2;
  padding: .4rem .6rem;
  border-radius: .5rem;
  cursor: pointer;
}

.text-modal button:focus {
  outline: 2px solid #2684ff;
  outline-offset: 2px;
}

.text-modal header .actions button[disabled] {
  opacity: .5;
  cursor: not-allowed;
}

/* Loading and Error states */
.text-modal .loading,
.text-modal .error {
  padding: 1rem;
  font: 400 .95rem/1.35 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.text-modal .error {
  color: #b42318;
  background: #fee4e2;
}

/* Text content (pre element) */
.text-modal pre {
  margin: 0;
  padding: 1rem;
  flex: 1;                    /* Fill remaining space */
  overflow: auto;             /* Enable scrolling */
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.4;
  white-space: pre;           /* Preserve formatting by default */
}

/* Soft-wrap mode for text */
.text-modal.soft-wrap pre {
  white-space: pre-wrap;      /* Allow long lines to wrap */
  overflow-wrap: anywhere;    /* Break long words if needed */
}

/* HTML content (iframe) */
.text-modal iframe {
  display: block;
  border: 0;
  width: 100%;
  flex: 1;                    /* Fill remaining height */
  min-height: 0;              /* Allow flexbox to shrink */
}
