/* ==========================================================================
   USMS Calls CSS
   File: public/assets/css/calls.css
   ========================================================================== */

.call-overlay {
  position: fixed;
  z-index: var(--usms-z-call);
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(0, 168, 132, 0.18), transparent 36%),
    radial-gradient(circle at bottom right, rgba(83, 189, 235, 0.14), transparent 36%),
    rgba(3, 13, 18, 0.92);
  backdrop-filter: blur(24px);
}

.call-window {
  width: min(980px, 100%);
  height: min(720px, calc(100vh - 48px));
  overflow: hidden;
  display: grid;
  grid-template-rows: 72px 1fr 94px;
  border: 1px solid rgba(134, 150, 160, 0.18);
  border-radius: 30px;
  background:
    linear-gradient(180deg, rgba(17, 27, 33, 0.96), rgba(11, 20, 26, 0.98)),
    radial-gradient(circle at 50% 0%, rgba(0, 168, 132, 0.18), transparent 34%);
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.55);
}

.call-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  border-bottom: 1px solid rgba(134, 150, 160, 0.12);
  background: rgba(17, 27, 33, 0.72);
  backdrop-filter: blur(18px);
}

.call-header h3 {
  margin: 0;
  color: #e9edef;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.call-header p {
  margin: 5px 0 0;
  color: #8696a0;
  font-size: 13px;
}

.call-video-area {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, rgba(0, 168, 132, 0.08), transparent 38%),
    linear-gradient(135deg, #071016, #0b141a);
}

.call-video-area::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.13;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 22px 22px, rgba(255, 255, 255, 0.22) 1px, transparent 1px);
  background-size: 34px 34px;
}

#remoteVideo {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #071016;
}

#remoteVideo:empty,
#remoteVideo:not([srcObject]) {
  background: transparent;
}

#localVideo {
  position: absolute;
  z-index: 3;
  right: 18px;
  bottom: 18px;
  width: 210px;
  height: 150px;
  object-fit: cover;
  border: 2px solid rgba(233, 237, 239, 0.14);
  border-radius: 22px;
  background: #111b21;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
}

.audio-call-avatar {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}

.audio-call-avatar img {
  width: 138px;
  height: 138px;
  border-radius: 999px;
  border: 4px solid rgba(0, 168, 132, 0.24);
  box-shadow:
    0 0 0 12px rgba(0, 168, 132, 0.08),
    0 0 0 26px rgba(0, 168, 132, 0.035),
    0 22px 60px rgba(0, 0, 0, 0.35);
}

.audio-call-avatar h3 {
  margin: 10px 0 0;
  color: #e9edef;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.audio-call-avatar p {
  margin: 0;
  color: #8696a0;
  font-size: 15px;
}

.call-actions {
  min-height: 94px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 18px;
  border-top: 1px solid rgba(134, 150, 160, 0.12);
  background: rgba(17, 27, 33, 0.76);
  backdrop-filter: blur(18px);
}

.call-control {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: #e9edef;
  background: rgba(134, 150, 160, 0.16);
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease;
}

.call-control span {
  display: block;
  line-height: 1;
  font-size: 22px;
}

.call-control:hover {
  transform: translateY(-1px);
  background: rgba(134, 150, 160, 0.24);
}

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

.call-control.active {
  color: #031d17;
  background: #06cf9c;
  box-shadow: 0 16px 36px rgba(6, 207, 156, 0.22);
}

.call-control.off {
  color: #ff5c75;
  background: rgba(255, 92, 117, 0.15);
}

.call-control.danger {
  color: #fff;
  background: #ff3b55;
  box-shadow: 0 16px 36px rgba(255, 59, 85, 0.26);
}

.call-control.danger:hover {
  background: #ff2443;
}

.incoming-call {
  position: fixed;
  z-index: calc(var(--usms-z-call) + 10);
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 13, 18, 0.72);
  backdrop-filter: blur(22px);
}

.incoming-call-card {
  position: relative;
  width: min(380px, 100%);
  overflow: hidden;
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 34px 28px 28px;
  border: 1px solid rgba(134, 150, 160, 0.18);
  border-radius: 30px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(0, 168, 132, 0.22), transparent 42%),
    rgba(17, 27, 33, 0.96);
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.5);
}

