@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600&display=swap');

body {
  font-family: 'Manrope', 'Segoe UI', Arial, sans-serif;
  font-weight: 400;
  background-color: #f4f4f4;
  margin: 0;
  padding: 0;
  scrollbar-gutter: stable;
}

/* Sleek, non-bold typography: cap emphasis at medium weight. */
h1, h2, h3, h4, h5, h6, b, strong { font-weight: 500; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0px;
}
.chemspace-container {
  max-width: 1200px;
  display: flex;
  justify-content: center;
}

h1 {
  color: #333;
  text-align: center;
}

/* App page title block — Option B style: left navy border, Manrope thin */
.app-title {
  border-left: 4px solid #003372;
  padding: 4px 0 4px 16px;
  margin-bottom: 32px;
}

.app-title h1 {
  font-family: 'Manrope', sans-serif;
  font-weight: 300;
  font-size: 1.9rem;
  color: #0f172a;
  text-align: left;
  margin: 0 0 4px;
}
.app-title p {
  font-size: 0.88rem;
  color: #64748b;
  margin: 0;
  text-align: left;
}

/* Legacy centered-column rules — kept for h1/p fallback but no longer constraining */
.container > h1,
.container > p[align="center"] {
  margin-left: auto;
  margin-right: auto;
}

.stdout-message pre {
  white-space: pre-wrap;
  word-break: break-word;
}

form {
  margin-top: 20px;
}

form label {
  display: block;
  margin-top: 14px;
  margin-bottom: 4px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
}

form input,
form textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  resize: vertical;
  font-size: 0.95rem;
  font-family: inherit;
  background-color: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

form textarea { min-height: 90px; }

form input:focus,
form textarea:focus {
  outline: none;
  border-color: #003372;
  box-shadow: 0 0 0 3px rgba(0, 51, 114, 0.12);
}

/* Checkboxes (BooleanField): the generic `width:100%` above blows them up and
   a centering parent floats them to the middle. Keep them small and put the box
   in FRONT of the label text. Django renders label-then-input, so the row is a
   flexbox and the checkbox is given order:-1 to move ahead of the label. */
form input[type="checkbox"] {
  width: auto;
  min-height: 0;
  padding: 0;
  margin: 0;
  vertical-align: middle;
}
form p:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}
form p:has(input[type="checkbox"]) input[type="checkbox"] {
  order: -1;
  flex: 0 0 auto;
}
form p:has(input[type="checkbox"]) label {
  display: inline;
  margin: 0;
}

/* All primary action buttons (Submit, Download CSV, Post Process, …) share one
   Cage-navy style. */
form button,
.btn-primary,
a.btn-primary,
.execute-button {
    background: #003372;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 11px 18px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.15s ease;
}
form button { margin-top: 18px; min-width: 180px; }
form button:hover,
.btn-primary:hover,
a.btn-primary:hover,
.execute-button:hover {
  background-color: #0a4a9c;
  color: #fff;
}
.btn-primary:focus, a.btn-primary:focus { box-shadow: none; outline: none; }

