/* ═══════════════════════════════════════════════════════════════
   embed-form.css  v2
   Structural + visual CSS for the new form system.
   All design-token-driven values come from scoped design CSS
   emitted by FormEmbedRenderer / FormCssWriter / forms-css-writer.js
   (scoped to .ps-form-{id}). This file handles structure only.
════════════════════════════════════════════════════════════════ */

/* ── Scope reset ─────────────────────────────────────────────── */

.ps-form-shell {
  display: block;
  width: 100%;
  box-sizing: border-box;
  position: relative;
}

.ps-form-shell *,
.ps-form-shell *::before,
.ps-form-shell *::after {
  box-sizing: border-box;
}

/* ── Inner form ──────────────────────────────────────────────── */

.ps-form-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* ── Field wrap ──────────────────────────────────────────────── */

.ps-form-field-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ps-form-field-wrap--label-left {
  flex-direction: row;
  align-items: flex-start;
  gap: 12px;
}

.ps-form-field-wrap--label-left .ps-form-label {
  min-width: 120px;
  flex-shrink: 0;
  margin-bottom: 0;
  padding-top: 10px;
}

.ps-form-field-wrap--label-left .ps-form-input,
.ps-form-field-wrap--label-left .ps-form-textarea,
.ps-form-field-wrap--label-left .ps-form-select-wrap,
.ps-form-field-wrap--label-left .ps-form-checkbox-group,
.ps-form-field-wrap--label-left .ps-form-radio-group {
  flex: 1;
}

.ps-form-field-wrap--label-floating {
  position: relative;
}

.ps-form-field-wrap--label-floating .ps-form-label {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  transition: all 0.15s ease;
  pointer-events: none;
  margin-bottom: 0;
  z-index: 1;
  background: transparent;
  padding: 0 4px;
  font-size: 14px;
  color: #94a3b8;
}

.ps-form-field-wrap--label-floating .ps-form-input {
  padding-top: 18px;
}

.ps-form-field-wrap--label-floating .ps-form-input:focus ~ .ps-form-label,
.ps-form-field-wrap--label-floating .ps-form-input:not(:placeholder-shown) ~ .ps-form-label {
  top: 0px;
  font-size: 10px;
  background: #fff;
  color: #6366f1;
}

.ps-form-field-wrap--label-floating .ps-form-textarea {
  padding-top: 24px;
}

.ps-form-field-wrap--label-floating .ps-form-textarea:focus ~ .ps-form-label,
.ps-form-field-wrap--label-floating .ps-form-textarea:not(:placeholder-shown) ~ .ps-form-label {
  top: 0px;
  font-size: 10px;
  background: #fff;
  color: #6366f1;
}

/* ── Label ───────────────────────────────────────────────────── */

.ps-form-label {
  display: block;
  line-height: 1.4;
  font-weight: 500;
  margin-bottom: 5px;
}

.ps-form-req {
  margin-left: 2px;
  color: #ef4444;
}

/* ── Help text ───────────────────────────────────────────────── */

.ps-form-help {
  display: block;
  margin-top: 4px;
  line-height: 1.5;
  font-size: 11px;
  color: #94a3b8;
}

/* ── Error message ───────────────────────────────────────────── */

.ps-form-error {
  display: block;
  line-height: 1.4;
  font-size: 11px;
  color: #ef4444;
  margin-top: 4px;
}

.ps-form-field-wrap .ps-form-error[hidden] {
  display: none;
}

/* ── Input / Textarea ────────────────────────────────────────── */

