:root {
  --tapchat-size: 56px;
  --tapchat-mobile-size: 56px;
  --tapchat-color: #25D366;
}

.tapchat-fab {
  position: fixed;
  bottom: 18px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--tapchat-color);
  color: #fff;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(0,0,0,.2);
  z-index: 99999;
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
  flex-direction: row;
}
[dir="rtl"] .tapchat-fab { flex-direction: row-reverse; }
.tapchat-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(0,0,0,.25); }
.tapchat-pos-right { right: 18px; }
.tapchat-pos-left { left: 18px; }
.tapchat-icon { width: var(--tapchat-size); height: var(--tapchat-size); display: inline-block; fill: #fff; }
.tapchat-label { white-space: nowrap; }

/* Desktop - Perfectly round button when label is hidden */
@media (min-width: 481px) {
  .tapchat-hide-label-desktop .tapchat-label { 
    display: none; 
  }
  
  .tapchat-hide-label-desktop.tapchat-fab {
    padding: 0;
    width: calc(var(--tapchat-size) + 20px);
    height: calc(var(--tapchat-size) + 20px);
    min-width: calc(var(--tapchat-size) + 20px);
    min-height: calc(var(--tapchat-size) + 20px);
    border-radius: 50%;
    justify-content: center;
    align-items: center;
    gap: 0;
  }
  
  .tapchat-hide-label-desktop.tapchat-fab .tapchat-icon {
    width: calc(var(--tapchat-size) - 8px);
    height: calc(var(--tapchat-size) - 8px);
  }
}

/* Mobile - Separate size and round button */
@media (max-width: 480px) { 
  /* Use mobile size */
  .tapchat-icon { 
    width: var(--tapchat-mobile-size); 
    height: var(--tapchat-mobile-size); 
  }
  
  .tapchat-hide-label-mobile .tapchat-label { 
    display: none; 
  }
  
  /* When label is hidden, button should be perfectly round */
  .tapchat-hide-label-mobile.tapchat-fab {
    padding: 0;
    width: calc(var(--tapchat-mobile-size) + 20px);
    height: calc(var(--tapchat-mobile-size) + 20px);
    min-width: calc(var(--tapchat-mobile-size) + 20px);
    min-height: calc(var(--tapchat-mobile-size) + 20px);
    border-radius: 50%;
    justify-content: center;
    align-items: center;
    gap: 0;
  }
  
  .tapchat-hide-label-mobile.tapchat-fab .tapchat-icon {
    width: calc(var(--tapchat-mobile-size) - 8px);
    height: calc(var(--tapchat-mobile-size) - 8px);
  }
}

.tapchat-inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; text-decoration: none; border-bottom: 2px solid currentColor; }

/* Welcome Bubble */
.tapchat-welcome-bubble {
  position: fixed;
  bottom: 105px;
  display: none;
  gap: 14px;
  padding: 20px 24px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);
  z-index: 99998;
  max-width: 380px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.tapchat-welcome-bubble.visible {
  display: flex;
  animation: tapchat-bubble-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.tapchat-welcome-bubble::after {
  content: '';
  position: absolute;
  bottom: -9px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  transform: rotate(45deg);
  border-right: 1px solid rgba(0, 0, 0, 0.05);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  z-index: -1;
}

.tapchat-pos-right ~ .tapchat-welcome-bubble::after {
  right: 35px;
}

.tapchat-pos-left ~ .tapchat-welcome-bubble::after {
  left: 35px;
}

.tapchat-pos-right ~ .tapchat-welcome-bubble {
  right: 18px;
}

.tapchat-pos-left ~ .tapchat-welcome-bubble {
  left: 18px;
}

[dir="rtl"] .tapchat-welcome-bubble {
  flex-direction: row-reverse;
}

.tapchat-bubble-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 3px 12px rgba(37, 211, 102, 0.25);
  border: 3px solid #fff;
}

