/* ORAC admin: full content width, flat layout (no inner “card” box) */

.dashboard-main.admin-orac-page {
  width: 100%;
  max-width: none;
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  align-self: stretch;
  /* Fill the scroll region so the page uses full viewport height under the navbar */
  min-height: calc(100vh - var(--top-navbar-height, 64px) - 44px);
  box-sizing: border-box;
}

.admin-orac-page .admin-page-header {
  border: none;
  box-shadow: none;
  background: transparent;
  border-radius: 0;
  padding: 8px 0 20px;
  margin: 0;
  border-bottom: 1px solid var(--theme-gray-100);
}

.admin-form-builder-panel,
.admin-orac-page .admin-form-builder-panel {
  border: none;
  box-shadow: none;
  background: transparent;
  border-radius: 0;
  padding: 20px 0 32px;
  margin: 0;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.admin-form-builder-panel h2 {
  margin: 0 0 12px;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.admin-form-builder-hint {
  font-size: 13px;
  color: var(--theme-gray-500);
  margin: 0 0 16px;
  line-height: 1.45;
  max-width: 52rem;
}

.admin-form-builder-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
}

@media (max-width: 720px) {
  .admin-form-builder-grid {
    grid-template-columns: 1fr;
  }
}

.admin-form-builder-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-form-builder-field label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--theme-gray-500);
}

.admin-form-builder-field input,
.admin-form-builder-field select,
.admin-form-builder-field textarea {
  border: 1px solid var(--theme-gray-200);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  width: 100%;
  box-sizing: border-box;
}

.admin-form-builder-field textarea {
  min-height: 72px;
  resize: vertical;
}

.admin-form-builder-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.admin-form-builder-msg {
  font-size: 13px;
  margin: 8px 0 0;
}

.admin-form-builder-msg--ok {
  color: var(--theme-green, #15803d);
}

.admin-form-builder-msg--err {
  color: var(--theme-red);
}

.admin-form-builder-table-wrap {
  overflow-x: auto;
  margin-top: 16px;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

.admin-form-builder-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-form-builder-table th,
.admin-form-builder-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--theme-gray-100);
  vertical-align: top;
}

.admin-form-builder-table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--theme-gray-500);
  background: rgba(0, 0, 0, 0.02);
}

.admin-form-builder-table tr:last-child td {
  border-bottom: none;
}

.admin-form-builder-danger {
  border: 1px solid rgba(185, 28, 28, 0.35);
  border-radius: 8px;
  background: var(--theme-white);
  color: #b91c1c;
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit;
}

.admin-form-builder-danger:hover {
  background: #fef2f2;
}

.admin-form-builder-subcard {
  margin-top: 16px;
  padding: 16px 0 0;
  border-radius: 0;
  border: none;
  border-top: 1px dashed var(--theme-gray-200);
  background: transparent;
  width: 100%;
}

.admin-form-builder-subcard summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--theme-gray-700);
}

.admin-form-builder-form-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
  width: 100%;
}

.admin-form-builder-form-row .admin-form-builder-field {
  flex: 1;
  min-width: min(200px, 100%);
}

.admin-form-builder-section-block {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--theme-gray-100);
  width: 100%;
}

.admin-form-builder-section-block:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.admin-form-builder-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.admin-form-builder-section-head strong {
  font-size: 15px;
}

.admin-form-builder-question-list {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  color: var(--theme-gray-700);
}

.admin-form-builder-question-list li {
  margin-bottom: 6px;
}

/* Form edit — questions hidden until expanded */
.admin-form-details__section-questions {
  margin-top: 6px;
  border: 1px solid var(--theme-gray-100);
  border-radius: 8px;
  background: var(--theme-gray-50, #f8fafc);
}

.admin-form-details__section-questions-summary {
  cursor: pointer;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--theme-gray-700);
  list-style: none;
}

.admin-form-details__section-questions-summary::-webkit-details-marker {
  display: none;
}

