/* YalaBobo - Premium WhatsApp-Style Calling Screen CSS */

/* ===================================================
   Call Overlay Base - Full Screen
   =================================================== */
#callOverlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 9999;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  font-family: var(--font-tajawal);
  direction: rtl;
  /* Entrance animation */
  animation: callScreenIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#callOverlay.call-active {
  display: flex;
}

@keyframes callScreenIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes callScreenOut {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.92) translateY(40px);
  }
}

/* ===================================================
   Background Blur Layer
   =================================================== */
#callBgBlur {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  background-size: cover;
  background-position: center;
  filter: blur(50px) brightness(0.2);
  opacity: 0.85;
  transition: background-image 0.5s ease;
}

/* ===================================================
   Video Container (video call mode)
   =================================================== */
#callVideoContainer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: none;
  z-index: 1;
  overflow: hidden;
  background: #000;
}

.video-full {
  width: 100% !important;
  height: 100% !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: auto !important;
  bottom: auto !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  object-fit: cover !important;
  z-index: 1 !important;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.video-floating {
  position: absolute !important;
  width: 110px !important;
  height: 165px !important;
  border-radius: 16px !important;
  object-fit: cover !important;
  border: 2px solid rgba(255, 255, 255, 0.3) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
  z-index: 10 !important;
  cursor: grab !important;
  pointer-events: auto !important;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.video-floating:hover {
  border-color: var(--primary) !important;
  box-shadow: 0 10px 30px rgba(37, 211, 102, 0.3) !important;
}

.video-floating:active {
  cursor: grabbing !important;
}

#localVideo {
  transform: scaleX(-1);
}

/* ===================================================
   Call Header Section
   =================================================== */
.call-header-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
  z-index: 2;
  padding-top: 50px;
  width: 100%;
}

/* Call type badge */
.call-type-badge {
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 8px 18px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Avatar ring with animated pulse */
.call-avatar-wrapper {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  padding: 5px;
  position: relative;
}

.call-avatar-ring {
  position: absolute;
  top: -8px; left: -8px; right: -8px; bottom: -8px;
  border-radius: 50%;
  border: 2px solid rgba(37, 211, 102, 0.4);
  animation: avatarRingPulse 2s ease-in-out infinite;
}

.call-avatar-ring:nth-child(2) {
  top: -18px; left: -18px; right: -18px; bottom: -18px;
  border-color: rgba(37, 211, 102, 0.2);
  animation-delay: 0.5s;
}

@keyframes avatarRingPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.06);
    opacity: 0.6;
  }
}

.call-avatar-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(37, 211, 102, 0.5);
}

.call-avatar-inner svg {
  width: 100%;
  height: 100%;
}

/* User name */
#callUserName {
  font-size: 26px;
  font-weight: 800;
  color: #FFF;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

/* Status text with pulsing dot when active */
#callStatusText {
  color: var(--primary);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

#callStatusText.ringing::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  margin-left: 6px;
  animation: statusDotBlink 1s ease-in-out infinite;
}

@keyframes statusDotBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ===================================================
   Call Controls Section (bottom area)
   =================================================== */
.call-controls-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  z-index: 5;
  padding-bottom: 50px;
  width: 100%;
}

/* Active toggles row */
#activeCallControls {
  display: none;
  gap: 20px;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.call-toggle-btn {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  width: 56px;
  height: 56px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  color: #FFF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  position: relative;
}

.call-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

.call-toggle-btn.muted {
  background: #EF4444;
  border-color: rgba(239, 68, 68, 0.5);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.call-toggle-btn .btn-label {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  font-family: var(--font-tajawal);
}

/* Main action buttons row */
.call-action-row {
  display: flex;
  gap: 40px;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.call-btn-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-family: var(--font-tajawal);
}

/* Decline button */
#declineCallBtn {
  background: #EF4444;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(239, 68, 68, 0.5);
  transition: all 0.2s ease;
  /* Rotate phone icon to show "hang up" */
  transform: rotate(135deg);
  flex-shrink: 0;
}

#declineCallBtn:hover {
  background: #DC2626;
  transform: rotate(135deg) scale(1.08);
  box-shadow: 0 12px 35px rgba(239, 68, 68, 0.6);
}

#declineCallBtn:active {
  transform: rotate(135deg) scale(0.95);
}

/* Accept button */
#acceptCallBtn {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(37, 211, 102, 0.5);
  transition: all 0.2s ease;
  flex-shrink: 0;
  /* Slight shake animation to draw attention */
  animation: acceptBtnShake 1.5s ease-in-out infinite;
}

