/* ==========================================================================
   Popup: Consultation Form from Ecosystem (Accurate to Mockup 2 Refinements)
   ========================================================================== */

/* Lock body scrolling when popup is open */
body.m-english-popup-locked {
  overflow: hidden;
}

/* Keep the page width stable when the vertical scrollbar is removed. */
html {
  scrollbar-gutter: stable;
}

/* Popup Overlay */
.m-english-popup {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0s linear 300ms;
}

.m-english-popup.is-open {
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

/* Backdrop */
.m-english-popup__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 14, 10, 0.62);
  opacity: 0;
  cursor: pointer;
  transition: opacity 240ms ease;
  will-change: opacity;
}

.m-english-popup.is-open .m-english-popup__backdrop {
  opacity: 1;
}

/* Popup Outer Box: Đồng bộ thời gian 280ms với khung ngoài, tăng tốc GPU mượt mà */
.m-english-popup__box {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 630px;
  border-radius: 12px;
  overflow: hidden; /* Bo tất cả các góc kể cả hình minh họa góc trên */
  isolation: isolate;
  background: linear-gradient(150deg, #fff9f6 0%, #ffefe8 45%, #fff0f3 100%);
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow:
    0 20px 50px -10px rgba(244, 118, 43, 0.22),
    0 10px 25px -6px rgba(30, 20, 10, 0.12);
  transform: translate3d(0, 14px, 0) scale(0.97);
  opacity: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-origin: 50% 50%;
  will-change: transform, opacity;
  transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1), opacity 220ms ease;
}

.m-english-popup.is-open .m-english-popup__box {
  transform: translate3d(0, 0, 0) scale(1);
  opacity: 1;
}

/* Release the large compositor layer after the transition has finished. */
.m-english-popup:not(.is-animating) .m-english-popup__box,
.m-english-popup:not(.is-animating) .m-english-popup__backdrop {
  will-change: auto;
}

/* Vô hiệu hóa animation rời rạc của các phần tử con bên trong popup để tránh giật kép */
.m-english-popup [data-motion] {
  animation: none !important;
  transition: none !important;
  transform: none !important;
  opacity: 1 !important;
}

/* Close Button (Top-Right) */
.m-english-popup__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  background: #ffffff;
  color: #555555;
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: all 200ms ease;
}

.m-english-popup__close:hover,
.m-english-popup__close:focus-visible {
  background: #f4762b;
  color: #ffffff;
  border-color: #f4762b;
  transform: rotate(90deg) scale(1.06);
}

/* Mascot 1: Top-Left Monkey (Hiển thị sát góc, tay dưới chạm nhẹ viền trên card) */
.m-english-popup__img-top {
  position: absolute;
  top: 0;
  left: 0;
  width: 132px;
  height: auto;
  z-index: 15;
  pointer-events: none;
  border-top-left-radius: 12px;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.06));
}

/* Mascot 2: Bottom-Right Child (Nhỏ gọn hơn, nằm phía trên nút submit ở cạnh phải) */
.m-english-popup__img-bottom {
  position: absolute;
  right: 22px;
  bottom: 74px; /* Đặt phía trên nút submit */
  width: 62px; /* Nhỏ hơn theo yêu cầu */
  height: auto;
  z-index: 15;
  pointer-events: none;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.08));
}

/* Consultation Form Section inside Popup */
.m-english-popup .consultation-form {
  position: relative;
  width: 100%;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 20px 20px 16px !important;
  overflow: visible !important;
}

.m-english-popup .consultation-form::before,
.m-english-popup .consultation-form::after,
.m-english-popup .consultation-form__shape {
  display: none !important;
}

/* Heading: Compact, Centered, with side padding to prevent mascot clash */
.m-english-popup .consultation-form__heading {
  margin-bottom: 12px;
  text-align: center;
  padding: 0 45px 0 118px; /* Chừa không gian thoáng cho khỉ góc trái và nút đóng góc phải */
}

.m-english-popup .consultation-form__heading p {
  margin: 0 0 2px;
  font-size: 16px;
  line-height: 1.3;
}

.m-english-popup .consultation-form__heading strong {
  color: #f4762b;
  font-weight: 700;
}

.m-english-popup .consultation-form__heading h2 {
  margin: 0;
  font-size: clamp(17px, 2vw, 21px);
  font-weight: 850;
  line-height: 1.25;
  text-transform: uppercase;
  color: #2c2c2c;
  letter-spacing: -0.01em;
}

/* Inner Form Panel: Khung trắng bo góc nhỏ hơn (12px) */
.m-english-popup .consultation-form__body {
  position: relative;
  background: #ffffff !important;
  border-radius: 12px;
  padding: 16px 20px 18px !important;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.04);
}

.m-english-popup .consultation-form__panel {
  width: 100%;
  max-width: 100%;
}

/* Compact Form Fields */
.m-english-popup .ff-el-group {
  margin-bottom: 10px;
}

.m-english-popup .ff-el-input--label label,
.m-english-popup .m-english-field-label {
  display: block;
  margin-bottom: 4px;
  font-size: 14.5px;
  font-weight: 700 !important;
  color: #444;
}

