/**
 * Nút Gọi Mobile - Frontend Styles
 * @author vithanhlam
 */

:root {
  --ngm-primary-color: #e74c3c;
  --ngm-messenger-color: #0084ff;
  --ngm-zalo-color: #0068ff;
  --ngm-contact-color: #27ae60;
}

/* =====================================================
   Animations
   ===================================================== */
@keyframes ngm-pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
  }
  50% {
    transform: scale(1.08);
    box-shadow:
      0 6px 25px rgba(0, 0, 0, 0.3),
      0 0 0 8px rgba(231, 76, 60, 0.2);
  }
}

@keyframes ngm-ripple-wave {
  0% {
    box-shadow:
      0 0 0 0 rgba(231, 76, 60, 0.5),
      0 0 0 0 rgba(231, 76, 60, 0.3);
  }
  50% {
    box-shadow:
      0 0 0 12px rgba(231, 76, 60, 0),
      0 0 0 24px rgba(231, 76, 60, 0);
  }
  100% {
    box-shadow:
      0 0 0 0 rgba(231, 76, 60, 0),
      0 0 0 0 rgba(231, 76, 60, 0);
  }
}

@keyframes ngm-heartbeat {
  0%,
  100% {
    transform: scale(1);
  }
  14% {
    transform: scale(1.12);
  }
  28% {
    transform: scale(1);
  }
  42% {
    transform: scale(1.12);
  }
  70% {
    transform: scale(1);
  }
}

@keyframes ngm-glow {
  0%,
  100% {
    box-shadow:
      0 4px 15px rgba(0, 0, 0, 0.2),
      0 0 15px rgba(231, 76, 60, 0.4);
  }
  50% {
    box-shadow:
      0 4px 20px rgba(0, 0, 0, 0.3),
      0 0 35px rgba(231, 76, 60, 0.6);
  }
}

@keyframes ngm-bounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-12px);
  }
  60% {
    transform: translateY(-6px);
  }
}

