/* =========================================================
 * THANH CTA TOÀN TRANG – Thẩm mỹ Linh Anh (prefix: lacta-)
 * Desktop (≥ 769px): dock dọc kính tím nổi bên phải, căn giữa màn hình;
 *   rê chuột → nút sáng + bật nhãn phụ bên trái (số hotline, "Tư vấn miễn phí"…).
 * Mobile (≤ 768px): thanh nổi đáy màn hình (chừa vùng vuốt iPhone),
 *   nút "Ưu đãi" nhô lên khỏi thanh, gradient chạy + vòng sóng lan.
 *
 * ⚙️ BIẾN TINH CHỈNH (đặt trên .lacta):
 *   --lacta-bg          : nền thanh / dock
 *   --lacta-offer       : gradient nút Ưu đãi
 *   --lacta-right       : khoảng cách dock tới mép phải (desktop)
 *   --lacta-bottom      : khoảng cách thanh tới đáy màn hình (mobile)
 *   --lacta-z           : lớp hiển thị (thấp hơn popup Flatsome 1042)
 * ========================================================= */
.lacta {
  --lacta-bg: linear-gradient(180deg, rgba(126, 27, 196, 0.94) 0%, rgba(69, 17, 128, 0.96) 100%);
  --lacta-offer: linear-gradient(135deg, #f5935c 0%, #e0668a 35%, #a45cf2 70%, #f5935c 100%);
  --lacta-right: 18px;
  --lacta-bottom: 10px;
  --lacta-z: 999;

  position: fixed;
  top: 50%;
  right: var(--lacta-right);
  z-index: var(--lacta-z);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: var(--lacta-bg);
  box-shadow: 0 22px 44px -14px rgba(69, 17, 128, 0.7), 0 0 0 6px rgba(255, 255, 255, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font-family: "Geomanist", "Roboto", sans-serif;
  transform: translateY(-50%);
  animation: lacta-in-right 0.8s cubic-bezier(0.22, 0.61, 0.36, 1) 0.4s both;
  -webkit-tap-highlight-color: transparent;
}

.lacta *,
.lacta *::before,
.lacta *::after {
  box-sizing: border-box;
}

/* ----- Nút ----- */
.lacta .lacta__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 72px;
  margin: 0;
  padding: 8px 4px 7px;
  border-radius: 22px;
  color: #fff;
  text-decoration: none;
  transition: background-color 0.3s ease, translate 0.3s ease;
}

.lacta .lacta__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  transition: scale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.3s ease;
}

.lacta .lacta__icon svg {
  display: block;
}

.lacta .lacta__label {
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* Hotline: icon rung chuông định kỳ */
.lacta .lacta__item--phone .lacta__icon svg {
  animation: lacta-ring 3.6s ease-in-out infinite;
  transform-origin: 50% 50%;
}

/* Zalo: icon nền trắng cho logo xanh nổi */
.lacta .lacta__item--zalo .lacta__icon {
  border-color: rgba(255, 255, 255, 0.85);
  background: #fff;
}

/* ----- Nút ƯU ĐÃI nổi bật ----- */
.lacta .lacta__item--offer {
  width: 82px;
  margin: 6px 0;
  padding: 12px 4px 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  border-radius: 24px;
  background: var(--lacta-offer);
  background-size: 220% 220%;
  box-shadow: 0 12px 26px -8px rgba(224, 102, 138, 0.85), 0 0 22px rgba(245, 147, 92, 0.45);
  overflow: hidden;
  isolation: isolate;
  animation: lacta-gradient 4s ease infinite;
}

/* vệt sáng quét */
.lacta .lacta__item--offer::before {
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1;
  width: 45%;
  height: 100%;
  content: "";
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.55) 50%, rgba(255, 255, 255, 0) 100%);
  transform: translateX(-160%) skewX(-20deg);
  animation: lacta-shine 3s ease-in-out infinite;
  pointer-events: none;
}

.lacta .lacta__item--offer .lacta__icon {
  width: 48px;
  height: 48px;
  border-color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.22);
}

