/**
 * Professional Mobile Support Chat Box for Mama Fua
 * Enhanced mobile-first design with modern UI/UX and professional styling
 * Version 2.0 - Redesigned for better organization and user experience
 */

/* ==========================================================================
   Mobile Support Chat Box - Enhanced Professional Version
   ========================================================================== */

.mobile-support-chat {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1070; /* Higher z-index to be above bottom navigation */
  display: flex; /* Always visible for mobile devices */
  flex-direction: column;
  align-items: flex-end;
  max-width: 380px;
  width: calc(100vw - 40px);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  pointer-events: none; /* Allow clicks to pass through container */
}

/* Chat Toggle Button */
.chat-toggle-btn {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  border: none;
  color: white;
  font-size: 1.6rem;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  pointer-events: auto; /* Enable clicks on the button itself */
  z-index: 1071; /* Ensure button is above everything */
  touch-action: manipulation; /* Improve touch responsiveness */
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight on iOS */
}

.chat-toggle-btn:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 40px rgba(102, 126, 234, 0.4);
  background: linear-gradient(135deg, #7c8ce8 0%, #8a5cb8 100%);
}

.chat-toggle-btn:active {
  transform: scale(0.95);
}

/* Pulse animation for attention */
.chat-toggle-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  animation: chat-pulse 2s infinite;
  opacity: 0;
}

@keyframes chat-pulse {
  0% {
    transform: scale(0.8);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.3;
  }
  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

/* Notification badge */
.chat-notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ff4757;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  animation: bounce 1s infinite;
}

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

/* Chat Panel - Enhanced Professional Design */
.mobile-chat-panel {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(25px);
  border-radius: 24px;
  box-shadow: 
    0 25px 70px rgba(0, 0, 0, 0.12),
    0 10px 30px rgba(102, 126, 234, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.3);
  margin-bottom: 20px;
  width: 100%;
  max-width: 380px;
  max-height: 550px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(40px) scale(0.88);
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
  border: 1px solid rgba(102, 126, 234, 0.1);
  pointer-events: auto; /* Enable clicks on the panel */
  z-index: 1071; /* Ensure panel is above everything */
}

.mobile-chat-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chat Header - Professional Branding */
.chat-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  border-radius: 24px 24px 0 0;
}

.chat-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.chat-header-info {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  font-size: 1.2rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  position: relative;
  flex-shrink: 0;
}

.chat-avatar::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: #4ade80;
  border-radius: 50%;
  border: 2px solid white;
  animation: online-pulse 2s infinite;
}

@keyframes online-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.chat-header-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.chat-header-text h4 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.chat-header-text p {
  margin: 4px 0 0 0;
  font-size: 0.8rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.chat-header-text p::before {
  content: '🟢';
  font-size: 0.7rem;
  animation: online-pulse 2s infinite;
  flex-shrink: 0;
}

.chat-close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s ease;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Chat Body */
.chat-body {
  padding: 24px;
  max-height: 320px;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.8) 0%, rgba(255, 255, 255, 0.9) 100%);
}

.chat-body::-webkit-scrollbar {
  width: 4px;
}

.chat-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 2px;
}

.chat-body::-webkit-scrollbar-thumb {
  background: rgba(102, 126, 234, 0.3);
  border-radius: 2px;
}

.chat-body::-webkit-scrollbar-thumb:hover {
  background: rgba(102, 126, 234, 0.5);
}

.chat-welcome-message {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.06) 0%, rgba(118, 75, 162, 0.03) 100%);
  padding: 24px;
  border-radius: 18px;
  margin-bottom: 24px;
  border: 1px solid rgba(102, 126, 234, 0.12);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.04);
}

.chat-welcome-message::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
  border-radius: 0 2px 2px 0;
}

.chat-welcome-message h5 {
  margin: 0 0 12px 0;
  color: #1e293b;
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.02em;
}

.chat-welcome-message p {
  margin: 0;
  color: #475569;
  font-size: 0.95rem;
  line-height: 1.6;
  font-weight: 400;
  letter-spacing: -0.01em;
}

/* Quick Actions - Enhanced Organization */
.chat-quick-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.chat-action-btn {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(102, 126, 234, 0.12);
  border-radius: 16px;
  padding: 18px 22px;
  text-align: left;
  color: #1e293b;
  text-decoration: none;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  font-size: 0.96rem;
  font-weight: 500;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.04);
  letter-spacing: -0.01em;
}

.chat-action-btn:hover {
  border-color: rgba(102, 126, 234, 0.25);
  background: rgba(102, 126, 234, 0.06);
  color: #667eea;
  text-decoration: none;
  transform: translateX(4px) translateY(-3px);
  box-shadow: 0 12px 32px rgba(102, 126, 234, 0.12);
}

.chat-action-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transition: left 0.5s;
}

.chat-action-btn:hover::before {
  left: 100%;
}

.chat-action-btn i {
  margin-right: 18px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #667eea;
  font-size: 1.15rem;
  background: rgba(102, 126, 234, 0.08);
  border-radius: 10px;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.chat-action-btn:hover i {
  background: rgba(102, 126, 234, 0.2);
  transform: scale(1.1);
}

/* Professional Chat Input Section */
.chat-input-section {
  margin: 20px 0;
  padding: 16px 0;
  border-top: 1px solid rgba(102, 126, 234, 0.1);
  border-bottom: 1px solid rgba(102, 126, 234, 0.1);
}

.chat-input-wrapper {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: 24px;
  padding: 4px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.chat-input-wrapper:focus-within {
  border-color: rgba(102, 126, 234, 0.4);
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.15);
}

.chat-message-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 12px 16px;
  font-size: 0.9rem;
  background: transparent;
  color: #1e293b;
  font-family: inherit;
}

