/* VoIP web overlay — modal-style fullscreen call UI.
   Активен когда data-state != 'idle'. */

#voip-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #1B743E 0%, #103D22 100%);
  color: #fff;
  z-index: 10000;
  display: none;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
}
#voip-overlay.is-active { display: flex; }

.voip-video-stage {
  position: relative;
  flex: 1;
  background: #000;
  overflow: hidden;
}
#voip-remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.voip-local-pip {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 120px;
  height: 160px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0,0,0,.4);
  background: #000;
}
#voip-local-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);  /* mirror — для front camera */
}

/* Когда incoming или audio-only — скрываем video-stage, показываем плашку. */
#voip-overlay[data-state="ringing-in"] .voip-video-stage,
#voip-overlay[data-state="connecting"] .voip-video-stage {
  flex: 0 0 0;
  height: 0;
}

.voip-info {
  text-align: center;
  padding: 48px 24px 16px;
}
.voip-info__avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 600;
  margin-bottom: 14px;
}
.voip-info__name {
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 4px;
}
.voip-info__status {
  font-size: 15px;
  opacity: 0.85;
  margin: 0;
}
.voip-info__duration {
  display: block;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

.voip-controls {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  padding: 24px 16px 36px;
  gap: 12px;
}
.voip-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.voip-btn__circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.voip-btn__circle svg,
.voip-btn__circle .material-symbols-outlined {
  font-size: 28px;
  color: #fff;
}
.voip-btn:hover .voip-btn__circle { background: rgba(255,255,255,.28); }
.voip-btn--danger .voip-btn__circle { background: #d23a3a; }
.voip-btn--accept .voip-btn__circle { background: #1ea651; }
.voip-btn.is-on .voip-btn__circle { background: #ffb74d; color: #000; }
.voip-btn.is-on .voip-btn__circle svg { color: #000; }
.voip-btn__label { font-size: 12px; opacity: 0.85; }

/* ringing-in: показываем только Accept/Decline */
#voip-overlay[data-state="ringing-in"] .voip-controls-active,
#voip-overlay[data-state="ringing-in"] .voip-controls-video,
#voip-overlay[data-state="connecting"] .voip-controls-incoming,
#voip-overlay[data-state="connecting"] .voip-controls-video,
#voip-overlay[data-state="connected"] .voip-controls-incoming {
  display: none;
}
#voip-overlay[data-state="ringing-in"] .voip-controls-incoming,
#voip-overlay[data-state="connecting"] .voip-controls-active,
#voip-overlay[data-state="connected"] .voip-controls-active {
  display: flex;
}
.voip-controls-video { display: none; }
/* Включается JS если _isVideoCall=true */

/* Кнопки звонка в карточке объявления */
.detail-call-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.detail-call-actions .btn {
  flex: 1 1 0;
}
.btn--call {
  border: 1.5px solid #43a047;
  color: #2e7d32;
  background: rgba(76,175,80,0.05);
}
.btn--call:hover { background: rgba(76,175,80,0.15); }

/* Toggle VoIP в header — chip */
.header-voip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.06);
  color: inherit;
  font-size: 13px;
  cursor: pointer;
}
.header-voip-toggle[data-enabled="1"] {
  background: rgba(30,166,81,.15);
  border-color: rgba(30,166,81,.6);
  color: #1ea651;
}

/* Mobile */
@media (max-width: 640px) {
  .voip-info { padding-top: 32px; }
  .voip-info__avatar { width: 78px; height: 78px; font-size: 32px; }
  .voip-info__name { font-size: 20px; }
  .voip-local-pip { width: 96px; height: 130px; top: 12px; right: 12px; }
}

/* Full-screen режим (toggle через кнопку voip-toggle-fullscreen). */
.voip-toggle-fullscreen {
  position: absolute; top: 12px; right: 12px;
  background: rgba(0,0,0,0.5); color: #fff;
  border: none; border-radius: 50%; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 2;
}
.voip-toggle-fullscreen:hover { background: rgba(0,0,0,0.7); }
#voip-overlay.voip-overlay--fullscreen {
  inset: 0 !important;
  width: 100vw !important; height: 100vh !important;
  max-width: 100vw !important; max-height: 100vh !important;
  border-radius: 0 !important;
  z-index: 10000;
}
#voip-overlay.voip-overlay--fullscreen .voip-video-stage {
  flex: 1; min-height: 0;
}
#voip-overlay.voip-overlay--fullscreen #voip-remote-video {
  width: 100% !important; height: 100% !important; object-fit: cover;
}
#voip-overlay.voip-overlay--fullscreen .voip-local-pip {
  position: absolute; top: 80px; right: 16px;
  width: 140px; height: 200px;
}
#voip-overlay.voip-overlay--fullscreen .voip-controls {
  padding: 24px; gap: 20px;
}
#voip-overlay.voip-overlay--fullscreen .voip-btn__circle {
  width: 64px !important; height: 64px !important;
}
