/* ═══════════════════════════════════════════════════════════════════════════
   call.css  –  WebRTC audio & video call UI styles.
   Follows the design tokens from app.css (dark theme, accent colours, radii).
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Call overlay (full-screen, above everything) ───────────────────────── */

.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-base, #0D0D1A);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.call-overlay.hidden {
  display: none;
}

/* ── Call screen container ──────────────────────────────────────────────── */

.call-screen {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* ── Avatar (audio calls & ringing states) ──────────────────────────────── */

.call-screen__avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent, #6C63FF), var(--teal, #3ECFCF));
  position: relative;
  z-index: 2;
  overflow: hidden;
}

.call-screen__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Pulse ring animation for ringing state */
.call-screen__avatar--ringing::before,
.call-screen__avatar--ringing::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--accent, #6C63FF);
  animation: pulse-ring 1.5s ease-out infinite;
  z-index: -1;
}

.call-screen__avatar--ringing::after {
  animation-delay: 0.75s;
}

@keyframes pulse-ring {
  0% {
    transform: scale(1);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

/* Pulse animation for connected audio call */
.call-screen__avatar--connected {
  animation: avatar-pulse 2s ease-in-out infinite;
}

@keyframes avatar-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(108, 99, 255, 0.4); }
  50%      { box-shadow: 0 0 0 20px rgba(108, 99, 255, 0); }
}

/* ── Info text (name, status) ───────────────────────────────────────────── */

.call-screen__info {
  text-align: center;
  margin-top: 24px;
  z-index: 2;
}

.call-screen__name {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary, #E8E6F0);
}

.call-screen__status {
  font-size: 0.9rem;
  color: var(--text-secondary, #8B8A9A);
  margin-top: 6px;
}

.call-screen__status--connecting {
  color: var(--accent, #6C63FF);
}

/* ── Timer ───────────────────────────────────────────────────────────────── */

.call-screen__timer {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-primary, #E8E6F0);
  font-variant-numeric: tabular-nums;
  z-index: 10;
  padding: 6px 16px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-md, 12px);
  backdrop-filter: blur(8px);
}

/* ── Video elements ─────────────────────────────────────────────────────── */

.call-screen__remote-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  z-index: 0;
}

.call-screen__local-video {
  position: absolute;
  top: 80px;
  right: 20px;
  width: 120px;
  height: 170px;
  border-radius: var(--radius-md, 12px);
  object-fit: cover;
  background: #1A1A2E;
  z-index: 10;
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,0.5));
}

/* Mirror front camera (natural selfie view like WhatsApp) */
.call-screen__local-video--mirror {
  transform: scaleX(-1);
}

/* Video-off placeholder in local PiP */
.call-screen__local-video-off {
  position: absolute;
  top: 80px;
  right: 20px;
  width: 120px;
  height: 170px;
  border-radius: var(--radius-md, 12px);
  background: var(--bg-elevated, #1A1A2E);
  z-index: 10;
  border: 2px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #4A4960);
}

/* ── Control bar ────────────────────────────────────────────────────────── */

.call-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 30px 20px;
  padding-bottom: max(30px, env(safe-area-inset-bottom, 30px));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  z-index: 20;
}

.call-control-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transition: background 0.18s ease, transform 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

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

.call-control-btn:active {
  transform: scale(0.92);
}

.call-control-btn--active {
  background: rgba(255, 255, 255, 0.95);
  color: #1A1A2E;
}

.call-control-btn--active:hover {
  background: rgba(255, 255, 255, 0.85);
}

.call-control-btn--end {
  width: 64px;
  height: 64px;
  background: #EF4444;
  color: #fff;
}

.call-control-btn--end:hover {
  background: #DC2626;
}

/* ── Incoming call layout ───────────────────────────────────────────────── */

.call-incoming {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
}

.call-incoming__type {
  font-size: 0.85rem;
  color: var(--text-secondary, #8B8A9A);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 32px;
}

.call-incoming__actions {
  display: flex;
  align-items: center;
  gap: 60px;
  margin-top: 60px;
}

.call-incoming__action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.call-incoming__action-label {
  font-size: 0.8rem;
  color: var(--text-secondary, #8B8A9A);
}

.call-control-btn--accept {
  width: 64px;
  height: 64px;
  background: #22C55E;
  color: #fff;
}

.call-control-btn--accept:hover {
  background: #16A34A;
}

.call-control-btn--decline {
  width: 64px;
  height: 64px;
  background: #EF4444;
  color: #fff;
}

.call-control-btn--decline:hover {
  background: #DC2626;
}

/* ── Call header buttons in chat header ─────────────────────────────────── */

.call-btn {
  color: var(--accent, #6C63FF) !important;
  transition: color 0.18s ease, opacity 0.18s ease;
}

.call-btn:hover {
  color: var(--teal, #3ECFCF) !important;
}

/* ── Encryption badge (WhatsApp-style) ──────────────────────────────────── */

.call-screen__e2e {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--text-muted, #4A4960);
  z-index: 10;
  white-space: nowrap;
}

/* ── Ended call feedback ────────────────────────────────────────────────── */

.call-ended {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
}

.call-ended__reason {
  font-size: 1.1rem;
  color: var(--text-secondary, #8B8A9A);
}

/* ── Responsive tweaks ──────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .call-screen__local-video,
  .call-screen__local-video-off {
    width: 90px;
    height: 130px;
    top: 60px;
    right: 12px;
  }

  .call-controls {
    gap: 16px;
    padding: 24px 16px;
  }

  .call-control-btn {
    width: 50px;
    height: 50px;
  }

  .call-control-btn--end,
  .call-control-btn--accept,
  .call-control-btn--decline {
    width: 58px;
    height: 58px;
  }

  .call-screen__timer {
    top: 40px;
  }
}
