/* Calling UI Styles */

.call-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease-out;
}

.call-overlay.active {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.call-container {
  background: var(--bg-secondary, #2a2d31);
  border-radius: 12px;
  padding: 32px;
  min-width: 400px;
  max-width: 600px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.3s ease-out;
  position: relative;
}

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

.call-header {
  text-align: center;
  margin-bottom: 24px;
  position: relative;
  padding-top: 12px;
}

.call-minimize-btn {
  position: absolute;
  top: 0;
  right: 0;
  background: transparent;
  border: none;
  color: var(--text-muted, #b5bac1);
  font-size: 18px;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.2s ease;
  padding: 2px 6px;
  border-radius: 6px;
}

.call-minimize-btn:hover {
  color: var(--text-primary, #f2f3f5);
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.08);
}

.call-status {
  font-size: 14px;
  color: var(--text-muted, #b5bac1);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  margin-top: 4px;
}

.call-participant-name {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary, #f2f3f5);
  margin-bottom: 4px;
}

.call-duration {
  font-size: 16px;
  color: var(--text-muted, #b5bac1);
  font-variant-numeric: tabular-nums;
}

.call-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 600;
  color: white;
  position: relative;
  overflow: hidden;
}

/* When an image is applied by JS, render it like other avatars */
.call-avatar.has-image {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: transparent;
}

.call-avatar.ringing {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(88, 101, 242, 0.7);
  }
  50% {
    box-shadow: 0 0 0 20px rgba(88, 101, 242, 0);
  }
}

.call-controls {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.call-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: all 0.2s ease;
  position: relative;
}

.call-btn:hover {
  transform: scale(1.1);
}

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

.call-btn.mute {
  background: var(--bg-tertiary, #3c4043);
  color: var(--text-primary, #f2f3f5);
}

.call-btn.mute.active {
  background: #ed4245;
  color: white;
}

.call-btn.record {
  background: var(--bg-tertiary, #3c4043);
  color: var(--text-primary, #f2f3f5);
}

.call-btn.record.active {
  background: #ed4245;
  color: white;
  animation: recordingPulse 1.5s ease-in-out infinite;
}

@keyframes recordingPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(237, 66, 69, 0.7);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(237, 66, 69, 0);
  }
}

.call-btn.settings {
  background: var(--bg-tertiary, #3c4043);
  color: var(--text-primary, #f2f3f5);
}

.call-btn.settings.active {
  background: #5865f2;
  color: white;
}

.call-btn.video {
  background: var(--bg-tertiary, #3c4043);
  color: var(--text-primary, #f2f3f5);
}

.call-btn.video.active {
  background: #ed4245;
  color: white;
}

.call-btn.accept {
  background: #3ba55d;
  color: white;
}

.call-btn.accept:hover {
  background: #2d7d46;
}

.call-btn.reject,
.call-btn.end {
  background: #ed4245;
  color: white;
}

.call-btn.reject:hover,
.call-btn.end:hover {
  background: #c03537;
}

/* Settings Panel */
.call-settings-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-secondary, #2a2d31);
  border-radius: 0 0 12px 12px;
  border-top: 1px solid var(--border-color, #3c4043);
  padding: 20px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 1;
}

.settings-section {
  margin-bottom: 20px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section h4 {
  color: var(--text-primary, #f2f3f5);
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.device-selector {
  margin-bottom: 12px;
}

.device-selector label {
  display: block;
  color: var(--text-muted, #b5bac1);
  font-size: 13px;
  margin-bottom: 4px;
}

.device-selector select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-tertiary, #3c4043);
  border: 1px solid var(--border-color, #4f5660);
  border-radius: 6px;
  color: var(--text-primary, #f2f3f5);
  font-size: 13px;
}

.device-selector select:focus {
  outline: none;
  border-color: #5865f2;
}

.audio-setting {
  margin-bottom: 8px;
}

.audio-setting label {
  display: flex;
  align-items: center;
  color: var(--text-primary, #f2f3f5);
  font-size: 13px;
  cursor: pointer;
}

.audio-setting input[type="checkbox"] {
  margin-right: 8px;
  accent-color: #5865f2;
}

.call-info {
  font-size: 12px;
  color: var(--text-muted, #b5bac1);
}

.call-info div {
  margin-bottom: 4px;
}

.call-incoming-actions {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 24px;
}

.call-participants {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color, #3c4043);
}

.call-participant-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.call-participant-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 6px;
  background: var(--bg-tertiary, #3c4043);
}

.call-participant-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: white;
}

.call-participant-info {
  flex: 1;
}

.call-participant-username {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary, #f2f3f5);
}

.call-participant-status {
  font-size: 12px;
  color: var(--text-muted, #b5bac1);
  display: flex;
  align-items: center;
  gap: 6px;
}

.call-participant-status .status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.call-participant-status .status-indicator.muted {
  background: #ed4245;
}

.call-participant-status .status-indicator.speaking {
  background: #3ba55d;
  animation: pulse-speaking 1s ease-in-out infinite;
}

@keyframes pulse-speaking {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Audio elements (hidden) */
audio {
  display: none;
}

/* Responsive */
@media (max-width: 600px) {
  .call-container {
    min-width: 90vw;
    padding: 24px;
  }

  .call-avatar {
    width: 100px;
    height: 100px;
    font-size: 40px;
  }

  .call-participant-name {
    font-size: 20px;
  }

  .call-btn {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
  
  .call-settings-panel {
    padding: 16px;
  }
}

/* Minimized state */
.call-overlay.minimized .call-container {
  min-width: 300px;
  padding: 16px;
}

.call-overlay.minimized .call-avatar {
  width: 60px;
  height: 60px;
  font-size: 24px;
  margin-bottom: 12px;
}

.call-overlay.minimized .call-participant-name {
  font-size: 16px;
  margin-bottom: 2px;
}

.call-overlay.minimized .call-duration {
  font-size: 12px;
}

.call-overlay.minimized .call-btn {
  width: 40px;
  height: 40px;
  font-size: 18px;
}

.call-overlay.minimized .call-controls {
  gap: 12px;
  margin-top: 12px;
}

.call-overlay.minimized .call-settings-panel {
  display: none !important;
}

/* Audio level visualization */
.call-btn.mute.speaking {
  animation: speakingIndicator 0.5s ease-in-out infinite alternate;
}

@keyframes speakingIndicator {
  from {
    box-shadow: 0 0 0 0 rgba(59, 165, 93, 0.7);
  }
  to {
    box-shadow: 0 0 0 8px rgba(59, 165, 93, 0);
  }
}

/* Call notification toast */
.call-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--bg-secondary, #2a2d31);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  z-index: 9999;
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.call-notification .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: white;
}

.call-notification .content {
  flex: 1;
}

.call-notification .title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #f2f3f5);
  margin-bottom: 2px;
}

.call-notification .subtitle {
  font-size: 12px;
  color: var(--text-muted, #b5bac1);
}

.call-notification .actions {
  display: flex;
  gap: 8px;
}

.call-notification .btn-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s ease;
}

.call-notification .btn-small.accept {
  background: #3ba55d;
  color: white;
}

.call-notification .btn-small.reject {
  background: #ed4245;
  color: white;
}

.call-overlay.minimized {
  background: transparent;
  backdrop-filter: none;
  display: block;
  pointer-events: none;
}

.call-overlay.minimized .call-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  min-width: 260px;
  max-width: 320px;
  width: 320px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  animation: none;
}

.call-overlay.minimized .call-header {
  margin-bottom: 12px;
  text-align: left;
  padding-top: 0;
  width: 100%;
}

.call-overlay.minimized .call-minimize-btn {
  position: absolute;
  top: 0;
  right: 0;
}

.call-overlay.minimized .call-participant-name {
  font-size: 18px;
}

.call-overlay.minimized .call-avatar {
  width: 56px;
  height: 56px;
  font-size: 24px;
  margin: 0 0 12px;
}

.call-overlay.minimized .call-controls,
.call-overlay.minimized .call-incoming-actions {
  justify-content: flex-start;
}

.call-overlay.minimized .call-controls {
  gap: 12px;
}

.call-overlay.minimized .call-container .call-participants {
  display: none !important;
}

@media (max-width: 600px) {
  .call-overlay.minimized .call-container {
    right: 12px;
    left: 12px;
    width: auto;
    min-width: 0;
  }
}
