/* ============================================================
   Dozzo — WhatsApp Consultation Form (reusable component)
   ------------------------------------------------------------
   How to reuse:
     1. Copy the <section class="wa-form-section"> block onto
        any page (contact / service / about).
     2. Add this stylesheet to the page <head>.
     3. Add js/whatsapp-form.js before </body>.
   All styles are scoped under .wa-* so they won't clash with
   the rest of the site. Colour / layout tweaks happen here only.
   ============================================================ */

/* --- Section shell ----------------------------------------- */
.wa-form-section {
  padding: 5rem 0;
  background: linear-gradient(180deg, #ffffff 0%, #fbf5f3 100%);
}
.wa-form-section .wrap { max-width: 1080px; }

/* --- Two-column split: pitch left, form right -------------- */
.wa-form-split {
  display: grid;
  grid-template-columns: 0.92fr 1.08fr;
  gap: 3.2rem;
  align-items: start;
}

/* --- Left: pitch ------------------------------------------- */
.wa-form-pitch .section-title,
.wa-form-pitch h2 { margin-bottom: 1rem; }
.wa-form-pitch > p {
  color: var(--text-dim);
  line-height: 1.75;
  font-size: 16px;
  margin-bottom: 1.6rem;
}
.wa-form-perks {
  list-style: none;
  margin: 0 0 1.6rem;
  padding: 0;
}
.wa-form-perks li {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  margin-bottom: 0.85rem;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
}
.wa-form-perks i { color: var(--red); margin-top: 0.2rem; }
.wa-form-note { font-size: 14px; color: var(--text-dim); }
.wa-form-note a { color: var(--red); font-weight: 600; }
.wa-form-note a:hover { text-decoration: underline; }

/* --- Right: form card --------------------------------------- */
.wa-form {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.8rem 1.8rem 1.5rem;
  box-shadow: 0 18px 44px rgba(158, 37, 34, 0.08);
}
.wa-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.3rem;
}
.wa-field { display: flex; flex-direction: column; gap: 0.5rem; }
.wa-field label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.wa-req { color: var(--red); }
.wa-field input,
.wa-field select,
.wa-field textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.9rem 1rem;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #d7e9de;
  border-radius: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
/* Clean custom arrow on selects (avoids the native "{" glitch) */
.wa-field select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235b524e' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.2rem;
  cursor: pointer;
}
.wa-field textarea { resize: vertical; min-height: 84px; }
.wa-field input:focus,
.wa-field select:focus,
.wa-field textarea:focus {
  outline: none;
  border-color: #25d366;
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.16);
  background: #fff;
}
.wa-field input::placeholder,
.wa-field textarea::placeholder { color: #b3a7a3; }

/* In-field left icons (popup) */
.wa-input-wrap { position: relative; }
.wa-input-wrap > .wa-field-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #edf8f1;
  color: #166534;
  pointer-events: none;
  z-index: 1;
}
.wa-input-wrap > .wa-field-icon i { font-size: 15px; }
.wa-input-wrap input,
.wa-input-wrap select,
.wa-input-wrap textarea { padding-left: 2.95rem; }
.wa-input-wrap select { padding-right: 2.4rem; }

