/* ═══════════════════════════════════════════
   WP Messenger — Audio Calls UI
   ═══════════════════════════════════════════ */

/* ── Активный звонок (полноэкранный оверлей) ── */
#call-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(4, 8, 22, 0.97);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  animation: callFadeIn .25s ease;
}

#call-overlay.show { display: flex; }

@keyframes callFadeIn {
  from { opacity: 0; transform: scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* Аватар */
#call-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  margin-bottom: 20px;
  border: 3px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 0 0 6px rgba(56, 189, 248, 0.08), 0 0 0 12px rgba(56, 189, 248, 0.04);
  animation: callAvaRing 2.2s ease-out infinite;
}

@keyframes callAvaRing {
  0%   { box-shadow: 0 0 0 4px rgba(56,189,248,.12), 0 0 0 10px rgba(56,189,248,.04); }
  50%  { box-shadow: 0 0 0 8px rgba(56,189,248,.16), 0 0 0 18px rgba(56,189,248,.05); }
  100% { box-shadow: 0 0 0 4px rgba(56,189,248,.12), 0 0 0 10px rgba(56,189,248,.04); }
}

#call-avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

#call-avatar span {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  font-size: 2rem; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, rgba(56,130,255,.3), rgba(124,58,237,.3));
}

#call-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: #e8f0ff;
  margin-bottom: 6px;
  letter-spacing: -.02em;
}

#call-status {
  font-size: .85rem;
  color: rgba(140, 180, 255, .6);
  min-height: 20px;
}

#call-timer {
  font-size: 1.1rem;
  font-weight: 500;
  color: rgba(56, 189, 248, .85);
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  min-height: 28px;
  margin-top: 4px;
}

/* Кнопки управления */
.call-controls {
  display: flex;
  gap: 24px;
  margin-top: 48px;
  align-items: center;
}

.call-ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: transform .15s;
}

.call-ctrl-btn:active { transform: scale(.9); }

.call-ctrl-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .12);
  transition: background .2s, border-color .2s, box-shadow .2s;
}

.call-ctrl-btn:hover .call-ctrl-icon {
  background: rgba(255, 255, 255, .16);
}

.call-ctrl-btn.active .call-ctrl-icon {
  background: rgba(56, 189, 248, .18);
  border-color: rgba(56, 189, 248, .4);
}

.call-ctrl-btn svg {
  width: 22px; height: 22px;
  stroke: rgba(255, 255, 255, .85);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.call-ctrl-btn.active svg { stroke: #38bdf8; }

.call-btn-label {
  font-size: .68rem;
  color: rgba(180, 210, 255, .6);
  font-family: inherit;
}

/* Кнопка завершения */
#call-btn-end .call-ctrl-icon {
  background: #dc2626;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(220, 38, 38, .45);
  width: 68px; height: 68px;
}

#call-btn-end:hover .call-ctrl-icon {
  background: #b91c1c;
  box-shadow: 0 6px 22px rgba(220, 38, 38, .55);
}

#call-btn-end svg {
  width: 26px; height: 26px;
  stroke: #fff;
  transform: rotate(135deg);
}

/* ── Входящий звонок ─────────────────────────── */
#incoming-overlay {
  position: fixed;
  top: max(16px, env(safe-area-inset-top, 16px));
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  z-index: 9100;
  width: min(360px, calc(100vw - 32px));
  background: rgba(8, 16, 38, 0.97);
  border: 1px solid rgba(56, 130, 255, .2);
  border-radius: 22px;
  padding: 18px 20px;
  backdrop-filter: blur(28px) saturate(1.5);
  -webkit-backdrop-filter: blur(28px) saturate(1.5);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255,255,255,.04);
  transition: transform .35s cubic-bezier(.22, 1, .36, 1), opacity .25s ease;
  opacity: 0;
  pointer-events: none;
}

#incoming-overlay.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.incoming-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

#incoming-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid rgba(56, 189, 248, .3);
}

#incoming-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

#incoming-avatar span {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  font-size: 1.2rem; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, rgba(56,130,255,.3), rgba(124,58,237,.3));
}

#incoming-name {
  font-size: 1rem;
  font-weight: 700;
  color: #e8f0ff;
}

#incoming-sub {
  font-size: .78rem;
  color: rgba(140, 180, 255, .55);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

#incoming-sub::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, .6);
  animation: incomingPulse 1s ease infinite;
}

@keyframes incomingPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

.incoming-actions {
  display: flex;
  gap: 10px;
}

.incoming-btn {
  flex: 1;
  border: none;
  border-radius: 14px;
  padding: 12px;
  font-size: .88rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: opacity .15s, transform .12s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.incoming-btn:active { transform: scale(.95); }

#incoming-btn-accept {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  box-shadow: 0 4px 16px rgba(34, 197, 94, .35);
}

#incoming-btn-accept:hover { opacity: .9; }

#incoming-btn-decline {
  background: rgba(220, 38, 38, .15);
  color: rgba(252, 165, 165, .9);
  border: 1px solid rgba(220, 38, 38, .25);
}

#incoming-btn-decline:hover { background: rgba(220, 38, 38, .22); }

.incoming-btn svg {
  width: 16px; height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

#incoming-btn-decline svg { transform: rotate(135deg); }

/* ── Кнопка звонка в шапке чата ─────────────── */
#call-btn-header {
  color: rgba(140, 180, 230, .65);
  transition: all .16s;
}

#call-btn-header:hover {
  color: #22c55e;
  background: rgba(34, 197, 94, .1);
}

#call-btn-header.in-call {
  color: #22c55e;
  background: rgba(34, 197, 94, .12);
  border: 1px solid rgba(34, 197, 94, .25) !important;
  animation: callBtnPulse 2s ease infinite;
}

@keyframes callBtnPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,.3); }
  50%       { box-shadow: 0 0 0 6px rgba(34,197,94,.0); }
}

/* Скрыть кнопку в групповых чатах */
body.wpm-room-group #call-btn-header { display: none !important; }

/* ── Адаптив ─────────────────────────────────── */
@media (max-width: 680px) {
  .call-controls { gap: 16px; }
  .call-ctrl-icon { width: 50px; height: 50px; }
  #call-btn-end .call-ctrl-icon { width: 60px; height: 60px; }
  #call-name { font-size: 1.15rem; }
}