.admin-form-details__section-questions-summary::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  margin-right: 8px;
  vertical-align: middle;
  border-left: 5px solid var(--theme-gray-500);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s ease;
}

.admin-form-details__section-questions[open] .admin-form-details__section-questions-summary::before {
  transform: rotate(90deg);
}

.admin-form-details__section-questions .admin-form-builder-question-list {
  margin: 0 12px 12px;
  padding: 10px 12px 10px 28px;
  background: var(--theme-white, #fff);
  border-radius: 6px;
  border: 1px solid var(--theme-gray-100);
}

/* Section detail page — must keep overflow-y:auto so AppShell’s main scroll region works
   (overflow:visible overrides .app-shell-content-main > .dashboard-main and breaks page scroll). */
.dashboard-main.admin-orac-page.admin-section-detail {
  --asd-maroon: var(--theme-maroon-deep, #7a1530);
  --asd-gray: #64748b;
  --asd-gray-light: #cbd5e1;
  --asd-gray-soft: #f1f5f9;
  --asd-divider: linear-gradient(
    90deg,
    rgba(148, 163, 184, 0.85) 0%,
    rgba(122, 21, 48, 0.88) 50%,
    rgba(148, 163, 184, 0.85) 100%
  );
  --asd-bar-v: linear-gradient(180deg, #94a3b8 0%, #7a1530 50%, #94a3b8 100%);
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  background: linear-gradient(180deg, #f8fafc 0%, var(--theme-white, #fff) 28%);
  gap: 0;
  padding-top: 10px;
  padding-bottom: 24px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.dashboard-main.admin-section-detail .admin-page-header.admin-section-detail__toolbar {
  padding: 16px 18px 18px;
  margin: 0 0 0;
  border: 1px solid rgba(122, 21, 48, 0.14);
  border-left: 4px solid var(--asd-maroon);
  border-radius: 14px;
  background: linear-gradient(
    155deg,
    rgba(148, 163, 184, 0.14) 0%,
    rgba(255, 255, 255, 0.98) 42%,
    rgba(122, 21, 48, 0.07) 100%
  );
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.07);
}

.dashboard-main.admin-section-detail .admin-section-detail__toolbar .admin-page-badge {
  border-color: rgba(122, 21, 48, 0.22);
  background: rgba(122, 21, 48, 0.07);
  color: var(--asd-maroon);
  font-weight: 700;
}

.dashboard-main.admin-section-detail .admin-section-detail__toolbar h1 {
  margin: 0 0 8px;
  font-size: clamp(1.35rem, 2.5vw, 1.65rem);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--asd-maroon);
  background: linear-gradient(100deg, #64748b 0%, #7a1530 48%, #64748b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

@supports not (background-clip: text) {
  .dashboard-main.admin-section-detail .admin-section-detail__toolbar h1 {
    color: var(--asd-maroon);
    background: none;
  }
}

.dashboard-main.admin-section-detail .admin-section-detail__lead {
  margin: 0;
  font-size: 14px;
  color: var(--theme-gray-600);
  line-height: 1.45;
  border-left: 3px solid rgba(122, 21, 48, 0.4);
  padding-left: 12px;
}

.dashboard-main.admin-section-detail .admin-form-builder-msg {
  margin: 10px 0 0;
}

.admin-section-detail__toolbar {
  flex-shrink: 0;
}

/* Region: linked questions — divider from hero header */
.admin-section-detail__list-heading {
  flex-shrink: 0;
  position: relative;
  margin-top: 22px;
  padding: 18px 4px 10px;
}

.admin-section-detail__list-heading::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 2px;
  background: var(--asd-divider);
  opacity: 0.95;
}

.admin-section-detail__list-heading h2 {
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--asd-maroon);
}

.admin-section-detail__list-heading h2::before {
  content: '';
  width: 5px;
  height: 1.2em;
  border-radius: 4px;
  background: var(--asd-bar-v);
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(122, 21, 48, 0.25);
}

.admin-section-detail__list-heading .admin-form-builder-hint {
  margin: 0 0 8px;
  line-height: 1.45;
  padding-left: 15px;
  color: var(--theme-gray-600);
}

/* Scroll still works (wheel / touch / keyboard); bars hidden for a cleaner panel */
.dashboard-main.admin-orac-page.admin-section-detail,
.admin-section-detail__list-scroll,
.admin-section-detail__checkboxes {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.dashboard-main.admin-orac-page.admin-section-detail::-webkit-scrollbar,
.admin-section-detail__list-scroll::-webkit-scrollbar,
.admin-section-detail__checkboxes::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* Grow removed: was flex:1 which stretched empty space between header and footer */
.admin-section-detail__list-scroll {
  position: relative;
  flex: 0 1 auto;
  align-self: stretch;
  /* Taller panel so more linked questions are visible without scrolling */
  min-height: 220px;
  max-height: min(62vh, 560px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  margin: 0;
  padding: 12px 0 10px;
  border: 1px solid rgba(148, 163, 184, 0.38);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--asd-gray-soft) 0%, var(--theme-white) 56px);
  box-shadow:
    0 8px 28px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.admin-section-detail__list-scroll::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(90deg, #94a3b8 0%, #7a1530 50%, #94a3b8 100%);
  pointer-events: none;
}

.admin-section-detail__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.admin-section-detail__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.28);
  background: linear-gradient(90deg, rgba(148, 163, 184, 0.12) 0%, rgba(122, 21, 48, 0.05) 14%, rgba(241, 245, 249, 0.5) 28%, transparent 55%);
}

.admin-section-detail__row:last-child {
  border-bottom: none;
}

.admin-section-detail__row--group {
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

.admin-section-detail__row-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.admin-section-detail__combined-children {
  margin: 8px 0 0 12px;
  padding: 0 0 0 18px;
  list-style: disc;
  font-size: 13px;
  color: var(--theme-gray-600);
  width: 100%;
  box-sizing: border-box;
}

.admin-section-detail__qtext {
  font-size: 15px;
  line-height: 1.45;
  color: var(--theme-gray-800);
  word-break: break-word;
}

.admin-section-detail__qid {
  font-size: 13px;
  color: var(--theme-gray-400);
  margin-left: 6px;
}

.admin-section-detail__empty {
  padding: 12px 14px;
  text-align: center;
  font-size: 14px;
  color: var(--theme-gray-500);
}

.admin-section-detail__footer {
  flex-shrink: 0;
  position: relative;
  padding: 22px 4px 4px;
  margin-top: 24px;
  border-top: none;
}

.admin-section-detail__footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 2px;
  background: var(--asd-divider);
}

.admin-section-detail__footer .admin-form-builder-form-row {
  margin-top: 0;
}

.admin-section-detail__footer .admin-form-builder-field {
  gap: 4px;
}

.admin-section-detail__footer-actions {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed rgba(15, 23, 42, 0.1);
}

.admin-section-detail__add-form {
  width: 100%;
}

.admin-section-detail__fieldset {
  border: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.admin-section-detail__legend {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--asd-maroon);
  background: linear-gradient(135deg, rgba(148, 163, 184, 0.2) 0%, rgba(255, 255, 255, 0.95) 45%, rgba(148, 163, 184, 0.16) 100%);
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(122, 21, 48, 0.06);
}

.admin-section-detail__legend::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #94a3b8, #7a1530, #94a3b8);
  flex-shrink: 0;
}

.admin-section-detail__add-hint {
  margin-bottom: 10px !important;
}

.admin-section-detail__pool-empty {
  margin: 0;
  font-size: 14px;
  color: var(--theme-gray-500);
}

.admin-section-detail__checkboxes {
  max-height: min(48vh, 480px);
  overflow-y: auto;
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 12px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(241, 245, 249, 0.95) 0%, var(--theme-white) 36px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 0 rgba(122, 21, 48, 0.06);
}

.admin-section-detail__pick-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 4px;
  margin: 0;
  cursor: pointer;
  font-size: 15px;
  line-height: 1.4;
}

