/* ============================================================
   ITI Smart Form Builder — Frontend Styles v1.4
   Design : Deep Navy + Orange (#ff6a00) / DM Sans
   Widget : WhatsApp-style fixed FAB + slide-up popup
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

/* ── CSS Variables ── */
:root {
  --iti-form-bg:       #ffffff;
  --iti-input-bg:      #ffffff;
  --iti-input-border:  #d1d5db;
  --iti-focus-color:   #ff6a00;
  --iti-label-color:   #1f2937;
  --iti-btn-bg:        #ff6a00;
  --iti-border-radius: 8px;
  --iti-font:          'DM Sans', 'Segoe UI', system-ui, sans-serif;
  --iti-shadow:        0 4px 24px rgba(0,0,0,.10);
  --iti-accent:        #ff6a00;
}

/* ── Honeypot ── */
.iti-hp {
  position: absolute !important;
  left: -9999px !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
}

/* ── Standalone Form Container ── */
.iti-form-container {
  background: var(--iti-form-bg);
  border-radius: var(--iti-border-radius);
  box-shadow: var(--iti-shadow);
  padding: 28px 32px;
  font-family: var(--iti-font);
  max-width: 100%;
  box-sizing: border-box;
}

/* ── Fields Grid ── */
.iti-fields-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 16px;
}
.iti-field-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.iti-width-full  { flex: 0 0 100%;                 max-width: 100%; }
.iti-width-half  { flex: 0 0 calc(50% - 8px);      max-width: calc(50% - 8px); }
.iti-width-third { flex: 0 0 calc(33.333% - 11px); max-width: calc(33.333% - 11px); }

/* ── Labels ── */
.iti-field-wrap label,
.iti-field-radio legend,
.iti-field-checkbox legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--iti-label-color);
  letter-spacing: .1px;
  line-height: 1.4;
}
.iti-req { color: #e53e3e; margin-left: 2px; }

/* ── Inputs / Textarea / Select ── */
.iti-form input[type="text"],
.iti-form input[type="email"],
.iti-form input[type="tel"],
.iti-form input[type="number"],
.iti-form input[type="date"],
.iti-form input[type="phone"],
.iti-form textarea,
.iti-form select {
  width: 100%;
  background: var(--iti-input-bg);
  border: 1.5px solid var(--iti-input-border);
  border-radius: var(--iti-border-radius);
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: var(--iti-font);
  color: #111827;
  transition: border-color .18s, box-shadow .18s;
  outline: none;
  box-sizing: border-box;
  line-height: 1.5;
  -webkit-appearance: none;
  appearance: none;
}
.iti-form input::placeholder,
.iti-form textarea::placeholder { color: #9ca3af; }
.iti-form input:focus,
.iti-form textarea:focus,
.iti-form select:focus {
  border-color: var(--iti-focus-color);
  box-shadow: 0 0 0 3px rgba(255,106,0,.15);
}
.iti-form textarea { resize: vertical; min-height: 84px; }
.iti-form select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ── Radio / Checkbox ── */
.iti-field-radio,
.iti-field-checkbox { border: none; padding: 0; margin: 0; }
.iti-radio-label,
.iti-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  padding: 3px 0;
}

/* ── File ── */
.iti-form input[type="file"] {
  padding: 7px 10px;
  background: #fafafa;
  border: 1.5px dashed var(--iti-input-border);
  border-radius: var(--iti-border-radius);
  cursor: pointer;
  width: 100%;
  font-size: 12px;
  box-sizing: border-box;
}

/* ── Heading / Divider ── */
.iti-field-heading {
  font-size: 16px;
  font-weight: 700;
  color: #0c1230;
  margin: 6px 0 0;
  width: 100%;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--iti-accent);
}
.iti-field-divider {
  border: none;
  border-top: 1.5px solid #e5e7eb;
  margin: 6px 0;
  width: 100%;
}

/* ── Submit Button ── */
.iti-form-footer { margin-top: 18px; }
.iti-submit-btn {
  background: var(--iti-btn-bg);
  color: #fff;
  border: none;
  border-radius: var(--iti-border-radius);
  padding: 11px 0;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--iti-font);
  cursor: pointer;
  letter-spacing: .4px;
  transition: filter .2s, transform .12s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}
.iti-submit-btn:hover    { filter: brightness(1.08); transform: translateY(-1px); }
.iti-submit-btn:active   { transform: translateY(0);  filter: brightness(.97); }
.iti-submit-btn:disabled { opacity: .7; cursor: not-allowed; transform: none; }

.iti-btn-loader {
  display: none;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: iti-spin .6s linear infinite;
}
@keyframes iti-spin { to { transform: rotate(360deg); } }

