/* ============ CALL UI — Clean Rail matched ============ */

/* Discord-style call dock: call takes top portion, chat continues below */
.call-dock {
  flex-shrink: 0;
  height: 50%;
  max-height: 420px;
  min-height: 280px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-2);
}
.call-dock > .active-call {
  flex: 1;
  min-height: 0;
}
.call-dock .call-topbar { padding: 8px 14px; }
.call-dock .call-stage { padding: 10px; }
.call-dock .grid { gap: 8px; }
.call-dock .participant-tile { border-radius: 10px; }
.call-dock .audio-ring .avatar.lg { width: 52px; height: 52px; font-size: 20px; }
.call-dock .participant-meta { padding: 4px 8px; font-size: 11px; bottom: 6px; left: 6px; right: 6px; }
.call-dock .participant-name { font-size: 11px; }
.call-dock .pi { width: 18px; height: 18px; }
/* When docked, compact the controls */
.call-dock .call-controls { padding: 8px; gap: 8px; }
.call-dock .cc-btn { width: 36px; height: 36px; border-radius: 10px; }
.call-dock .cc-btn.hangup { width: 54px; }
.call-dock .ss-content { padding: 8px; gap: 4px; }
.call-dock .ss-line { height: 4px; }
.call-dock .ss-block { height: 20px; }
.call-dock .ss-badge { font-size: 9px; padding: 3px 7px; }

/* Screen switcher pill (top-right of window) */
.screen-switcher {
  position: absolute;
  top: 52px;
  right: 20px;
  z-index: 50;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 11px;
}
.screen-switcher button {
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--fg-muted);
  font-weight: 500;
}
.screen-switcher button.active { background: var(--accent); color: #fff; }

/* Call stage overlay */
.call-screen {
  position: absolute;
  inset: 38px 0 0 0; /* below window bar */
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* === Incoming Call === */
.incoming-call {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 30% 20%, rgba(79,70,229,0.15), transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(109,115,255,0.1), transparent 50%),
    var(--bg);
}
.incoming-card {
  width: 420px;
  padding: 40px 32px 28px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.1);
}
.variant-clean.dark .incoming-card { box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.incoming-ringing {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-muted);
  font-weight: 600;
}
.incoming-avatar {
  margin: 22px auto 18px;
  width: 112px; height: 112px;
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.incoming-avatar .avatar.lg {
  width: 96px; height: 96px;
  font-size: 40px;
  font-weight: 700;
  border: 3px solid var(--bg-3);
}
.pulse-ring {
  position: absolute;
  inset: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  opacity: 0;
  animation: pulseRing 2s ease-out infinite;
}
.pulse-ring.d2 { animation-delay: 1s; }
@keyframes pulseRing {
  0% { transform: scale(0.85); opacity: 0.6; }
  100% { transform: scale(1.25); opacity: 0; }
}
.incoming-name {
  font-size: 24px;
  font-weight: 700;
  font-family: 'Outfit', 'Inter', sans-serif;
  letter-spacing: -0.02em;
}
.incoming-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--fg-muted);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.incoming-actions {
  margin-top: 28px;
  display: flex;
  gap: 12px;
  justify-content: center;
}
.incoming-btn {
  flex: 1;
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s;
}
.incoming-btn.decline {
  background: transparent;
  color: #dc2626;
  border: 1px solid rgba(220,38,38,0.3);
}
.variant-clean.dark .incoming-btn.decline { color: #fb7185; border-color: rgba(251,113,133,0.3); }
.incoming-btn.decline:hover { background: rgba(220,38,38,0.08); }
.incoming-btn.accept {
  background: #16a34a;
  color: #fff;
  box-shadow: 0 4px 14px rgba(22,163,74,0.3);
}
.incoming-btn.accept:hover { background: #15803d; }

/* === Active Call === */
.active-call {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
}
.call-topbar {
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--bg-3);
}
.call-topbar-left { display: flex; flex-direction: column; gap: 2px; }
.call-title {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 14px;
}
.call-dot { opacity: 0.4; }
.call-duration { font-variant-numeric: tabular-nums; color: var(--fg-muted); font-size: 13px; }
.call-e2ee {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: #16a34a; font-weight: 500;
}
.variant-clean.dark .call-e2ee { color: #4ade80; }
.call-topbar-right { display: flex; gap: 4px; }

.call-stage {
  flex: 1;
  padding: 16px;
  overflow: hidden;
  display: flex;
}

/* Participant tiles */
.participant-tile {
  position: relative;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}
.participant-tile:hover { border-color: var(--accent); }
.participant-tile.speaking { border-color: #16a34a; box-shadow: 0 0 0 2px rgba(22,163,74,0.25); }
.participant-tile.focused { border-color: var(--accent); }
.participant-tile.small { min-width: 140px; }

.participant-audio, .participant-video {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}
.audio-ring {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.audio-ring .avatar.lg {
  width: 72px; height: 72px;
  font-size: 28px;
  font-weight: 700;
}
.participant-tile.small .audio-ring .avatar.lg { width: 44px; height: 44px; font-size: 18px; }
.audio-ring.pulse::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid #22c55e;
  animation: audioPulse 1.3s ease-out infinite;
}
@keyframes audioPulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.3); opacity: 0; }
}

