/* Audio Level Meter - Real-time microphone volume visualization */

.audio-level-meter {
  display: flex;
  align-items: center;
  padding: 0 12px;
  height: 100%;
  transition: opacity 0.2s ease;
}

.audio-level-meter--hidden {
  opacity: 0;
  pointer-events: none;
}

.audio-level-meter__container {
  display: flex;
  gap: 2px;
  align-items: center;
  height: 20px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
}

/* LED indicators */
.audio-level-meter__led {
  width: 4px;
  height: 12px;
  border-radius: 2px;
  transition: all 0.05s ease; /* Fast response for real-time feedback */
  box-shadow: none;
}

/* LED states */
.audio-level-meter__led--inactive {
  opacity: 0.2;
  filter: grayscale(1);
}

.audio-level-meter__led--active {
  opacity: 1;
  filter: none;
  animation: ledPulse 0.2s ease;
}

/* LED colors */
.audio-level-meter__led--green {
  background: #4ade80; /* Green 400 */
}

.audio-level-meter__led--green.audio-level-meter__led--active {
  background: #22c55e; /* Green 500 */
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

.audio-level-meter__led--yellow {
  background: #facc15; /* Yellow 400 */
}

.audio-level-meter__led--yellow.audio-level-meter__led--active {
  background: #eab308; /* Yellow 500 */
  box-shadow: 0 0 6px rgba(234, 179, 8, 0.6);
}

.audio-level-meter__led--red {
  background: #f87171; /* Red 400 */
}

.audio-level-meter__led--red.audio-level-meter__led--active {
  background: #ef4444; /* Red 500 */
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
  animation: ledPeakPulse 0.3s ease;
}

/* Peak indicator flash */
.audio-level-meter__led--peak {
  animation: ledPeakFlash 0.2s ease;
  background: white !important;
}

/* Container states based on audio level */
.audio-level-meter--speaking .audio-level-meter__container {
  background: rgba(34, 197, 94, 0.1); /* Green tint when speaking */
}

.audio-level-meter--loud .audio-level-meter__container {
  background: rgba(234, 179, 8, 0.1); /* Yellow tint when loud */
}

.audio-level-meter--peaking .audio-level-meter__container {
  background: rgba(239, 68, 68, 0.1); /* Red tint when peaking */
  animation: containerPeakPulse 0.3s ease;
}

/* Animations */
@keyframes ledPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes ledPeakPulse {
  0% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.3);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes ledPeakFlash {
  0% {
    background: inherit;
  }
  50% {
    background: white;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.8);
  }
  100% {
    background: inherit;
  }
}

@keyframes containerPeakPulse {
  0% {
    background: rgba(239, 68, 68, 0.1);
  }
  50% {
    background: rgba(239, 68, 68, 0.2);
  }
  100% {
    background: rgba(239, 68, 68, 0.1);
  }
}

/* Integration with call panel */
.call-panel .audio-level-meter {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 50%;
  margin-top: -10px;
  z-index: 1;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .audio-level-meter__led {
    width: 3px;
    height: 10px;
  }

  .audio-level-meter__container {
    gap: 1px;
    padding: 3px 6px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .audio-level-meter__container {
    background: rgba(255, 255, 255, 0.1);
  }

  .audio-level-meter--speaking .audio-level-meter__container {
    background: rgba(34, 197, 94, 0.15);
  }

  .audio-level-meter--loud .audio-level-meter__container {
    background: rgba(234, 179, 8, 0.15);
  }

  .audio-level-meter--peaking .audio-level-meter__container {
    background: rgba(239, 68, 68, 0.15);
  }
}