/* Product Pills */
.m-english-popup .m-english-product-grid,
.m-english-popup .consultation-form .choices[data-type="select-multiple"] > .choices__list--dropdown > .choices__list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 10px;
  margin-bottom: 10px;
}

.m-english-popup .m-english-product-option,
.m-english-popup .consultation-form .choices__item--choice {
  min-height: 42px;
  padding: 6px 46px 6px 12px !important;
  font-size: 15px !important;
  font-weight: 700;
  border-radius: 6px;
}

.m-english-popup .m-english-product-option i,
.m-english-popup .consultation-form .choices__item--choice::after {
  width: 26px;
  height: 26px;
  right: 10px;
  border-radius: 8px;
}

/* Inputs */
.m-english-popup :is(input, select, textarea).ff-el-form-control {
  min-height: 40px !important;
  height: 40px !important;
  padding: 6px 12px !important;
  font-size: 14px !important;
  border-radius: 6px !important;
  border: 1px solid #ddd7d2 !important;
  box-shadow: 0 1px 4px rgba(60, 45, 35, 0.05) !important;
}

.m-english-popup :is(input, select, textarea).ff-el-form-control:focus {
  border-color: #f4762b !important;
  box-shadow: 0 0 0 2.5px rgba(244, 118, 43, 0.16) !important;
}

/* Submit Button: Khoảng cách rộng rãi hơn với ô input bên trên (margin-top: 36px) */
.m-english-popup .ff_submit_btn_wrapper {
  display: flex !important;
  justify-content: flex-end !important;
  margin-top: 36px !important; /* Tạo khoảng cách rõ ràng, thoáng hơn với ô input bên trên */
  margin-bottom: 0 !important;
  position: relative;
  z-index: 25;
}

.m-english-popup .ff-btn-submit {
  min-height: 44px !important;
  padding: 10px 26px !important;
  font-size: 14px !important;
  font-weight: 750 !important;
  border-radius: 6px !important;
  background: #e46626 !important;
  box-shadow: 0 3px 12px rgba(228, 102, 38, 0.32) !important;
  transition: all 200ms ease !important;
}

.m-english-popup .ff-btn-submit:hover,
.m-english-popup .ff-btn-submit:focus-visible {
  background: #cc5418 !important;
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(228, 102, 38, 0.42) !important;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-height: 680px) {
  .m-english-popup .consultation-form {
    max-height: 90vh;
    overflow-y: auto !important;
  }
}

@media (max-width: 680px) {
  .m-english-popup {
    padding: 16px 12px;
  }

  .m-english-popup__box {
    width: 100%;
    max-width: min(92vw, 380px);
    max-height: 88vh;
    border-radius: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .m-english-popup__close {
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    font-size: 18px;
  }

  .m-english-popup .consultation-form {
    padding: 14px 10px 10px !important;
  }

  .m-english-popup .consultation-form__heading {
    padding: 0 30px 0 65px;
    margin-bottom: 8px;
  }

  .m-english-popup .consultation-form__heading p {
    font-size: 13px;
    margin-bottom: 2px;
  }

  .m-english-popup .consultation-form__heading h2 {
    font-size: 15px;
    line-height: 1.25;
  }

  .m-english-popup .consultation-form__body {
    padding: 12px 10px 12px !important;
    border-radius: 8px;
  }

  .m-english-popup__img-top {
    width: 65px;
    border-top-left-radius: 12px;
  }

  .m-english-popup__img-bottom {
    display: none;
  }

  .m-english-popup .ff-el-group {
    margin-bottom: 7px;
  }

  .m-english-popup .ff-el-input--label label,
  .m-english-popup .m-english-field-label {
    font-size: 12.5px;
    margin-bottom: 2px;
  }

  .m-english-popup :is(input, select, textarea).ff-el-form-control {
    min-height: 35px !important;
    height: 35px !important;
    font-size: 13px !important;
    padding: 5px 10px !important;
    border-radius: 6px !important;
  }

  .m-english-popup .m-english-product-grid,
  .m-english-popup .consultation-form .choices[data-type="select-multiple"] > .choices__list--dropdown > .choices__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 8px;
  }

  .m-english-popup .m-english-product-option,
  .m-english-popup .consultation-form .choices__item--choice {
    min-height: 34px;
    font-size: 12px !important;
    padding: 4px 30px 4px 8px !important;
  }

  .m-english-popup .m-english-product-option i,
  .m-english-popup .consultation-form .choices__item--choice::after {
    width: 20px;
    height: 20px;
    right: 6px;
  }

  .m-english-popup .ff_submit_btn_wrapper {
    margin-top: 14px !important;
  }

  .m-english-popup .ff_submit_btn_wrapper,
  .m-english-popup .ff-btn-submit {
    width: 100% !important;
  }

  .m-english-popup .ff-btn-submit {
    min-height: 38px !important;
    font-size: 13.5px !important;
    padding: 8px 16px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .m-english-popup,
  .m-english-popup__box,
  .m-english-popup__close,
  .m-english-popup .ff-btn-submit {
    transition: none !important;
    transform: none !important;
  }
}
