/* ==============================================================================
   KERSANTARA FABRIC — FLOATING WHATSAPP POPUP FORM
   Aesthetic: Neo-Brutalism with Heritage Warmth (DESIGN.md SSOT)
   ============================================================================== */

:root {
  --kf-navy: #1c4b62;
  --kf-navy-deep: #14384c;
  --kf-gold: #e8a519;
  --kf-gold-hover: #f3b12b;
  --kf-red: #cd3318;
  --kf-paper: #fff8eb;
  --kf-white: #ffffff;
  --kf-sand: #aea594;
  --kf-clay: #5a6e78;
  --kf-overlay: rgba(28, 75, 98, 0.48);
}

/* 1. Backdrop Overlay with Background Blur */
.kf-wa-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--kf-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2147483645;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s;
}

.kf-wa-backdrop.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* 2. Modal Dialog Container */
.kf-wa-dialog {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: var(--kf-white);
  border: 2.5px solid var(--kf-navy);
  border-radius: 12px;
  box-shadow: 8px 8px 0px var(--kf-navy);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.96);
  opacity: 0;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.28s ease;
  font-family: 'Jost', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--kf-navy);
  box-sizing: border-box;
}

.kf-wa-backdrop.is-active .kf-wa-dialog {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* 3. Modal Header */
.kf-wa-header {
  background: var(--kf-paper);
  border-bottom: 2px solid var(--kf-navy);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.kf-wa-header-icon {
  width: 42px;
  height: 42px;
  background: #25d366;
  border: 2px solid var(--kf-navy);
  border-radius: 10px;
  box-shadow: 2px 2px 0px var(--kf-navy);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kf-wa-header-icon svg {
  width: 24px;
  height: 24px;
  fill: #ffffff;
}

.kf-wa-header-info {
  flex: 1;
  min-width: 0;
}

.kf-wa-header-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--kf-navy);
  margin: 0;
  line-height: 1.25;
}

.kf-wa-header-subtitle {
  font-size: 11.5px;
  color: var(--kf-clay);
  margin: 3px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kf-wa-status-dot {
  width: 8px;
  height: 8px;
  background: #25d366;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.25);
  animation: kf-pulse 2s infinite ease-in-out;
}

@keyframes kf-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.kf-wa-close-btn {
  background: var(--kf-white);
  border: 2px solid var(--kf-navy);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  color: var(--kf-navy);
  cursor: pointer;
  box-shadow: 2px 2px 0px var(--kf-navy);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  padding: 0;
  margin-left: auto;
  flex-shrink: 0;
}

.kf-wa-close-btn:hover {
  background: #fee;
  transform: translate(-1.5px, -1.5px);
  box-shadow: 3px 3px 0px var(--kf-navy);
}

.kf-wa-close-btn:active {
  transform: translate(1.5px, 1.5px);
  box-shadow: 1px 1px 0px var(--kf-navy);
}

/* 4. Form Body */
.kf-wa-body {
  padding: 20px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.kf-wa-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.kf-wa-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--kf-navy);
  display: flex;
  align-items: center;
  gap: 4px;
}

.kf-wa-req {
  color: var(--kf-red);
}

.kf-wa-input {
  width: 100%;
  height: 44px;
  background: #fdfdfd;
  border: 2px solid var(--kf-navy);
  border-radius: 8px;
  padding: 0 14px;
  font-family: 'Jost', sans-serif;
  font-size: 14.5px;
  color: var(--kf-navy);
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.kf-wa-input::placeholder {
  color: #9aa8af;
  font-size: 13.5px;
}

.kf-wa-input:focus {
  outline: none;
  background: var(--kf-white);
  border-color: var(--kf-navy);
  box-shadow: 3px 3px 0px var(--kf-gold);
}

.kf-wa-input.is-invalid {
  border-color: var(--kf-red);
  background: #fff8f8;
  box-shadow: 2px 2px 0px var(--kf-red);
}

.kf-wa-error-msg {
  font-size: 11px;
  color: var(--kf-red);
  font-weight: 600;
  display: none;
  margin-top: 2px;
}

.kf-wa-field.has-error .kf-wa-error-msg {
  display: block;
}

/* 5. Submit CTA Button */
.kf-wa-submit-btn {
  width: 100%;
  height: 46px;
  margin-top: 4px;
  background: var(--kf-gold);
  color: var(--kf-navy);
  border: 2.5px solid var(--kf-navy);
  border-radius: 8px;
  font-family: 'Jost', sans-serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 4px 4px 0px var(--kf-navy);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.kf-wa-submit-btn svg {
  width: 18px;
  height: 18px;
  fill: var(--kf-navy);
  transition: transform 0.2s ease;
}

.kf-wa-submit-btn:hover {
  background: var(--kf-gold-hover);
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px var(--kf-navy);
}

.kf-wa-submit-btn:hover svg {
  transform: scale(1.1);
}

.kf-wa-submit-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0px var(--kf-navy);
}

/* 6. Footer Microcopy */
.kf-wa-footer-text {
  text-align: center;
  font-size: 11px;
  color: var(--kf-clay);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 4px;
  line-height: 1.35;
}

/* 7. Mobile & Tablet Responsiveness */
@media (max-width: 767px) {
  .kf-wa-backdrop {
    padding: 12px;
    align-items: flex-end; /* Slide up nicely from bottom on mobile */
  }

  .kf-wa-dialog {
    max-width: 100%;
    border-radius: 12px;
    box-shadow: 5px 5px 0px var(--kf-navy);
    transform: translateY(40px) scale(0.97);
  }

  .kf-wa-backdrop.is-active .kf-wa-dialog {
    transform: translateY(0) scale(1);
  }

  .kf-wa-header {
    padding: 14px 16px;
  }

  .kf-wa-header-icon {
    width: 38px;
    height: 38px;
  }

  .kf-wa-header-title {
    font-size: 15px;
  }

  .kf-wa-body {
    padding: 16px 16px 18px;
    gap: 12px;
  }

  .kf-wa-input {
    height: 44px;
    font-size: 16px; /* Prevents auto-zoom on iOS Safari */
  }

  .kf-wa-submit-btn {
    height: 46px;
    font-size: 12.5px;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .kf-wa-dialog {
    max-width: 420px;
    box-shadow: 6px 6px 0px var(--kf-navy);
  }
}

/* Prevent document scroll lock jitter */
body.kf-wa-modal-open {
  overflow: hidden !important;
  touch-action: none;
}

/* Ensure floating WhatsApp button appears immediately without needing scroll */
.sc-floating-widgets {
  transform: none !important;
  filter: none !important;
  perspective: none !important;
  contain: none !important;
  z-index: 2147483647 !important;
}

.sc-btn-whatsapp {
  position: fixed !important;
  bottom: 25px !important;
  right: 25px !important;
  z-index: 2147483647 !important;
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) scale(1) !important;
  pointer-events: auto !important;
  display: flex !important;
}

.sc-btn-whatsapp.sc-show {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) scale(1) !important;
  pointer-events: auto !important;
  display: flex !important;
}

@media (max-width: 767px) {
  .sc-btn-whatsapp {
    bottom: 16px !important;
    right: 16px !important;
    height: 44px !important;
    width: 44px !important;
  }
}

/* KECUALIKAN tampil pada page detail produk catalog & cart */
body.template-product .sc-btn-whatsapp,
body.template-product .sc-floating-widgets,
.template-product .sc-btn-whatsapp,
.template-product .sc-floating-widgets,
#product-detail-page .sc-btn-whatsapp,
#product-detail-page .sc-floating-widgets,
[data-page="product-detail"] .sc-btn-whatsapp,
[data-page="product-detail"] .sc-floating-widgets,
.page-product-detail .sc-btn-whatsapp,
.page-product-detail .sc-floating-widgets,
.product-single .sc-btn-whatsapp,
.product-single .sc-floating-widgets,
#shopify-section-template--20532470775969__main ~ .sc-floating-widgets,
#shopify-section-template--20532470775969__main ~ .sc-btn-whatsapp,
body.template-cart .sc-btn-whatsapp,
body.template-cart .sc-floating-widgets,
.template-cart .sc-btn-whatsapp,
.template-cart .sc-floating-widgets,
#cart .sc-btn-whatsapp,
#cart .sc-floating-widgets,
.cart-page .sc-btn-whatsapp,
.cart-page .sc-floating-widgets,
main#MainContent:has(#shopify-section-template--20532470874273__main) ~ .sc-floating-widgets,
#shopify-section-template--20532470874273__main ~ .sc-floating-widgets {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ==============================================================================
   HEADER QUICK-ACCESS PORTAL & ACCOUNT POPOVER
   ============================================================================== */
.nav-item-account-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.kf-account-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: -10px;
  width: 290px;
  background: #ffffff;
  border: 2px solid #1c4b62;
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(28, 75, 98, 0.16), 4px 4px 0px #1c4b62;
  padding: 16px;
  z-index: 99999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  font-family: 'Jost', -apple-system, BlinkMacSystemFont, sans-serif;
  text-align: left;
}

