/* =========================================================
   WA Lead Pro v2.1 — Frontend Styles
   ========================================================= */

/* ----- CSS Custom Properties (dari walp_label_css()) ----- */
:root {
  --wasf-label-size:   13px;
  --wasf-label-weight: 600;
  --wasf-label-pt:     0px;
  --wasf-label-pb:     4px;
}

/* =========================================================
   Floating Action Button
   ========================================================= */
#wasf-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  /* When no label: perfect circle via width/height set by JS */
  /* When label present: auto width, pill shape */
  min-width: 56px;
  height: 56px;
  background: #25d366;
  border: none;
  border-radius: 9999px; /* pill default, overridden by shape class */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  z-index: 9900;
  box-shadow: 0 4px 16px rgba(0,0,0,.28);
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
  padding: 0 18px;
  white-space: nowrap;
  /* Pulse ring */
  isolation: isolate;
  box-sizing: border-box;
}

/* No label: remove horizontal padding so it stays a perfect circle */
#wasf-fab:not([data-has-label]) {
  padding: 0;
}

/* With label: auto width expands to fit icon + text */
#wasf-fab[data-has-label] {
  width: auto !important;
  padding: 0 20px 0 16px;
  gap: 10px;
}

#wasf-fab:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 22px rgba(0,0,0,.36);
}

/* Shape variants */
#wasf-fab.wasf-round  { border-radius: 9999px; }
#wasf-fab.wasf-square { border-radius: 14px !important; }

/* Label text style */
#wasf-fab .wasf-btn-label {
  color: inherit; /* inherits from setupFab iconColor logic */
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Position variants */
#wasf-fab.wasf-left { right: auto; left: 24px; }

/* Sembunyikan FAB saat modal terbuka */
body.wasf-modal-open #wasf-fab {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

/* Label text — see also #wasf-fab .wasf-btn-label above */
.wasf-btn-label {
  font-family: inherit; /* follows page font */
}

/* Icon — fill proportionally using CSS, not just attribute */
#wasf-fab svg {
  flex-shrink: 0;
  display: block;
  overflow: visible;
  /* Critical: prevent theme 'height:auto' from collapsing icon on mobile */
  height: 55% !important;
  width: 55% !important;
  max-width: none !important;
  max-height: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
}

/* Icon fills 55% of button - works on all devices */
#wasf-fab:not([data-has-label]) svg,
#wasf-fab:not([data-has-label]) svg:not([width]) {
  width: 55% !important;
  height: 55% !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: none !important;
  max-height: none !important;
  /* Reset any theme height:auto that breaks mobile */
  aspect-ratio: 1 / 1;
}

/* Force on mobile - beats theme overrides */
@media (max-width: 768px) {
  #wasf-fab svg {
    width: 55% !important;
    height: 55% !important;
    max-width: none !important;
    max-height: none !important;
  }
}

/* Pulse animation */
#wasf-fab::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #25d366;
  opacity: 0;
  z-index: -1;
  animation: wasf-pulse 2.8s ease-out infinite;
}

@keyframes wasf-pulse {
  0%   { transform: scale(1);   opacity: .45; }
  70%  { transform: scale(1.5); opacity: 0;   }
  100% { opacity: 0; }
}

/* =========================================================
   Greeting Bubble
   ========================================================= */
#wasf-greeting {
  position: fixed;
  bottom: 90px;
  right: 92px;
  background: #fff;
  border-radius: 14px 14px 0 14px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: system-ui, -apple-system, sans-serif;
  box-shadow: 0 4px 18px rgba(0,0,0,.18);
  z-index: 9899;
  max-width: 220px;
  line-height: 1.45;
  animation: wasf-pop .3s ease;
}

#wasf-greeting.wasf-left {
  right: auto;
  left: 92px;
  border-radius: 14px 14px 14px 0;
}

