:root {
  --form-bg: #ffffff;
  --form-border: rgba(15, 23, 42, 0.08);
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --muted: #64748b;
  --danger: #ef4444;
  --success: #16a34a;
  --surface: #f8fafc;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-sm: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 100%);
  color: #0f172a;
  /* voorkomt iOS “elastisch” effect in iframes */
  min-height: 0;          /* was 100vh */
  height: auto;
}

main {
  padding: clamp(1.5rem, 4vw, 3rem) 1.5rem;
}

.form-shell {
  max-width: 980px;
  margin: 0 auto;
  background: var(--form-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--form-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.header {
  padding: clamp(2rem, 4vw, 3rem);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(129, 140, 248, 0.08));
  border-bottom: 1px solid var(--form-border);
}

.header h1 {
  margin: 0;
  font-size: clamp(1.75rem, 2.8vw, 2.4rem);
  font-weight: 700;
}

.header p {
  margin: 0.75rem 0 0;
  color: var(--muted);
  max-width: 60ch;
}

.notice-banner {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: var(--radius-md);
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  font-size: 0.95rem;
  color: #1d4ed8;
}

.form-body {
  padding: clamp(2rem, 4vw, 3rem);
}

.section {
  margin-bottom: clamp(2rem, 4vw, 3rem);
}

.section-header {
  margin-bottom: 1.25rem;
}

.section-header h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.6rem);
  font-weight: 600;
}

.section-header p {
  margin: 0.5rem 0 0;
  color: var(--muted);
  max-width: 60ch;
  font-size: 0.95rem;
}

.section-note {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(37, 99, 235, 0.08);
  border-left: 3px solid rgba(37, 99, 235, 0.45);
  color: #1d4ed8;
  font-weight: 500;
}

.language-select {
  max-width: 200px;
}

.control-group {
  display: grid;
  gap: 1rem;
}

.control-group.two-cols {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.address-search-group {
  margin-bottom: 1rem;
}

gmp-place-autocomplete {
  display: block;
  width: 100%;
  color-scheme: light;
}

.address-autocomplete-status {
  min-height: 1.25rem;
  margin-top: 0.4rem;
  font-size: 0.85rem;
}

.address-autocomplete-status.success {
  color: var(--success);
}

.address-autocomplete-status.error {
  color: var(--danger);
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.field-hint {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background-color: var(--surface);
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
  background-color: #fff;
}

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

.item-table {
  border: 1px solid var(--form-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.item-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.item-table thead {
  background: rgba(15, 23, 42, 0.02);
}

.item-table th,
.item-table td {
  padding: 0.9rem 1rem;
  text-align: left;
  vertical-align: top;
}

.item-table tbody tr + tr {
  border-top: 1px solid rgba(15, 23, 42, 0.04);
}

.item-table tbody .item-row.row-error {
  background: rgba(239, 68, 68, 0.08);
}

.item-description-row td {
  background: rgba(15, 23, 42, 0.02);
  border-top: 1px solid rgba(15, 23, 42, 0.04);
  padding: 0.75rem 1rem 1rem;
}

.item-description-row .description-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.item-description-row .description-display {
  font-weight: 600;
  color: #0f172a;
}

.item-description-row .description-display.is-placeholder {
  color: var(--muted);
  font-style: italic;
  font-weight: 500;
}

.item-table tbody .item-row.row-error input,
.item-table tbody .item-row.row-error select,
.item-table tbody .item-row.row-error textarea {
  border-color: rgba(239, 68, 68, 0.6);
  background: rgba(255, 255, 255, 0.9);
}

.item-table td.actions {
  width: 56px;
  text-align: right;
}

.item-table td[data-label]::before {
  display: none;
}

@media (max-width: 720px) {
  .item-table table,
  .item-table thead,
  .item-table tbody,
  .item-table th,
  .item-table td,
  .item-table tr {
    display: block;
  }

  .item-table thead {
    display: none;
  }

  .item-table tbody tr {
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
    padding: 1rem 1.25rem;
  }

  .item-table td {
    padding: 0.4rem 0;
  }

  .item-table td[data-label]::before {
    display: block;
    content: attr(data-label);
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--muted);
  }

  .item-table td.actions {
    text-align: left;
  }
}

button {
  font-size: 0.95rem;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.75rem 1.4rem;
  font-weight: 600;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.45);
  outline-offset: 2px;
}

.btn-add {
  background: rgba(37, 99, 235, 0.12);
  color: var(--accent);
  margin-top: 1rem;
}

.btn-add:hover {
  background: rgba(37, 99, 235, 0.18);
  transform: translateY(-1px);
}

.btn-remove {
  background: transparent;
  color: var(--danger);
  padding: 0.5rem;
}

.btn-remove:hover {
  color: #b91c1c;
}

.form-footer {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  padding: 1.75rem clamp(2rem, 4vw, 3rem);
  background: rgba(15, 23, 42, 0.02);
}

.btn-submit {
  background: var(--accent);
  color: #fff;
  padding-inline: 2.5rem;
}

.btn-submit:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.18);
}