.admin-section-detail__pick-row input {
  margin-top: 3px;
  flex-shrink: 0;
}

.admin-section-detail__pick-text {
  flex: 1;
  min-width: 0;
}

.admin-section-detail__add-actions {
  margin-top: 12px;
}

.admin-orac-form-add-questions__box {
  max-height: min(32vh, 280px);
}

/* Sections page: stack of section blocks with question tools */
.admin-orac-sections-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  margin-top: 8px;
}

/* ORAC sections list: white canvas, tighter header spacing, tall scrollable table */
.dashboard-main.admin-orac-sections-page {
  background: var(--theme-white, #fff);
  gap: 8px;
  padding-top: 12px;
  padding-bottom: 20px;
  box-sizing: border-box;
}

.dashboard-main.admin-orac-sections-page .admin-orac-sections-page__header {
  padding: 2px 0 10px;
  margin: 0;
  border-bottom: 1px solid var(--theme-gray-100);
}

.dashboard-main.admin-orac-sections-page .admin-orac-sections-page__header h1 {
  margin: 0 0 4px;
  font-size: 25px;
  line-height: 1.2;
}

.dashboard-main.admin-orac-sections-page .admin-orac-sections-page__lead {
  margin: 0;
  font-size: 14px;
  color: var(--theme-gray-500);
  line-height: 1.35;
}

.dashboard-main.admin-orac-sections-page .admin-form-builder-msg {
  margin: 4px 0 0;
}

.dashboard-main.admin-orac-sections-page .admin-orac-sections-page__panel {
  padding: 8px 0 12px;
}

.dashboard-main.admin-orac-sections-page .admin-orac-sections-page__panel > h2:first-of-type {
  margin: 0 0 4px;
  font-size: 19px;
}

.dashboard-main.admin-orac-sections-page .admin-orac-sections-page__hint {
  margin: 0 0 10px;
}

.dashboard-main.admin-orac-sections-page .admin-orac-sections-page__form .admin-form-builder-actions {
  margin-top: 8px;
}

.dashboard-main.admin-orac-sections-all {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--theme-gray-100);
}

