/* ============================================================
   Voice AI Agent — Premium Dark Glassmorphic Theme
   ============================================================ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-hover: rgba(255, 255, 255, 0.07);
  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --text-muted: #55556a;
  --accent: #7c6aef;
  --accent-glow: rgba(124, 106, 239, 0.35);
  --accent-light: #a594ff;
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --user-bubble: rgba(124, 106, 239, 0.15);
  --ai-bubble: rgba(255, 255, 255, 0.05);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 999px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html,
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Animated background gradient */
.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(124, 106, 239, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 80%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(168, 85, 247, 0.05) 0%, transparent 40%);
  animation: bgShift 20s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes bgShift {
  0% {
    transform: scale(1) translate(0, 0);
  }

  50% {
    transform: scale(1.05) translate(-2%, 3%);
  }

  100% {
    transform: scale(1) translate(2%, -2%);
  }
}

/* Floating particles */
.particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(124, 106, 239, 0.25);
  animation: float linear infinite;
}

@keyframes float {
  0% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  90% {
    opacity: 1;
  }

  100% {
    transform: translateY(-10vh) scale(1);
    opacity: 0;
  }
}

/* ---- Layout ---- */
.app-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---- Header ---- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 12px;
  border-bottom: 1px solid var(--glass-border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #a855f7);
  color: #fff;
}

.logo-text {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  backdrop-filter: blur(12px);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.6;
    transform: scale(0.85);
  }
}

.status-badge.listening .status-dot {
  background: var(--accent-light);
  box-shadow: 0 0 8px var(--accent-glow);
}

.status-badge.thinking .status-dot {
  background: var(--warning);
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.4);
}

.status-badge.speaking .status-dot {
  background: #60a5fa;
  box-shadow: 0 0 8px rgba(96, 165, 250, 0.4);
}

.status-badge.error .status-dot {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.4);
}

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: 16px;
}

/* ---- Setup Form ---- */
.setup-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 24px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  animation: fadeIn 0.6s ease;
}

.setup-container h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 24px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

#interviewSetupForm {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}

.submit-btn {
  margin-top: 8px;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #a855f7);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.submit-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.submit-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* ---- Video Feeds & PiP Layout ---- */
.video-feeds-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  width: 100%;
}

.ai-avatar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transform: scale(1.4);
  /* Make Recruiter Avatar the centerpiece */
}

/* Picture-in-Picture Local Camera */
.camera-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: absolute;
  bottom: 0;
  right: 0;
  z-index: 10;
  transform-origin: bottom right;
}

.camera-container #localVideo {
  width: 100px;
  /* Smaller PiP size */
  height: 100px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.avatar-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* AI Avatar */
.ai-avatar-container {
  position: relative;
}

.glow-ring {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.ai-avatar-container.speaking .glow-ring {
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {

  0%,
  100% {
    transform: scale(1);
    opacity: 0.2;
    box-shadow: 0 0 15px var(--accent-glow);
  }

  50% {
    transform: scale(1.15);
    opacity: 0.6;
    box-shadow: 0 0 35px var(--accent), 0 0 10px rgba(255, 255, 255, 0.5);
  }
}

.avatar-icon {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(30, 30, 40, 0.8), rgba(20, 20, 30, 0.9));
  border: 2px solid var(--glass-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-light);
  z-index: 1;
  transition: transform 0.3s ease, border-color 0.3s ease;
  overflow: hidden;
  transform-origin: bottom center;
}

#recruiterAvatarImg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.15s ease-out;
}

.ai-avatar-container.speaking #recruiterAvatarImg.talking-word {
  transform: scaleY(1.05) translateY(-2px);
  filter: brightness(1.1);
}

.ai-avatar-container.speaking .avatar-icon {
  transform: scale(1.05);
  border-color: var(--accent);
  color: #fff;
}

/* Local Camera */
#localVideo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--glass-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* Conversation Panel */
.conversation-panel {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 8px;
  scroll-behavior: smooth;
}

.conversation-panel::-webkit-scrollbar {
  width: 5px;
}

.conversation-panel::-webkit-scrollbar-track {
  background: transparent;
}

.conversation-panel::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 3px;
}

/* Live Subtitles */
.live-subtitles {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  max-width: 800px;
  text-align: center;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(10px);
  padding: 16px 24px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  font-size: 1.25rem;
  line-height: 1.5;
  color: #fff;
  z-index: 20;
  display: none;
  animation: fadeIn 0.3s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transition: opacity 0.3s ease;
}

.live-subtitles .spoken-word {
  color: var(--accent-light);
  font-weight: 600;
  text-shadow: 0 0 8px var(--accent-glow);
  transition: color 0.1s ease;
}

.live-subtitles .upcoming-word {
  color: rgba(255, 255, 255, 0.6);
}

/* ---- Transcript Bar ---- */
.transcript-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  margin: 8px 0;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(12px);
  animation: fadeIn 0.3s ease;
}

.transcript-bar.visible {
  display: flex;
}

.transcript-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-light);
  white-space: nowrap;
}

.transcript-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse-dot 1s ease-in-out infinite;
}

.transcript-text {
  flex: 1;
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Mic Button ---- */
.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0 28px;
  gap: 10px;
}

.mic-button {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
  box-shadow: 0 4px 24px var(--accent-glow);
  z-index: 2;
}

.mic-button:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 32px var(--accent-glow);
}

.mic-button:active {
  transform: scale(0.96);
}

.mic-button.listening {
  background: linear-gradient(135deg, #ef4444, #f97316);
  box-shadow: 0 4px 24px rgba(239, 68, 68, 0.35);
}

.mic-icon,
.mic-icon-stop {
  position: relative;
  z-index: 2;
}

/* Pulse Rings */
.mic-rings {
  position: absolute;
  inset: -20px;
  pointer-events: none;
}

.ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  transform: scale(0.7);
}

.mic-button.listening .ring {
  animation: ringPulse 2s ease-out infinite;
}

.mic-button.listening .ring-1 {
  animation-delay: 0s;
  border-color: #ef4444;
}

.mic-button.listening .ring-2 {
  animation-delay: 0.5s;
  border-color: #f97316;
}

.mic-button.listening .ring-3 {
  animation-delay: 1s;
  border-color: #fbbf24;
}

@keyframes ringPulse {
  0% {
    transform: scale(0.8);
    opacity: 0.6;
  }

  100% {
    transform: scale(1.3);
    opacity: 0;
  }
}

.mic-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ---- Report Container ---- */
.report-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  animation: fadeIn 0.4s ease;
}

.report-content {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  color: var(--text-primary);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.report-content h2 {
  font-size: 1.8rem;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.report-content p,
.report-content li {
  line-height: 1.6;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.report-content h3 {
  color: var(--accent-light);
  margin-top: 16px;
  font-size: 1.3rem;
}

.report-content ul {
  padding-left: 20px;
  margin-bottom: 16px;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .app-container {
    padding: 0 14px;
  }

  .message-bubble {
    max-width: 85%;
  }

  .mic-button {
    width: 64px;
    height: 64px;
  }
}