/* ── Editor Three-Panel Layout ────────────────────────────── */
.editor-layout {
  display: flex;
  height: calc(100vh - 3.5rem); /* subtract navbar height */
  overflow: hidden;
}

/* ── Rail ─────────────────────────────────────────────────── */
.editor-rail {
  width: 64px;
  background: #1e293b;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 0.5rem;
  gap: 0.25rem;
  flex-shrink: 0;
}

.rail-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  padding: 0.5rem 0.25rem;
  width: 56px;
  border: none;
  border-radius: 0.375rem;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.rail-btn:hover {
  background: #334155;
  color: #e2e8f0;
  text-decoration: none;
}

.rail-btn.active {
  background: #334155;
  color: #fff;
}

.rail-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.55rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.editor-sidebar {
  width: 280px;
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

#sidebar-content {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
}

/* ── Main Content ────────────────────────────────────────── */
.editor-main {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* ── Sidebar Tree Nodes ──────────────────────────────────── */
.sidebar-section {
  padding: 0.75rem;
}

.sidebar-section-title {
  display: flex;
  align-items: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #64748b;
  padding: 0.25rem 0.5rem;
  margin-bottom: 0.25rem;
}

.tree-section-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  width: 1.1rem;
  height: 1.1rem;
  padding: 0;
  border: none;
  border-radius: 0.25rem;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.tree-section-toggle:hover {
  background: #e2e8f0;
  color: #334155;
}

.tree-section-toggle svg {
  width: 0.85rem;
  height: 0.85rem;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  border-radius: 0.25rem;
  transition: background 0.1s;
}

.tree-row:hover {
  background: #e2e8f0;
}

.tree-node {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.8rem;
  color: #334155;
  text-decoration: none;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}

.tree-node.active {
  background: #dbeafe;
  color: #1e40af;
  font-weight: 500;
}

.tree-node-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.tree-node-icon.hw { color: #c2410c; }
.tree-node-icon.sw { color: #6d28d9; }

.tree-children {
  padding-left: 1rem;
}

.tree-children[data-collapsed="true"] {
  display: none;
}

.tree-folder-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex: 1;
  min-width: 0;
}

/* ── Sidebar Resource List ───────────────────────────────── */
.resource-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  font-size: 0.8rem;
  color: #334155;
  text-decoration: none;
  transition: background 0.1s;
}

.resource-item:hover {
  background: #e2e8f0;
}

.resource-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
  padding: 0.1rem 0.4rem;
  border-radius: 9999px;
}

/* ── Collapsible Tree Toggle ─────────────────────────────── */
.tree-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  padding: 0;
  border: none;
  border-radius: 0.125rem;
  background: transparent;
  cursor: pointer;
  color: #94a3b8;
  flex-shrink: 0;
}

.tree-toggle:hover {
  color: #334155;
}

.tree-toggle-icon {
  width: 0.7rem;
  height: 0.7rem;
  transition: transform 0.15s;
}

.tree-toggle.expanded .tree-toggle-icon {
  transform: rotate(90deg);
}

.tree-toggle-spacer {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* ── Editor Tabs ─────────────────────────────────────────── */
.editor-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 1rem;
}

.editor-tab {
  padding: 0.5rem 1rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #64748b;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: all 0.15s;
}

.editor-tab:hover {
  color: #334155;
  background: #f8fafc;
}

.editor-tab.active {
  color: #1e40af;
  border-bottom-color: #1e40af;
}

/* ── Sentry Bar (sidebar bottom) ─────────────────────────── */
.sentry-bar {
  flex: 0 0 auto;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  padding: 0.5rem;
  display: flex;
  gap: 0.375rem;
}

.sentry-badge {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 0.375rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.1s, box-shadow 0.1s;
}

