/* ─── Reset & Base ─── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-0: #0a0a12;
  --bg-1: #0f0f1a;
  --bg-2: #16162a;
  --bg-3: #1e1e3f;
  --accent-cyan: #00d4ff;
  --accent-purple: #7b2cbf;
  --accent-pink: #ff2a6d;
  --accent-orange: #ff6b35;
  --text-primary: #e8e8f0;
  --text-secondary: #9090a8;
  --text-muted: #606070;
  --glass: rgba(255,255,255,0.04);
  --glass-border: rgba(255,255,255,0.08);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow-glow: 0 0 30px rgba(0,212,255,0.08);
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-0);
  color: var(--text-primary);
  overflow: hidden;
}

/* ─── Background Effects ─── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 40%, rgba(0,212,255,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 80% 60%, rgba(123,44,191,0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ─── App Layout ─── */
.app {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  margin: 0 auto;
}

/* ─── Header ─── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--glass-border);
  background: linear-gradient(180deg, var(--bg-1) 0%, transparent 100%);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* ─── Voice Selector ─── */
.voice-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

.voice-selector:hover {
  border-color: rgba(0, 212, 255, 0.2);
}

.voice-selector label {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent-cyan);
  white-space: nowrap;
}

.voice-selector select {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  padding-right: 4px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2300d4ff' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right center;
  padding-right: 16px;
}

.voice-selector select option {
  background: var(--bg-2);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fox-icon {
  width: 40px;
  height: 40px;
  filter: drop-shadow(0 0 8px rgba(255,107,53,0.3));
}

.logo-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 1px;
}

.logo-sub {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 2px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
  transition: all 0.3s ease;
}

.status-badge.listening .status-dot {
  background: var(--accent-cyan);
  box-shadow: 0 0 10px var(--accent-cyan);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.status-badge.processing .status-dot {
  background: var(--accent-orange);
  box-shadow: 0 0 10px var(--accent-orange);
  animation: pulse-dot 0.8s ease-in-out infinite;
}

.status-badge.speaking .status-dot {
  background: var(--accent-pink);
  box-shadow: 0 0 10px var(--accent-pink);
  animation: pulse-dot 0.6s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

/* ─── Chat Container ─── */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  scroll-behavior: smooth;
}

.chat-container::-webkit-scrollbar {
  width: 4px;
}
.chat-container::-webkit-scrollbar-track {
  background: transparent;
}
.chat-container::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 4px;
}

/* ─── Welcome Screen ─── */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  min-height: 50vh;
}

.welcome.hidden {
  display: none;
}

.welcome-icon {
  width: 120px;
  height: 120px;
  margin-bottom: 24px;
  opacity: 0.8;
}

.welcome h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.8rem;
  font-weight: 500;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
}

.welcome p {
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 420px;
  margin-bottom: 36px;
  font-size: 0.95rem;
}

.features {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.feature {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.feature-icon {
  font-size: 1.1rem;
}

/* ─── Messages ─── */
.messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: fadeInUp 0.3s ease;
}

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

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.assistant {
  align-self: flex-start;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.message.user .message-avatar {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
}

.message.assistant .message-avatar {
  background: linear-gradient(135deg, var(--accent-orange), var(--accent-pink));
}

.message-bubble {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  line-height: 1.6;
  word-wrap: break-word;
}

.message.user .message-bubble {
  background: linear-gradient(135deg, rgba(123,44,191,0.15), rgba(0,212,255,0.1));
  border: 1px solid rgba(123,44,191,0.2);
  border-bottom-right-radius: 4px;
  color: var(--text-primary);
}

.message.assistant .message-bubble {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-bottom-left-radius: 4px;
  color: var(--text-primary);
}

.message-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.message.user .message-time {
  text-align: right;
}

/* ─── Typing Indicator ─── */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 6px 0;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cyan);
  animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-8px); opacity: 1; }
}

/* ─── Listening Overlay ─── */
.listening-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
  background: rgba(10,10,18,0.85);
  backdrop-filter: blur(8px);
  z-index: 50;
}

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

