/* ============================================================
   SMARTLead Frontend Widget
   ============================================================ */

/* ---- Universal box-sizing + font inside root ---- */
#sl-widget-root *,
#sl-widget-root *::before,
#sl-widget-root *::after {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ---- Reset margins on layout elements ---- */
#sl-widget-root div,
#sl-widget-root span,
#sl-widget-root h1, #sl-widget-root h2, #sl-widget-root h3,
#sl-widget-root p, #sl-widget-root ul, #sl-widget-root li {
  margin: 0;
}

/* ============================================================
   HARD RESET — strip every theme override (Elementor, etc.)
   for buttons and form fields before our own rules apply
   ============================================================ */
#sl-widget-root button,
#sl-widget-root input,
#sl-widget-root textarea,
#sl-widget-root select {
  all: unset;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: normal;
  letter-spacing: normal;
  text-transform: none;
  border-radius: 0;
  background: none;
  color: inherit;
  padding: 0;
  margin: 0;
}
#sl-widget-root button               { cursor: pointer; }
#sl-widget-root input,
#sl-widget-root textarea             { cursor: text; }
#sl-widget-root select               { cursor: pointer; }
#sl-widget-root textarea             { resize: vertical; }

/* ---- Trigger Button ---- */
#sl-widget-root .sl-trigger {
  position: fixed;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #99b640;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: transform .2s, box-shadow .2s;
  color: #fff;
  padding: 0;
}
#sl-widget-root .sl-trigger:hover        { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0,0,0,.25); }
#sl-widget-root .sl-trigger.sl-pos-right { right: 24px; }
#sl-widget-root .sl-trigger.sl-pos-left  { left: 24px; }
#sl-widget-root .sl-trigger svg          { width: 26px; height: 26px; fill: #fff; flex-shrink: 0; }

#sl-widget-root .sl-trigger-badge {
  position: absolute; top: -2px; right: -2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #ef4444; color: #fff; font-size: 10px; font-weight: 700;
  display: none; align-items: center; justify-content: center;
  border: 2px solid #fff;
}

/* ---- Widget Panel ---- */
#sl-widget-root .sl-widget {
  position: fixed;
  bottom: 92px;
  width: 360px;
  max-height: 600px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
  z-index: 9997;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform .3s cubic-bezier(.34,1.4,.64,1), opacity .25s ease;
  transform-origin: bottom center;
}
#sl-widget-root .sl-widget.sl-pos-right { right: 24px; transform-origin: bottom right; }
#sl-widget-root .sl-widget.sl-pos-left  { left: 24px;  transform-origin: bottom left; }
#sl-widget-root .sl-widget.sl-hidden    { transform: scale(.85) translateY(20px); opacity: 0; pointer-events: none; }
#sl-widget-root .sl-widget.sl-visible   { transform: scale(1) translateY(0); opacity: 1; }

/* ---- Widget Header ---- */
#sl-widget-root .sl-w-header {
  background: #2d3139;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#sl-widget-root .sl-w-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: #99b640;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: #fff; flex-shrink: 0;
  position: relative;
}
#sl-widget-root .sl-w-avatar-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #22c55e; border: 2px solid #2d3139;
}
#sl-widget-root .sl-w-header-info { flex: 1; }
#sl-widget-root .sl-w-name   { color: #fff; font-weight: 700; font-size: 14.5px; }
#sl-widget-root .sl-w-status { color: rgba(255,255,255,.55); font-size: 12px; margin-top: 1px; }

/* Close button — full reset then restyle */
#sl-widget-root .sl-w-close {
  all: unset;
  box-sizing: border-box;
  color: rgba(255,255,255,.55);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color .15s;
  flex-shrink: 0;
}
#sl-widget-root .sl-w-close:hover { color: #fff; }

/* ---- Widget Body ---- */
#sl-widget-root .sl-w-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #eef0e8;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---- Welcome Message ---- */
#sl-widget-root .sl-w-welcome {
  background: #fff;
  border-radius: 14px;
  padding: 18px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  font-size: 14.5px;
  line-height: 1.6;
  color: #1a1f24;
  white-space: pre-line;
}

/* ---- Progress Indicator ---- */
#sl-widget-root .sl-w-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  font-size: 11px;
  font-weight: 800;
  color: #4b5563;
  letter-spacing: .7px;
  text-transform: uppercase;
}
#sl-widget-root .sl-w-progress-dot   { width: 8px; height: 8px; border-radius: 50%; background: #99b640; flex-shrink: 0; }
#sl-widget-root .sl-progress-bar-wrap { flex: 1; height: 5px; background: #e5e7eb; border-radius: 3px; overflow: hidden; }
#sl-widget-root .sl-progress-bar     { height: 100%; background: #99b640; border-radius: 3px; transition: width .35s ease; }

/* ---- Question Card ---- */
#sl-widget-root .sl-w-question {
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  font-size: 15px;
  color: #1a1f24;
  font-weight: 600;
  line-height: 1.45;
}

/* ---- Options (multiple choice) ---- */
#sl-widget-root .sl-w-options { display: flex; flex-direction: column; gap: 8px; }

#sl-widget-root .sl-w-option {
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #1a1f24;
  transition: border-color .15s, background .15s, box-shadow .15s;
  text-align: left;
  width: 100%;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
#sl-widget-root .sl-w-option:hover    { border-color: #99b640; background: #f9fce8; box-shadow: 0 2px 8px rgba(153,182,64,.15); }
#sl-widget-root .sl-w-option.selected { border-color: #99b640; background: #f0f8d0; }