.incoming-call-pulse {
  position: absolute;
  top: 46px;
  width: 132px;
  height: 132px;
  border-radius: 999px;
  background: rgba(0, 168, 132, 0.16);
  animation: usmsIncomingPulse 1.45s ease-in-out infinite;
}

.incoming-call-card img {
  position: relative;
  z-index: 1;
  width: 118px;
  height: 118px;
  border-radius: 999px;
  border: 4px solid rgba(0, 168, 132, 0.22);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

.incoming-call-card h3 {
  position: relative;
  z-index: 1;
  margin: 12px 0 0;
  color: #e9edef;
  font-size: 25px;
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.incoming-call-card p {
  position: relative;
  z-index: 1;
  margin: 0;
  color: #8696a0;
  font-size: 14px;
}

.incoming-call-actions {
  position: relative;
  z-index: 1;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}

.call-reject,
.call-accept {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  font-weight: 900;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    opacity 0.16s ease;
}

.call-reject span,
.call-accept span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.call-reject {
  background: #ff3b55;
  box-shadow: 0 14px 32px rgba(255, 59, 85, 0.28);
}

.call-accept {
  background: #00a884;
  box-shadow: 0 14px 32px rgba(0, 168, 132, 0.28);
}

.call-reject:hover,
.call-accept:hover {
  transform: translateY(-1px);
}

.call-reject:active,
.call-accept:active {
  transform: scale(0.98);
}

.call-mini {
  position: fixed;
  z-index: var(--usms-z-call);
  right: 20px;
  bottom: 20px;
  width: 280px;
  overflow: hidden;
  border: 1px solid rgba(134, 150, 160, 0.18);
  border-radius: 22px;
  background: rgba(17, 27, 33, 0.96);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(20px);
}

.call-mini-header {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid rgba(134, 150, 160, 0.12);
}

.call-mini-title {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.call-mini-title strong {
  overflow: hidden;
  color: #e9edef;
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.call-mini-title span {
  color: #8696a0;
  font-size: 12px;
}

.call-mini-body {
  position: relative;
  height: 160px;
  background: #071016;
}

.call-mini-body video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.call-mini-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
}

.call-mini-actions button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: #e9edef;
  background: rgba(134, 150, 160, 0.16);
}

.call-mini-actions button.danger {
  color: #fff;
  background: #ff3b55;
}

.call-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  color: #06cf9c;
  background: rgba(6, 207, 156, 0.12);
  font-size: 12px;
  font-weight: 900;
}

.call-status-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  animation: usmsCallDot 1s ease-in-out infinite;
}

.call-status-badge.ringing {
  color: #f5c542;
  background: rgba(245, 197, 66, 0.13);
}

.call-status-badge.ended {
  color: #8696a0;
  background: rgba(134, 150, 160, 0.12);
}

.call-status-badge.missed,
.call-status-badge.rejected {
  color: #ff5c75;
  background: rgba(255, 92, 117, 0.12);
}

.call-permission-card {
  width: min(440px, calc(100% - 32px));
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 28px;
  border: 1px solid rgba(245, 197, 66, 0.28);
  border-radius: 26px;
  color: #e9edef;
  text-align: center;
  background: rgba(245, 197, 66, 0.08);
}

.call-permission-card h3 {
  color: #f5c542;
  font-size: 22px;
}

.call-permission-card p {
  color: #cfd7dc;
  font-size: 14px;
  line-height: 1.55;
}

.call-device-panel {
  position: absolute;
  z-index: 5;
  left: 18px;
  bottom: 18px;
  width: min(340px, calc(100% - 36px));
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(134, 150, 160, 0.18);
  border-radius: 18px;
  background: rgba(17, 27, 33, 0.94);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(18px);
}

.call-device-panel label {
  display: grid;
  gap: 6px;
  color: #cfd7dc;
  font-size: 12px;
  font-weight: 800;
}

.call-device-panel select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid rgba(134, 150, 160, 0.18);
  border-radius: 12px;
  color: #e9edef;
  background: #202c33;
}

.call-network-quality {
  position: absolute;
  z-index: 4;
  left: 18px;
  top: 18px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid rgba(134, 150, 160, 0.14);
  border-radius: 999px;
  color: #06cf9c;
  background: rgba(17, 27, 33, 0.72);
  backdrop-filter: blur(16px);
  font-size: 12px;
  font-weight: 900;
}