.flash-messages {
  margin-bottom: 1.5rem;
}

.flash-message {
  --flash-bg: rgba(37, 99, 235, 0.08);
  --flash-border: rgba(37, 99, 235, 0.18);
  --flash-text: #1d4ed8;
  --flash-icon-bg: rgba(37, 99, 235, 0.12);
  --flash-icon-color: #1d4ed8;
  --flash-title-color: var(--flash-text);
  --flash-body-color: var(--flash-text);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  line-height: 1.45;
  background: var(--flash-bg);
  border: 1px solid var(--flash-border);
  color: var(--flash-body-color, var(--flash-text));
  box-shadow: none;
}

.flash-message.success {
  --flash-bg: linear-gradient(135deg, rgba(34, 197, 94, 0.14), rgba(16, 185, 129, 0.1));
  --flash-border: rgba(22, 163, 74, 0.28);
  --flash-text: #166534;
  --flash-icon-bg: rgba(34, 197, 94, 0.18);
  --flash-icon-color: #15803d;
  --flash-title-color: #166534;
  --flash-body-color: #065f46;
  box-shadow: 0 18px 35px rgba(22, 163, 74, 0.18);
}

.flash-message.danger,
.flash-message.error {
  --flash-bg: rgba(239, 68, 68, 0.1);
  --flash-border: rgba(239, 68, 68, 0.2);
  --flash-text: #b91c1c;
  --flash-icon-bg: rgba(239, 68, 68, 0.18);
  --flash-icon-color: #b91c1c;
  --flash-title-color: #b91c1c;
  --flash-body-color: #7f1d1d;
}

.flash-message.warning {
  --flash-bg: rgba(245, 158, 11, 0.12);
  --flash-border: rgba(245, 158, 11, 0.28);
  --flash-text: #b45309;
  --flash-icon-bg: rgba(245, 158, 11, 0.18);
  --flash-icon-color: #b45309;
  --flash-title-color: #92400e;
  --flash-body-color: #78350f;
}

.flash-message.info {
  --flash-bg: rgba(37, 99, 235, 0.08);
  --flash-border: rgba(37, 99, 235, 0.2);
  --flash-text: #1d4ed8;
  --flash-icon-bg: rgba(37, 99, 235, 0.12);
  --flash-icon-color: #1d4ed8;
  --flash-title-color: #1e3a8a;
  --flash-body-color: #1d4ed8;
}

.flash-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  background: var(--flash-icon-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--flash-icon-color);
  flex-shrink: 0;
}

.flash-content {
  display: grid;
  gap: 0.3rem;
}

.flash-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--flash-title-color, inherit);
}

.flash-body {
  margin: 0;
  color: var(--flash-body-color, inherit);
  font-size: 0.95rem;
}

.helper-text {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.3rem;
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: rgba(239, 68, 68, 0.6);
  background-color: rgba(239, 68, 68, 0.08);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.08);
}

.item-row-flex {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

@media (max-width: 720px) {
  .form-footer {
    justify-content: stretch;
  }

  .btn-submit {
    width: 100%;
  }

  .item-table tbody {
    display: block;
  }

  .item-table tbody .item-row {
    display: block;
  }

  .item-table td {
    padding: 0;
  }

  .item-table td + td {
    margin-top: 0.85rem;
  }

  .item-table td + td {
    margin-top: 0.75rem;
  }

  .item-table td.actions {
    text-align: left;
  }

}

/* --- IFRAME-EMBED FIXES / SAFETY NETS --- */

/* Zorg dat er nul buitenmarge is in de iframe zelf (HTML-level ook) */
html { margin: 0; padding: 0; }

/* Media in content kan nooit breder worden dan de iframe-breedte */
img, svg, table {
  max-width: 100%;
}

/* Als een thema/host een font-boost doet, houd de layout stabiel op iOS */
@supports (-webkit-touch-callout: none) {
  body { -webkit-text-size-adjust: 100%; }
}

/* Tabel: horizontaal scrollen toestaan als er toch nog overflow is op mid-breakpoints */
.item-table {
  overflow-x: auto; /* behoudt jouw bestaande styling; voegt alleen X-scroll toe waar nodig */
}
