/**
 * Video Call Modal Styles
 * Full-screen video call overlay
 */

/* Overlay - full screen dark background */
.video-call-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #000;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.video-call-overlay-visible {
  opacity: 1;
}

/* Container */
.video-call-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Remote video - full screen */
.video-call-remote {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background-color: #1a1a2e;
}

/* Local video preview - bottom right corner */
.video-call-local-container {
  position: absolute;
  bottom: 100px;
  right: 20px;
  width: 180px;
  height: 135px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.2);
  z-index: 10;
}

.video-call-local {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background-color: #2d2d44;
  transform: scaleX(-1); /* Mirror local video */
}

/* Status overlay - top center */
.video-call-status {
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 10;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.video-call-target-name {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.video-call-status-text {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 4px;
}

.video-call-timer {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
  font-variant-numeric: tabular-nums;
}

/* Controls bar - bottom center */
.video-call-controls {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 20px;
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 50px;
  z-index: 10;
}

/* Control buttons */
.video-call-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.video-call-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

.video-call-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.video-call-btn:active {
  transform: scale(0.95);
}

/* Muted state */
.video-call-btn.muted {
  background: rgba(239, 68, 68, 0.8);
}

.video-call-btn.muted:hover {
  background: rgba(239, 68, 68, 0.9);
}

/* End call button - always red */
.video-call-btn-end {
  background: #ef4444;
  width: 64px;
  height: 64px;
}

.video-call-btn-end:hover {
  background: #dc2626;
}

/* SVG icons */
.video-call-btn svg {
  width: 24px;
  height: 24px;
}

.video-call-btn-end svg {
  width: 28px;
  height: 28px;
}

/* Audio-only call - show placeholder instead of video */
.video-call-overlay.audio-only .video-call-remote {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.video-call-overlay.audio-only .video-call-local-container {
  display: none;
}

.video-call-overlay.audio-only .video-call-btn-video {
  display: none;
}

/* Avatar placeholder for audio calls */
.video-call-avatar-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  color: #fff;
  text-transform: uppercase;
  z-index: 5;
}

/* Connecting animation */
@keyframes pulse {
  0% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.6;
  }
}

.video-call-status-text.connecting {
  animation: pulse 1.5s ease-in-out infinite;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .video-call-local-container {
    width: 120px;
    height: 90px;
    bottom: 120px;
    right: 16px;
  }

  .video-call-controls {
    gap: 12px;
    padding: 12px 20px;
  }

  .video-call-btn {
    width: 48px;
    height: 48px;
  }

  .video-call-btn-end {
    width: 56px;
    height: 56px;
  }

  .video-call-target-name {
    font-size: 1.25rem;
  }
}

@media (max-width: 480px) {
  .video-call-local-container {
    width: 100px;
    height: 75px;
    bottom: 130px;
    right: 12px;
  }

  .video-call-status {
    top: 20px;
  }

  .video-call-controls {
    bottom: 20px;
    gap: 10px;
    padding: 10px 16px;
  }

  .video-call-btn {
    width: 44px;
    height: 44px;
  }

  .video-call-btn-end {
    width: 52px;
    height: 52px;
  }

  .video-call-btn svg {
    width: 20px;
    height: 20px;
  }

  .video-call-btn-end svg {
    width: 24px;
    height: 24px;
  }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .video-call-status {
    top: 10px;
  }

  .video-call-local-container {
    bottom: 80px;
    width: 140px;
    height: 105px;
  }

  .video-call-controls {
    bottom: 10px;
    padding: 8px 16px;
  }

  .video-call-btn {
    width: 40px;
    height: 40px;
  }

  .video-call-btn-end {
    width: 48px;
    height: 48px;
  }
}

/* ========================================
   Incoming Call Notification
   ======================================== */

.incoming-call-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 320px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 10001;
  overflow: hidden;
  transform: translateX(400px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.incoming-call-notification.incoming-call-visible {
  transform: translateX(0);
  opacity: 1;
}

.incoming-call-content {
  display: flex;
  align-items: center;
  padding: 20px;
  gap: 16px;
}

.incoming-call-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  animation: pulse-ring 1.5s ease-in-out infinite;
}

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.5);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(102, 126, 234, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
  }
}

.incoming-call-info {
  flex: 1;
  min-width: 0;
}

.incoming-call-type {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 4px;
}

.incoming-call-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.incoming-call-actions {
  display: flex;
  padding: 0 20px 20px;
  gap: 12px;
}

.incoming-call-btn {
  flex: 1;
  height: 48px;
  border-radius: 24px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-weight: 500;
}

.incoming-call-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

.incoming-call-decline {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.incoming-call-decline:hover {
  background: rgba(239, 68, 68, 0.3);
}

.incoming-call-accept {
  background: #10b981;
  color: #fff;
}

.incoming-call-accept:hover {
  background: #059669;
}

.incoming-call-btn svg {
  width: 24px;
  height: 24px;
}

/* Mobile adjustments for notification */
@media (max-width: 480px) {
  .incoming-call-notification {
    top: 10px;
    right: 10px;
    left: 10px;
    width: auto;
  }
}

/* Federation styles for incoming call */
.incoming-call-federated {
  border-left: 4px solid #8b5cf6;
}

.incoming-call-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.incoming-call-federation-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.incoming-call-federation-badge svg {
  width: 12px;
  height: 12px;
}

.incoming-call-village {
  font-size: 0.8rem;
  color: #9ca3af;
  margin-top: 2px;
}

.incoming-call-federated .incoming-call-icon {
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
}

/* ========================================
   Navbar Presence Component
   ======================================== */

.navbar-presence {
  position: relative;
  display: inline-block;
}

.navbar-presence-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary, #6b7280);
  transition: all 0.2s ease;
}

