/* Omnichannel Chat Widget CSS */

.omnichat-widget {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* Admin bar adjustment */
body.admin-bar .omnichat-container {
  bottom: calc(22px + var(--wp-admin--admin-bar--height, 0px));
}

@media (max-width: 768px) {
  body.admin-bar .omnichat-container {
    bottom: calc(32px + var(--wp-admin--admin-bar--height, 0px));
  }
}

.omnichat-widget * {
  box-sizing: border-box;
}

.omnichat-container {
  position: fixed;
  z-index: 99999;
  display: block;
  transform-origin: calc(100% + 40px) calc(100% + 40px);
  /* Default desktop positioning */
  right: 47px;
  bottom: 22px;
}

/* Welcome Message */
.omnichat-welcome {
  position: absolute;
  bottom: 80px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 16px 20px;
  min-width: 260px;
  max-width: 320px;
  opacity: 0;
  transform: scale(0.9) translateY(10px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.omnichat-welcome.show {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}

.omnichat-welcome.right {
  right: 0;
}

.omnichat-welcome.left {
  left: 0;
}

.omnichat-welcome-close {
  position: absolute;
  top: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.omnichat-widget.ltr .omnichat-welcome-close {
  right: 8px;
  left: auto;
}

.omnichat-widget.rtl .omnichat-welcome-close {
  left: 8px;
  right: auto;
}

.omnichat-welcome-close:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.omnichat-welcome-text {
  margin-right: 20px;
  color: #333;
  font-size: 14px;
  line-height: 1.5;
}

/* Main Button */
.omnichat-main-button {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  position: relative;
  overflow: visible;
  background: linear-gradient(135deg, #448AFF 0%, #2979FF 100%);
}

.omnichat-main-button:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 20px rgba(68, 138, 255, 0.4);
}

.omnichat-main-button:active {
  transform: scale(0.95);
}

.omnichat-icon-open,
.omnichat-icon-close {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.omnichat-icon-close {
  opacity: 0;
  transform: rotate(-180deg) scale(0.3);
}

.omnichat-widget.active .omnichat-icon-open {
  opacity: 0;
  transform: rotate(180deg) scale(0.3);
}

.omnichat-widget.active .omnichat-icon-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* Caption */
.omnichat-caption {
  position: absolute;
  left: -10px;
  transform: translateX(-100%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.omnichat-main-button:hover .omnichat-caption {
  opacity: 1;
}

/* Channel Items */
.omnichat-channels {
  position: absolute;
  bottom: 80px;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.omnichat-widget.active .omnichat-channels {
  opacity: 1;
  pointer-events: all;
}

.omnichat-channel-item {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  opacity: 0;
  transform: translateY(20px) scale(0.8);
  transition: all 0.3s ease;
}

.omnichat-widget.active .omnichat-channel-item {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.omnichat-channel-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  border: none;
  cursor: pointer;
  padding: 0;
  outline: none;
}

.omnichat-channel-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.omnichat-channel-button svg {
  z-index: 1;
  position: relative;
}

/* Instagram gradient background */
.omnichat-instagram {
  background: linear-gradient(45deg, #FFD521 0%, #F30005 50%, #B900B4 100%);
}

/* Channel Caption */
.omnichat-channel-caption {
  position: absolute;
  left: -10px;
  transform: translateX(-100%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.omnichat-channel-item:hover .omnichat-channel-caption {
  opacity: 1;
}

/* Branding */
.omnichat-branding {
  position: absolute;
  bottom: -30px;
  right: 0;
  font-size: 11px;
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

.omnichat-branding:hover {
  opacity: 1;
}

.omnichat-branding a {
  color: #666;
  text-decoration: none;
}

.omnichat-branding a:hover {
  text-decoration: underline;
}

/* Animations */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(68, 138, 255, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(68, 138, 255, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(68, 138, 255, 0);
  }
}

.omnichat-main-button.pulse {
  animation: pulse 2s infinite;
}

/* Tablet */
@media (max-width: 1024px) {
  .omnichat-widget.ltr .omnichat-container.right {
    right: 40px;
    bottom: 25px;
  }
  
  .omnichat-widget.rtl .omnichat-container.left {
    left: 40px;
    bottom: 25px;
  }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .omnichat-widget.ltr .omnichat-container {
    transform-origin: calc(100% + 20px) calc(100% + 20px);
  }
  
  .omnichat-widget.rtl .omnichat-container {
    transform-origin: calc(0% - 20px) calc(100% + 20px);
  }
  
  .omnichat-widget.ltr .omnichat-container.right {
    right: 20px;
    bottom: 32px;
  }
  
  .omnichat-widget.rtl .omnichat-container.left {
    left: 20px;
    bottom: 32px;
  }
  
  .omnichat-main-button,
  .omnichat-channel-button {
    width: 50px;
    height: 50px;
  }
  
  .omnichat-main-button svg,
  .omnichat-channel-button svg {
    width: 28px;
    height: 28px;
  }
  
  .omnichat-welcome {
    max-width: 280px;
    bottom: 70px;
  }
  
  .omnichat-channels {
    bottom: 70px;
  }
  
  .omnichat-caption,
  .omnichat-channel-caption {
    font-size: 12px;
    padding: 4px 8px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .omnichat-welcome {
    background: #1e1e1e;
    color: #e0e0e0;
  }
  
  .omnichat-welcome-text {
    color: #e0e0e0;
  }
  
  .omnichat-welcome-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
  }
  
  .omnichat-branding a {
    color: #999;
  }
}

/* RTL Support */
.omnichat-widget.rtl .omnichat-container {
  transform-origin: calc(0% - 40px) calc(100% + 40px);
}

.omnichat-widget.ltr .omnichat-container {
  transform-origin: calc(100% + 40px) calc(100% + 40px);
}

/* RTL positioning for left-aligned widget */
.omnichat-widget.rtl .omnichat-container.left {
  left: 47px;
  right: auto;
}

/* LTR positioning for right-aligned widget */
.omnichat-widget.ltr .omnichat-container.right {
  right: 47px;
  left: auto;
}

/* Welcome message positioning */
.omnichat-widget.rtl .omnichat-welcome.left {
  left: 0;
  right: auto;
}

.omnichat-widget.ltr .omnichat-welcome.right {
  right: 0;
  left: auto;
}

/* Caption positioning */
.omnichat-widget.rtl .omnichat-caption,
.omnichat-widget.rtl .omnichat-channel-caption {
  left: auto;
  right: -10px;
  transform: translateX(100%);
}

.omnichat-widget.ltr .omnichat-caption,
.omnichat-widget.ltr .omnichat-channel-caption {
  left: -10px;
  right: auto;
  transform: translateX(-100%);
}

/* Channels positioning */
.omnichat-widget.rtl .omnichat-channels {
  right: auto;
  left: 0;
}

.omnichat-widget.ltr .omnichat-channels {
  left: auto;
  right: 0;
}

/* Channel items alignment */
.omnichat-widget.rtl .omnichat-channel-item {
  justify-content: flex-start;
  flex-direction: row-reverse;
}

.omnichat-widget.ltr .omnichat-channel-item {
  justify-content: flex-end;
  flex-direction: row;
}

/* Bird Chat Widget Compatibility */
/* Ensure our widget doesn't overlap with Bird's widget */
.omnichat-widget {
  z-index: 999998; /* Just below Bird's typical z-index */
}

/* When Bird widget is present, adjust our position */
body:has([data-bird-chat-widget]) .omnichat-container.right,
body:has(.bird-chat-widget) .omnichat-container.right,
body:has(iframe[src*="bird.com"]) .omnichat-container.right {
  bottom: 120px !important; /* Move up to avoid Bird widget */
}

/* Alignment with other fixed position elements */
.omnichat-container {
  /* Ensure consistent spacing with other icons */
  transition: all 0.3s ease;
}

/* When multiple fixed position widgets exist */
body:has(.header-whatsapp) .omnichat-container {
  /* Adjust positioning to stack properly with WhatsApp icon */
  bottom: calc(22px + 80px); /* Base position + WhatsApp icon height + spacing */
}

@media (max-width: 768px) {
  body:has(.header-whatsapp) .omnichat-container {
    bottom: calc(32px + 65px);
  }
}

body:has([data-bird-chat-widget]) .omnichat-container.left,
body:has(.bird-chat-widget) .omnichat-container.left {
  right: 40px !important; /* Move to opposite side if Bird is on left */
  left: auto !important;
}

/* Hide our widget when Bird chat is open */
.bird-chat-open .omnichat-widget,
[data-bird-chat-open="true"] .omnichat-widget,
body:has(.bird-chat-open) .omnichat-widget {
  opacity: 0.3;
  pointer-events: none;
}

/* Ensure Bird widget stays hidden when configured */
.omnichat-hide-bird [data-bird-chat-widget],
.omnichat-hide-bird .bird-chat-widget,
.omnichat-hide-bird .bird-widget-launcher,
.omnichat-hide-bird .bird-chat-button,
.omnichat-hide-bird iframe[src*="bird.com"]:not(.bird-chat-frame) {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Conversation History Styles */
.bird-chat-history {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.bird-chat-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.bird-chat-history-header h4 {
  margin: 0;
  font-size: 16px;
  color: #333;
}

.bird-chat-history-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.bird-chat-new-conversation {
  background: #007cba;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.bird-chat-new-conversation:hover {
  background: #005a87;
}

.bird-chat-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bird-chat-history-item {
  background: #f5f5f5;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.bird-chat-history-item:hover {
  background: #e8e8e8;
}

.bird-chat-history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.bird-chat-history-item-name {
  font-weight: 500;
  color: #333;
  font-size: 14px;
}

.bird-chat-history-item-date {
  font-size: 12px;
  color: #666;
}

.bird-chat-history-item-status {
  font-size: 12px;
  color: #888;
}

.bird-chat-back-btn {
  background: #f0f0f0;
  color: #333;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.bird-chat-back-btn:hover {
  background: #e0e0e0;
}

/* ======================
   UI Enhancements
   ====================== */

/* Typing Indicator */
.omnichat-typing-indicator,
#bird-typing-indicator {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 18px;
  margin: 4px 0;
  animation: fadeIn 0.3s ease-in-out;
}

.omnichat-typing-dots {
  display: flex;
  gap: 4px;
}

.omnichat-typing-dot {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: typingDot 1.4s infinite ease-in-out;
}

.omnichat-typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.omnichat-typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typingDot {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Notification Badge */
.omnichat-notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ff4444;
  color: white;
  font-size: 11px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(255, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 68, 68, 0);
  }
}

/* Skeleton Loading */
.omnichat-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeletonLoading 1.5s infinite;
  border-radius: 4px;
}

.omnichat-skeleton-text {
  height: 14px;
  margin: 8px 0;
  border-radius: 4px;
}

.omnichat-skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

@keyframes skeletonLoading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Smooth Reveal Animations - Professional entrance */
.omnichat-fade-in {
  animation: elegantFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  opacity: 0;
}

@keyframes elegantFadeIn {
  0% {
    opacity: 0;
    transform: scale(0.98);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.omnichat-slide-up {
  animation: elegantSlideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  transform: translateY(15px);
  opacity: 0;
}

@keyframes elegantSlideUp {
  0% {
    transform: translateY(15px) scale(0.98);
    opacity: 0;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Business Hours Indicator */
.omnichat-business-hours {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 20px;
  font-size: 12px;
  margin-bottom: 10px;
}

.omnichat-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4CAF50;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);
}

.omnichat-status-dot.offline {
  background: #999;
  box-shadow: 0 0 0 2px rgba(153, 153, 153, 0.3);
}

/* Sound Toggle */
.omnichat-sound-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.omnichat-sound-toggle:hover {
  background: rgba(0, 0, 0, 0.1);
  transform: scale(1.1);
}

.omnichat-sound-toggle.muted {
  background: rgba(255, 0, 0, 0.1);
}

/* Minimize/Maximize Animations - Professional smooth transitions */
.omnichat-widget.minimizing .omnichat-channels {
  animation: smoothClose 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.omnichat-widget.maximizing .omnichat-channels {
  animation: smoothOpen 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes smoothClose {
  0% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  100% {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
}

@keyframes smoothOpen {
  0% {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Glass Effect for Premium Feel */
.omnichat-glass {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Ripple Effect */
.omnichat-ripple {
  position: relative;
  overflow: hidden;
}

.omnichat-ripple::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.omnichat-ripple:active::after {
  width: 300px;
  height: 300px;
}

/* Hover Lift Effect */
.omnichat-channel-item {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.omnichat-channel-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ======================
   Mobile Specific Styles
   ====================== */

/* Mobile Detection */
@media (max-width: 768px) {
  .omnichat-widget {
    --mobile-safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --mobile-safe-area-left: env(safe-area-inset-left, 0px);
    --mobile-safe-area-right: env(safe-area-inset-right, 0px);
  }
}

/* Mobile uses same button sizes as desktop */

/* Small Mobile */
@media (max-width: 480px) {
  .omnichat-container {
    right: 15px;
    bottom: 20px;
  }
}

/* Mobile uses same container positioning as desktop */

/* Mobile uses same floating layout as desktop */

/* Mobile uses same floating behavior as desktop - no fullscreen mode */

/* Mobile uses exact same channel layout as desktop */

/* Mobile uses desktop styles - no special mobile styles needed */

/* No special landscape adjustments - mobile uses desktop layout */

/* No mobile-specific body scroll prevention needed */

/* Mobile uses same accessibility and animations as desktop */

/* Hide tooltips option */
.omnichat-widget.omnichat-hide-tooltips .omnichat-welcome {
  display: none !important;
}

.omnichat-widget.omnichat-hide-tooltips .omnichat-caption {
  display: none !important;
}

.omnichat-widget.omnichat-hide-tooltips .omnichat-channel-caption {
  display: none !important;
}