.video-stub {
  width: 100%; height: 100%;
  background:
    radial-gradient(circle at 30% 40%, rgba(109,115,255,0.2), transparent 60%),
    linear-gradient(135deg, #1a1a24, #0A0A0F);
  display: flex;
  align-items: center;
  justify-content: center;
}
.variant-clean:not(.dark) .video-stub { background: linear-gradient(135deg, #e0e7ff, #c7d2fe); }

/* Screenshare stub */
.screenshare-stub {
  width: 100%; height: 100%;
  position: relative;
  background: #0A0A0F;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.variant-clean:not(.dark) .screenshare-stub { background: #111118; }
.ss-window {
  width: 90%; height: 85%;
  background: #1a1a24;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
}
.ss-chrome {
  height: 20px;
  background: #252533;
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 4px;
}
.ss-chrome span { width: 6px; height: 6px; border-radius: 50%; background: #3A3A4D; }
.ss-content { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.ss-line { height: 6px; background: #3A3A4D; border-radius: 3px; }
.ss-block { height: 40px; background: rgba(109,115,255,0.25); border-radius: 4px; margin: 4px 0; }
.participant-tile.small .ss-content { padding: 6px; gap: 3px; }
.participant-tile.small .ss-line { height: 3px; }
.participant-tile.small .ss-block { height: 14px; }
.ss-badge {
  position: absolute;
  top: 12px; left: 12px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  color: #fff;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 500;
  display: flex; align-items: center; gap: 5px;
}
.participant-tile.small .ss-badge { display: none; }

.participant-meta {
  position: absolute;
  bottom: 8px; left: 8px; right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  color: #fff;
}
.participant-tile.small .participant-meta { padding: 4px 8px; font-size: 10px; }
.participant-name {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.e2ee-dot { opacity: 0.7; display: flex; }
.participant-icons { display: flex; gap: 4px; }
.pi {
  width: 20px; height: 20px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.pi.muted { background: rgba(220,38,38,0.8); }
.pi.sharing { background: rgba(34,197,94,0.8); }

/* Grid layouts */
.grid {
  display: grid;
  gap: 10px;
  width: 100%; height: 100%;
}
.grid-1 { grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
.grid-5, .grid-6 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); }

/* Focus layout */
.focus-layout {
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.focus-main { flex: 1; min-height: 0; }
.focus-main .participant-tile { height: 100%; }
.focus-strip {
  height: 110px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
}
.focus-strip .participant-tile { min-width: 160px; height: 100%; }

/* Fullscreen layout (hides topbar, pure cinema) */
.active-call.mode-fullscreen .call-topbar { display: none; }
.active-call.mode-fullscreen .call-stage { padding: 0; position: relative; }
.fullscreen-layout {
  width: 100%; height: 100%;
  position: relative;
}
.fullscreen-layout > .participant-tile { width: 100%; height: 100%; border-radius: 0; border: none; }
.fs-strip {
  position: absolute;
  bottom: 90px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 180px;
}
.fs-strip .participant-tile { height: 100px; backdrop-filter: blur(20px); background: rgba(0,0,0,0.4); }

/* Call controls bar */
.call-controls {
  padding: 16px;
  display: flex;
  justify-content: center;
  gap: 10px;
  background: var(--bg-3);
  border-top: 1px solid var(--line);
}
.active-call.mode-fullscreen .call-controls {
  position: absolute;
  bottom: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(10,10,15,0.7);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: 10px;
}
.cc-btn {
  width: 48px; height: 48px;
  border-radius: 14px;
  background: var(--bg-2);
  color: var(--fg);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  border: 1px solid var(--line);
}
.cc-btn:hover { background: var(--bg); transform: translateY(-1px); }
.cc-btn.sm { width: 32px; height: 32px; border-radius: 8px; }
.cc-btn.active-brand { background: var(--accent); color: #fff; border-color: var(--accent); }
.cc-btn.active-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.cc-btn.hangup { background: #dc2626; color: #fff; border-color: #dc2626; width: 72px; }
.cc-btn.hangup:hover { background: #b91c1c; }

.active-call.mode-fullscreen .cc-btn { background: rgba(255,255,255,0.08); color: #fff; border-color: rgba(255,255,255,0.1); }
.active-call.mode-fullscreen .cc-btn.active-brand { background: var(--accent); border-color: var(--accent); }
.active-call.mode-fullscreen .cc-btn.active-danger { background: #dc2626; border-color: #dc2626; }
.active-call.mode-fullscreen .cc-btn.hangup { background: #dc2626; border-color: #dc2626; }

/* Exit fullscreen button */
.fs-exit {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  padding: 8px 14px;
  background: rgba(10,10,15,0.7);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.fs-exit:hover { background: rgba(10,10,15,0.9); transform: translateY(-1px); }

/* Fullscreen hint — subtle, fades in then out */
.fs-hint {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  background: rgba(10,10,15,0.6);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: rgba(255,255,255,0.7);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  z-index: 10;
  animation: fsHintFade 3.5s ease-out forwards;
  pointer-events: none;
}
@keyframes fsHintFade {
  0% { opacity: 0; transform: translate(-50%, -6px); }
  15%, 75% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -6px); }
}

/* PiP in chat view */
.pip-call {
  position: absolute;
  bottom: 82px; right: 20px;
  width: 260px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-3);
  border: 1px solid var(--accent);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2), 0 0 0 3px rgba(79,70,229,0.15);
  cursor: pointer;
  z-index: 30;
  animation: slideInCall 0.4s cubic-bezier(0.22,1,0.36,1);
  transition: transform 0.15s;
}
.pip-call:hover { transform: translateY(-2px); }
.pip-preview {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.pip-preview .ss-window.mini {
  width: 36px; height: 28px;
  background: #1a1a24;
  border-radius: 4px;
}
.pip-info { flex: 1; min-width: 0; }
.pip-title { font-weight: 600; font-size: 13px; }
.pip-sub {
  font-size: 11px; color: var(--fg-muted);
  margin-top: 2px;
  display: flex; align-items: center; gap: 5px;
}
.live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #ef4444;
  animation: liveDotPulse 1.5s ease-in-out infinite;
}
@keyframes liveDotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.pip-hangup {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
}
