/* SMB Forms — minimal CSS, CSS-variable driven */

/* ── Variables (defaults, overridden per-form via inline style) ────────── */
.smb-form-wrap {
  --smb-accent:        #2563eb;
  --smb-label-color:   #374151;
  --smb-input-border:  #d1d5db;
  --smb-input-radius:  4px;
  --smb-btn-bg:        #2563eb;
  --smb-btn-color:     #ffffff;
  --smb-btn-radius:    6px;
  --smb-font-size:     15px;
  --smb-gap:           16px;

  font-size: var(--smb-font-size);
}

/* ── Field rows ────────────────────────────────────────────────────────── */
.smb-fields {
  display: flex;
  flex-wrap: wrap;
  gap: var(--smb-gap);
}

.smb-row {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  /* width is set inline per-field, defaults to 100% */
  min-width: min(100%, 220px);
}

/* Gutenberg / page builder friendliness: always 100% on small screens */
@media (max-width: 600px) {
  .smb-row { width: 100% !important; }
}

/* ── Labels ────────────────────────────────────────────────────────────── */
.smb-label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: var(--smb-label-color);
  font-size: .9em;
}

.smb-required { color: #ef4444; margin-left: 2px; }

/* ── Inputs ────────────────────────────────────────────────────────────── */
.smb-form input[type="text"],
.smb-form input[type="email"],
.smb-form input[type="tel"],
.smb-form input[type="number"],
.smb-form input[type="url"],
.smb-form input[type="date"],
.smb-form select,
.smb-form textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid var(--smb-input-border);
  border-radius: var(--smb-input-radius);
  font-size: 1em;
  font-family: inherit;
  color: inherit;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.smb-form input:focus,
.smb-form select:focus,
.smb-form textarea:focus {
  border-color: var(--smb-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--smb-accent) 20%, transparent);
}

.smb-form textarea { resize: vertical; min-height: 90px; }
.smb-form select   { appearance: auto; }

/* ── Radio / Checkbox groups ───────────────────────────────────────────── */
.smb-radio-group,
.smb-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.smb-radio-label,
.smb-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: normal;
}

/* ── Validation errors ─────────────────────────────────────────────────── */
.smb-row--error input,
.smb-row--error select,
.smb-row--error textarea {
  border-color: #ef4444;
}

.smb-field-error {
  display: none;
  margin-top: 4px;
  font-size: .82em;
  color: #ef4444;
}

/* ── Submit button ─────────────────────────────────────────────────────── */
.smb-row--submit { width: 100%; margin-top: 4px; }

.smb-btn-submit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--smb-btn-bg);
  color: var(--smb-btn-color);
  border: none;
  border-radius: var(--smb-btn-radius);
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}

.smb-btn-submit:hover:not(:disabled) { opacity: .88; }
.smb-btn-submit:active:not(:disabled){ transform: scale(.98); }
.smb-btn-submit:disabled             { opacity: .6; cursor: not-allowed; }

/* Spinner */
.smb-btn-spinner {
  display: none;
  width: 14px; height: 14px;
  border: 2px solid color-mix(in srgb, var(--smb-btn-color) 40%, transparent);
  border-top-color: var(--smb-btn-color);
  border-radius: 50%;
  animation: smb-spin .6s linear infinite;
}
.smb-btn--loading .smb-btn-spinner { display: block; }
@keyframes smb-spin { to { transform: rotate(360deg); } }

/* ── Form-level messages ───────────────────────────────────────────────── */
.smb-form-message {
  margin-top: 12px;
  font-size: .9em;
}

.smb-form-message--error { color: #ef4444; }

/* ── Success message ───────────────────────────────────────────────────── */
.smb-success-message {
  padding: 14px 18px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: var(--smb-input-radius, 4px);
  color: #166534;
  font-weight: 600;
  animation: smb-fadein .3s ease;
}

@keyframes smb-fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Honeypot ──────────────────────────────────────────────────────────── */
.smb-hp {
  position: absolute;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
  height: 0;
  overflow: hidden;
}

/* ── Popup / Dialog ────────────────────────────────────────────────────── */
.smb-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  border: none;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  padding: 32px;
  max-width: min(560px, 94vw);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
}

/* Native backdrop */
.smb-dialog::backdrop {
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
}

/* Open animation */
.smb-dialog[open] {
  animation: smb-dialog-in .2s ease;
}

@keyframes smb-dialog-in {
  from { opacity: 0; transform: translateY(-16px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.smb-dialog-close {
  position: absolute;
  top: 12px; right: 14px;
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: #6b7280;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.smb-dialog-close:hover { background: #f3f4f6; color: #111; }

/* ── Misc ──────────────────────────────────────────────────────────────── */
.smb-row--captcha { width: 100%; }