.nav-item-account-wrapper:hover .kf-account-popover,
.nav-item-account-wrapper:focus-within .kf-account-popover,
.kf-account-popover.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.kf-account-popover::before {
  content: '';
  position: absolute;
  top: -7px;
  right: 22px;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border-left: 2px solid #1c4b62;
  border-top: 2px solid #1c4b62;
  transform: rotate(45deg);
}

.kf-popover-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8a6d3b;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kf-popover-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  margin-bottom: 8px;
  border: 1px solid #eef2f5;
  background: #fafcfe;
  transition: all 0.18s ease;
}

.kf-popover-item:hover {
  background: #f0f7fa;
  border-color: #1c4b62;
  transform: translateX(3px);
}

.kf-popover-item.admin:hover {
  background: #fdf8ed;
  border-color: #8a6d3b;
}

.kf-popover-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  background: #e8f3f8;
  color: #1c4b62;
}

.kf-popover-item.admin .kf-popover-icon {
  background: #faeed9;
  color: #8a6d3b;
}

.kf-popover-info strong {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: #1c4b62;
  line-height: 1.25;
}

.kf-popover-item.admin strong {
  color: #8a6d3b;
}

.kf-popover-info span {
  display: block;
  font-size: 11px;
  color: #6a7c85;
  margin-top: 2px;
}

.kf-popover-divider {
  height: 1px;
  background: #eef2f5;
  margin: 12px 0;
}

.kf-popover-footer-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.kf-popover-btn {
  display: block;
  text-align: center;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
}

.kf-popover-btn.login {
  background: #1c4b62;
  color: #ffffff;
}

.kf-popover-btn.login:hover {
  background: #14384c;
}

.kf-popover-btn.hub {
  background: #f4eee5;
  color: #8a6d3b;
  border: 1px solid #d9ccbe;
}

.kf-popover-btn.hub:hover {
  background: #ede3d5;
}


