/* Chat Bubble Widget Styles */
.chat-bubble-container * {
  box-sizing: border-box;
}

.chat-bubble-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Ensure chat bubble is always visible */
.chat-bubble-button,
.chat-widget {
  pointer-events: auto;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .chat-bubble-container {
    bottom: 10px;
    right: 10px;
  }

  .chat-bubble-button {
    width: 56px !important;
    height: 56px !important;
  }
}

/* Prevent conflicts with existing styles */
.chat-bubble-container button {
  font-family: inherit;
}

.chat-bubble-container input,
.chat-bubble-container textarea {
  font-family: inherit;
}

/* ==================== Call UI Styles ==================== */

/* Call Buttons in Thread Header */
.call-buttons {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.call-button {
  background: transparent;
  border: 1px solid #e0e0e0;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}

.call-button:hover:not(:disabled) {
  background: #f5f5f5;
  border-color: #4CAF50;
}

.call-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.call-button.voice-call svg {
  color: #4CAF50;
}

.call-button.video-call svg {
  color: #2196F3;
}

/* Incoming Call Modal */
.call-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.incoming-call-modal {
  background: white;
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.call-modal-header {
  margin-bottom: 32px;
}

.caller-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 600;
  margin: 0 auto 16px;
}

.call-modal-header h3 {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 8px;
  color: #333;
}

.call-type {
  color: #666;
  font-size: 14px;
  margin: 0;
}

.ringing-animation {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 24px auto 0;
}

.ringing-animation .ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  border: 3px solid #4CAF50;
  border-radius: 50%;
  animation: ring-pulse 1.5s ease-out infinite;
}

.ringing-animation .ring:nth-child(2) {
  animation-delay: 0.5s;
}

.ringing-animation .ring:nth-child(3) {
  animation-delay: 1s;
}

@keyframes ring-pulse {
  0% {
    width: 60px;
    height: 60px;
    opacity: 1;
  }
  100% {
    width: 100px;
    height: 100px;
    opacity: 0;
  }
}

.call-modal-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.call-action-button {
  flex: 1;
  max-width: 140px;
  padding: 16px;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.call-action-button.reject {
  background: #f44336;
  color: white;
}

.call-action-button.reject:hover {
  background: #d32f2f;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

.call-action-button.accept {
  background: #4CAF50;
  color: white;
}

.call-action-button.accept:hover {
  background: #45a049;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

/* Active Call Interface */
.active-call-interface {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 600px;
  height: 80vh;
  max-height: 700px;
  background: #1a1a1a;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.call-interface-header {
  background: rgba(0, 0, 0, 0.5);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(10px);
}

.call-participant-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.participant-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
}

.participant-details h4 {
  margin: 0;
  color: white;
  font-size: 16px;
  font-weight: 600;
}

.call-status-text {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

.minimize-call-button {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  transition: all 0.2s ease;
}

.minimize-call-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Video Container */
.call-video-container {
  flex: 1;
  position: relative;
  background: #000;
}

.remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.local-video {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 150px;
  height: 112px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.video-disabled-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #1a1a1a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.video-disabled-overlay .avatar-large {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 600;
}

.video-disabled-overlay p {
  color: rgba(255, 255, 255, 0.7);
  margin: 0;
}

/* Audio Call Container */
.call-audio-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.audio-call-avatar {
  text-align: center;
}

.audio-call-avatar .avatar-large {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 600;
  margin: 0 auto 24px;
  backdrop-filter: blur(10px);
}

.audio-wave-animation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 40px;
}

.audio-wave-animation span {
  width: 4px;
  background: white;
  border-radius: 2px;
  animation: audio-wave 1.2s ease-in-out infinite;
}

.audio-wave-animation span:nth-child(1) { animation-delay: 0s; }
.audio-wave-animation span:nth-child(2) { animation-delay: 0.1s; }
.audio-wave-animation span:nth-child(3) { animation-delay: 0.2s; }
.audio-wave-animation span:nth-child(4) { animation-delay: 0.3s; }
.audio-wave-animation span:nth-child(5) { animation-delay: 0.4s; }

@keyframes audio-wave {
  0%, 100% {
    height: 10px;
  }
  50% {
    height: 30px;
  }
}

/* Call Controls */
.call-controls {
  background: rgba(0, 0, 0, 0.5);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  backdrop-filter: blur(10px);
}

.call-control-button {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.call-control-button:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.call-control-button.active {
  background: rgba(244, 67, 54, 0.8);
}

.call-control-button.end-call {
  background: #f44336;
  width: 64px;
  height: 64px;
}

.call-control-button.end-call:hover {
  background: #d32f2f;
  transform: scale(1.1);
}

/* Call Connection Status */
.call-connection-status {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  padding: 16px 24px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: white;
  backdrop-filter: blur(10px);
}

/* Transitions */
.fade-enter-active, .fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from, .fade-leave-to {
  opacity: 0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .active-call-interface {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    top: 0;
    left: 0;
    transform: none;
  }

  .local-video {
    width: 100px;
    height: 75px;
    bottom: 100px;
    right: 12px;
  }

  .call-controls {
    padding: 16px;
  }

  .call-control-button {
    width: 48px;
    height: 48px;
  }

  .call-control-button.end-call {
    width: 56px;
    height: 56px;
  }

  .incoming-call-modal {
    padding: 24px;
  }

  .caller-avatar {
    width: 60px;
    height: 60px;
    font-size: 24px;
  }

  .call-modal-header h3 {
    font-size: 20px;
  }
}


/* Chat Bubble Button */
.chat-bubble-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  position: relative;
}

.chat-bubble-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.chat-bubble-button.has-unread {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }
  50% {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.6);
  }
}

.notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ff4444;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  border: 2px solid white;
}

