/* ==========================================================================
   BGS Forms - front-end + builder preview styles.  Everything is scoped
   under .bgsf so it can't clash with the site theme.
   Accent colour comes from --bgsf-accent (set from the theme colour).
   ========================================================================== */
.bgsf, .bgsf *, .bgsf *::before, .bgsf *::after { box-sizing: border-box; }

.bgsf {
  --bgsf-accent: #4f46e5;
  --bgsf-accent-soft: color-mix(in srgb, var(--bgsf-accent) 9%, #fff);
  --bgsf-accent-ring: color-mix(in srgb, var(--bgsf-accent) 18%, transparent);
  --bgsf-accent-dark: color-mix(in srgb, var(--bgsf-accent) 82%, #000);
  --bgsf-ink: #1b2236;
  --bgsf-muted: #6b7489;
  --bgsf-line: #e2e6ef;
  --bgsf-bg: #f8f9fc;
  --bgsf-danger: #d92d20;
  --bgsf-gap: 10px;
  font-family: inherit;
  color: var(--bgsf-ink);
  line-height: 1.5;
  width: 100%;
}

/* ---- Card ------------------------------------------------------------- */
.bgsf-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--bgsf-line);
  border-radius: 20px;
  padding: 38px 40px 34px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 24px 60px -24px rgba(16,24,40,.18);
  overflow: hidden;
}
.bgsf-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 5px;
  background: linear-gradient(90deg, var(--bgsf-accent), color-mix(in srgb, var(--bgsf-accent) 45%, #ffb347));
}
.bgsf-head { text-align: center; margin-bottom: 30px; }
.bgsf-head h2 { margin: 0 0 6px; font-size: 28px; line-height: 1.25; font-weight: 700; color: var(--bgsf-ink); letter-spacing: -.01em; }
.bgsf-head p  { margin: 0; color: var(--bgsf-muted); font-size: 14.5px; }

/* ---- Grid: widths come from --w (100 / 75 / 66 / 50 / 33 / 25 / 20 / 15 %) */
.bgsf-grid { display: flex; flex-wrap: wrap; margin: 0 calc(var(--bgsf-gap) * -1); }
.bgsf-col  { flex: 0 0 var(--w, 100%); max-width: var(--w, 100%); padding: 0 var(--bgsf-gap); margin-bottom: 20px; position: relative; }

@media (max-width: 900px) {
  .bgsf-col { flex-basis: max(var(--w, 100%), 50%); max-width: max(var(--w, 100%), 50%); }
}
@media (max-width: 600px) {
  .bgsf-card { padding: 28px 18px 24px; border-radius: 16px; }
  .bgsf-col { flex-basis: 100% !important; max-width: 100% !important; }
  .bgsf-head h2 { font-size: 23px; }
}

/* ---- Section headings -------------------------------------------------- */
.bgsf-section { display: flex; align-items: center; gap: 12px; margin: 12px 0 2px; padding-bottom: 10px; border-bottom: 1px dashed var(--bgsf-line); }
.bgsf-section__bar { width: 5px; height: 24px; border-radius: 6px; background: linear-gradient(180deg, var(--bgsf-accent), color-mix(in srgb, var(--bgsf-accent) 40%, #fff)); flex: none; }
.bgsf-section h4 { margin: 0; font-size: 17px; font-weight: 700; color: var(--bgsf-accent); letter-spacing: .01em; }
.bgsf-section small { display: block; color: var(--bgsf-muted); font-weight: 400; font-size: 13px; margin-top: 2px; }
.bgsf-note { margin: 0; padding: 14px 16px; border-radius: 12px; background: var(--bgsf-accent-soft); border: 1px solid color-mix(in srgb, var(--bgsf-accent) 16%, #fff); color: #46506a; font-size: 13.5px; }

/* ---- Labels ------------------------------------------------------------ */
.bgsf-label { display: flex; align-items: baseline; gap: 6px; margin: 0 0 7px; font-size: 13.5px; font-weight: 600; color: var(--bgsf-ink); }
.bgsf-req { color: var(--bgsf-danger); font-weight: 700; }
.bgsf-opt { margin-left: auto; font-size: 11px; font-weight: 500; color: #98a1b5; background: #f1f3f8; padding: 1px 8px; border-radius: 20px; }
.bgsf-help { display: block; margin-top: 6px; color: var(--bgsf-muted); font-size: 12.5px; }

/* ---- Inputs ------------------------------------------------------------ */
.bgsf-input {
  display: block; width: 100%; height: 50px; padding: 0 16px;
  font: inherit; font-size: 15px; color: var(--bgsf-ink);
  background: var(--bgsf-bg); border: 1.5px solid var(--bgsf-line); border-radius: 12px;
  outline: none; transition: border-color .18s, box-shadow .18s, background .18s, transform .18s;
  appearance: none; -webkit-appearance: none;
}
textarea.bgsf-input { height: auto; min-height: 110px; padding: 13px 16px; resize: vertical; }
.bgsf-input::placeholder { color: #a3abbd; }
.bgsf-input:hover { border-color: #c9d0e0; background: #fff; }
.bgsf-input:focus {
  background: #fff; border-color: var(--bgsf-accent);
  box-shadow: 0 0 0 4px var(--bgsf-accent-ring);
}
.bgsf-field:focus-within > .bgsf-label { color: var(--bgsf-accent); }

select.bgsf-input {
  padding-right: 44px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236b7489' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
input[type="date"].bgsf-input { cursor: text; }

/* ---- Radio / checkbox cards ------------------------------------------- */
.bgsf-choices { display: flex; flex-wrap: wrap; gap: 10px; }
.bgsf-choice {
  position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 11px 16px; margin: 0; font-size: 14.5px; font-weight: 500; color: var(--bgsf-ink);
  background: var(--bgsf-bg); border: 1.5px solid var(--bgsf-line); border-radius: 12px;
  transition: border-color .18s, background .18s, box-shadow .18s, transform .18s; user-select: none;
}
.bgsf-choice:hover { border-color: #c2cadb; background: #fff; transform: translateY(-1px); }
.bgsf-choice input { position: absolute; opacity: 0; pointer-events: none; }
.bgsf-choice__mark {
  flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid #b7bfd1; background: #fff;
  display: grid; place-items: center; transition: all .18s;
}
.bgsf-choice__mark::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; transform: scale(0); transition: transform .18s; }
.bgsf-choice input[type="checkbox"] + .bgsf-choice__mark { border-radius: 6px; }
.bgsf-choice input[type="checkbox"] + .bgsf-choice__mark::after {
  width: 10px; height: 6px; border-radius: 0; background: none; border: solid #fff; border-width: 0 0 2.5px 2.5px;
  transform: rotate(-45deg) scale(0) translate(1px,-1px);
}
.bgsf-choice input:checked + .bgsf-choice__mark { background: var(--bgsf-accent); border-color: var(--bgsf-accent); }
.bgsf-choice input[type="radio"]:checked + .bgsf-choice__mark::after { transform: scale(1); }
.bgsf-choice input[type="checkbox"]:checked + .bgsf-choice__mark::after { transform: rotate(-45deg) scale(1) translate(1px,-1px); }
.bgsf-choice:has(input:checked) { background: var(--bgsf-accent-soft); border-color: var(--bgsf-accent); box-shadow: 0 0 0 3px var(--bgsf-accent-ring); }
.bgsf-choice:has(input:focus-visible) { box-shadow: 0 0 0 4px var(--bgsf-accent-ring); }
.bgsf-choice--single { display: flex; width: 100%; padding: 15px 18px; }
.bgsf-other-input { margin-top: 10px; }
.bgsf-other-input[hidden] { display: none; }

/* ---- File upload ------------------------------------------------------- */
.bgsf-file { position: relative; }
.bgsf-file__input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 2; }
.bgsf-file__drop {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 16px;
  background: var(--bgsf-bg); border: 1.5px dashed #bcc5d8; border-radius: 12px; margin: 0;
  transition: all .18s; color: var(--bgsf-muted); font-size: 13.5px;
}
.bgsf-file:hover .bgsf-file__drop, .bgsf-file.is-drag .bgsf-file__drop { border-color: var(--bgsf-accent); background: var(--bgsf-accent-soft); }
.bgsf-file__icon { flex: none; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: #fff; color: var(--bgsf-accent); border: 1px solid var(--bgsf-line); }
.bgsf-file__text { min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.bgsf-file__text strong { color: var(--bgsf-ink); font-weight: 600; }
.bgsf-file__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.bgsf-file.has-file .bgsf-file__drop { border-style: solid; border-color: var(--bgsf-accent); background: var(--bgsf-accent-soft); }
.bgsf-file.has-file .bgsf-file__name { color: var(--bgsf-accent-dark); font-weight: 600; }

/* ---- Errors ------------------------------------------------------------ */
.bgsf-error { display: none; margin-top: 6px; color: var(--bgsf-danger); font-size: 12.5px; font-weight: 500; }
.bgsf-field.has-error .bgsf-error { display: block; animation: bgsf-shake .3s; }
.bgsf-field.has-error .bgsf-input { border-color: var(--bgsf-danger); background: #fff8f7; box-shadow: 0 0 0 4px rgba(217,45,32,.1); }
.bgsf-field.has-error .bgsf-file__drop, .bgsf-field.has-error .bgsf-choice { border-color: var(--bgsf-danger); }
@keyframes bgsf-shake { 20%{transform:translateX(-4px)} 50%{transform:translateX(4px)} 80%{transform:translateX(-2px)} }
.bgsf-alert { display: none; margin: 0 0 18px; padding: 12px 16px; border-radius: 12px; background: #fff1f0; border: 1px solid #ffd0cc; color: #b42318; font-size: 14px; }
.bgsf-alert.is-visible { display: block; }

/* ---- Submit ------------------------------------------------------------ */
.bgsf-actions { display: flex; justify-content: flex-end; margin-top: 8px; padding-top: 24px; border-top: 1px solid var(--bgsf-line); }
.bgsf-submit {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-width: 200px; height: 52px; padding: 0 30px; border: 0; border-radius: 14px; cursor: pointer;
  font: inherit; font-size: 15.5px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, var(--bgsf-accent), var(--bgsf-accent-dark));
  box-shadow: 0 10px 24px -8px color-mix(in srgb, var(--bgsf-accent) 70%, transparent);
  transition: transform .18s, box-shadow .18s, filter .18s;
}
.bgsf-submit:hover { transform: translateY(-2px); box-shadow: 0 16px 28px -10px color-mix(in srgb, var(--bgsf-accent) 75%, transparent); filter: brightness(1.05); }
.bgsf-submit:active { transform: translateY(0); }
.bgsf-submit[disabled] { opacity: .75; cursor: progress; transform: none; }
.bgsf-submit.is-loading .bgsf-submit__label { opacity: .0; }
.bgsf-submit.is-loading::after {
  content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.35); border-top-color: #fff; animation: bgsf-spin .7s linear infinite;
}
@keyframes bgsf-spin { to { transform: rotate(360deg); } }
@media (max-width: 600px) { .bgsf-submit { width: 100%; } }

.bgsf-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }

/* ---- Page wrapper ------------------------------------------------------ */
.bgsf-page { padding: 70px 0 90px; background: linear-gradient(180deg, #f6f7fb, #fff 60%); }
.bgsf-page__wrap { max-width: 880px; margin: 0 auto; }
.bgsf-embed-body { margin: 0; padding: 16px; background: transparent; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

/* ==========================================================================
   Popup modal + success dialog (shared)
   ========================================================================== */
.bgsf-modal { position: fixed; inset: 0; z-index: 99990; display: none; }
.bgsf-modal.is-open { display: block; }
.bgsf-modal__backdrop { position: absolute; inset: 0; background: rgba(16,22,38,.62); backdrop-filter: blur(3px); animation: bgsf-fade .2s; }
.bgsf-modal__scroll { position: absolute; inset: 0; overflow-y: auto; padding: 4vh 16px; -webkit-overflow-scrolling: touch; }
.bgsf-modal__dialog { position: relative; max-width: 880px; margin: 0 auto; animation: bgsf-pop .28s cubic-bezier(.2,.9,.3,1.2); }
.bgsf-modal__close {
  position: absolute; top: 14px; right: 14px; z-index: 5; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--bgsf-line, #e2e6ef); background: #fff; color: #44506b; cursor: pointer; display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(16,24,40,.12); transition: transform .18s, color .18s;
}
.bgsf-modal__close:hover { transform: rotate(90deg); color: #d92d20; }
.bgsf-modal__loading { background: #fff; border-radius: 20px; padding: 70px 20px; text-align: center; color: #6b7489; }
.bgsf-modal__loading i { display: inline-block; width: 34px; height: 34px; border-radius: 50%; border: 3px solid #e2e6ef; border-top-color: #4f46e5; animation: bgsf-spin .7s linear infinite; }
body.bgsf-lock { overflow: hidden; }
@keyframes bgsf-fade { from { opacity: 0 } }
@keyframes bgsf-pop  { from { opacity: 0; transform: translateY(18px) scale(.97) } }

.bgsf-done { position: fixed; inset: 0; z-index: 99999; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(16,22,38,.55); backdrop-filter: blur(3px); }
.bgsf-done.is-open { display: flex; animation: bgsf-fade .2s; }
.bgsf-done__box { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; padding: 34px 28px 28px; text-align: center; box-shadow: 0 30px 70px -20px rgba(0,0,0,.4); animation: bgsf-pop .3s cubic-bezier(.2,.9,.3,1.2); font-family: inherit; }
.bgsf-done__icon { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%; background: #e7f8ef; display: grid; place-items: center; color: #12a150; }
.bgsf-done__icon svg { stroke-dasharray: 30; stroke-dashoffset: 30; animation: bgsf-draw .5s .15s forwards; }
@keyframes bgsf-draw { to { stroke-dashoffset: 0; } }
.bgsf-done__box h3 { margin: 0 0 8px; font-size: 21px; font-weight: 700; color: #1b2236; }
.bgsf-done__box p  { margin: 0 0 22px; color: #6b7489; font-size: 14.5px; }
.bgsf-done__ok { min-width: 120px; height: 44px; padding: 0 26px; border: 0; border-radius: 12px; background: var(--bgsf-accent, #4f46e5); color: #fff; font: inherit; font-weight: 600; cursor: pointer; transition: filter .18s, transform .18s; }
.bgsf-done__ok:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* ==========================================================================
   Builder (dashboard) additions
   ========================================================================== */
.bgsf--builder .bgsf-card { box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.bgsf--builder .bgsf-col { cursor: pointer; }
.bgsf--builder .bgsf-col > .bgsf-field,
.bgsf--builder .bgsf-col > .bgsf-section,
.bgsf--builder .bgsf-col > .bgsf-note { pointer-events: none; }
.bgsf--builder .bgsf-col::before {
  content: ""; position: absolute; inset: -6px calc(var(--bgsf-gap) - 6px); border: 2px dashed transparent; border-radius: 14px; transition: all .15s; pointer-events: none;
}
.bgsf--builder .bgsf-col:hover::before { border-color: color-mix(in srgb, var(--bgsf-accent) 45%, transparent); background: color-mix(in srgb, var(--bgsf-accent) 3%, transparent); }
.bgsf--builder .bgsf-col.is-editing::before { border-style: solid; border-color: var(--bgsf-accent); background: color-mix(in srgb, var(--bgsf-accent) 5%, transparent); }
.bgsf--builder .bgsf-input { background: var(--bgsf-bg); }

.bgsf-tools {
  position: absolute; z-index: 6; top: -18px; right: calc(var(--bgsf-gap) + 2px);
  display: none; align-items: center; gap: 2px; padding: 3px; background: #1b2236; color: #fff; border-radius: 10px;
  box-shadow: 0 8px 20px rgba(16,24,40,.28); font-size: 12px; white-space: nowrap;
}
.bgsf--builder .bgsf-col:hover > .bgsf-tools, .bgsf--builder .bgsf-col.is-editing > .bgsf-tools { display: flex; }
.bgsf-tool {
  display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 7px; border: 0; background: transparent;
  color: #fff; border-radius: 7px; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; transition: background .15s;
}
.bgsf-tool:hover { background: rgba(255,255,255,.16); }
.bgsf-tool--danger:hover { background: #d92d20; }
.bgsf-tool--req.is-on { background: #d92d20; }
.bgsf-tool--req.is-off { background: rgba(255,255,255,.12); }
.bgsf-handle { cursor: grab; }
.bgsf-handle:active { cursor: grabbing; }
.bgsf-tool-width {
  height: 28px; border: 0; border-radius: 7px; background: rgba(255,255,255,.12); color: #fff; font: inherit; font-size: 12px; font-weight: 600; padding: 0 4px; cursor: pointer; outline: none;
}
.bgsf-tool-width option { color: #1b2236; }
.bgsf-ghost { opacity: .35; }
.bgsf-chosen { cursor: grabbing; }
.bgsf-empty { padding: 50px 10px; text-align: center; color: var(--bgsf-muted); width: 100%; }