#sl-widget-root .sl-w-option-label {
  width: 28px; height: 28px; border-radius: 50%;
  background: #f3f4f6; color: #6b7280;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; flex-shrink: 0;
  border: 1.5px solid #e5e7eb;
  transition: background .15s, color .15s, border-color .15s;
}
#sl-widget-root .sl-w-option.selected .sl-w-option-label { background: #99b640; color: #fff; border-color: #99b640; }

/* ---- Text Inputs ---- */
#sl-widget-root .sl-w-input,
#sl-widget-root .sl-w-textarea {
  all: unset;
  box-sizing: border-box;
  display: block;
  width: 100%;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px 15px;
  font-size: 14px;
  color: #1a1f24;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  transition: border-color .15s, box-shadow .15s;
  cursor: text;
}
#sl-widget-root .sl-w-input:focus,
#sl-widget-root .sl-w-textarea:focus  { border-color: #99b640; box-shadow: 0 0 0 3px rgba(153,182,64,.15); outline: none; }
#sl-widget-root .sl-w-textarea        { min-height: 80px; resize: vertical; }

/* ---- Dropdown ---- */
#sl-widget-root .sl-w-select {
  all: unset;
  box-sizing: border-box;
  display: block;
  width: 100%;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px 38px 12px 15px;
  font-size: 14px;
  color: #1a1f24;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 12px center;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
#sl-widget-root .sl-w-select:focus { border-color: #99b640; box-shadow: 0 0 0 3px rgba(153,182,64,.15); outline: none; }

/* ---- Next Button ---- */
#sl-widget-root .sl-w-next {
  all: unset;
  box-sizing: border-box;
  display: block;
  width: 100%;
  background: #99b640;
  color: #fff;
  border-radius: 12px;
  padding: 13px;
  font-size: 14.5px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
  box-shadow: 0 2px 8px rgba(153,182,64,.35);
}
#sl-widget-root .sl-w-next:hover     { background: #8ab418; box-shadow: 0 4px 12px rgba(153,182,64,.45); }
#sl-widget-root .sl-w-next:disabled  { background: #d1d5db; box-shadow: none; cursor: not-allowed; opacity: .7; }

/* ---- Contact Form ---- */
#sl-widget-root .sl-w-contact-form {
  background: #fff;
  border-radius: 14px;
  padding: 18px 16px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#sl-widget-root .sl-w-contact-title {
  font-size: 15px;
  font-weight: 800;
  color: #1a1f24;
  line-height: 1.35;
  padding-bottom: 8px;
  border-bottom: 1px solid #f3f4f6;
}
#sl-widget-root .sl-w-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
#sl-widget-root .sl-w-field label {
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .6px;
}
#sl-widget-root .sl-required-star { color: #ef4444; }

/* ---- Submit Button ---- */
#sl-widget-root .sl-w-submit {
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: #99b640;
  color: #fff;
  border-radius: 12px;
  padding: 14px;
  font-size: 14.5px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  margin-top: 6px;
  transition: background .15s, box-shadow .15s;
  box-shadow: 0 2px 8px rgba(153,182,64,.35);
}
#sl-widget-root .sl-w-submit:hover    { background: #8ab418; box-shadow: 0 4px 12px rgba(153,182,64,.45); }
#sl-widget-root .sl-w-submit:disabled { background: #d1d5db; box-shadow: none; cursor: not-allowed; }

#sl-widget-root .sl-w-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: sl-fw-spin .6s linear infinite;
  display: none;
  flex-shrink: 0;
}
@keyframes sl-fw-spin { to { transform: rotate(360deg); } }

/* ---- Thank You Screen ---- */
#sl-widget-root .sl-w-thankyou { text-align: center; padding: 32px 20px; }
#sl-widget-root .sl-w-thankyou-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: #f0f8d0; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center; font-size: 28px;
}
#sl-widget-root .sl-w-thankyou h3 { font-size: 18px; font-weight: 800; color: #1a1f24; margin-bottom: 8px; }
#sl-widget-root .sl-w-thankyou p  { font-size: 14px; color: #6b7280; line-height: 1.5; }

/* ---- Error Message ---- */
#sl-widget-root .sl-w-error { color: #ef4444; font-size: 12px; margin-top: 4px; }

/* ---- Footer Branding ---- */
#sl-widget-root .sl-w-footer {
  text-align: center;
  padding: 10px;
  font-size: 11px;
  color: #9ca3af;
  border-top: 1px solid #f3f4f6;
  background: #fff;
  flex-shrink: 0;
  letter-spacing: .3px;
}
#sl-widget-root .sl-w-footer span { color: #99b640; font-weight: 700; }

/* ---- Inline shortcode trigger ---- */
#sl-widget-root .sl-widget-trigger-inline {
  all: unset;
  box-sizing: border-box;
  background: #99b640; color: #fff;
  border-radius: 8px; padding: 10px 20px;
  font-size: 14px; font-weight: 700;
  cursor: pointer; transition: background .15s;
}
#sl-widget-root .sl-widget-trigger-inline:hover { background: #8ab418; }

/* ---- Responsive ---- */
@media (max-width: 480px) {
  #sl-widget-root .sl-widget { width: calc(100vw - 16px); left: 8px !important; right: 8px !important; bottom: 80px; border-radius: 14px; }
  #sl-widget-root .sl-trigger { bottom: 16px; }
  #sl-widget-root .sl-trigger.sl-pos-right { right: 16px; }
  #sl-widget-root .sl-trigger.sl-pos-left  { left: 16px; }
}