.dashboard-main.admin-orac-sections-all > h2 {
  margin: 0 0 4px;
  font-size: 19px;
}

.dashboard-main.admin-orac-sections-all .admin-orac-sections-all__hint {
  margin: 0 0 8px;
}

.dashboard-main.admin-orac-sections-page .admin-orac-sections-table-wrap {
  margin-top: 0;
  min-height: min(65vh, 800px);
  overflow: auto;
  border: 1px solid var(--theme-gray-100);
  border-radius: 8px;
  background: var(--theme-white);
  flex: 1 1 auto;
}

.dashboard-main.admin-orac-sections-page .admin-orac-sections-table-wrap .admin-form-builder-table {
  margin: 0;
}

.dashboard-main.admin-orac-sections-page .admin-orac-sections-table-wrap .admin-form-builder-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  box-shadow: 0 1px 0 var(--theme-gray-100);
}

/* ORAC questions page: two tabs (list vs create) */
.admin-questions-tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 20px;
  padding: 0;
  border-bottom: 1px solid var(--theme-gray-100);
  padding-bottom: 12px;
}

.admin-questions-tab {
  border: 1px solid var(--theme-gray-200);
  border-radius: 999px;
  padding: 8px 16px;
  background: var(--theme-white);
  color: var(--theme-gray-600);
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.admin-questions-tab:hover {
  background: var(--theme-gray-50);
}

.admin-questions-tab--active {
  background: var(--theme-black);
  border-color: var(--theme-black);
  color: var(--theme-gray-50);
}

.admin-questions-tab--active:hover {
  background: var(--theme-gray-900);
}

/* All questions tab: table only — no inner panel/card wrappers */
.admin-questions-tab-body {
  width: 100%;
  padding: 0 0 8px;
}

.admin-questions-inline-options {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--theme-gray-100);
}