.tapchat-bubble-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tapchat-bubble-avatar svg {
  width: 28px;
  height: 28px;
  fill: #fff;
}

.tapchat-bubble-content {
  flex: 1;
  min-width: 0;
}

.tapchat-bubble-name {
  font-weight: 700;
  font-size: 16px;
  color: #0a0a0a;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 7px;
  letter-spacing: -0.3px;
}

.tapchat-bubble-online {
  width: 10px;
  height: 10px;
  background: #25D366;
  border-radius: 50%;
  animation: tapchat-pulse 2.5s ease-in-out infinite;
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.2);
}

.tapchat-bubble-message {
  font-size: 15px;
  color: #5a5a5a;
  line-height: 1.6;
  word-wrap: break-word;
  font-weight: 400;
  letter-spacing: -0.1px;
}

.tapchat-bubble-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px !important;
  height: 28px !important;
  border: none !important;
  background: none !important;
  background-color: transparent !important;
  box-shadow: none !important;
  cursor: pointer;
  padding: 0 !important;
  margin: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.4;
  transition: all 0.3s ease;
  color: #666 !important;
  font-size: 20px !important;
  line-height: 1 !important;
  font-family: Arial, sans-serif !important;
  font-weight: 400 !important;
  z-index: 10;
  outline: none;
  min-width: 28px !important;
  min-height: 28px !important;
  border-radius: 50%;
}

.tapchat-bubble-close::before {
  content: "✕";
  display: inline-block;
  font-size: 20px !important;
  line-height: 1;
  transition: transform 0.3s ease;
  transform-origin: center center;
  width: 20px;
  height: 20px;
  text-align: center;
}

[dir="rtl"] .tapchat-bubble-close {
  right: auto;
  left: 10px;
}

.tapchat-bubble-close:hover {
  opacity: 1 !important;
  background: rgba(0, 0, 0, 0.05) !important;
  background-color: rgba(0, 0, 0, 0.05) !important;
  color: #333 !important;
}

.tapchat-bubble-close:hover::before {
  transform: rotate(90deg);
}

.tapchat-bubble-close:focus {
  outline: none;
  background: rgba(0, 0, 0, 0.05) !important;
}

.tapchat-bubble-close svg {
  display: none;
}

@keyframes tapchat-bubble-in {
  from {
    opacity: 0;
    transform: translateY(15px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes tapchat-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.2);
  }
  50% {
    opacity: 0.7;
    transform: scale(0.92);
    box-shadow: 0 0 0 5px rgba(37, 211, 102, 0.15);
  }
}

.tapchat-welcome-bubble:hover {
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.16), 0 8px 16px rgba(0, 0, 0, 0.08);
  transform: translateY(-3px);
  border-color: rgba(0, 0, 0, 0.08);
}

@media (max-width: 480px) {
  .tapchat-welcome-bubble {
    max-width: calc(100vw - 40px);
    bottom: 90px;
    padding: 16px 20px;
    gap: 12px;
  }
  
  .tapchat-bubble-avatar {
    width: 46px;
    height: 46px;
    border: 2.5px solid #fff;
  }
  
  .tapchat-bubble-avatar svg {
    width: 26px;
    height: 26px;
  }
  
  .tapchat-bubble-name {
    font-size: 15px;
  }
  
  .tapchat-bubble-message {
    font-size: 14px;
  }
  
  .tapchat-bubble-close {
    top: 8px;
    right: 8px;
    width: 26px !important;
    height: 26px !important;
    font-size: 18px !important;
    min-width: 26px !important;
    min-height: 26px !important;
  }
  
  .tapchat-bubble-close::before {
    font-size: 18px !important;
    width: 18px;
    height: 18px;
  }
  
  [dir="rtl"] .tapchat-bubble-close {
    right: auto;
    left: 8px;
  }
  
  .tapchat-welcome-bubble::after {
    bottom: -8px;
    width: 14px;
    height: 14px;
  }
}

.tapchat-welcome-bubble.hidden {
  display: none;
}