/* LonWorks XIF -> QuickServer converter
   ----------------------------------------
   Clean, readable, framework-free. The visual tone follows docs.chipkin.com:
   neutral background, slightly rounded cards, a single accent colour for
   the interactive parts. */

:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --border: #d6dce5;
  --text: #1d2330;
  --muted: #5a6473;
  --accent: #1a6dc1;
  --accent-hover: #145397;
  --warn-bg: #fff7e0;
  --warn-fg: #6b4d00;
  --error-bg: #fde8e8;
  --error-fg: #861b1b;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

header.page {
  background: linear-gradient(180deg, #1a6dc1 0%, #145397 100%);
  color: #fff;
  padding: 1.25rem 1.5rem;
}
header.page h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
}
header.page p {
  margin: 0.25rem 0 0;
  opacity: 0.85;
  font-size: 0.95rem;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

section.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}
section.card h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

/* Drop zone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.dropzone:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone.hover, .dropzone:hover {
  background: #eef4fb;
  border-color: var(--accent);
  color: var(--text);
}
.dropzone strong { color: var(--text); }

/* Summary */
dl.summary {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.35rem 1rem;
  margin: 0 0 1rem;
  font-size: 0.95rem;
}
dl.summary dt { color: var(--muted); font-weight: 600; }
dl.summary dd { margin: 0; font-family: var(--mono); }
dl.summary dd.dt-desc {
  grid-column: 1 / -1;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 0.4rem 0;
  padding-bottom: 0.3rem;
  border-bottom: 1px dashed var(--border);
}
dl.summary dd.dt-desc a { color: var(--accent); }
dl.summary dd.dt-desc code {
  font-family: var(--mono);
  background: #eef1f5;
  padding: 0 0.25rem;
  border-radius: 3px;
}

.subhead {
  margin: 1.2rem 0 0.4rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.help-text {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.6rem 0;
  line-height: 1.55;
}
.help-text a { color: var(--accent); }
.help-text code {
  font-family: var(--mono);
  background: #eef1f5;
  padding: 0 0.25rem;
  border-radius: 3px;
}

.field-help {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.25rem;
  line-height: 1.45;
  font-family: var(--sans);
}
.field-help a { color: var(--accent); }
.field-help code {
  font-family: var(--mono);
  background: #eef1f5;
  padding: 0 0.25rem;
  border-radius: 3px;
}

.scrollbox {
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 0.5rem;
}

/* Highlight for required-but-no-good-default fields (Neuron ID). */
.form-grid label.required-field {
  background: #fff7e0;
  border: 1px solid #f1c40f;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  box-shadow: 0 0 0 3px rgba(241, 196, 15, 0.12);
}
.required-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  font-weight: 600;
}
.required-pill {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  background: #d97706;
  color: #fff;
  border-radius: 999px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.required-input {
  border-color: #f1c40f !important;
}
.required-input:focus {
  border-color: #d97706 !important;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.2) !important;
}

/* Inline code inside the NV-table direction column. */
table.nv td code {
  font-family: var(--mono);
  font-size: 0.82rem;
  background: #eef1f5;
  padding: 0 0.25rem;
  border-radius: 3px;
}

#nv-table-wrap {
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 0.5rem;
}
table.nv {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  font-family: var(--mono);
}
table.nv th, table.nv td {
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
table.nv th {
  background: #f0f3f7;
  position: sticky;
  top: 0;
  font-weight: 600;
}

/* Config form */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem 1.5rem;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.form-grid input {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.92rem;
  color: var(--text);
  background: #fff;
}
.form-grid input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 109, 193, 0.15);
}

/* Tabs */
.tablist {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}
.tab {
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  padding: 0.5rem 1rem;
  font-size: 0.92rem;
  cursor: pointer;
  color: var(--muted);
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}
.tab[aria-selected="true"] {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
  position: relative;
  top: 1px;
}
.tab:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

pre#preview {
  font-family: var(--mono);
  font-size: 0.82rem;
  background: #0f1623;
  color: #e7eaf0;
  padding: 1rem;
  border-radius: 6px;
  overflow: auto;
  max-height: 480px;
  margin: 0;
  white-space: pre;
}

.button-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
button.primary, button.secondary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 0.92rem;
  cursor: pointer;
  font-family: inherit;
}
button.secondary {
  background: #fff;
  color: var(--accent);
}
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.secondary:hover { background: #eef4fb; }

#error-banner {
  background: var(--error-bg);
  color: var(--error-fg);
  border: 1px solid #f3b0b0;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  font-size: 0.92rem;
}

.warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border: 1px solid #f3dca0;
  padding: 0.55rem 0.85rem;
  border-radius: 6px;
  font-size: 0.88rem;
  margin-top: 0.5rem;
}

.version-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 999px;
  vertical-align: middle;
  letter-spacing: 0.04em;
}

.cfg-help {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 1rem 0;
}
.cfg-help a { color: var(--accent); }
.cfg-help code {
  font-family: var(--mono);
  background: #eef1f5;
  padding: 0 0.3rem;
  border-radius: 3px;
}

footer.page {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 2rem 1.5rem 3rem;
  background: #eef1f5;
  border-top: 1px solid var(--border);
}
footer.page strong { color: var(--text); }
.footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  max-width: 960px;
  margin: 0 auto;
}
.footer-block h3 {
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
  color: var(--text);
}
.footer-block ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.footer-block ul li {
  margin-bottom: 0.25rem;
}
.footer-block a {
  color: var(--accent);
  text-decoration: none;
}
.footer-block a:hover { text-decoration: underline; }
.footer-meta {
  margin-top: 1rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.cta {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff !important;
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
}
.cta:hover {
  background: var(--accent-hover);
  text-decoration: none;
}

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  main { padding: 1rem; }
  .footer-grid { grid-template-columns: 1fr; }
}