.listening-waves {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 80px;
}

.listening-waves span {
  width: 4px;
  background: linear-gradient(180deg, var(--accent-cyan), var(--accent-purple));
  border-radius: 999px;
  animation: wave 1s ease-in-out infinite;
}

.listening-waves span:nth-child(1) { height: 20%; animation-delay: 0s; }
.listening-waves span:nth-child(2) { height: 40%; animation-delay: 0.1s; }
.listening-waves span:nth-child(3) { height: 70%; animation-delay: 0.2s; }
.listening-waves span:nth-child(4) { height: 40%; animation-delay: 0.3s; }
.listening-waves span:nth-child(5) { height: 20%; animation-delay: 0.4s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.5); opacity: 0.5; }
  50% { transform: scaleY(1.2); opacity: 1; }
}

.listening-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.1rem;
  color: var(--accent-cyan);
  letter-spacing: 2px;
  text-transform: uppercase;
  animation: textPulse 2s ease-in-out infinite;
}

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

/* ─── Controls ─── */
.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--glass-border);
  background: linear-gradient(0deg, var(--bg-1) 0%, transparent 100%);
}

/* Micro Button */
.mic-button {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(0,212,255,0.25);
  flex-shrink: 0;
}

.mic-button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 30px rgba(0,212,255,0.4);
}

.mic-button:active {
  transform: scale(0.95);
}

.mic-button.listening {
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-orange));
  box-shadow: 0 4px 25px rgba(255,42,109,0.4);
  animation: micPulse 1.5s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 4px 25px rgba(255,42,109,0.4); }
  50% { box-shadow: 0 4px 40px rgba(255,42,109,0.6), 0 0 60px rgba(255,42,109,0.2); }
}

.mic-icon {
  width: 24px;
  height: 24px;
}

/* Input Area */
.input-area {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 4px 4px 4px 16px;
  transition: border-color 0.3s ease;
}

.input-area:focus-within {
  border-color: rgba(0,212,255,0.3);
}

.input-area input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
}

.input-area input::placeholder {
  color: var(--text-muted);
}

.send-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.send-button:hover {
  transform: scale(1.08);
}

.send-button svg {
  width: 18px;
  height: 18px;
}

/* TTS Toggle */
.tts-toggle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.tts-toggle:hover {
  border-color: rgba(0,212,255,0.3);
  color: var(--text-primary);
}

.tts-toggle.active {
  background: rgba(0,212,255,0.1);
  border-color: rgba(0,212,255,0.3);
  color: var(--accent-cyan);
}

.tts-toggle svg {
  width: 20px;
  height: 20px;
}

/* ─── Call Mode Badge ─── */
.call-mode-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: 999px;
  font-size: 0.8rem;
  color: #22c55e;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  animation: callBadgeIn 0.3s ease;
}

@keyframes callBadgeIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

.call-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
  animation: callPulse 1.2s ease-in-out infinite;
}

@keyframes callPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.5; }
}

/* ─── Call Active Overlay ─── */
.call-active-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  background: rgba(10,10,18,0.7);
  backdrop-filter: blur(4px);
  z-index: 40;
  pointer-events: none;
}

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

.call-waves {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 100px;
  min-width: 200px;
}