@keyframes acceptBtnShake {
  0%, 100% { transform: rotate(0deg) scale(1); }
  10% { transform: rotate(-6deg) scale(1.05); }
  20% { transform: rotate(6deg) scale(1.05); }
  30% { transform: rotate(-4deg) scale(1.03); }
  40% { transform: rotate(4deg) scale(1.03); }
  50% { transform: rotate(0deg) scale(1); }
}

#acceptCallBtn:hover {
  box-shadow: 0 12px 35px rgba(37, 211, 102, 0.7);
  animation: none;
  transform: scale(1.08);
}

#acceptCallBtn:active {
  transform: scale(0.95);
}

/* ===================================================
   Sound wave animation for voice call
   =================================================== */
.call-wave-container {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 30px;
}

.call-wave-bar {
  width: 4px;
  border-radius: 4px;
  background: var(--primary);
  animation: callWave 1.2s ease-in-out infinite;
}

.call-wave-bar:nth-child(1) { height: 10px; animation-delay: 0s; }
.call-wave-bar:nth-child(2) { height: 18px; animation-delay: 0.1s; }
.call-wave-bar:nth-child(3) { height: 24px; animation-delay: 0.2s; }
.call-wave-bar:nth-child(4) { height: 18px; animation-delay: 0.3s; }
.call-wave-bar:nth-child(5) { height: 12px; animation-delay: 0.4s; }

@keyframes callWave {
  0%, 100% { transform: scaleY(1); opacity: 0.6; }
  50% { transform: scaleY(1.6); opacity: 1; }
}

/* ===================================================
   Incoming call ripple effect
   =================================================== */
.call-avatar-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 140px;
  height: 140px;
}

.call-ripple {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: 2px solid rgba(37, 211, 102, 0.4);
  animation: rippleOut 2s ease-out infinite;
}

.call-ripple:nth-child(2) {
  animation-delay: 0.5s;
}

.call-ripple:nth-child(3) {
  animation-delay: 1s;
}

@keyframes rippleOut {
  0% {
    width: 130px;
    height: 130px;
    opacity: 0.8;
  }
  100% {
    width: 200px;
    height: 200px;
    opacity: 0;
  }
}

/* ===================================================
   Timer display (once call is connected)
   =================================================== */
#callTimer {
  font-family: 'Courier New', monospace;
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 2px;
  display: none;
}

/* ===================================================
   Mobile Responsive
   =================================================== */
@media (max-width: 480px) {
  .call-header-section {
    padding-top: 40px;
    gap: 14px;
  }

  #callUserName {
    font-size: 22px;
  }

  .call-avatar-wrapper {
    width: 110px;
    height: 110px;
  }

  .call-controls-section {
    padding-bottom: 40px;
    gap: 20px;
  }

  #declineCallBtn,
  #acceptCallBtn {
    width: 58px;
    height: 58px;
  }

  #localVideo {
    width: 90px;
    height: 130px;
    bottom: 110px;
    right: 14px;
  }
}

/* ===================================================
   Landscape Orientation Layout (Horizontal Call Screen)
   =================================================== */
@media (orientation: landscape) {
  #callOverlay {
    flex-direction: row !important;
    justify-content: space-around !important;
    align-items: center !important;
    padding: 20px 40px !important;
  }

  .call-header-section {
    width: 45% !important;
    padding-top: 0 !important;
    justify-content: center !important;
    gap: 12px !important;
  }

  .call-avatar-container {
    width: 110px !important;
    height: 110px !important;
  }

  .call-avatar-wrapper {
    width: 100px !important;
    height: 100px !important;
  }

  .call-ripple {
    width: 100px !important;
    height: 100px !important;
  }

  @keyframes rippleOut {
    0% {
      width: 100px;
      height: 100px;
      opacity: 0.8;
    }
    100% {
      width: 160px;
      height: 160px;
      opacity: 0;
    }
  }

  #callUserName {
    font-size: 20px !important;
  }

  .call-controls-section {
    width: 45% !important;
    padding-bottom: 0 !important;
    justify-content: center !important;
    gap: 20px !important;
  }

  .video-floating {
    width: 160px !important;
    height: 100px !important; /* landscape aspect ratio */
  }

  #activeCallControls {
    gap: 15px !important;
  }

  .call-toggle-btn {
    width: 48px !important;
    height: 48px !important;
  }

  #declineCallBtn,
  #acceptCallBtn {
    width: 52px !important;
    height: 52px !important;
  }
}