.chat-message-input::placeholder {
  color: #64748b;
  opacity: 0.8;
}

.chat-input-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 4px;
}

.chat-action-button {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 1rem;
}

.attachment-btn {
  background: rgba(102, 126, 234, 0.1);
  color: #667eea;
}

.attachment-btn:hover {
  background: rgba(102, 126, 234, 0.2);
  transform: scale(1.05);
}

.send-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.send-btn:hover {
  background: linear-gradient(135deg, #7c8ce8 0%, #8a5cb8 100%);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.file-input-hidden {
  display: none !important;
}

/* Contact Methods - Professional Layout */
.contact-methods {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(102, 126, 234, 0.08);
}

.contact-method {
  padding: 16px 12px;
  border-radius: 14px;
  text-align: center;
  text-decoration: none;
  color: white;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  letter-spacing: -0.01em;
}

.contact-method.whatsapp {
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
}

.contact-method.phone {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.contact-method.email {
  background: linear-gradient(135deg, #ff6b6b 0%, #ff8e8e 100%);
}

.contact-method:hover {
  transform: translateY(-6px) scale(1.08);
  text-decoration: none;
  color: white;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.contact-method::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.contact-method:hover::before {
  left: 100%;
}

.contact-method i {
  font-size: 1.3rem;
  margin-bottom: 2px;
}

/* Service Hours Indicator - Enhanced */
.service-hours {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.08) 0%, rgba(16, 185, 129, 0.05) 100%);
  border: 1px solid rgba(34, 197, 94, 0.15);
  border-radius: 14px;
  padding: 14px 18px;
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.87rem;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.06);
}

.service-hours i {
  color: #22c55e;
  font-size: 1rem;
}

.service-hours-text {
  color: #166534;
  font-weight: 500;
}

/* Professional Badge - Enhanced */
.professional-badge {
  position: absolute;
  top: -8px;
  right: 18px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.35);
  z-index: 10;
  animation: badge-glow 3s ease-in-out infinite;
}

@keyframes badge-glow {
  0%, 100% {
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.35);
  }
  50% {
    box-shadow: 0 8px 24px rgba(245, 158, 11, 0.5);
  }
}

/* Mobile Responsive Adjustments - Enhanced */
@media (max-width: 768px) {
  .mobile-support-chat {
    bottom: 90px !important; /* Position above bottom navigation on all mobile devices */
    right: 20px;
    z-index: 1070 !important; /* Force higher z-index on mobile */
  }
  
  .chat-toggle-btn {
    touch-action: manipulation; /* Improve touch responsiveness */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on iOS */
    z-index: 1071 !important; /* Force higher z-index on mobile */
  }
}

@media (max-width: 480px) {
  .mobile-support-chat {
    bottom: 90px; /* Position above bottom navigation */
    right: 15px;
    width: calc(100vw - 30px);
  }
  
  .chat-toggle-btn {
    width: 58px;
    height: 58px;
    font-size: 1.35rem;
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.25);
  }
  
  .mobile-chat-panel {
    max-width: 100%;
    max-height: 480px;
    border-radius: 20px;
  }
  
  .chat-body {
    padding: 22px;
    max-height: 320px;
  }
  
  .chat-header {
    padding: 18px 20px;
    border-radius: 20px 20px 0 0;
  }
  
  .chat-avatar {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    margin-right: 10px;
  }
  
  .chat-header-text h4 {
    font-size: 0.95rem;
  }
  
  .chat-header-text p {
    font-size: 0.75rem;
  }
  
  .chat-close-btn {
    width: 32px;
    height: 32px;
    padding: 6px;
    font-size: 1.1rem;
  }
  
  .contact-methods {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 18px;
  }
  
  .contact-method {
    flex-direction: row;
    justify-content: flex-start;
    gap: 14px;
    padding: 14px 18px;
    text-align: left;
  }
  
  .contact-method i {
    font-size: 1.4rem;
    margin-bottom: 0;
  }
  
  .service-hours {
    flex-direction: row;
    text-align: left;
    gap: 10px;
    padding: 12px 16px;
  }
  
  .chat-action-btn {
    padding: 16px 20px;
    border-radius: 14px;
  }
  
  .chat-action-btn i {
    width: 26px;
    height: 26px;
    margin-right: 16px;
  }
  
  .professional-badge {
    right: 15px;
    font-size: 0.65rem;
    padding: 3px 10px;
  }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
  .mobile-chat-panel {
    max-height: 280px;
  }
  
  .chat-body {
    max-height: 150px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .chat-toggle-btn {
    box-shadow: 0 2px 10px rgba(37, 211, 102, 0.4);
  }
  
  .mobile-chat-panel {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  .chat-toggle-btn::before {
    animation: none;
  }
  
  .chat-notification-badge {
    animation: none;
  }
  
  .mobile-chat-panel {
    transition: opacity 0.2s ease, visibility 0.2s ease;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .mobile-chat-panel {
    background: #2d3748;
    color: white;
  }
  
  .chat-welcome-message {
    background: #4a5568;
    color: white;
  }
  
  .chat-welcome-message h5 {
    color: white;
  }
  
  .chat-welcome-message p {
    color: #e2e8f0;
  }
  
  .chat-action-btn {
    background: #4a5568;
    border-color: #718096;
    color: white;
  }
  
  .chat-action-btn:hover {
    background: rgba(102, 126, 234, 0.2);
    color: #90cdf4;
  }
}

/* Focus states for accessibility */
.chat-toggle-btn:focus,
.chat-close-btn:focus,
.chat-action-btn:focus,
.contact-method:focus {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

/* Loading state */
.chat-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.chat-loading::after {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid #e9ecef;
  border-top: 2px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