.sentry-badge:hover {
  filter: brightness(0.95);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.sentry-badge-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.sentry-badge-count {
  font-variant-numeric: tabular-nums;
}

.sentry-badge-error {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}

.sentry-badge-warning {
  background: #fef3c7;
  color: #b45309;
  border-color: #fde68a;
}

.sentry-badge-info {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

/* `sentry-badge-active` is applied by the template when the badge's
   count is > 0 — saturated background + white text so the badge reads
   as "something to resolve" instead of blending in with the chrome. */
.sentry-badge-error.sentry-badge-active {
  background: #dc2626;
  color: #fff;
  border-color: #b91c1c;
}

.sentry-badge-warning.sentry-badge-active {
  background: #f59e0b;
  color: #fff;
  border-color: #d97706;
}

.sentry-badge-info.sentry-badge-active {
  background: #2563eb;
  color: #fff;
  border-color: #1d4ed8;
}

/* ── Resizable table edit dialogs ───────────────────────── */
.modal-box.resizable-edit-modal {
  width: min(72rem, calc(100vw - 2rem)) !important;
  max-width: calc(100vw - 2rem) !important;
  max-height: calc(100vh - 2rem) !important;
  min-width: min(24rem, calc(100vw - 2rem));
  min-height: 18rem;
  resize: both;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.modal-box.resizable-edit-modal.is-fullscreen {
  width: calc(100vw - 2rem) !important;
  height: calc(100vh - 2rem) !important;
  max-width: calc(100vw - 2rem) !important;
  max-height: calc(100vh - 2rem) !important;
  resize: none;
}

.mca-modal-box {
  display: flex;
  flex-direction: column;
}

.mca-step-panel {
  flex: 1 1 auto;
}

.resizable-edit-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex: 0 0 auto;
}

.resizable-edit-fullscreen-toggle {
  flex: 0 0 auto;
}

.resizable-edit-form {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}

.resizable-edit-table-wrap {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.resizable-edit-table-wrap table {
  width: 100%;
  min-width: max-content;
}

.resizable-edit-table-wrap table,
.resizable-edit-table-wrap tbody,
.resizable-edit-table-wrap tr,
.resizable-edit-table-wrap td {
  height: 100%;
}

.resizable-edit-table-wrap td:has(.resizable-edit-textarea) {
  min-width: 18rem;
}

.resizable-edit-textarea {
  min-width: 100%;
  min-height: 10rem;
  width: 100%;
  height: 100%;
  resize: both;
}

@media (max-width: 640px) {
  .modal-box.resizable-edit-modal,
  .modal-box.resizable-edit-modal.is-fullscreen {
    width: calc(100vw - 1rem) !important;
    max-width: calc(100vw - 1rem) !important;
    max-height: calc(100vh - 1rem) !important;
    min-width: 0;
  }
}

.safety-editor-table {
  min-width: 100%;
  width: max-content;
  table-layout: fixed;
}

.safety-editor-table-select-col {
  width: 4rem;
}

.safety-editor-table-approved-col {
  width: 5.75rem;
}

.safety-editor-table-actions-col {
  width: 10rem;
}

.safety-editor-table-id-col {
  width: 5.5rem;
}

.safety-editor-table-guide-word-col {
  width: 8.5rem;
}

.safety-editor-table-score-col {
  width: 4.5rem;
}

.safety-editor-table-compact-data-col {
  width: 7.5rem;
}

.safety-editor-table-medium-data-col {
  width: 13rem;
}

.safety-editor-table-wide-data-col {
  width: 18rem;
}

.safety-editor-table-extra-wide-data-col {
  width: 24rem;
}

.safety-editor-table .safety-editor-table-control-col {
  white-space: nowrap;
}

.safety-editor-table .safety-editor-table-data-col,
.safety-editor-table .safety-editor-table-cell {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
  resize: horizontal;
  overflow: auto;
}

.safety-editor-table .safety-editor-table-data-col {
  vertical-align: bottom;
}

.safety-editor-table .safety-editor-table-compact-heading {
  overflow-wrap: normal;
}

/* ── Sentry Popup (fixed-position issue list) ───────────── */
.sentry-popup {
  position: fixed;
  bottom: 60px;
  left: 350px;
  width: min(800px, calc(100vw - 380px));
  height: min(520px, 50vh);
  min-width: min(360px, calc(100vw - 2rem));
  min-height: 220px;
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  background: #fff;
  background-color: #fff;
  border-radius: 0.5rem;
  z-index: 1200;
  overflow: hidden;
  resize: both;
  pointer-events: auto;
}

.sentry-popup.sentry-popup-fullscreen {
  inset: 1rem;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  resize: none;
}

.sentry-popup-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e2e8f0;
  background: rgba(255, 255, 255, 0.6);
}

.sentry-popup-fullscreen-toggle,
.sentry-popup-close {
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 0.25rem;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
  color: inherit;
  cursor: pointer;
}

.sentry-popup-fullscreen-toggle {
  margin-left: auto;
  margin-right: 0.25rem;
}

.sentry-popup-fullscreen-toggle:hover,
.sentry-popup-close:hover {
  background: rgba(0, 0, 0, 0.06);
}

.sentry-popup-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .editor-sidebar {
    display: none;
  }
  .editor-rail {
    width: 52px;
  }
  .sentry-popup {
    left: 1rem;
    width: calc(100vw - 2rem);
  }
}
