/* define var for bg color */
:root {
  --bg-color: #eaebef;
  --text-color: #000000;
  --border-color: #c7cbd5;
}

body {
  font-family: sans-serif;
  margin: 10px;
  background-color: var(--bg-color);
  color: var(--text-color);
}

main {
  display: flex;
  flex-direction: column;
  width: fit-content;
}

menu {
  padding: 0;
  margin: 0 0 1em 0;
  display: flex;
  justify-content: space-between;
  max-width: 950px;
}

.tabs {
  display: flex;
  gap: 0.5em;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1em;
}

.tabs > .tab {
  padding: 0.5em 1em;
  background: var(--bg-color);
  border-radius: 0.5em 0.5em 0 0;
  border: 1px solid var(--border-color);
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
  color: inherit;
  font: inherit;
  position: relative;
  top: 1px;
  transition: filter 0.1s ease-in-out;
}

.tabs > .tab:hover {
  filter: brightness(95%);
}
.tabs > .tab.active {
  border-bottom: none;
}

.btn {
  appearance: none;
  border: 1px solid var(--border-color);
  background-color: var(--bg-color);
  cursor: pointer;
  padding: 0.5em 1em;
  border-radius: 0.5em;
  display: inline-block;
  text-decoration: none;
  color: inherit;
  font: inherit;
  transition: filter 0.1s ease-in-out;
}

.btn:hover {
  filter: brightness(95%);
}

.btn:disabled, .btn:disabled:hover {
  cursor: not-allowed;
  filter: brightness(100%);
  opacity: 0.5;
}

pre > code {
  max-width: 950px;
  overflow-x: scroll;
  border-radius: 0.5em;
}

.spinner {
  width: 16px;
  height: 16px;
  margin: 4px;
  border: 5px solid #f3f3f3; /* Light gray */
  border-top: 5px solid #3498db; /* Blue */
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.payload-size {
  font-size: 0.85em;
  opacity: 0.6;
  margin: 0.5em 0 0.2em;
}

/* A coloured badge is a warning — full opacity so the colour reads true. */
.payload-size--ok { color: #1a7f37; opacity: 1; }
.payload-size--warn { color: #bf8700; opacity: 1; }
.payload-size--over { color: #d1242f; opacity: 1; }

/* Custom Fields Editor */
.custom-fields-editor {
  margin: 1em 0;
  max-width: 950px;
  border: 1px solid var(--border-color);
  border-radius: 0.5em;
  background: var(--bg-color);
}

.custom-fields-editor summary {
  padding: 0.75em 1em;
  cursor: pointer;
  font-weight: bold;
}

/* Border only when expanded, so a collapsed editor has no doubled edge. */
.custom-fields-editor[open] summary {
  border-bottom: 1px solid var(--border-color);
}

#custom-fields-container {
  padding: 1em;
  display: flex;
  flex-direction: column;
  gap: 0.5em;
}

.custom-field-row {
  display: flex;
  gap: 0.5em;
  align-items: center;
}

.custom-field-row input {
  padding: 0.5em;
  border: 1px solid var(--border-color);
  border-radius: 0.25em;
  background: var(--bg-color);
  color: var(--text-color);
}

.custom-field-row input[name="key"] {
  width: 150px;
}

.custom-field-row input[name="key"].required-field {
  background: #3b82f620;
  border-color: #3b82f6;
  font-weight: bold;
}

.custom-field-row input[name="value"] {
  flex: 1;
}

.custom-field-row select[name="value"],
.custom-field-select {
  flex: 1;
  padding: 0.5em;
  border: 1px solid var(--border-color);
  border-radius: 0.25em;
  background: var(--bg-color);
  color: var(--text-color);
  font: inherit;
}

.custom-field-row .btn-remove {
  padding: 0.3em 0.6em;
  background: #ef4444;
  color: white;
  border: none;
}

.custom-fields-actions {
  padding: 1em;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 0.5em;
  justify-content: flex-end;
}

/* Matches the transform-error banner styling used above the preview. */
.custom-fields-error {
  margin: 0 1em 1em;
  padding: 0.5em 0.75em;
  background: #fee;
  border: 1px solid #c33;
  border-radius: 4px;
  color: #900;
  white-space: pre-wrap;
}

.btn-primary {
  background: #3b82f6;
  color: white;
  border-color: #2563eb;
}

.btn-primary:hover {
  filter: brightness(110%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #191b21;
    --text-color: #eeeeee;
    --border-color: #3a3e47;
  }
}
