/* =========================================================
   MakeFormsFast — Builder UI Styles (responsive panels)
   ========================================================= */

/* Theme */
:root {
  --bg: #fff;
  --fg: #111;
  --muted: #666;
  --pri: #111;
  --ok: #0a0;
  --err: #b00;
  --bd: #ddd;
}

/* Reset / sizing */
*, *::before, *::after { box-sizing: border-box; }

html {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
}

body {
  margin: 20px;
  padding: 0;
  font: 18px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100svh;
}

h2 { margin-top: 0; font-size: 24px; }

/* Header */
header {
  width: 100%;
  padding: 24px 16px;
}
header h1 { margin: 0; font-style: italic; }

header p  { margin: 4px 0 0; color: var(--muted); }

/* Main layout container */
main {
  width: 100%;
  max-width: 1000px;     /* <- container width cap */
  margin: 0 auto;
  padding: 16px;
}

/* Panels (responsive) */
.panel {
  background: #fafafa;
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
  width: 100%;
  max-width: 900px;
  z-index: 1;/* <- fluid, fill container */
}

/* Labels */
label {
  display: block;
  font-weight: 600;
  margin: 12px 0 6px;
}

/* Form controls */
textarea,
input[type="text"],
input[type="email"],
input[type="url"],
select {
  display: block;
  width: 100%;
  max-width: 100%;
  padding: 10px;
  border: 1px solid var(--bd);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  appearance: none;
  -webkit-appearance: none;
  outline: 0;
  margin: 4px 0 16px;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

/* Code box for JSON spec */
.code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 14px;
  min-height: 200px;
  white-space: pre;
  overflow: auto;
}

/* Buttons */
button {
  margin-top: 8px;
  background: var(--pri);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
}
button:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* Errors */
.err {
  display: none;
  color: var(--err);
  white-space: pre-wrap;
  margin-top: 8px;
}

/* Muted text */
.muted { color: var(--muted); }

/* Two-column split: safe, no overflow */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}
.split > * { min-width: 0; }  /* allow children to shrink */

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
}

/* Preview iframe */
.preview {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 520px;
  border: 1px solid var(--bd);
  border-radius: 10px;
  background: #fff;
}

/* Footer */
footer {
  width: 100%;
  padding: 16px;
  text-align: center;
  color: var(--muted);
}

/* Loading state for buttons */
@keyframes _spin { to { transform: rotate(360deg); } }
button.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.85;
  padding-left: 34px;
}
button.loading::after {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 16px; height: 16px; margin-top: -8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: _spin .6s linear infinite;
}

/* Background canvas stays behind content */
#bgfx {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
header, main, footer { position: relative; z-index: 1; }