@keyframes wasf-pop {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   Note Below Button
   ========================================================= */
.wasf-btn-note {
  position: fixed;
  bottom: 90px;
  right: 28px;
  font-size: 12px;
  color: #555;
  background: rgba(255,255,255,.9);
  border-radius: 6px;
  padding: 3px 9px;
  z-index: 9898;
  backdrop-filter: blur(4px);
  box-shadow: 0 1px 6px rgba(0,0,0,.1);
  margin: 0;
  transition: opacity .2s;
}

.wasf-btn-note.wasf-left {
  right: auto;
  left: 28px;
}

/* Sembunyikan note saat modal terbuka */
body.wasf-modal-open .wasf-btn-note {
  opacity: 0;
  pointer-events: none;
}

/* =========================================================
   Modal Backdrop
   ========================================================= */
#wasf-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 9950;
  animation: wasf-fade-in .2s ease;
}

#wasf-backdrop[hidden] { display: none; }

@keyframes wasf-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* =========================================================
   Modal
   ========================================================= */
#wasf-modal {
  position: fixed;
  z-index: 9960;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 18px;
  width: min(460px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px 26px 24px;
  box-shadow: 0 24px 64px rgba(0,0,0,.22);
  font-family: system-ui, -apple-system, sans-serif;
  animation: wasf-modal-in .25s cubic-bezier(.34,1.4,.64,1);
  overscroll-behavior: contain;
}

#wasf-modal[hidden] { display: none; }

@keyframes wasf-modal-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 20px)) scale(.97); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Modal header */
.wasf-modal-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
  /* justify-content ensures close button stays right even when title is empty */
  justify-content: space-between;
}

/* When no title: push close button to top-right naturally */
.wasf-modal-header > svg:first-child {
  flex-shrink: 0;
  margin-top: 2px;
}

.wasf-modal-title {
  flex: 1;
  font-size: 17px;
  font-weight: 700;
  color: #111;
  margin: 0;
  line-height: 1.3;
}

.wasf-modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: #bbb;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color .15s, background .15s;
  flex-shrink: 0;
}

.wasf-modal-close:hover { color: #333; background: #f0f0f0; }

/* =========================================================
   Form Fields Layout
   ========================================================= */
.wasf-fields-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0 12px;
}

/* Full width = 100%, Half = ~50% */
.wasf-field {
  width: 100%;
  margin-bottom: 14px;
  box-sizing: border-box;
}

.wasf-field-half {
  width: calc(50% - 6px);
}

/* Label */
.wasf-label {
  display: block;
  font-size: var(--wasf-label-size);
  font-weight: var(--wasf-label-weight);
  color: #333;
  padding-top: var(--wasf-label-pt);
  padding-bottom: var(--wasf-label-pb);
  line-height: 1.4;
}

/* Input / Select / Textarea — unified rounded style */
.wasf-input,
.wasf-select,
.wasf-textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #ddd;
  border-radius: 8px;   /* same rounded corner for ALL field types */
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
  background: #fafafa;
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;     /* normalize date/select across browsers */
}

/* Date input: keep native picker but uniform style */
.wasf-input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
}

.wasf-input:focus,
.wasf-select:focus,
.wasf-textarea:focus {
  border-color: #25d366;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,211,102,.12);
}

.wasf-input.wasf-error,
.wasf-select.wasf-error,
.wasf-textarea.wasf-error {
  border-color: #e53e3e;
  box-shadow: 0 0 0 3px rgba(229,62,62,.1);
}

/* Error message */
.wasf-error-msg {
  display: block;
  font-size: 11px;
  color: #e53e3e;
  margin-top: 3px;
  min-height: 16px;
}

.wasf-textarea {
  resize: vertical;
  min-height: 72px;
}

.wasf-select {
  cursor: pointer;
  /* Custom dropdown arrow */
  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 d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  /* Force same height as text inputs — browsers shrink select by default */
  height: auto;
  min-height: 46px;       /* matches padding:10px*2 + font:14px * line-height:1.4 */
  line-height: 1.4;       /* same as text inputs */
  vertical-align: middle; /* center text vertically */
}