.navbar-presence-btn:hover {
  background: var(--hover-bg, rgba(0, 0, 0, 0.05));
  color: var(--text-primary, #1f2937);
}

.navbar-presence-btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus-ring, rgba(59, 130, 246, 0.5));
}

.navbar-presence-icon {
  width: 20px;
  height: 20px;
}

.navbar-presence-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  background: #10b981;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.navbar-presence-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  background: var(--dropdown-bg, #fff);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color, #e5e7eb);
  z-index: 1000;
  overflow: hidden;
}

.navbar-presence-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  background: var(--header-bg, #f9fafb);
}

.navbar-presence-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary, #1f2937);
}

.navbar-presence-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
}

.navbar-presence-list {
  max-height: 280px;
  overflow-y: auto;
}

.navbar-presence-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  transition: background 0.15s ease;
}

.navbar-presence-user:hover {
  background: var(--hover-bg, #f3f4f6);
}

.presence-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.presence-online-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  flex-shrink: 0;
}

.presence-user-name {
  font-size: 0.9rem;
  color: var(--text-primary, #1f2937);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.presence-user-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.presence-action-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary, #6b7280);
  transition: all 0.15s ease;
}

.presence-action-btn:hover {
  background: var(--action-hover-bg, #e5e7eb);
  color: var(--text-primary, #1f2937);
}

.presence-action-call:hover {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.navbar-presence-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-secondary, #6b7280);
  font-size: 0.9rem;
}

.navbar-presence-more {
  padding: 8px 16px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary, #6b7280);
  border-top: 1px solid var(--border-color, #e5e7eb);
}

.navbar-presence-footer {
  padding: 8px 16px;
  border-top: 1px solid var(--border-color, #e5e7eb);
}

.navbar-presence-view-all {
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--primary-color, #3b82f6);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.navbar-presence-view-all:hover {
  background: rgba(59, 130, 246, 0.1);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .navbar-presence-dropdown {
    background: #1f2937;
    border-color: #374151;
  }

  .navbar-presence-header {
    background: #111827;
    border-color: #374151;
  }

  .navbar-presence-title {
    color: #f9fafb;
  }

  .navbar-presence-user:hover {
    background: #374151;
  }

  .presence-user-name {
    color: #f9fafb;
  }

  .navbar-presence-empty,
  .navbar-presence-more {
    color: #9ca3af;
  }

  .navbar-presence-footer {
    border-color: #374151;
  }
}

/* ========================================
   Federated User Lookup Component
   ======================================== */

.federated-lookup {
  width: 100%;
}

.federated-lookup-search {
  display: flex;
  gap: 0.5rem;
}

.federated-lookup-input {
  flex: 1;
  padding: 0.625rem 0.875rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.federated-lookup-input:focus {
  border-color: #14b8a6;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}

.federated-lookup-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: #14b8a6;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.federated-lookup-btn:hover {
  background: #0d9488;
}

.federated-lookup-btn:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

.federated-lookup-results {
  margin-top: 1rem;
}

.federated-lookup-loading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 8px;
  color: #64748b;
  font-size: 0.875rem;
}

.federated-lookup-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-top-color: #14b8a6;
  border-radius: 50%;
  animation: federated-spin 0.8s linear infinite;
}

.federated-lookup-spinner-small {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: federated-spin 0.8s linear infinite;
}

@keyframes federated-spin {
  to { transform: rotate(360deg); }
}

.federated-lookup-error {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #dc2626;
  font-size: 0.875rem;
}

.federated-lookup-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.federated-lookup-user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.federated-lookup-user-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #8b5cf6, #14b8a6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.federated-lookup-user-details {
  display: flex;
  flex-direction: column;
}

.federated-lookup-user-name {
  font-weight: 600;
  color: #1e293b;
  font-size: 0.9375rem;
}

.federated-lookup-user-village {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: #64748b;
  font-size: 0.8125rem;
}

.federated-lookup-actions {
  display: flex;
  gap: 0.5rem;
}

.federated-lookup-action-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.federated-lookup-call-btn {
  background: #14b8a6;
  color: white;
}

.federated-lookup-call-btn:hover {
  background: #0d9488;
}

.federated-lookup-add-btn {
  background: #e2e8f0;
  color: #475569;
}

.federated-lookup-add-btn:hover {
  background: #cbd5e1;
}

.federated-lookup-add-btn.federated-lookup-success {
  background: #22c55e;
  color: white;
}

.federated-lookup-action-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .federated-lookup-input {
    background: #1f2937;
    border-color: #374151;
    color: #f9fafb;
  }

  .federated-lookup-input:focus {
    border-color: #14b8a6;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2);
  }

  .federated-lookup-loading {
    background: #1f2937;
    color: #9ca3af;
  }

  .federated-lookup-spinner {
    border-color: #374151;
    border-top-color: #14b8a6;
  }

  .federated-lookup-error {
    background: #450a0a;
    border-color: #7f1d1d;
    color: #fca5a5;
  }

  .federated-lookup-user {
    background: #1f2937;
    border-color: #374151;
  }

  .federated-lookup-user-name {
    color: #f9fafb;
  }

  .federated-lookup-user-village {
    color: #9ca3af;
  }

  .federated-lookup-add-btn {
    background: #374151;
    color: #e5e7eb;
  }

  .federated-lookup-add-btn:hover {
    background: #4b5563;
  }
}