.ps-form-input {
  display: block;
  width: 100%;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.ps-form-textarea {
  display: block;
  width: 100%;
  outline: none;
  resize: vertical;
  min-height: 80px;
}

.ps-form-input:focus,
.ps-form-textarea:focus,
.ps-form-select:focus {
  outline: none;
}

/* Input error state */
.ps-form-input.ps-input-error,
.ps-form-textarea.ps-input-error,
.ps-form-select-wrap.ps-input-error .ps-form-select {
  border-color: #ef4444 !important;
}

/* ── Select wrap ─────────────────────────────────────────────── */

.ps-form-select-wrap {
  position: relative;
  display: block;
}

.ps-form-select {
  display: block;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding-right: 2.5rem;
}

.ps-form-chevron {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 18px;
  line-height: 1;
}

/* ── Checkbox ────────────────────────────────────────────────── */

.ps-form-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ps-form-checkbox-group--grid {
  display: grid;
  gap: 8px;
}

.ps-form-checkbox-item {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.ps-form-checkbox-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.ps-form-checkbox-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 2px solid #d1d5db;
  border-radius: 4px;
  box-sizing: border-box;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ps-form-checkbox-input:checked ~ .ps-form-checkbox-custom {
  background: var(--ps-cb-accent, #6366f1);
  border-color: var(--ps-cb-accent, #6366f1);
}

.ps-form-checkbox-input:checked ~ .ps-form-checkbox-custom::after {
  content: '';
  display: block;
  width: 5px;
  height: 9px;
  border: 2px solid var(--ps-cb-check-color, #ffffff);
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
}

.ps-form-checkbox-label {
  margin-left: 8px;
  font-size: 14px;
  color: #374151;
  cursor: pointer;
}

/* ── Radio ───────────────────────────────────────────────────── */

.ps-form-radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ps-form-radio-group--grid {
  display: grid;
  gap: 8px;
}

.ps-form-radio-item {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  gap: 8px;
}

.ps-form-radio-item input[type="radio"] {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--ps-primary, #6366f1);
}

.ps-form-radio-custom {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #d1d5db;
  border-radius: 50%;
  flex-shrink: 0;
  transition: border-color 0.15s ease;
  position: relative;
}

.ps-form-radio-item input[type="radio"]:checked + .ps-form-radio-custom {
  border-color: var(--ps-primary, #6366f1);
}

.ps-form-radio-item input[type="radio"]:checked + .ps-form-radio-custom::after {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ps-primary, #6366f1);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.ps-form-radio-label {
  font-size: 14px;
  color: #374151;
}

/* ── Yes/No ──────────────────────────────────────────────────── */

.ps-form-yesno {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ps-form-yesno-btn {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.ps-form-yesno-btn input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.ps-form-yesno-btn input[type="radio"]:checked + span {
  background: var(--ps-primary, #6366f1);
  color: #fff;
  border-color: var(--ps-primary, #6366f1);
}

/* ── Rating ──────────────────────────────────────────────────── */

.ps-form-rating {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.ps-form-rating-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--ps-rating-empty, #e2e8f0);
  transition: color 0.1s ease;
  font-family: 'Material Icons Round', sans-serif;
}

.ps-form-rating-btn.is-filled {
  color: var(--ps-rating-fill, #f59e0b);
}

.ps-form-scale-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  width: 100%;
}

.ps-form-scale-label-low,
.ps-form-scale-label-high {
  font-size: 11px;
  color: inherit;
  opacity: 0.7;
}

/* ── Scale ───────────────────────────────────────────────────── */

.ps-form-scale {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.ps-form-scale-btn {
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: background 0.12s ease, color 0.12s ease;
}

.ps-form-scale-btn.is-active {
  background: var(--ps-scale-active-bg, #6366f1);
  color: var(--ps-scale-active-color, #ffffff);
}

/* ── File upload ─────────────────────────────────────────────── */

.ps-form-file-wrap {
  position: relative;
  cursor: pointer;
}

.ps-form-file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.ps-form-file-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  transition: border-color 0.2s;
}

.ps-form-file-wrap:hover .ps-form-file-zone {
  border-color: var(--ps-primary, #6366f1);
}

.ps-form-file-icon {
  font-size: 32px;
  color: #94a3b8;
  font-family: 'Material Icons Round', sans-serif;
}

.ps-form-file-text {
  font-size: 13px;
  color: #64748b;
}

/* ── Signature ───────────────────────────────────────────────── */

.ps-form-signature-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ps-form-signature-pad {
  touch-action: none;
  cursor: crosshair;
  display: block;
}

.ps-form-signature-clear {
  align-self: flex-end;
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  color: #64748b;
  cursor: pointer;
  transition: background 0.15s;
}

.ps-form-signature-clear:hover {
  background: #f1f5f9;
}

/* ── Submit wrap ─────────────────────────────────────────────── */

.ps-form-submit-wrap {
  display: flex;
}

.ps-form-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
  font-family: inherit;
  text-decoration: none;
}

.ps-form-btn:hover {
  transform: translateY(-1px);
}

.ps-form-btn:active {
  transform: scale(0.97);
}

.ps-form-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

/* ── Spinner (submit loading) ────────────────────────────────── */

.ps-btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ps-spin 0.6s linear infinite;
  flex-shrink: 0;
}

@keyframes ps-spin {
  to { transform: rotate(360deg); }
}

/* ── Progress bar ────────────────────────────────────────────── */

.ps-form-progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

.ps-form-progress-bar {
  flex: 1;
  overflow: hidden;
  border-radius: 99px;
  background: #e2e8f0;
  height: 6px;
}

.ps-form-progress-fill {
  height: 100%;
  background: var(--ps-primary, #6366f1);
  border-radius: 99px;
  transition: width 0.3s ease;
}

.ps-form-progress-text {
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 11px;
  color: #64748b;
}

/* ── Step ────────────────────────────────────────────────────── */

.ps-form-step {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.ps-form-step[hidden] {
  display: none;
}

.ps-form-step-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

/* ── Layout row ──────────────────────────────────────────────── */

.ps-form-layout-row {
  display: flex;
}

.ps-form-layout-col {
  min-width: 0;
  box-sizing: border-box;
}

/* ── Content nodes ───────────────────────────────────────────── */

.ps-form-heading {
  margin: 0;
  line-height: 1.3;
}

.ps-form-paragraph {
  margin: 0;
  line-height: 1.6;
}

.ps-form-divider {
  border: none;
  border-top: 1px solid #e2e8f0;
  width: 100%;
  margin: 0;
}

.ps-form-spacer {
  display: block;
}

.ps-form-image {
  display: block;
}

.ps-form-image img {
  max-width: 100%;
  height: auto;
  display: block;
}

.ps-form-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px dashed #cbd5e1;
}

.ps-form-html-block {
  width: 100%;
}

/* ── Success card ────────────────────────────────────────────── */

.ps-form-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-sizing: border-box;
  width: 100%;
  padding: 2rem;
  background: #f0fdf4;
  border-radius: 12px;
}

.ps-form-success[hidden] {
  display: none;
}

.ps-form-success-icon {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  font-size: 48px;
  color: #16a34a;
  font-family: 'Material Icons Round', sans-serif;
}

.ps-form-success-heading {
  margin: 0 0 8px;
  font-weight: 700;
  line-height: 1.2;
  font-size: 20px;
  color: #14532d;
}

.ps-form-success-text {
  margin: 0;
  line-height: 1.6;
  font-size: 14px;
  color: #166534;
}

/* Back to form button (inline mode) */
.ps-form-success-back {
  margin-top: 16px;
  background: none;
  border: none;
  color: #6366f1;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
}

/* Redirect countdown */
.ps-form-success-redirect {
  margin-top: 12px;
  font-size: 13px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ps-form-success-countdown {
  font-weight: 700;
  color: #6366f1;
}

/* ── Error banner ────────────────────────────────────────────── */

.ps-form-error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #fef2f2;
  border-radius: 8px;
  border-left: 4px solid #ef4444;
  color: #991b1b;
}

.ps-form-error-banner[hidden] {
  display: none;
}

.ps-form-error-banner-icon {
  font-size: 20px;
  color: #ef4444;
  font-family: 'Material Icons Round', sans-serif;
  flex-shrink: 0;
}

.ps-form-error-banner-msg {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
}

/* ── Honeypot (visually hidden) ─────────────────────────────── */

.ps-form-hp-wrap {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
}

/* ── Responsive ──────────────────────────────────────────────── */

@media (max-width: 768px) {
  .ps-form-field-wrap--label-left {
    flex-direction: column;
    gap: 4px;
  }
  .ps-form-field-wrap--label-left .ps-form-label {
    min-width: unset;
    padding-top: 0;
  }
}

@media (max-width: 480px) {
  .ps-form-yesno {
    flex-direction: column;
  }
}



/* ── Fix: Force hidden form to actually hide (overrides display:flex) ── */
.ps-form-inner[hidden] {
  display: none !important;
}

/* ── Fix: Ensure Material Icons render inside the form shell ── */
.ps-form-shell .ms {
  font-family: 'Material Icons Round', sans-serif;
  display: inline-block;
  font-size: inherit;
  line-height: 1;
}
