/* ==========================================================================
   CALL.CSS — WebRTC Audio/Video Call Overlays & Control Interface
   ========================================================================== */

/* Floating Incoming Call Popup (Global Overlay) */
.incoming-call-popup {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 3000;
  width: 360px;
  background: rgba(22, 28, 40, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), var(--shadow-glow);
  display: none;
  flex-direction: column;
  gap: 1rem;
  animation: pulseIncoming 1.8s infinite ease-in-out;
}

.incoming-call-popup.active {
  display: flex;
}

@keyframes pulseIncoming {
  0%, 100% { border-color: rgba(99, 102, 241, 0.4); box-shadow: 0 0 20px rgba(99, 102, 241, 0.3); }
  50% { border-color: rgba(6, 182, 212, 0.8); box-shadow: 0 0 35px rgba(6, 182, 212, 0.6); }
}

.incoming-call-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.incoming-call-type-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.incoming-call-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.btn-accept-call {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border: none;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.btn-decline-call {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #ffffff;
  border: none;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}

/* Fullscreen Active Call Overlay */
.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 2500;
  background: #06080d;
  display: none;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.call-overlay.active {
  display: flex;
}

/* Call Header / Info Bar */
.call-top-bar {
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
}

.call-peer-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.call-timer {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

/* Video Stage Area */
.video-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #090c15;
  display: flex;
  align-items: center;
  justify-content: center;
}

#remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #090c15;
}

#local-video-wrapper {
  position: absolute;
  bottom: 6rem;
  right: 2rem;
  width: 180px;
  height: 240px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 2px solid var(--border-glow);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  background: var(--bg-card);
  transition: all var(--transition-normal);
}

#local-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror local video preview */
}

/* Audio Call Stage Layout */
.audio-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  z-index: 5;
}

.audio-avatar-glow {
  width: 120px;
  height: 120px;
  border-radius: var(--radius-full);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.audio-avatar-glow::before {
  content: '';
  position: absolute;
  inset: -15px;
  border-radius: var(--radius-full);
  background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
  animation: pulseGlow 2s infinite ease-in-out;
}

.audio-avatar-glow img {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 3px solid var(--primary);
}

/* Call Control Bar (Bottom Floating Dock) */
.call-control-bar {
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  z-index: 30;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
}

.call-control-btn {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-subtle);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  backdrop-filter: blur(12px);
  position: relative;
}

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

.call-control-btn.muted,
.call-control-btn.off {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--danger);
  color: var(--danger);
}

.call-control-btn.end-call-btn {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border: none;
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
}

.call-control-btn.end-call-btn:hover {
  transform: scale(1.1);
}

.call-control-btn svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* Volume Control Popup Drawer */
.volume-popover {
  position: absolute;
  bottom: 80px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 0.75rem;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-lg);
}

.volume-popover.active {
  display: flex;
}

.volume-slider {
  writing-mode: bt-lr;
  -webkit-appearance: slider-vertical;
  width: 8px;
  height: 100px;
  accent-color: var(--primary);
}

/* Responsive Mobile Screen Call Adaptations */
@media (max-width: 768px) {
  .incoming-call-popup {
    width: calc(100% - 2rem);
    top: 1rem;
    right: 1rem;
    left: 1rem;
  }
  
  #local-video-wrapper {
    width: 120px;
    height: 160px;
    bottom: 5.5rem;
    right: 1rem;
  }

  .call-control-bar {
    gap: 0.75rem;
    padding: 1rem;
  }

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