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

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

/* =========================================================
   Floating Action Button
   ========================================================= */
#walp-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 */
#walp-fab:not([data-has-label]) {
  padding: 0;
}

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

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

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

/* Label text style */
#walp-fab .walp-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 */
#walp-fab.walp-left { right: auto; left: 24px; }

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

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

/* Icon — fill proportionally using CSS, not just attribute */
#walp-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 */
#walp-fab:not([data-has-label]) svg,
#walp-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) {
  #walp-fab svg {
    width: 55% !important;
    height: 55% !important;
    max-width: none !important;
    max-height: none !important;
  }
}

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

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

/* =========================================================
   Greeting Bubble
   ========================================================= */
#walp-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: walp-pop .3s ease;
}

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

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

/* =========================================================
   Note Below Button
   ========================================================= */
.walp-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;
}

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

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

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

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

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

/* =========================================================
   Modal
   ========================================================= */
#walp-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: walp-modal-in .25s cubic-bezier(.34,1.4,.64,1);
  overscroll-behavior: contain;
}

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

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

/* Modal header */
.walp-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 */
.walp-modal-header > svg:first-child {
  flex-shrink: 0;
  margin-top: 2px;
}

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

.walp-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;
}

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

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

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

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

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

/* Input / Select / Textarea — unified rounded style */
.walp-input,
.walp-select,
.walp-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 */
.walp-input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
}

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

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

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

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

.walp-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) {
  .walp-select {
    -webkit-appearance: none;
    padding-top: 10px;
    padding-bottom: 10px;
    line-height: 1.4;
  }
}

/* Submit button */
.walp-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;
}

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

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

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

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

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

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

/* =========================================================
   Mobile — sheet dari bawah, half tetap 2 kolom
   ========================================================= */
@media (max-width: 520px) {
  #walp-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: walp-sheet-up .28s cubic-bezier(.34,1.3,.64,1);
  }

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

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

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

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

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

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

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

#walp-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: walp-pop .25s cubic-bezier(.34,1.4,.64,1);
}
#walp-capture-popup[hidden] { display: none; }
#walp-capture-popup.walp-left { right: auto; left: 24px; }

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

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

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

/* Submit */
.walp-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;
}
.walp-capture-submit:hover { filter: brightness(1.08); }

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

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