.call-network-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 13px;
}

.call-network-bars span {
  width: 3px;
  border-radius: 99px;
  background: currentColor;
}

.call-network-bars span:nth-child(1) {
  height: 5px;
}

.call-network-bars span:nth-child(2) {
  height: 8px;
}

.call-network-bars span:nth-child(3) {
  height: 11px;
}

.call-network-quality.medium {
  color: #f5c542;
}

.call-network-quality.low {
  color: #ff5c75;
}

.call-timer {
  position: absolute;
  z-index: 4;
  right: 18px;
  top: 18px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(134, 150, 160, 0.14);
  border-radius: 999px;
  color: #e9edef;
  background: rgba(17, 27, 33, 0.72);
  backdrop-filter: blur(16px);
  font-size: 12px;
  font-weight: 900;
}

.group-call-join {
  position: fixed;
  z-index: calc(var(--usms-z-call) + 5);
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 32px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(0, 168, 132, 0.26);
  border-radius: 22px;
  background: rgba(17, 27, 33, 0.94);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(20px);
}

.group-call-join-text {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.group-call-join-text strong {
  color: #e9edef;
  font-size: 14px;
}

.group-call-join-text span {
  overflow: hidden;
  color: #8696a0;
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.group-call-join-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.group-call-join-actions button {
  min-height: 38px;
  padding: 0 13px;
  border: 0;
  border-radius: 999px;
  font-weight: 900;
}

.group-call-join-actions .join {
  color: #031d17;
  background: #06cf9c;
}

.group-call-join-actions .dismiss {
  color: #e9edef;
  background: rgba(134, 150, 160, 0.14);
}

.call-history-list {
  display: grid;
  gap: 8px;
}

.call-history-item {
  min-height: 68px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 16px;
  background: transparent;
  transition: background 0.16s ease;
}

.call-history-item:hover {
  background: rgba(134, 150, 160, 0.09);
}

.call-history-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #06cf9c;
  background: rgba(6, 207, 156, 0.12);
}

.call-history-icon.missed {
  color: #ff5c75;
  background: rgba(255, 92, 117, 0.12);
}

.call-history-icon.group {
  color: #53bdeb;
  background: rgba(83, 189, 235, 0.12);
}

.call-history-content {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.call-history-content strong {
  overflow: hidden;
  color: var(--usms-text);
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.call-history-content span {
  overflow: hidden;
  color: var(--usms-muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.call-history-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.call-history-actions button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: var(--usms-muted);
  background: transparent;
}

.call-history-actions button:hover {
  color: var(--usms-text);
  background: rgba(134, 150, 160, 0.12);
}

@keyframes usmsIncomingPulse {
  0% {
    opacity: 0.82;
    transform: scale(0.84);
  }

  70% {
    opacity: 0;
    transform: scale(1.45);
  }

  100% {
    opacity: 0;
    transform: scale(1.45);
  }
}

@keyframes usmsCallDot {
  0%,
  100% {
    opacity: 0.45;
  }

  50% {
    opacity: 1;
  }
}

@media (max-width: 760px) {
  .call-overlay {
    padding: 0;
  }

  .call-window {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    grid-template-rows: 68px 1fr 92px;
  }

  .call-header {
    min-height: 68px;
    padding: 0 16px;
  }

  #localVideo {
    right: 12px;
    bottom: 12px;
    width: 128px;
    height: 176px;
    border-radius: 18px;
  }

  .call-actions {
    gap: 10px;
    padding: 14px;
  }

  .call-control {
    width: 54px;
    height: 54px;
  }

  .incoming-call-card {
    width: min(350px, 100%);
    padding: 30px 22px 24px;
  }

  .incoming-call-actions {
    gap: 10px;
  }

  .group-call-join {
    bottom: 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .group-call-join-actions {
    width: 100%;
  }

  .group-call-join-actions button {
    flex: 1;
  }
}

@media (max-width: 430px) {
  .call-header h3 {
    font-size: 18px;
  }

  .call-header p {
    font-size: 12px;
  }

  #localVideo {
    width: 108px;
    height: 150px;
  }

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

  .call-control span {
    font-size: 19px;
  }

  .audio-call-avatar img {
    width: 118px;
    height: 118px;
  }

  .audio-call-avatar h3 {
    font-size: 24px;
  }
}