/* Extra reset for WebKit/Safari mobile which ignore padding on <select> */
@supports (-webkit-appearance: none) {
  .wasf-select {
    -webkit-appearance: none;
    padding-top: 10px;
    padding-bottom: 10px;
    line-height: 1.4;
  }
}

/* Submit button */
.wasf-submit-btn {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 20px;
  background: #25d366;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-top: 6px;
  transition: filter .2s, transform .15s;
}

.wasf-submit-btn:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.wasf-submit-btn:disabled { opacity: .65; cursor: not-allowed; transform: none; }
.wasf-submit-btn svg { flex-shrink: 0; }

/* Success state */
.wasf-success {
  text-align: center;
  padding: 16px 0 8px;
}

.wasf-success-icon { font-size: 52px; display: block; margin-bottom: 12px; }

/* =========================================================
   Embedded Form (shortcode)
   ========================================================= */
.wasf-embed-wrap {
  font-family: system-ui, -apple-system, sans-serif;
}

.wasf-embed-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 18px;
  color: #111;
}

.wasf-embed-form .wasf-fields-wrap {
  gap: 0 12px;
}

/* =========================================================
   Mobile — sheet dari bawah, half tetap 2 kolom
   ========================================================= */
@media (max-width: 520px) {
  #wasf-modal {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    transform: none;
    width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    padding: 24px 18px 28px;
    animation: wasf-sheet-up .28s cubic-bezier(.34,1.3,.64,1);
  }

  @keyframes wasf-sheet-up {
    from { transform: translateY(40px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }

  /* half kolom TETAP 2 kolom di mobile */
  .wasf-field-half {
    width: calc(50% - 6px);
  }

  /* Sedikit perkecil input di mobile untuk muat */
  .wasf-input, .wasf-select, .wasf-textarea {
    font-size: 16px; /* prevent zoom on iOS */
    padding: 9px 10px;
  }

  .wasf-select {
    min-height: 44px;
    line-height: 1.4;
    padding-top: 9px;
    padding-bottom: 9px;
  }

  #wasf-fab { bottom: 20px; right: 20px; }
  #wasf-fab.wasf-left { right: auto; left: 20px; }

  #wasf-greeting { right: 80px; }
  #wasf-greeting.wasf-left { right: auto; left: 80px; }
}

/* =========================================================
   Pre-Click Capture Popup (Floating Button mode)
   ========================================================= */
#wasf-capture-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.48);
  z-index: 9950;
  animation: wasf-fade-in .2s ease;
}
#wasf-capture-backdrop[hidden] { display: none; }

#wasf-capture-popup {
  position: fixed;
  z-index: 9960;
  bottom: 90px;
  right: 24px;
  width: min(320px, 90vw);
  background: #fff;
  border-radius: 16px;
  padding: 20px 20px 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.22);
  font-family: system-ui, -apple-system, sans-serif;
  animation: wasf-pop .25s cubic-bezier(.34,1.4,.64,1);
}
#wasf-capture-popup[hidden] { display: none; }
#wasf-capture-popup.wasf-left { right: auto; left: 24px; }

@media (max-width:520px) {
  #wasf-capture-popup {
    bottom: 0; right: 0; left: 0;
    width: 100%;
    border-radius: 16px 16px 0 0;
    animation: wasf-sheet-up .25s ease;
  }
  #wasf-capture-popup.wasf-left { left: 0; right: 0; }
}