/* ── Validation ── */
.iti-field-error input,
.iti-field-error textarea,
.iti-field-error select {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,.12) !important;
}
.iti-field-error-msg { font-size: 11.5px; color: #ef4444; margin-top: 2px; }


/* ============================================================
   FLOATING WIDGET
   ─────────────
   KEY FIX: .iti-widget-popup is position:fixed independent of
   the FAB wrapper. JS calculates its bottom = FAB.bottom + FAB.height + gap.
   This avoids ANY parent stacking-context / overflow issue.
   ============================================================ */

/* ── FAB Wrapper — only holds the button ── */
.iti-widget {
  position: fixed !important;
  bottom: 24px !important;
  right: 16px !important;
  left: auto !important;
  top: auto !important;
  z-index: 2147483647 !important;
  transform: none !important;
  pointer-events: none;
  display: block !important;
  width: auto !important;
  height: auto !important;
}
.iti-widget-left {
  right: auto !important;
  left: 16px !important;
}

/* ── FAB Button ── */
.iti-widget-tab {
  pointer-events: auto;
  display: inline-flex !important;
  align-items: center;
  gap: 9px;
  background: #ff6a00;
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 13px 22px 13px 18px;
  font-size: 13.5px;
  font-weight: 700;
  font-family: var(--iti-font);
  cursor: pointer;
  letter-spacing: .4px;
  box-shadow: 0 4px 18px rgba(0,0,0,.24), 0 1px 4px rgba(0,0,0,.12);
  transition: transform .2s ease, box-shadow .2s ease, filter .18s;
  user-select: none;
  white-space: nowrap;
  line-height: 1;
}
.iti-widget-tab:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 28px rgba(0,0,0,.26);
  filter: brightness(1.08);
}
.iti-widget-tab:active { transform: scale(.97); filter: brightness(.94); }

.iti-tab-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.iti-tab-icon svg { display: block; }


/* ── Popup Panel — fully independent fixed element ── */
/*
  JS sets:
    popup.style.position = 'fixed'
    popup.style.bottom   = (fabRect.bottom from viewport bottom + gap) + 'px'
    popup.style.right    = '16px'   (or left for left-side widget)
*/
.iti-widget-popup {
  position: fixed !important;
  bottom: 90px;      /* JS overrides this */
  right: 16px;
  left: auto;
  top: auto !important;
  z-index: 2147483646 !important;
  transform: none;

  background: #fff;
  border-radius: 14px;
  box-shadow:
    0 8px 40px rgba(0,0,0,.18),
    0 2px 12px rgba(0,0,0,.10);
  overflow: hidden;
  max-height: 82vh;
  overflow-y: auto;

  /* HIDDEN: faded + shifted down */
  opacity: 0;
  translate: 0 18px;
  transition:
    opacity   .26s cubic-bezier(.4,0,.2,1),
    translate .26s cubic-bezier(.4,0,.2,1),
    visibility .26s;
  visibility: hidden;
  pointer-events: none;
}

/* Left-side variant */
.iti-widget-left ~ .iti-widget-popup,
.iti-widget-popup[data-position="left"],
.iti-widget-left .iti-widget-popup {
  right: auto;
  left: 16px;
}

/* OPEN: visible + slid up */
.iti-widget-popup.iti-popup-open {
  opacity: 1;
  translate: 0 0;
  visibility: visible;
  pointer-events: auto;
}


/* ── Popup Header ── */
.iti-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: #ff6a00;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  font-family: var(--iti-font);
  letter-spacing: .2px;
  user-select: none;
}
.iti-popup-header > span {
  display: flex;
  align-items: center;
  gap: 7px;
}
.iti-popup-close {
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  transition: background .18s;
  flex-shrink: 0;
  padding: 0;
}
.iti-popup-close:hover { background: rgba(255,255,255,.38); }
.iti-popup-close svg  { display: block; }

/* ── Popup Body ── */
.iti-popup-body {
  padding: 18px 20px 22px;
}
.iti-popup-body .iti-form-container {
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
}


/* ============================================================
   RESPONSIVE — Mobile bottom sheet
   ============================================================ */
@media (max-width: 600px) {
  .iti-width-half,
  .iti-width-third { flex: 0 0 100%; max-width: 100%; }

  .iti-widget {
    bottom: 20px !important;
    right: 12px !important;
  }
  .iti-widget-left {
    left: 12px !important;
    right: auto !important;
  }

  /* Full-width bottom sheet */
  .iti-widget-popup {
    right: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    border-radius: 18px 18px 0 0 !important;
    max-height: 90vh;
    translate: 0 100% !important;
  }
  .iti-widget-popup.iti-popup-open {
    translate: 0 0 !important;
  }
  .iti-popup-body { padding: 16px 16px 32px; }
}