.call-waves span {
  width: 4px;
  background: linear-gradient(180deg, #22c55e, #4ade80);
  border-radius: 999px;
  transition: height 0.1s ease;
  min-height: 8px;
}

.call-waves span:nth-child(1) { height: 15%; }
.call-waves span:nth-child(2) { height: 25%; }
.call-waves span:nth-child(3) { height: 45%; }
.call-waves span:nth-child(4) { height: 65%; }
.call-waves span:nth-child(5) { height: 45%; }
.call-waves span:nth-child(6) { height: 25%; }
.call-waves span:nth-child(7) { height: 15%; }

/* Animation quand l'utilisateur parle */
.call-waves.speaking span:nth-child(1) { animation: callWave1 0.3s ease-in-out infinite alternate; }
.call-waves.speaking span:nth-child(2) { animation: callWave2 0.25s ease-in-out infinite alternate; }
.call-waves.speaking span:nth-child(3) { animation: callWave3 0.35s ease-in-out infinite alternate; }
.call-waves.speaking span:nth-child(4) { animation: callWave4 0.28s ease-in-out infinite alternate; }
.call-waves.speaking span:nth-child(5) { animation: callWave5 0.32s ease-in-out infinite alternate; }
.call-waves.speaking span:nth-child(6) { animation: callWave2 0.26s ease-in-out infinite alternate; }
.call-waves.speaking span:nth-child(7) { animation: callWave1 0.3s ease-in-out infinite alternate; }

@keyframes callWave1 { from { height: 15%; } to { height: 40%; } }
@keyframes callWave2 { from { height: 25%; } to { height: 70%; } }
@keyframes callWave3 { from { height: 45%; } to { height: 90%; } }
@keyframes callWave4 { from { height: 65%; } to { height: 100%; } }
@keyframes callWave5 { from { height: 45%; } to { height: 85%; } }

.call-active-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.2rem;
  color: #22c55e;
  letter-spacing: 3px;
  text-transform: uppercase;
}

.call-active-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ─── Call Button ─── */
.call-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.call-button:hover {
  border-color: rgba(34,197,94,0.3);
  color: #4ade80;
}

.call-button.active {
  background: rgba(34,197,94,0.15);
  border-color: rgba(34,197,94,0.4);
  color: #22c55e;
  box-shadow: 0 0 20px rgba(34,197,94,0.2);
  animation: callBtnPulse 2s ease-in-out infinite;
}

@keyframes callBtnPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(34,197,94,0.2); }
  50% { box-shadow: 0 0 30px rgba(34,197,94,0.35); }
}

.call-button .call-icon {
  width: 20px;
  height: 20px;
}

.call-button .call-label {
  font-size: 0.6rem;
  font-family: 'Orbitron', sans-serif;
  letter-spacing: 0.5px;
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
  .call-button {
    width: 48px;
    height: 48px;
  }
  .call-button .call-label {
    display: none;
  }
  .call-active-text {
    font-size: 1rem;
  }
}

@media (max-width: 380px) {
  .logo-sub {
    display: none;
  }

  .feature span:last-child {
    display: none;
  }
}

/* ─── Wake Word Visualizer ─── */
.wake-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
  background: rgba(10,10,18,0.75);
  backdrop-filter: blur(6px);
  z-index: 35;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

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

.wake-visualizer {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wake-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid;
  opacity: 0;
}

/* État VEILLE (aucun anneau animé) */
.wake-overlay.active .wake-ring {
  border-color: rgba(0,212,255,0.3);
  width: 60px;
  height: 60px;
  opacity: 0.3;
}

/* État ACTIF (anneaux en expansion) */
.wake-overlay.wake-active .wake-ring {
  border-color: rgba(255,107,53,0.6);
  animation: wakeRingExpand 1.2s ease-out infinite;
}

.wake-overlay.wake-active .wake-ring:nth-child(1) { animation-delay: 0s; }
.wake-overlay.wake-active .wake-ring:nth-child(2) { animation-delay: 0.3s; }
.wake-overlay.wake-active .wake-ring:nth-child(3) { animation-delay: 0.6s; }

@keyframes wakeRingExpand {
  0%   { width: 40px; height: 40px; opacity: 0.8; border-width: 3px; }
  100% { width: 140px; height: 140px; opacity: 0; border-width: 1px; }
}

.wake-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.9rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-cyan);
  opacity: 0.7;
  transition: all 0.3s ease;
}

.wake-overlay.wake-active .wake-text {
  color: var(--accent-orange);
  opacity: 1;
  animation: wakeTextPulse 0.8s ease-in-out infinite;
}

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

/* ─── Scrollbar Firefox ─── */
.chat-container {
  scrollbar-width: thin;
  scrollbar-color: var(--glass-border) transparent;
}