/* Custom styles for the dropdown list */
select {
  appearance: none;
  -webkit-appearance: none;
  background-color: #fff;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 11px;
  border: 1px solid #d1d5db;
  padding: 10px 34px 10px 12px;
  font-size: 0.95rem;
  width: 100%;
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select:focus {
  outline: none;
  border-color: #003372;
  box-shadow: 0 0 0 3px rgba(0, 51, 114, 0.12);
}

/* Custom styles for the dropdown arrow */
select::-ms-expand {
  display: none;
}

select::after {
  content: '\25BC';
  color: #666;
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  pointer-events: none;
}

/* Custom styles for the dropdown options */
select option {
  background-color: #fff;
  color: #333;
}

/* Custom hover effect for the dropdown options */
select option:hover {
  background-color: #f2f2f2;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.refresh-btn {
    display: inline-block;
    margin-bottom: 10px;
}
.svg-container {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

/* Inline field validation messages (field_validation.js) */
.field-msg {
  display: block;
  font-size: 0.75rem;
  margin-top: 3px;
  min-height: 1em;
}
.field-msg-hint  { color: #94a3b8; }
.field-msg-error { color: #dc2626; }
input.input-error, select.input-error { border-color: #dc2626 !important; }

.svg-container svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* SMILES copy buttons on mol cards */
.mol-copy-row {
  display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 4px; margin-top: 4px;
}
.mol-send-wrap { display: flex !important; }
.mol-copy-btn {
  font-size: 0.58rem; font-family: inherit;
  background: none; border: 1px solid #d1d5db; border-radius: 4px;
  padding: 0 5px; height: 22px; cursor: pointer; color: #475569;
  white-space: nowrap; transition: background 0.1s, color 0.1s;
  -webkit-appearance: none; appearance: none; box-sizing: border-box;
}
.mol-copy-btn:hover { background: #f1f5f9; color: #003372; border-color: #003372; }
.mol-copy-btn.copied { background: #d1fae5; color: #065f46; border-color: #059669; }
/* Allow dropdowns to overflow mol-cards */
.mol-card { overflow: visible !important; }
/* Send to dropdown lives in the same .mol-copy-row as Copy buttons */
.mol-send-wrap { position: relative; display: inline-block; }
/* Send-to dropdown — shared across all apps */
.send-to-wrap { position: relative; display: inline-block; }
.send-to-menu {
  display: none; position: absolute; top: calc(100% + 4px); left: 0;
  background: #fff; border: 1px solid #d1d5db; border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12); min-width: 130px; z-index: 500;
  overflow: hidden;
}
.send-to-wrap.open .send-to-menu { display: block; }
.send-to-menu a {
  display: block; padding: 6px 12px; font-size: 0.75rem; color: #374151;
  text-decoration: none; white-space: nowrap; text-align: left;
}
.send-to-menu a:hover { background: #f0fdf4; color: #166534; }

/* Save Session button — teal, matches Submit button dimensions */
.btn-save-session {
  background: #0e7490 !important; color: #fff !important; border: none !important;
  border-radius: 8px !important; padding: 11px 18px !important;
  font-size: 0.95rem !important; font-weight: 500 !important;
  cursor: pointer; min-width: 180px !important; margin-top: 18px !important;
}
.btn-save-session:hover { background: #0c6478 !important; }

/* Bulk "Send all to" button — cage blue, matches download button scale */
.send-all-btn {
  background: #003372 !important; color: #fff !important; border: none !important;
  border-radius: 4px !important; padding: 5px 12px !important;
  font-size: 0.7rem !important; cursor: pointer; white-space: nowrap;
  font-weight: 500 !important; margin-top: 0 !important; min-width: 0 !important;
  display: inline-block !important; text-decoration: none !important;
}
.send-all-btn:hover { background: #0a4a9c !important; color: #fff !important; }

.mol-send-toggle {
  background: #15803d !important; color: #fff !important; border: 1px solid #15803d !important;
  border-radius: 4px !important; padding: 0 5px !important; height: 22px !important;
  font-size: 0.58rem !important; font-family: inherit !important;
  cursor: pointer; white-space: nowrap;
  -webkit-appearance: none !important; appearance: none !important;
  box-shadow: none !important; min-width: 0 !important; margin: 0 !important;
  box-sizing: border-box !important;
}
.mol-send-toggle:hover { background: #166534 !important; }
.mol-send-menu {
  display: none; position: fixed;
  background: #fff; border: 1px solid #d1d5db !important; border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12); min-width: 120px; z-index: 9999;
  overflow: hidden; padding: 0 !important; text-align: left !important;
}
.mol-send-wrap.open .mol-send-menu { display: block; }
.mol-send-menu a {
  display: block !important; padding: 6px 12px !important;
  font-size: 0.72rem !important; color: #374151 !important;
  text-decoration: none !important; white-space: nowrap;
  font-family: -apple-system, sans-serif !important;
  text-align: left !important;
}
.mol-send-menu a:hover { background: #f0fdf4 !important; color: #166534 !important; }

/* ── Section labels — shared by both picker apps ── */
.hw-section-label {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  color: #64748b; letter-spacing: 0.05em; margin-bottom: 8px;
}

.hw-step-hint { font-size: 0.67rem; color: #94a3b8; margin-top: 2px; }

/* ── hw-num-btn toggle buttons — shared by hetero_walker and rgroup_enumerator ── */
.hw-num-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.hw-num-btn {
  width: 36px; height: 36px; border: 2px solid #cbd5e1; border-radius: 6px;
  background: #f1f5f9; font-size: 1rem; font-weight: 600; color: #94a3b8;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.12s; outline: none;
}
.hw-num-btn:focus { outline: none; box-shadow: none; }
.hw-num-btn:hover { border-color: #0a4a9c; }
.hw-num-btn.active { border-color: #003372; background: #003372; color: #fff; }

/* ── Group headers and grids — shared by rgroup_enumerator and hetero_walker ── */
.hw-group-header {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: #003372;
  padding: 10px 0 6px; border-bottom: 1px solid #e5e7eb; margin-bottom: 8px;
}
.hw-group-grid { margin-bottom: 16px; }

/* ── mol-card — shared by rgroup_enumerator, hetero_walker ── */
.mol-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 6px;
  padding: 5px; text-align: center; overflow: hidden;
}
.mol-card svg { width: 100%; height: auto; max-height: 260px; }
.mol-card .mol-smi {
  font-size: 0.58rem; color: #475569; word-break: break-all;
  margin-top: 4px; font-family: monospace; user-select: all; cursor: text;
}

/* ── Pagination buttons — shared by rgroup_enumerator, hetero_walker, molfilter ── */
.page-btn { background:none; border:1px solid #d1d5db; border-radius:4px; padding:1px 8px; font-size:0.72rem; color:#475569; cursor:pointer; margin-left:4px; }
.page-btn:hover { background:#f1f5f9; }

/* ── Ketcher + atom-picker — shared by rgroup_enumerator and hetero_walker ── */
.rge-panel {
  display: flex; gap: 0; border: 1px solid #e2e8f0; border-radius: 8px;
  overflow: hidden; margin-bottom: 20px;
}
.rge-editor { flex: 1.4; border-right: 1px solid #e2e8f0; display: flex; flex-direction: column; }
.rge-controls { flex: 1; display: flex; flex-direction: column; padding: 16px; min-width: 240px; }

#ketcher-frame { border: none; width: 100%; height: 480px; display: block; }
#ketcher-loading-overlay {
  position: absolute; inset: 0; background: #f8fafc;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; pointer-events: none; z-index: 10;
}
#ketcher-loading-overlay .klo-spinner {
  width: 28px; height: 28px; border: 3px solid #e2e8f0; border-top-color: #003372;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
#ketcher-loading-overlay p { font-size: 0.78rem; color: #64748b; margin: 0; text-align: center; line-height: 1.5; }

#pick-cta-bar {
  padding: 10px 14px; background: #eef4ff; border-top: 2px solid #003372;
  display: flex; align-items: center; gap: 12px;
}
#pick-attach-btn {
  background: #003372; color: #fff; border: none; border-radius: 6px;
  padding: 8px 18px; font-size: 0.82rem; font-weight: 700;
  cursor: pointer; white-space: nowrap; letter-spacing: 0.02em;
}
#pick-attach-btn:hover { background: #0a4a9c; }
#pick-attach-btn.active { background: #0a4a9c; }
#refresh-picker-btn {
  background: #475569; color: #fff; border: none; border-radius: 6px;
  padding: 8px 14px; font-size: 0.82rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
#refresh-picker-btn:hover { background: #334155; }
#pick-cta-hint { font-size: 0.72rem; color: #334155; }

#atom-picker-view { display: none; border-top: 1px solid #e2e8f0; flex-direction: column; }
#mol-svg-outer {
  display: flex; align-items: center; justify-content: center;
  background: #fff; padding: 12px; overflow: hidden;
}
#mol-svg-container { position: relative; display: inline-block; max-width: 100%; }
#mol-svg-container svg { display: block; max-width: 100%; height: auto; }
.atom-hit {
  position: absolute; border-radius: 50%; cursor: pointer;
  background: transparent; transition: background 0.12s;
}
.atom-hit:hover { background: rgba(0, 51, 114, 0.18); }
.atom-hit.selected { background: rgba(0, 51, 114, 0.72); }
#picker-hint {
  padding: 6px 14px 8px; font-size: 0.7rem; color: #64748b;
  border-top: 1px solid #e2e8f0; background: #f8fafc;
}
#attach-count-badge {
  display: inline-block; background: #003372; color: #fff;
  font-size: 0.65rem; font-weight: 700; border-radius: 10px;
  padding: 1px 7px; margin-left: 6px; vertical-align: middle;
}
#attach-clear-btn, #attach-select-all-btn {
  font-size: 0.68rem; color: #64748b; background: none; border: none;
  cursor: pointer; text-decoration: underline; padding: 0; margin-left: 8px;
}

#rge-enumerate-footer {
  padding: 10px 14px 12px; border-top: 1px solid #e2e8f0; background: #f8fafc;
}
#enumerate-btn {
  background: #003372; color: #fff; border: none; border-radius: 6px;
  padding: 9px; text-align: center; font-size: 0.82rem; font-weight: 600;
  cursor: pointer; width: 100%;
}
#enumerate-btn:hover { background: #0a4a9c; }
#enumerate-btn:disabled { background: #94a3b8; cursor: default; }
.rge-hint { font-size: 0.67rem; color: #94a3b8; text-align: center; margin-top: 5px; }

#results-section { display: none; }
.rge-results-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.rge-results-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; color: #64748b; letter-spacing: 0.05em; }
.rge-results-label span { color: #003372; }
.rge-dl-row { display: flex; gap: 6px; align-items: center; }
.rge-dl-btn { background: #e2e8f0; border: none; border-radius: 4px; padding: 5px 12px; font-size: 0.7rem; color: #475569; cursor: pointer; }
.rge-dl-btn:hover { background: #cbd5e1; }

#mol-grid-wrap { max-height: 600px; overflow-y: auto; border: 1px solid #e2e8f0; border-radius: 6px; padding: 8px; }
.rge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 700px) { .rge-grid { grid-template-columns: repeat(2, 1fr); } }

#enum-overlay {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 1080; background: rgba(15, 23, 42, 0.5);
  align-items: center; justify-content: center;
}
.enum-overlay-card {
  background: #fff; border-radius: 12px; padding: 32px 40px;
  max-width: 360px; width: 90%; text-align: center;
  box-shadow: 0 12px 48px rgba(0,0,0,0.3);
}
.enum-spinner {
  width: 2.5rem; height: 2.5rem; border: 4px solid #e2e8f0; border-top-color: #003372;
  border-radius: 50%; animation: spin 0.7s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
#enum-status-text { font-size: 0.85rem; color: #475569; margin: 0 0 16px; }
#cancel-enum-btn {
  margin-top: 4px; background: none; border: 1px solid #cbd5e1; border-radius: 6px;
  padding: 6px 18px; font-size: 0.8rem; color: #64748b; cursor: pointer;
}
#cancel-enum-btn:hover { background: #f1f5f9; }

/* ── Help icon + tooltip — shared across _form_fields.html and _expert_mode.html ── */
.help-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; min-width: 16px; min-height: 16px;
  margin-left: 4px; padding: 0;
  background: #94a3b8; color: #fff;
  border: none; border-radius: 50%;
  font-size: 11px; font-weight: bold; line-height: 1;
  cursor: help;
  transition: background 0.15s ease;
  vertical-align: text-bottom;
}
.help-icon:hover { background: #003372; }

.help-tooltip {
  position: absolute;
  z-index: 1000;
  max-width: 480px;
  padding: 10px 12px;
  background: #1f2937;
  color: #f3f4f6;
  font-size: 0.8rem;
  line-height: 1.4;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.help-tooltip.show { opacity: 1; }
.help-tooltip::before {
  content: '';
  position: absolute;
  top: -6px; left: 12px;
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #1f2937;
}

/* ── Shared streaming/results utilities ──────────────────────────────────── */
.pyxis-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid #cbd5e1;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
.pyxis-progress-wrap {
  margin-top: 10px;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  width: 400px;
  max-width: 100%;
}
.pyxis-progress-bar {
  height: 100%;
  background: #3b82f6;
  border-radius: 4px;
  width: 0%;
  transition: width 0.5s ease;
}
.pyxis-toolbar-btn {
  padding: 4px 12px;
  font-size: 0.8rem;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  color: #374151;
  white-space: nowrap;
}
.pyxis-toolbar-btn:hover { background: #f1f5f9; }
.pyxis-toolbar-btn.active { background: #dbeafe; border-color: #93c5fd; color: #1d4ed8; }
.pyxis-toolbar-btn:disabled { opacity: 0.45; cursor: default; }
