/* Real-Time Features CSS */

/* ==================== Typing Indicators ==================== */

.typing-indicators {
  padding: 0.5rem 1rem;
  background: #f8f9fa;
  border-top: 1px solid #dee2e6;
  display: none;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #6c757d;
  font-style: italic;
}

.typing-text {
  flex-shrink: 0;
}

.typing-dots {
  display: flex;
  gap: 0.25rem;
}

.typing-dots span {
  width: 4px;
  height: 4px;
  background: #6c757d;
  border-radius: 50%;
  animation: typing-pulse 1.4s infinite ease-in-out;
}

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

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

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

/* Mobile typing indicators */
@media (max-width: 768px) {
  .typing-indicators {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
  }

  .typing-dots span {
    width: 3px;
    height: 3px;
  }
}

/* ==================== Online Status Indicators ==================== */

.online-indicator {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: #28a745;
  border: 2px solid white;
  border-radius: 50%;
  z-index: 10;
}

.member-item {
  position: relative;
}

.room-card-avatar {
  position: relative;
}

/* Online status in member lists */
.member-list-item {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  border-radius: 0.375rem;
  transition: background-color 0.15s ease;
}

.member-list-item:hover {
  background: #f8f9fa;
}

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

.member-info {
  flex: 1;
}

.member-name {
  font-weight: 500;
  color: #212529;
  margin: 0;
}

.member-status {
  font-size: 0.8rem;
  color: #6c757d;
  margin: 0;
}

.member-status.online {
  color: #28a745;
}

/* ==================== Notification Toasts ==================== */

.notification-toast {
  min-width: 300px;
  max-width: 400px;
}

.notification-toast .toast-header {
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
}

.notification-toast .toast-body {
  background: white;
}

.notification-toast .btn-sm {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}

/* Toast container positioning */
.toast-container {
  z-index: 1055;
}

@media (max-width: 768px) {
  .toast-container {
    left: 0.75rem !important;
    right: 0.75rem !important;
    top: 70px !important; /* Account for mobile header */
  }

  .notification-toast {
    min-width: auto;
    max-width: none;
    width: 100%;
  }
}

/* ==================== Notification Badge ==================== */

.notification-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #dc3545;
  color: white;
  border-radius: 50%;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
  line-height: 1;
  z-index: 10;
  animation: notification-pulse 2s infinite;
}

@keyframes notification-pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

/* Mobile navigation badge */
.mobile-nav-badge {
  position: absolute;
  top: 0.25rem;
  right: 50%;
  transform: translateX(50%);
  background: #dc3545;
  color: white;
  border-radius: 50%;
  padding: 0.125rem 0.375rem;
  font-size: 0.625rem;
  font-weight: 600;
  min-width: 18px;
  text-align: center;
  line-height: 1;
  z-index: 10;
}

/* ==================== Real-Time Message Updates ==================== */

.message.new-message {
  animation: message-slide-in 0.3s ease-out;
}

@keyframes message-slide-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Message loading indicator */
.message-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  color: #6c757d;
  font-style: italic;
}

.message-loading::after {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid #f3f3f5;
  border-radius: 50%;
  border-top-color: #007bff;
  animation: spin 1s ease-in-out infinite;
  margin-left: 0.5rem;
}

/* ==================== Connection Status ==================== */

.connection-status {
  position: fixed;
  top: 60px;
  right: 1rem;
  background: #28a745;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 1050;
  display: none;
  transition: all 0.3s ease;
}

.connection-status.disconnected {
  background: #dc3545;
  display: block;
}

.connection-status.reconnecting {
  background: #ffc107;
  color: #212529;
  display: block;
}

@media (max-width: 768px) {
  .connection-status {
    top: 56px;
    left: 0.75rem;
    right: 0.75rem;
    text-align: center;
  }
}

/* ==================== Activity Indicators ==================== */

.activity-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: #28a745;
}

.activity-dot {
  width: 6px;
  height: 6px;
  background: #28a745;
  border-radius: 50%;
  animation: activity-pulse 2s infinite;
}

@keyframes activity-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* ==================== Real-Time Updates Indicator ==================== */

.real-time-indicator {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(0, 123, 255, 0.9);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 1040;
  display: none;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.real-time-indicator.active {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.real-time-indicator .spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s linear infinite;
}

@media (max-width: 768px) {
  .real-time-indicator {
    bottom: 80px; /* Account for mobile bottom nav */
    left: 1rem;
    right: 1rem;
    justify-content: center;
  }
}

/* ==================== Accessibility ==================== */

/* Screen reader only content for real-time updates */
.sr-only-live {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus indicators for interactive elements */
.typing-indicators:focus-within,
.notification-toast:focus-within {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

/* ==================== Dark Mode Support ==================== */

@media (prefers-color-scheme: dark) {
  .typing-indicators {
    background: #2d2d2d;
    border-top-color: #444;
    color: #adb5bd;
  }

  .typing-dots span {
    background: #adb5bd;
  }

  .member-list-item:hover {
    background: #3d3d3d;
  }

  .member-name {
    color: #f8f9fa;
  }

  .member-status {
    color: #adb5bd;
  }

  .notification-toast .toast-header {
    background: #2d2d2d;
    border-bottom-color: #444;
    color: #f8f9fa;
  }

  .notification-toast .toast-body {
    background: #1e1e1e;
    color: #f8f9fa;
  }

  .connection-status {
    backdrop-filter: blur(10px);
  }
}

/* ==================== Print Styles ==================== */

@media print {
  .typing-indicators,
  .notification-toast,
  .connection-status,
  .real-time-indicator,
  .online-indicator,
  .notification-badge,
  .mobile-nav-badge {
    display: none !important;
  }
}

/* ==================== Reduced Motion ==================== */

@media (prefers-reduced-motion: reduce) {
  .typing-dots span,
  .notification-badge,
  .activity-dot,
  .real-time-indicator .spinner {
    animation: none;
  }

  .message.new-message {
    animation: none;
  }

  .online-indicator {
    transition: none;
  }
}