/* Phone: country-code dropdown (default Malaysia) + local number */
.wa-phone-wrap {
  display: flex;
  gap: 0;
  border-radius: 10px;
  border: 1px solid #d7e9de;
  background: #fff;
  overflow: visible;
}
.wa-phone-wrap .wa-phone-cc {
  position: relative;
  flex-shrink: 0;
  border-right: 1px solid #d7e9de;
  background: #edf8f1;
  border-radius: 9px 0 0 9px;
  overflow: visible;
}
.wa-field:has(.wa-phone-wrap) {
  overflow: visible;
  position: relative;
  z-index: 1;
}
.wa-field:has(.wa-phone-cc-list:not([hidden])) {
  z-index: 40;
}
.wa-phone-country-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  clip: rect(0, 0, 0, 0);
}
.wa-phone-cc-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 100%;
  min-height: 46px;
  padding: 0.65rem 0.55rem 0.65rem 0.65rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  color: #166534;
}
.wa-phone-cc-btn:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(37, 211, 102, 0.35);
}
.wa-phone-cc-flag {
  width: 24px;
  height: 17px;
  object-fit: cover;
  border-radius: 2px;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.wa-phone-cc-dial {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.wa-phone-cc-caret {
  font-size: 10px;
  opacity: 0.55;
  margin-right: 2px;
}
.wa-phone-cc-list {
  position: absolute;
  z-index: 1300;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  max-height: 220px;
  overflow: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #fff;
  border: 1px solid #d7e9de;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(26, 18, 20, 0.12);
}
.wa-phone-cc-list li {
  display: grid;
  grid-template-columns: 24px auto 1fr;
  gap: 0.45rem;
  align-items: center;
  padding: 0.5rem 0.45rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #1c1412;
}
.wa-phone-cc-list li:hover,
.wa-phone-cc-list li[aria-selected="true"] {
  background: #edf8f1;
}
.wa-phone-cc-list img {
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.wa-phone-cc-name {
  font-weight: 500;
  color: #5c534e;
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-phone-cc-globe { font-size: 16px; text-align: center; }
.wa-phone-wrap input {
  flex: 1;
  min-width: 0;
  border: none;
  background: #fff;
  padding-left: 14px;
}
.wa-phone-wrap input:focus { box-shadow: none; }

/* Small helper line under a field (e.g. budget hint) */
.wa-modal-hint {
  display: block;
  font-size: 11px;
  color: #8a8a8a;
  margin-top: 5px;
  line-height: 1.45;
}

/* Submit button */
.wa-form-btn { width: 100%; margin-top: 0.4rem; }
.wa-form-btn i { font-size: 1.05em; }
.wa-form-legal {
  font-size: 12.5px;
  color: var(--text-dim);
  margin: 0.9rem 0 0;
  text-align: center;
  line-height: 1.55;
}

/* Anti-spam honeypot (injected by whatsapp-form.js — must hide on pages without home.css) */
.wa-form .hp-field {
  position: absolute !important;
  left: -10000px !important;
  top: auto !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Validation feedback (turns required fields red after submit) */
.wa-form--invalid input[required],
.wa-form--invalid select[required] { border-color: #c0392b; }
.wa-form--invalid input[required]:focus,
.wa-form--invalid select[required]:focus { box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12); }

/* Per-field invalid state + shake (mirrors the reference) */
.wa-field .wa-invalid,
.wa-field .wa-invalid:focus {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.10);
}
@keyframes ncFieldShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* --- Responsive -------------------------------------------- */
@media (max-width: 960px) {
  .wa-form-split { grid-template-columns: 1fr; gap: 2.2rem; }
}
@media (max-width: 560px) {
  .wa-form-row { grid-template-columns: 1fr; }
  .wa-form { padding: 1.4rem 1.25rem 1.25rem; }
}

/* ============================================================
   Popup modal (opened by the WhatsApp float button)
   ============================================================ */
.wa-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.wa-modal.is-open { display: flex; }
.wa-modal-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(130% 130% at 50% 40%, rgba(12, 6, 4, 0.72), rgba(5, 3, 2, 0.88));
  backdrop-filter: blur(3px);
}
.wa-modal-card {
  position: relative;
  width: 100%;
  max-width: 1080px;
  max-height: min(88vh, 700px);
  overflow: visible;
  background: #fff;
  border-radius: 20px;
  display: grid;
  grid-template-columns: 0.34fr 0.66fr;
  align-items: stretch;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.28);
  -webkit-animation: waModalIn 0.22s ease-out;
  animation: waModalIn 0.22s ease-out;
}
@-webkit-keyframes waModalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes waModalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.wa-modal-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.18);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 1.05rem;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: background 0.15s ease, transform 0.15s ease;
}
.wa-modal-close:hover { background: rgba(0, 0, 0, 0.32); transform: scale(1.05); }
.wa-modal-head {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: flex-start;
  margin: 0;
  padding: 2rem 1.85rem;
  background: linear-gradient(180deg, #e9f9f0 0%, #d6f1e1 100%);
  color: #0d3322;
  overflow: hidden;
  min-height: 0;
}
.wa-modal .wa-form-perks { list-style: none; margin: 0.45rem 0 0; padding: 0; }
.wa-modal .wa-form-perks li { display: flex; align-items: flex-start; gap: 0.55rem; color: #1a523a; font-size: 13px; line-height: 1.45; margin-bottom: 0.45rem; }
.wa-modal .wa-form-perks i { color: #25d366; font-size: 1rem; margin-top: 0.12rem; }
.wa-modal-ico {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: #ffffff;
  color: #25d366;
  font-size: 1.35rem;
}
.wa-modal-head h2 { font-size: 22px; margin: 0 0 0.4rem; color: #0d3322; line-height: 1.25; }
.wa-modal-head p { margin: 0; font-size: 14px; line-height: 1.6; color: #2c6e4f; }
/* The form sits in the right panel → drop its own frame, keep its padding */
.wa-modal .wa-form {
  border: none;
  box-shadow: none;
  padding: 1.35rem 1.65rem 1.15rem;
  background: transparent;
  overflow: visible;
  max-height: none;
  min-height: 0;
}
.wa-modal .wa-form-row {
  margin-bottom: 0.65rem;
  gap: 0.85rem;
}
.wa-modal .wa-field { gap: 0.35rem; }
.wa-modal .wa-field input,
.wa-modal .wa-field select,
.wa-modal .wa-field textarea {
  padding-top: 0.72rem;
  padding-bottom: 0.72rem;
}
.wa-modal .wa-field textarea {
  min-height: 52px;
  max-height: 68px;
  resize: none;
  line-height: 1.45;
}
.wa-modal .wa-form-legal { margin-top: 0.55rem; font-size: 11.5px; }
.wa-modal .wa-form-btn { padding-top: 0.75rem; padding-bottom: 0.75rem; }

/* WhatsApp-green accents for the popup */
.wa-modal .wa-form-btn { background: #25d366; border-color: #25d366; }
.wa-modal .wa-form-btn:hover { background: #1ebe5d; border-color: #1ebe5d; }
.wa-form-row:has(.wa-field:only-child) { grid-template-columns: 1fr; }

/* Submit area (sticky on mobile) */
.wa-form-submit-wrap { margin-top: 0.4rem; }

/* Landscape modal → stack to one column on small screens */
@media (max-width: 720px) {
  .wa-modal { align-items: flex-start; overflow: hidden; padding: 1rem; }
  .wa-modal-card { grid-template-columns: 1fr; max-height: none; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
  .wa-modal-head { padding: 1.25rem 1.25rem 0.85rem; }
  .wa-modal-head h2 { font-size: 20px; }
  /* Perks stay on tablet; hidden on phone (see 640px block) */
  .wa-modal .wa-form { max-height: none; padding: 1.5rem 1.25rem 1.25rem; overflow: visible; }
  .wa-modal .wa-field textarea { max-height: none; resize: vertical; }
}

/* Mobile ≤640px → bottom sheet sliding up + sticky submit */
@keyframes waSheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@media (max-width: 640px) {
  .wa-modal { align-items: flex-end; padding: 0; overflow: hidden; }
  .wa-modal-card {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    max-height: min(92dvh, calc(100dvh - env(safe-area-inset-bottom, 0px)));
    border-radius: 22px 22px 0 0;
    grid-template-columns: 1fr;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    -webkit-animation: waSheetUp .28s cubic-bezier(.32, 1, .23, 1);
    animation: waSheetUp .28s cubic-bezier(.32, 1, .23, 1);
  }
  .wa-modal-head {
    flex-shrink: 0;
    padding: 1.15rem 1.25rem 0.65rem;
    padding-top: calc(1.15rem + env(safe-area-inset-top, 0px));
  }
  .wa-modal-head p { font-size: 13px; line-height: 1.5; }
  .wa-modal-ico { width: 40px; height: 40px; font-size: 1.15rem; }
  .wa-modal .wa-form-perks { display: none; }
  .wa-modal .wa-form {
    flex: 1 1 auto;
    min-height: 0;
    overflow: visible;
    padding: 0.85rem 1.25rem 0;
  }
  .wa-form-submit-wrap {
    position: sticky;
    bottom: 0;
    z-index: 3;
    margin: 6px 0 0;
    padding: 12px 0 calc(14px + env(safe-area-inset-bottom, 12px));
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #fff 28%);
  }
}