.lacta .lacta__item--offer .lacta__icon svg {
  animation: lacta-wiggle 2.8s ease-in-out infinite;
}

.lacta .lacta__item--offer .lacta__label {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(69, 17, 128, 0.45);
}

/* Nhãn -50% */
.lacta .lacta__badge {
  position: absolute;
  top: 5px;
  right: 4px;
  padding: 2px 6px 1px;
  border: 1px solid #fff;
  border-radius: 999px;
  background: #ff2d55;
  box-shadow: 0 3px 8px rgba(255, 45, 85, 0.5);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.2;
  animation: lacta-badge 1.6s ease-in-out infinite;
}

/* ----- Nhãn phụ (tooltip) bên trái – desktop ----- */
.lacta .lacta__tip {
  position: absolute;
  top: 50%;
  right: calc(100% + 16px);
  padding: 9px 16px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 10px 24px -8px rgba(69, 17, 128, 0.45);
  color: #710dac;
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translate(10px, -50%);
  transition: opacity 0.25s ease, transform 0.3s ease, visibility 0s linear 0.3s;
  pointer-events: none;
}

.lacta .lacta__tip::after {
  position: absolute;
  top: 50%;
  right: -5px;
  width: 10px;
  height: 10px;
  content: "";
  background: #fff;
  transform: translateY(-50%) rotate(45deg);
}

.lacta .lacta__item--phone .lacta__tip {
  font-weight: 700;
  letter-spacing: 0.03em;
}

@media (hover: hover) and (pointer: fine) {
  .lacta .lacta__item:not(.lacta__item--offer):hover {
    background: rgba(255, 255, 255, 0.14);
  }

  .lacta .lacta__item:hover .lacta__icon {
    scale: 1.14;
  }

  .lacta .lacta__item--offer:hover {
    translate: -4px 0;
  }

  .lacta .lacta__item:hover .lacta__tip {
    opacity: 1;
    visibility: visible;
    transform: translate(0, -50%);
    transition: opacity 0.25s ease, transform 0.3s ease, visibility 0s;
  }
}

.lacta .lacta__item:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* =========================================================
 * MOBILE: thanh nổi đáy màn hình, nút Ưu đãi nhô lên
 * ========================================================= */