.wasf-capture-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}
.wasf-capture-title {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  color: #111;
  margin: 0;
  line-height: 1.4;
}
.wasf-capture-close {
  background: none;
  border: none;
  font-size: 20px;
  color: #bbb;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}
.wasf-capture-close:hover { color: #555; }

/* Fields inside capture popup */
#wasf-capture-popup .wasf-field { margin-bottom: 10px; }
#wasf-capture-popup .wasf-label { font-size: 12px; }
#wasf-capture-popup .wasf-input,
#wasf-capture-popup .wasf-select { padding: 8px 10px; font-size: 13px; }

/* Submit */
.wasf-capture-submit {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: #25d366;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: filter .2s;
  margin-top: 4px;
}
.wasf-capture-submit:hover { filter: brightness(1.08); }

/* Skip link */
.wasf-capture-skip {
  display: block;
  text-align: center;
  font-size: 12px;
  color: #888;
  margin-top: 8px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.wasf-capture-skip:hover { color: #444; }

/* ========================================================
   v2.4 FIX: Font inherit from page for all widget elements
   ======================================================== */
#wasf-fab,
#wasf-fab *,
#wasf-modal,
#wasf-modal *,
.wasf-embed-wrap,
.wasf-embed-wrap *,
#wasf-capture-popup,
#wasf-capture-popup * {
  font-family: inherit;
}

/* Success popup share buttons + image */
.wasf-success-share { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.wasf-success-share .wasf-share-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: 10px; font-size: 13px; font-weight: 600;
  background: #f4f6f8; color: #374151; border: 1px solid #e2e8f0;
  text-decoration: none; cursor: pointer; transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.wasf-success-share .wasf-share-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.wasf-success-share .wasf-share-btn:hover { background: #eceff3; border-color: #cbd5e1; color: #1e293b; }
.wasf-success img { display: block; margin: 6px auto 0; }
#wasf-success-overlay .wasf-modal { max-width: 420px; text-align: center; }

/* Floating button custom icon */
.wasf-fab-custom-icon { width: 60%; height: 60%; object-fit: contain; display: block; }

/* Success popup close button — pinned top-right */
.wasf-modal { position: relative; }
.wasf-success-close {
  position: absolute; top: 10px; right: 10px; z-index: 5;
  width: 30px; height: 30px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; line-height: 1; color: #94a3b8;
  background: rgba(0,0,0,.04); border: none; border-radius: 8px; cursor: pointer;
  transition: color .15s, background .15s;
}
.wasf-success-close:hover { color: #1e293b; background: rgba(0,0,0,.08); }

/* ════════════════════════════════════════════════════════════════
 * Theme-proofing — keep the plugin's popup form fields tidy no matter
 * what the active theme injects. High-specificity + !important on the
 * box-model essentials only (visuals above remain easy to override by
 * our own rules). Scoped strictly to plugin containers.
 * ════════════════════════════════════════════════════════════════ */
#wasf-modal .wasf-input,
#wasf-modal .wasf-select,
#wasf-modal .wasf-textarea,
.wasf-embed-form .wasf-input,
.wasf-embed-form .wasf-select,
.wasf-embed-form .wasf-textarea {
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 100% !important;
  min-height: 46px !important;
  margin: 0 !important;
  padding: 10px 12px !important;
  font-size: 14px !important;
  line-height: 1.4 !important;
  border-radius: 8px !important;
  letter-spacing: normal !important;
  text-transform: none !important;
  float: none !important;
}
#wasf-modal .wasf-textarea,
.wasf-embed-form .wasf-textarea {
  min-height: 72px !important;
  height: auto !important;
}
#wasf-modal .wasf-select,
.wasf-embed-form .wasf-select {
  padding-right: 32px !important;
  background-color: #fafafa !important;
}
/* Field rows: ensure even spacing isn't collapsed by theme resets */
#wasf-modal .wasf-field,
.wasf-embed-form .wasf-field {
  width: 100% !important;
  margin: 0 0 14px 0 !important;
  padding: 0 !important;
}
#wasf-modal .wasf-fields-wrap,
.wasf-embed-form .wasf-fields-wrap {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 0 12px !important;
}
#wasf-modal .wasf-field-half,
.wasf-embed-form .wasf-field-half {
  width: calc(50% - 6px) !important;
}
/* Submit button: stop themes from restyling width/transform */
#wasf-modal .wasf-submit-btn,
.wasf-embed-form .wasf-submit-btn {
  box-sizing: border-box !important;
  width: 100% !important;
  margin: 4px 0 0 0 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
}
