/* ---------- Base ---------- */
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  margin: 20px;
  background: #999;
}

h1 {
  margin-bottom: 10px;
}

b {
  background-color: rgba(0, 195, 255, 0.311);
}

/* ---------- Inputs ---------- */
textarea {
  width: 100%;
  height: 160px;
  padding: 10px;
  margin-bottom: 10px;
  font-family: monospace;
  border: 1px solid #888;
  border-radius: 6px;
}

b {
  display: inline;
}

button {
  padding: 8px 14px;
  margin-bottom: 15px;
  background: #4f46e5;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  background: #4338ca;
}

/* ---------- Viewer ---------- */
.viewer {
  background: #777;
  border-radius: 6px;
  padding: 12px;
  font-family: monospace;
  font-size: 14px;
}

.error {
  color: red;
  font-weight: bold;
}

/* ---------- Tree ---------- */
.node {
  margin-left: 16px;
}

.toggle {
  margin-right: 4px;
  cursor: pointer;
  user-select: none;
}

.header {
  font-size: 20px;
  border: 1px solid black;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
  margin-right: 1rem;
  padding-left: 1rem;
}

.collapsed>.children,
.collapsed>.flex {
  display: none;
}

.collapse_text {
  display: inline-block;
  min-width: 0;
  max-width: 60%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flex {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid black;
  border-bottom-left-radius: 5px;
  border-bottom-right-radius: 5px;
  margin-right: 1rem;
}

.tall {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0;
}

.tall button {
  min-width: 90px;
  margin: 1px 0 1px 0.5rem;
}

.flex>div:not(.tall):not(.collapse_text) {
  display: flex;
  align-items: center;
}

/* ---------- State ---------- */
.required>.header,
.required>.flex {
  background-color: #16a34a;
}

:not(.required)>.flex>span {
  opacity: 0.7;
}

.recommended:not(.required)>.header {
  background-color: rgb(187, 189, 19);
}

.recommended:not(.required)>.flex {
  background-color: rgba(187, 189, 19, 0.7);
}

.gm:not(.required)>.header {
  background-color: rgb(255, 255, 255);
}

.gm:not(.required)>.flex {
  background-color: rgb(200, 200, 200);
}

.gm:not(.required)>.flex>span {
  opacity: 1.0;
}

.need-review:not(.required)>.header {
  background-color: rgb(200, 79, 79);
}

.need-review:not(.required)>.flex {
  background-color: rgba(143, 19, 19, 0.7);
}

.hidden {
  display: none;
}

/* ---------- Value Types ---------- */
.string {
  color: black;
  padding-right: 0.5rem;
  display: block;
}

/* ---------- Header & Banner ---------- */
#header {
  margin: 0 auto;
  padding-top: 40px;
  text-align: center;
  opacity: 1;
}

#banner {
  background-color: #333;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  border-bottom: 3px solid #ccc;
  display: flex;
  justify-content: center;
  height: 80px;
}

#search {
  position: absolute;
  top: 18%;
  left: 2%;
  width: 10%;
  height: 25px;
}

#search_button {
  position: absolute;
  top: 20%;
  left: 15%;
}

#help {
  position: absolute;
  top: 20%;
  right: 2%;
}

#banner>p {
  color: white;
  font-size: 12px;
  position: inherit;
  text-align: center;
}

#disclaimer {
  top: 40px;
}

#dev {
  top: 53px;
}

#legend {
  background-color: #555;
  border-radius: 10px;
  margin: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  width: 450px;
}

#gm {
  color: red;
  background-color: #222;
  border-radius: 2px;
}
#errors {
  color: red;
  background-color: #222;
  border-radius: 2px;
}
.legend_text {
  height: 20px;
  font-size: 15px;
  padding: 0 10px;
  line-height: 20px;
  border: 2px solid black;
  border-radius: 10px;
}

.gray {
  background-color: #777;
  border-color: #222;
}

.yellow {
  background-color: rgba(187, 189, 19, 0.7);
  border-color: rgb(187, 189, 19);
}

.red {
  background-color: rgba(239, 81, 76, 0.7);
  border-color: rgb(150, 17, 12);
}

.green {
  background-color: #16a34a;
  border-color: #5afe96;
}

/* ---------- Modals ---------- */
.modal,
.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: white;
  padding: 2rem;
  padding-top: 1rem;
  width: 500px;
  height: 600px;
  overflow: auto;
  max-width: 90%;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  position: relative;
  animation: slideIn 0.25s ease;
}

.close-btn,
#closeHelp {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: none;
  font-size: 22px;
  cursor: pointer;
}

@keyframes slideIn {
  from {
    transform: translateY(-15px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ---------- Cluster Modal ---------- */
.modal_questions {
  background: white;
  width: 85%;
  height: 85vh;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 1rem;
  background: #1e293b;
  color: white;
  display: flex;
  justify-content: space-between;
}

.modal-header h2 {
  display: inline-block;
}

.modal-header button {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.modal-left {
  width: 40%;
  border-right: 1px solid #ddd;
  overflow-y: auto;
  padding: 1rem;
  background: #f8fafc;
}

.modal-right {
  width: 60%;
  padding: 1.5rem;
  overflow-y: auto;
}

.cluster-group {
  margin-bottom: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
}

.cluster-title {
  grid-column: 1 / -1;
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: #1e293b;
}

.node-card {
  padding: 0.5rem;
  margin-bottom: 0.4rem;
  border-radius: 6px;
  background: white;
  border: 1px solid #ddd;
  cursor: pointer;
  transition: background 0.15s ease;
}

.node-card:hover {
  background: #e2e8f0;
}

.node-card.active {
  background: #cbd5e1;
  border-color: #64748b;
}

/* ---------- Details ---------- */
.detail-section {
  font-weight: bold;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.detail-header {
  font-weight: bold;
  margin-bottom: 0.75rem;
}

.detail-text {
  line-height: 1.5;
  white-space: pre-wrap;
}

.detail-placeholder {
  color: #64748b;
  font-style: italic;
}

.detail-actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #ddd;
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
}

.detail-actions button,
.detail-actions select {
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  cursor: pointer;
  font-size: 14px;
  height: 35px;
}

.detail-actions button {
  background: #ef4444;
  color: white;
  border: none;
}

.detail-actions button:hover {
  background: #dc2626;
}

.detail-actions select {
  background: white;
}

#moveClusterSelect {
  color: white;
  background-color: #16a34a;
}

/* ---------- Loading Overlay ---------- */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 15, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  font-family: Arial, sans-serif;
  font-size: 18px;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
}

#loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #444;
  border-top: 5px solid #4f46e5;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}