@media (max-width: 768px) {
  .lacta {
    top: auto;
    right: 10px;
    bottom: calc(var(--lacta-bottom) + env(safe-area-inset-bottom, 0px));
    left: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr 1.25fr 1fr;
    align-items: end;
    gap: 0;
    height: 66px;
    padding: 0 6px 7px;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(126, 27, 196, 0.96) 0%, rgba(69, 17, 128, 0.98) 100%);
    box-shadow: 0 14px 30px -10px rgba(69, 17, 128, 0.75), 0 0 0 4px rgba(255, 255, 255, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.35);
    transform: none;
    animation: lacta-in-up 0.7s cubic-bezier(0.22, 0.61, 0.36, 1) 0.3s both;
    /* Ẩn / hiện khi cuộn dùng `transform` (animation vào dùng `translate`, 2 thuộc tính
     * độc lập → không đè nhau). JS gắn .is-hidden khi cuộn xuống, gỡ khi cuộn lên. */
    transition: transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1), visibility 0s;
  }

  /* Cuộn xuống: thanh trượt xuống dưới khung màn hình (cộng thêm phần nút Ưu đãi
   * nhô lên + nhãn -50% + viền an toàn iPhone để ẩn hẳn) */
  .lacta.is-hidden {
    visibility: hidden;
    transform: translateY(calc(100% + var(--lacta-bottom) + 90px + env(safe-area-inset-bottom, 0px)));
    transition: transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1), visibility 0s linear 0.45s;
    pointer-events: none;
  }

  .lacta .lacta__item {
    width: auto;
    padding: 0;
    gap: 3px;
    border-radius: 16px;
  }

  .lacta .lacta__icon {
    width: 36px;
    height: 36px;
    border: 0;
    background: rgba(255, 255, 255, 0.12);
  }

  .lacta .lacta__icon svg {
    width: 20px;
    height: 20px;
  }

  .lacta .lacta__item--zalo .lacta__icon svg {
    width: 24px;
    height: 24px;
  }

  .lacta .lacta__label {
    font-size: 11.5px;
  }

  .lacta .lacta__item:active .lacta__icon {
    scale: 0.9;
  }

  /* Ưu đãi: vòng tròn gradient nhô lên trên thanh */
  .lacta .lacta__item--offer {
    width: auto;
    margin: 0;
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    animation: none;
  }

  .lacta .lacta__item--offer::before {
    display: none;
  }

  .lacta .lacta__item--offer .lacta__icon {
    position: relative;
    width: 62px;
    height: 62px;
    margin-top: -30px;
    overflow: hidden;
    border: 3px solid #fff;
    background: var(--lacta-offer);
    background-size: 220% 220%;
    box-shadow: 0 10px 22px -6px rgba(224, 102, 138, 0.9), 0 0 0 5px rgba(255, 255, 255, 0.25);
    animation: lacta-gradient 4s ease infinite, lacta-pulse 2s ease-out infinite;
  }

  /* vệt sáng quét trong vòng tròn */
  .lacta .lacta__item--offer .lacta__icon::after {
    position: absolute;
    top: 0;
    left: 0;
    width: 45%;
    height: 100%;
    content: "";
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.6) 50%, rgba(255, 255, 255, 0) 100%);
    transform: translateX(-160%) skewX(-20deg);
    animation: lacta-shine 3s ease-in-out infinite;
  }

  .lacta .lacta__item--offer .lacta__icon svg {
    position: relative;
    z-index: 1;
    width: 28px;
    height: 28px;
  }

  .lacta .lacta__item--offer .lacta__label {
    font-size: 12px;
    color: #ffd27a;
  }

  .lacta .lacta__badge {
    top: -34px;
    right: calc(50% - 44px);
    z-index: 2;
    font-size: 10px;
  }

  .lacta .lacta__tip {
    display: none;
  }

  /* Chừa chỗ cuối trang để thanh không che nội dung / footer */
  body {
    padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  }
}

/* ----- Hiệu ứng ----- */
@keyframes lacta-in-right {
  from {
    opacity: 0;
    translate: 120% 0;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

@keyframes lacta-in-up {
  from {
    opacity: 0;
    translate: 0 120%;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

@keyframes lacta-gradient {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@keyframes lacta-shine {
  0% {
    transform: translateX(-160%) skewX(-20deg);
  }
  55%,
  100% {
    transform: translateX(360%) skewX(-20deg);
  }
}

@keyframes lacta-ring {
  0%,
  60%,
  100% {
    rotate: 0deg;
  }
  64%,
  72%,
  80% {
    rotate: -16deg;
  }
  68%,
  76%,
  84% {
    rotate: 16deg;
  }
}

@keyframes lacta-wiggle {
  0%,
  70%,
  100% {
    rotate: 0deg;
    scale: 1;
  }
  76% {
    rotate: -12deg;
    scale: 1.12;
  }
  84% {
    rotate: 10deg;
    scale: 1.12;
  }
  92% {
    rotate: -4deg;
    scale: 1;
  }
}

@keyframes lacta-badge {
  0%,
  100% {
    scale: 1;
  }
  50% {
    scale: 1.12;
  }
}

@keyframes lacta-pulse {
  0% {
    box-shadow: 0 10px 22px -6px rgba(224, 102, 138, 0.9), 0 0 0 0 rgba(245, 147, 92, 0.6);
  }
  70% {
    box-shadow: 0 10px 22px -6px rgba(224, 102, 138, 0.9), 0 0 0 14px rgba(245, 147, 92, 0);
  }
  100% {
    box-shadow: 0 10px 22px -6px rgba(224, 102, 138, 0.9), 0 0 0 0 rgba(245, 147, 92, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lacta,
  .lacta * {
    animation: none !important;
    transition: none !important;
  }
}

@media print {
  .lacta {
    display: none !important;
  }
}