/* ═══════════════════════════════════════════════════════
   AVATAR WIDGET – Premium Dark Theme CSS
   ═══════════════════════════════════════════════════════ */

:root {
  --bg-primary: #0a0d1a;
  --bg-secondary: #111527;
  --bg-card: rgba(20, 25, 50, 0.95);
  --accent: #4f8cff;
  --accent-glow: rgba(79, 140, 255, 0.3);
  --accent-secondary: #7c5cff;
  --text-primary: #f0f2f8;
  --text-secondary: rgba(240, 242, 248, 0.65);
  --border: rgba(255, 255, 255, 0.08);
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --radius: 20px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  overflow: hidden;
}

/* ─── Animated Background ─── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(79, 140, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(124, 92, 255, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(52, 211, 153, 0.04) 0%, transparent 50%);
  z-index: 0;
  animation: bgPulse 8s ease-in-out infinite alternate;
}

@keyframes bgPulse {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════
   AVATAR CONTAINER
   ═══════════════════════════════════════════════════════ */

.avatar-container {
  position: relative;
  z-index: 1;
  width: 420px;
  max-width: 95vw;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow:
    0 25px 60px rgba(0, 0, 0, 0.5),
    0 0 80px rgba(79, 140, 255, 0.05);
  backdrop-filter: blur(20px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ─── Header ─── */
.avatar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.avatar-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.avatar-header-right {
  display: flex;
  align-items: center;
}

.status-text {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ─── Status Dot ─── */
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: all 0.3s ease;
}

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 8px var(--success), 0 0 20px rgba(52, 211, 153, 0.3);
  animation: pulseDot 2s ease-in-out infinite;
}

.status-dot.error {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* ─── Avatar Video Area ─── */
.avatar-video-area {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(180deg, #080b18 0%, #0d1025 100%);
  overflow: hidden;
}

.avatar-video-area video {
  transition: opacity 0.15s ease-in-out;
  will-change: opacity;
  background-color: transparent;
}

/* ─── Audio Visualizer ─── */
.audio-visualizer {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 24px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.avatar-container.speaking .audio-visualizer {
  opacity: 1;
}

.viz-bar {
  width: 4px;
  height: 6px;
  background: var(--accent);
  border-radius: 2px;
  animation: vizPulse 0.8s ease-in-out infinite;
}

.viz-bar:nth-child(1) { animation-delay: 0s; }
.viz-bar:nth-child(2) { animation-delay: 0.15s; }
.viz-bar:nth-child(3) { animation-delay: 0.3s; }
.viz-bar:nth-child(4) { animation-delay: 0.15s; }
.viz-bar:nth-child(5) { animation-delay: 0s; }

@keyframes vizPulse {
  0%, 100% { height: 6px; opacity: 0.4; }
  50% { height: 22px; opacity: 1; }
}

/* ═══════════════════════════════════════════════════════
   KONTROLLER
   ═══════════════════════════════════════════════════════ */

.avatar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

/* ─── Connect Button ─── */
.btn-connect {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-secondary) 100%);
  color: #fff;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 0.3px;
}

.btn-connect:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 25px var(--accent-glow);
}

.btn-connect:active {
  transform: translateY(0);
}

.btn-connect:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-connect.active {
  background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
}

/* ─── Mic Button ─── */
.btn-mic {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}

.btn-mic:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
}

.btn-mic:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-mic.muted {
  background: rgba(248, 113, 113, 0.15);
  border-color: var(--danger);
  color: var(--danger);
}

/* ═══════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════ */

.avatar-footer {
  padding: 12px 20px;
  text-align: center;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.avatar-footer span {
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.avatar-footer strong {
  color: var(--accent);
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════ */

@media screen and (max-width: 480px) {
  .avatar-container {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    border-radius: 0;
    border: none;
  }

  .avatar-video-area {
    flex: 1;
    aspect-ratio: auto;
  }
}

/* ═══════════════════════════════════════════════════════
   ANİMASYONLAR
   ═══════════════════════════════════════════════════════ */

/* Connecting animation */
.btn-connect.connecting {
  position: relative;
  overflow: hidden;
}

.btn-connect.connecting::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Glow ring effect when speaking */
.avatar-video-area::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  border: 2px solid transparent;
  transition: border-color 0.3s ease;
  pointer-events: none;
}

.avatar-container.speaking .avatar-video-area::after {
  border-color: var(--accent);
  box-shadow: inset 0 0 30px rgba(79, 140, 255, 0.1);
}
