/* =========================================
   SHIFT AI - J.A.R.V.I.S. HUD THEME
   Design System & Variables
   ========================================= */
:root {
  /* Palette Principale - Cyan Électrique & Bleu Profond */
  --hud-bg: #050B14; /* Fond spatial */
  --hud-card-bg: rgba(10, 18, 32, 0.65); /* Verre sombre */
  
  --primary-glow: #00F0FF; /* Cyan néon principal */
  --primary-dim: #007780;
  
  --accent-blue: #38BDF8;
  --text-main: #E0F7FA; /* Blanc bleuté */
  --text-muted: #94A3B8;
  
  --system-success: #00FF9D;
  --system-warn: #FFB800;
  --system-alert: #FF2A6D;

  /* Glassmorphism Settings */
  --glass-border: 1px solid rgba(0, 240, 255, 0.15);
  --glass-blur: blur(25px);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);

  /* Dimensions */
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 8px;
}

/* =========================================
   RESET & BASE
   ========================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  height: 100%;
}

body {
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--hud-bg);
  /* Fond dynamique style nébuleuse sombre */
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(0, 240, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 85% 90%, rgba(56, 189, 248, 0.05) 0%, transparent 40%);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  overflow: hidden; /* Empêche le scroll global, on scroll dans le chat */
  -webkit-font-smoothing: antialiased;
}

/* =========================================
   LAYOUT & CONTAINER
   ========================================= */
.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  padding: 1rem;
  justify-content: center;
  align-items: center;
}

@media (min-width: 768px) {
  .container {
    padding: 2rem;
  }
}

/* =========================================
   MAIN CARD (THE HUD)
   ========================================= */
.chat-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 56rem; /* Plus large pour effet cinéma */
  height: 100%;
  max-height: 90vh;
  
  /* L'effet Verre High-Tech */
  background: var(--hud-card-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  box-shadow: 
    var(--glass-shadow),
    0 0 0 1px rgba(0, 240, 255, 0.05), /* Inner stroke subtil */
    0 0 40px rgba(0, 240, 255, 0.05); /* Glow externe diffus */
    
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  transition: box-shadow 0.3s ease;
}

/* Effet de lueur sur la carte au focus */
.chat-card:focus-within {
  box-shadow: 
    var(--glass-shadow),
    0 0 0 1px rgba(0, 240, 255, 0.2),
    0 0 60px rgba(0, 240, 255, 0.1);
}

/* =========================================
   HEADER
   ========================================= */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: var(--glass-border);
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Logo "Arc Reactor" */
.logo {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: rgba(0, 240, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 240, 255, 0.3);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.2);
  position: relative;
}

/* Anneau rotatif autour du logo */
.logo::after {
  content: '';
  position: absolute;
  top: -2px; left: -2px; right: -2px; bottom: -2px;
  border-radius: 50%;
  border: 1px dashed rgba(0, 240, 255, 0.4);
  animation: spin-slow 10s linear infinite;
}

.logo svg {
  width: 1.4rem;
  height: 1.4rem;
  color: var(--primary-glow);
  filter: drop-shadow(0 0 5px var(--primary-glow));
}

.header-info h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 2px; /* Espacement futuriste */
  color: var(--text-main);
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.header-info p {
  font-size: 0.75rem;
  color: var(--primary-glow);
  opacity: 0.8;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Status Indicator (HUD Style) */
.connection-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.8rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: 1px solid transparent;
  background: rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.connection-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}

/* Status States */
.connection-status.connected {
  border-color: rgba(0, 255, 157, 0.3);
  color: var(--system-success);
}
.connection-status.connected .connection-dot {
  background: var(--system-success);
  animation: pulse-green 3s infinite;
}

.connection-status.connecting {
  border-color: rgba(255, 184, 0, 0.3);
  color: var(--system-warn);
}
.connection-status.connecting .connection-dot {
  background: var(--system-warn);
  animation: blink-fast 1s infinite;
}

.connection-status.disconnected {
  border-color: rgba(255, 42, 109, 0.3);
  color: var(--system-alert);
}
.connection-status.disconnected .connection-dot {
  background: var(--system-alert);
}

/* =========================================
   MESSAGES AREA
   ========================================= */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  scroll-behavior: smooth;
}

/* Custom Scrollbar - Cyberpunk style */
.messages::-webkit-scrollbar {
  width: 6px;
}
.messages::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
.messages::-webkit-scrollbar-thumb {
  background: rgba(0, 240, 255, 0.2);
  border-radius: 3px;
}
.messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 240, 255, 0.5);
}

/* Empty State - Holographic feel */
.empty-state {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: hologram-fade-in 0.8s ease-out;
}

.empty-icon {
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0,240,255,0.15) 0%, transparent 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(0, 240, 255, 0.2);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.1) inset;
}

.empty-icon svg {
  width: 2.5rem;
  height: 2.5rem;
  color: var(--primary-glow);
  opacity: 0.8;
}

.empty-state h2 {
  font-size: 1.5rem;
  color: var(--text-main);
  margin-bottom: 0.5rem;
  font-weight: 300;
  letter-spacing: 1px;
}