@keyframes ngm-fade-in-right {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* =====================================================
   Main Wrapper
   ===================================================== */
.ngm-wrapper {
  position: fixed;
  z-index: 999999;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.ngm-position-right-center {
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}
.ngm-position-right-bottom {
  right: 0;
  bottom: 100px;
}
.ngm-position-left-center {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}
.ngm-position-left-bottom {
  left: 0;
  bottom: 100px;
}

/* =====================================================
   Desktop Side Buttons
   ===================================================== */
.ngm-side-buttons {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.ngm-button-wrap {
  animation: ngm-fade-in-right 0.4s ease backwards;
}
.ngm-button-wrap:nth-child(1) {
  animation-delay: 0.1s;
}
.ngm-button-wrap:nth-child(2) {
  animation-delay: 0.15s;
}
.ngm-button-wrap:nth-child(3) {
  animation-delay: 0.2s;
}
.ngm-button-wrap:nth-child(4) {
  animation-delay: 0.25s;
}

.ngm-side-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
  transition: all 0.25s ease;
  white-space: nowrap;
}

.ngm-position-right-center .ngm-side-btn,
.ngm-position-right-bottom .ngm-side-btn {
  border-radius: 25px 0 0 25px;
  padding-right: 16px;
}

.ngm-position-left-center .ngm-side-btn,
.ngm-position-left-bottom .ngm-side-btn {
  border-radius: 0 25px 25px 0;
  padding-left: 16px;
  flex-direction: row-reverse;
}

.ngm-side-btn:hover {
  transform: translateX(-6px);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.ngm-position-left-center .ngm-side-btn:hover,
.ngm-position-left-bottom .ngm-side-btn:hover {
  transform: translateX(6px);
}

.ngm-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.ngm-btn-icon svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.ngm-btn-label {
  font-size: 12px;
  font-weight: 600;
}

/* Button Colors */
.ngm-btn-phone {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
}
.ngm-btn-messenger {
  background: linear-gradient(135deg, #00c6ff, #0072ff);
}
.ngm-btn-zalo {
  background: linear-gradient(135deg, #0084ff, #0052cc);
}
.ngm-btn-contact {
  background: linear-gradient(135deg, #11998e, #38ef7d);
}

/* Animations */
.ngm-pulse-enabled .ngm-side-btn {
  animation: ngm-pulse 2.5s ease-in-out infinite;
}
.ngm-side-btn.ngm-anim-ripple {
  animation: ngm-ripple-wave 2s ease-out infinite;
}
.ngm-side-btn.ngm-anim-heartbeat {
  animation: ngm-heartbeat 1.5s ease infinite;
}
.ngm-side-btn.ngm-anim-glow {
  animation: ngm-glow 2s ease infinite;
}
.ngm-side-btn.ngm-anim-bounce {
  animation: ngm-bounce 2s ease infinite;
}

/* Tooltip */
.ngm-tooltip {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) scale(0.9);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  pointer-events: none;
}

.ngm-tooltip::after {
  content: "";
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-left-color: rgba(0, 0, 0, 0.85);
}

.ngm-tooltip-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) scale(1);
}

/* Size */
.ngm-size-small .ngm-side-btn {
  padding: 8px 10px;
}
.ngm-size-small .ngm-btn-icon {
  width: 20px;
  height: 20px;
}
.ngm-size-small .ngm-btn-icon svg {
  width: 16px;
  height: 16px;
}

.ngm-size-large .ngm-side-btn {
  padding: 14px 18px;
}
.ngm-size-large .ngm-btn-icon {
  width: 30px;
  height: 30px;
}
.ngm-size-large .ngm-btn-icon svg {
  width: 24px;
  height: 24px;
}

/* =====================================================
   Mobile Bottom Bar
   ===================================================== */
.ngm-mobile-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 999999;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.08);
  padding: 6px 8px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  transform: translateY(0);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.ngm-mobile-bar.ngm-bar-hidden {
  transform: translateY(100%);
}

.ngm-mobile-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 2px;
  text-decoration: none;
  color: inherit;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: transform 0.2s ease;
  max-width: 70px;
}

.ngm-mobile-btn:active {
  transform: scale(0.9);
}

.ngm-mobile-btn .ngm-btn-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin-bottom: 3px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.ngm-mobile-btn .ngm-btn-icon svg {
  width: 20px;
  height: 20px;
}

.ngm-mobile-btn .ngm-btn-label {
  font-size: 9px;
  font-weight: 600;
  color: #333;
  text-align: center;
}

/* Mobile Button Colors */
.ngm-mobile-btn.ngm-btn-phone .ngm-btn-icon {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
}
.ngm-mobile-btn.ngm-btn-messenger .ngm-btn-icon {
  background: linear-gradient(135deg, #00c6ff, #0072ff);
}
.ngm-mobile-btn.ngm-btn-zalo .ngm-btn-icon {
  background: linear-gradient(135deg, #0084ff, #0052cc);
}
.ngm-mobile-btn.ngm-btn-contact .ngm-btn-icon {
  background: linear-gradient(135deg, #11998e, #38ef7d);
}

/* =====================================================
   Popups (Phone & Zalo)
   ===================================================== */
.ngm-popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.ngm-popup.ngm-popup-active {
  opacity: 1;
  visibility: visible;
}

.ngm-popup-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.ngm-popup-content {
  position: relative;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 340px;
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ngm-popup.ngm-popup-active .ngm-popup-content {
  transform: scale(1) translateY(0);
}

/* Popup Header */
.ngm-popup-header {
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ngm-popup-header-phone {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.ngm-popup-header-zalo {
  background: linear-gradient(135deg, #0084ff, #0052cc);
}

.ngm-popup-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.ngm-popup-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  line-height: 1;
  margin: 0px;
}

.ngm-popup-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

/* Popup Body */
.ngm-popup-body {
  padding: 12px;
  max-height: 50vh;
  overflow-y: auto;
}

/* Popup Items */
.ngm-popup-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  text-decoration: none;
  color: #333;
  margin-bottom: 8px;
  border: 1px solid #eee;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s ease;
}

.ngm-popup-item.ngm-item-visible {
  opacity: 1;
  transform: translateY(0);
}

.ngm-popup-item:last-child {
  margin-bottom: 0;
}

.ngm-popup-item:active {
  transform: scale(0.98);
}

/* Phone item hover */
.ngm-popup-item-phone:hover {
  background: #fff5f5;
  border-color: #e74c3c;
}

/* Zalo item hover */
.ngm-popup-item-zalo:hover {
  background: #f0f7ff;
  border-color: #0084ff;
}

/* Item Icon */
.ngm-popup-item-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.ngm-icon-phone {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.ngm-icon-zalo {
  background: linear-gradient(135deg, #0084ff, #0052cc);
  box-shadow: 0 4px 12px rgba(0, 132, 255, 0.3);
}

.ngm-popup-item-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Item Info */
.ngm-popup-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ngm-popup-item-label {
  font-size: 11px;
  color: #888;
  font-weight: 500;
}

.ngm-popup-item-number {
  font-size: 17px;
  font-weight: 700;
  color: #222;
}

/* =====================================================
   Responsive
   ===================================================== */
@media (max-width: 768px) {
  .ngm-side-buttons {
    display: none !important;
  }
}

@media (min-width: 769px) {
  .ngm-mobile-bar {
    display: none !important;
  }
  .ngm-side-buttons {
    display: flex;
  }
}

/* =====================================================
   Utils
   ===================================================== */
body.ngm-popup-open {
  overflow: hidden;
}

@media print {
  .ngm-wrapper,
  .ngm-popup {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
  .ngm-mobile-bar {
    background: rgba(30, 30, 30, 0.92);
  }
  .ngm-mobile-btn .ngm-btn-label {
    color: #eee;
  }
  .ngm-popup-content {
    background: #1e1e1e;
  }
  .ngm-popup-item {
    color: #eee;
    border-color: #333;
  }
  .ngm-popup-item-phone:hover {
    background: #2a1a1a;
  }
  .ngm-popup-item-zalo:hover {
    background: #1a2233;
  }
  .ngm-popup-item-label {
    color: #999;
  }
  .ngm-popup-item-number {
    color: #fff;
  }
}