/* Chat Widget */
.chat-widget {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Chat Header */
.chat-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-content h3 {
  margin: 0 0 4px 0;
  font-size: 18px;
  font-weight: 600;
}

.chat-header-content p {
  margin: 0;
  font-size: 13px;
  opacity: 0.9;
}

.close-button {
  background: transparent;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s ease;
}

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

/* Chat Content */
.chat-content {
  flex: 1;
  overflow-y: auto;
  background: #f8f9fa;
}

/* Conversation List */
.conversation-list {
  padding: 16px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state svg {
  color: #ccc;
  margin-bottom: 16px;
}

.empty-state p {
  color: #666;
  margin-bottom: 20px;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Conversation Item */
.conversation-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
  margin-bottom: 8px;
}

.conversation-item:hover {
  background: white;
}

.conversation-item.has-unread {
  background: #f0f4ff;
}

.conversation-avatar {
  position: relative;
  flex-shrink: 0;
}

.avatar-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
}

.online-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: #4CAF50;
  border: 2px solid white;
  border-radius: 50%;
}

.conversation-details {
  flex: 1;
  min-width: 0;
}

.conversation-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.conversation-header-row h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #333;
}

.conversation-time {
  font-size: 12px;
  color: #999;
}

.conversation-preview-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.conversation-preview {
  margin: 0;
  font-size: 14px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-badge {
  background: #667eea;
  color: white;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

/* Message Thread */
.message-thread {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.thread-header {
  padding: 16px;
  background: white;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
}

.thread-user-info {
  flex: 1;
}

.thread-user-info h4 {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.typing-indicator,
.online-status,
.away-status,
.offline-status,
.checking-status {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-online {
  background: #4CAF50;
}

.status-away {
  background: #FFC107;
}

.status-offline {
  background: #999;
}

.status-checking {
  background: #2196F3;
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
}

.typing-dots span {
  width: 4px;
  height: 4px;
  background: #666;
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-6px);
  }
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f8f9fa;
}

.loading-spinner {
  display: flex;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.spinner-small {
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Messages */
.message {
  margin-bottom: 16px;
  display: flex;
}

.message-sent {
  justify-content: flex-end;
}

.message-received {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 16px;
  word-wrap: break-word;
}

.message-sent .message-bubble {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.message-received .message-bubble {
  background: white;
  color: #333;
  border-bottom-left-radius: 4px;
}

.message-bubble p {
  margin: 0 0 8px 0;
}

.message-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  opacity: 0.8;
}

.message-time {
  font-size: 11px;
}

.message-status svg {
  width: 12px;
  height: 12px;
}

/* Message Input */
.message-input-container {
  padding: 16px;
  background: white;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.message-input-container textarea {
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  padding: 10px 16px;
  resize: none;
  font-size: 14px;
  font-family: inherit;
  max-height: 100px;
}

.message-input-container textarea:focus {
  outline: none;
  border-color: #667eea;
}

.send-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.send-button:hover:not(:disabled) {
  transform: scale(1.1);
}

.send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Topic Selection */
.topic-selection {
  padding: 16px;
}

.topic-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.topic-header h3 {
  margin: 0 0 4px 0;
  font-size: 18px;
  font-weight: 600;
}

.topic-header p {
  margin: 0;
  font-size: 14px;
  color: #666;
}

.topic-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topic-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: white;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.topic-card:hover {
  border-color: #667eea;
  transform: translateX(4px);
}

.topic-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.topic-info {
  flex: 1;
}

.topic-info h4 {
  margin: 0 0 4px 0;
  font-size: 15px;
  font-weight: 600;
  color: #333;
}

.topic-info p {
  margin: 0;
  font-size: 13px;
  color: #666;
}

.topic-arrow {
  color: #999;
  flex-shrink: 0;
}

/* Guest Form */
.guest-form {
  padding: 24px;
}

.guest-form h3 {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 600;
  color: #333;
}

.guest-form > p {
  margin: 0 0 24px 0;
  font-size: 14px;
  color: #666;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #333;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

.form-group input:focus {
  outline: none;
  border-color: #667eea;
}

/* Status Message Banner */
.status-message-banner {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
}

.status-info {
  background: #e3f2fd;
  color: #1976d2;
}

.status-success {
  background: #e8f5e9;
  color: #388e3c;
}

.status-warning {
  background: #fff3e0;
  color: #f57c00;
}

.status-error {
  background: #ffebee;
  color: #d32f2f;
}

.status-close {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Transitions */
.slide-up-enter-active,
.slide-up-leave-active {
  transition: all 0.3s ease;
}

.slide-up-enter,
.slide-up-leave-to {
  transform: translateY(20px);
  opacity: 0;
}

.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter,
.fade-leave-to {
  opacity: 0;
}

.slide-down-enter-active,
.slide-down-leave-active {
  transition: all 0.3s ease;
}

.slide-down-enter,
.slide-down-leave-to {
  transform: translateY(-20px);
  opacity: 0;
}

/* Load More */
.load-more-container {
  text-align: center;
  padding: 16px 0;
}

.load-more-button {
  background: white;
  border: 1px solid #e0e0e0;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.load-more-button:hover {
  background: #f5f5f5;
  border-color: #667eea;
}

.loading-more-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  color: #666;
}