.empty-state p {
  color: var(--text-muted);
  max-width: 300px;
  font-size: 0.9rem;
}

/* =========================================
   CHAT BUBBLES
   ========================================= */
.message {
  display: flex;
  gap: 1rem;
  opacity: 0;
  transform: translateY(15px);
  animation: slide-up-fade 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* Avatar Logic */
.message-avatar {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px; /* Carrés arrondis tech */
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

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

/* User Bubble Styles */
.message.user .message-avatar {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), transparent);
  border-color: rgba(56, 189, 248, 0.3);
  color: var(--accent-blue);
}

.message.user .message-content {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.85), rgba(0, 119, 128, 0.8));
  color: #fff;
  border-radius: 18px 4px 18px 18px; /* Forme asymétrique */
  box-shadow: 0 4px 15px rgba(0, 119, 128, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Assistant Bubble Styles */
.message.assistant .message-avatar {
  background: rgba(0, 240, 255, 0.1);
  border-color: rgba(0, 240, 255, 0.2);
  color: var(--primary-glow);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.1);
}

.message.assistant .message-content {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 2px solid var(--primary-glow); /* Accent tech à gauche */
  border-radius: 4px 18px 18px 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.message-content {
  max-width: 80%;
  padding: 0.875rem 1.125rem;
  font-size: 0.95rem;
  line-height: 1.6;
  position: relative;
  backdrop-filter: blur(5px);
}

/* Typing Cursor - Holographic caret */
.typing-cursor {
  display: inline-block;
  width: 8px;
  height: 1.2em;
  background: var(--primary-glow);
  margin-left: 4px;
  vertical-align: middle;
  box-shadow: 0 0 8px var(--primary-glow);
  animation: blink 1s step-end infinite;
}

/* =========================================
   INPUT AREA (CONTROL PANEL)
   ========================================= */
.input-area {
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
}

/* Recording Overlay (Top of input) */
.recording-indicator {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 42, 109, 0.15);
  border: 1px solid rgba(255, 42, 109, 0.4);
  color: #ff8fa3;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(10px);
  box-shadow: 0 0 15px rgba(255, 42, 109, 0.2);
  z-index: 5;
  transition: all 0.3s ease;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: #FF2A6D;
  border-radius: 50%;
  box-shadow: 0 0 8px #FF2A6D;
  animation: pulse-red 1.5s infinite;
}

.input-container {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1rem;
  padding: 0.5rem;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.input-container:focus-within {
  border-color: rgba(0, 240, 255, 0.4);
  box-shadow: 
    inset 0 2px 10px rgba(0,0,0,0.3),
    0 0 15px rgba(0, 240, 255, 0.1);
}

.input-container textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.75rem 0.5rem;
  resize: none;
  min-height: 44px;
  max-height: 150px;
  caret-color: var(--primary-glow);
}

.input-container textarea::placeholder {
  color: rgba(255, 255, 255, 0.3);
  font-style: italic;
}

/* =========================================
   BUTTONS
   ========================================= */
.btn {
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.btn svg {
  width: 1.25rem;
  height: 1.25rem;
  position: relative;
  z-index: 2;
}

/* Ghost Button (Mic) */
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  color: var(--primary-glow);
  background: rgba(0, 240, 255, 0.05);
  border-color: rgba(0, 240, 255, 0.1);
}

/* Recording State for Button */
.btn-ghost.recording .mic-icon {
  color: var(--system-alert);
}

/* Primary Button (Send) */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-dim), #004d52);
  color: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 240, 255, 0.3);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.1);
}

.btn-primary:not(:disabled):hover {
  background: linear-gradient(135deg, var(--primary-glow), var(--primary-dim));
  color: #000; /* Contrast text on bright bg */
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background: rgba(255, 255, 255, 0.05);
  border-color: transparent;
  color: rgba(255, 255, 255, 0.2);
  cursor: not-allowed;
  box-shadow: none;
}

/* Loader Spin */
.loader-icon {
  animation: spin 1s linear infinite;
}

/* =========================================
   STATUS BAR (NOTIFICATIONS)
   ========================================= */
.status-bar {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-radius: 30px;
  background: rgba(5, 11, 20, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  min-width: 300px;
  justify-content: space-between;
}

/* Types of status */
.status-bar.error {
  border-color: rgba(255, 42, 109, 0.3);
  color: #ff8fa3;
}
.status-bar.error .status-icon {
  color: var(--system-alert);
}

.status-bar.info {
  border-color: rgba(0, 240, 255, 0.3);
  color: var(--text-main);
}
.status-bar.info .status-icon {
  color: var(--primary-glow);
}

.status-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
}
.status-close:hover { opacity: 1; }

/* =========================================
   ANIMATIONS
   ========================================= */
@keyframes slide-up-fade {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pulse-green {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--system-success); }
  50% { opacity: 0.5; box-shadow: 0 0 2px var(--system-success); }
}

@keyframes pulse-red {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.7; }
}

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

@keyframes blink-fast {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes hologram-fade-in {
  0% { opacity: 0; transform: scale(0.95); filter: blur(5px); }
  100% { opacity: 1; transform: scale(1); filter: blur(0); }
}

/* Utility Class */
.hidden {
  display: none !important;
}
