/* ========================================================
   AEITRON AI ASSISTANT — MODERN ENTERPRISE UI
   Matches UI Specification & Design Concepts (Screenshot 1 & 2)
   Features:
   - Floating assistant launcher button (all pages)
   - Expandable / Maximizable chat window
   - Text & Voice mode switch
   - Live audio waveform avatar
   - Conversation history
   - Live transcript in voice mode
   - 4-grid Suggested questions
   - Source links & documentation references
   - Copy response & thumbs up/down feedback buttons
   ======================================================== */

:root {
  --ae-ai-bg: #0b0f19;
  --ae-ai-surface: #111827;
  --ae-ai-surface-hover: #1e293b;
  --ae-ai-border: rgba(255, 255, 255, 0.08);
  --ae-ai-border-hover: rgba(59, 130, 246, 0.4);
  --ae-ai-primary: #2563eb;
  --ae-ai-primary-hover: #1d4ed8;
  --ae-ai-primary-glow: rgba(37, 99, 235, 0.35);
  --ae-ai-text: #f8fafc;
  --ae-ai-text-muted: #94a3b8;
  --ae-ai-text-dim: #64748b;
  --ae-ai-online: #22c55e;
}

/* ========================================================
   1. FLOATING ASSISTANT LAUNCHER (Disabled - Header Button Active)
   ======================================================== */
.aeitron-floating-launcher {
  display: none !important;
}

/* ========================================================
   2. EXPANDABLE CHAT WINDOW BACKDROP & CARD (Screenshot 1)
   ======================================================== */
.aeitron-ai-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  padding: 24px;
  overscroll-behavior: contain;
  touch-action: none;
}
.aeitron-ai-card {
  background: var(--ae-ai-bg);
  border: 1px solid var(--ae-ai-border);
  color: var(--ae-ai-text);
  width: 100%;
  max-width: 460px;
  height: 640px;
  max-height: calc(100vh - 48px);
  border-radius: 20px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  animation: aiCardPopIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes aiCardPopIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Expandable Mode */
.aeitron-ai-card.is-expanded {
  max-width: 820px;
  height: calc(100vh - 48px);
}

/* Header */
.ai-card-header {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--ae-ai-border);
  background: rgba(17, 24, 39, 0.6);
}
.ai-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.ai-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #60a5fa;
}
.ai-header-info {
  display: flex;
  flex-direction: column;
}
.ai-header-name {
  font-size: 0.98rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}
.ai-header-status {
  font-size: 0.76rem;
  color: var(--ae-ai-text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.ai-header-status .status-dot {
  width: 7px;
  height: 7px;
  background: var(--ae-ai-online);
  border-radius: 50%;
  display: inline-block;
}
.ai-header-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.ai-hdr-btn {
  background: transparent;
  border: none;
  color: var(--ae-ai-text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.ai-hdr-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

/* Dropdown Menu (Three dots) */
.ai-menu-dropdown {
  position: absolute;
  top: 56px;
  right: 16px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0.4rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  z-index: 100;
  min-width: 170px;
}
.ai-menu-item {
  background: transparent;
  border: none;
  color: #e2e8f0;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  text-align: left;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: inherit;
  transition: background 0.15s ease;
}
.ai-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

/* Body */
.ai-card-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.4rem;
  display: flex;
  flex-direction: column;
}

/* Initial Welcome View */
.ai-welcome-section {
  display: flex;
  flex-direction: column;
  margin-top: 0.5rem;
}
.ai-welcome-heading {
  font-size: 1.45rem;
  font-weight: 800;
  color: #ffffff;
  margin: 0 0 0.45rem;
  line-height: 1.25;
}
.ai-welcome-sub {
  font-size: 0.9rem;
  color: var(--ae-ai-text-muted);
  margin: 0 0 1.5rem;
  line-height: 1.45;
}

/* ========================================================
   3. SUGGESTED QUESTIONS (2x2 Grid - Screenshot 1)
   ======================================================== */
.ai-suggestions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.ai-suggestion-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--ae-ai-border);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  color: var(--ae-ai-text);
  font-family: inherit;
}
.ai-suggestion-card:hover {
  background: var(--ae-ai-surface-hover);
  border-color: var(--ae-ai-border-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}
.ai-sug-icon {
  width: 28px;
  height: 28px;
  color: #60a5fa;
  display: flex;
  align-items: center;
}
.ai-sug-label {
  font-size: 0.92rem;
  font-weight: 600;
  color: #f1f5f9;
  line-height: 1.3;
}

/* ========================================================
   4. CONVERSATION HISTORY & MESSAGES
   ======================================================== */
.ai-chat-history-view {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.ai-chat-reset-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--ae-ai-border);
  margin-bottom: 0.4rem;
}
.btn-ai-back {
  background: none;
  border: none;
  color: #60a5fa;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.btn-ai-back:hover {
  text-decoration: underline;
}
.ai-engine-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  border: 1px solid rgba(16, 185, 129, 0.25);
}
.ai-chat-stream {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ai-bubble {
  max-width: 90%;
  padding: 0.85rem 1.05rem;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.5;
  word-break: break-word;
}
.ai-bubble-user {
  align-self: flex-end;
  background: var(--ae-ai-primary);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}
.ai-bubble-bot {
  align-self: flex-start;
  background: var(--ae-ai-surface);
  border: 1px solid var(--ae-ai-border);
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
}

/* ========================================================
   CLAUDE-STYLE THINKING BLOCK (Accordion & Animation)
   ======================================================== */
.ai-thought-container {
  margin-bottom: 0.75rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: 10px;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.ai-thought-header {
  padding: 0.45rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  background: rgba(168, 85, 247, 0.05);
  transition: background 0.15s ease;
}
.ai-thought-header:hover {
  background: rgba(168, 85, 247, 0.12);
}
.ai-thought-title-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #c084fc;
}
.ai-thought-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #c084fc;
}
.ai-thought-icon.pulsing {
  animation: aiThoughtPulse 1.4s infinite ease-in-out;
}
@keyframes aiThoughtPulse {
  0%, 100% { opacity: 0.5; transform: scale(0.92); }
  50% { opacity: 1; transform: scale(1.1); filter: drop-shadow(0 0 6px rgba(192, 132, 252, 0.8)); }
}
.ai-thought-status {
  font-size: 0.78rem;
  font-weight: 600;
  color: #e9d5ff;
}
.ai-thought-chevron {
  color: #a855f7;
  transition: transform 0.2s ease;
  font-size: 0.75rem;
  display: inline-block;
}
.ai-thought-container.open .ai-thought-chevron {
  transform: rotate(180deg);
}
.ai-thought-content {
  display: none;
  padding: 0.65rem 0.85rem;
  border-top: 1px solid rgba(168, 85, 247, 0.15);
  font-size: 0.78rem;
  color: #cbd5e1;
  line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: rgba(0, 0, 0, 0.25);
  max-height: 200px;
  overflow-y: auto;
  border-left: 2px solid #a855f7;
  white-space: pre-wrap;
}
.ai-thought-container.open .ai-thought-content {
  display: block;
}

/* Streaming Blinking Cursor */
.ai-streaming-cursor {
  display: inline-block;
  width: 6px;
  height: 14px;
  background: #60a5fa;
  margin-left: 3px;
  vertical-align: middle;
  border-radius: 1px;
  animation: aiCursorBlink 0.75s infinite ease-in-out;
}
@keyframes aiCursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Message Meta & Action Buttons (Copy, Feedback, Audio) */
.ai-msg-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.65rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.ai-msg-btn-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.ai-action-icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--ae-ai-text-muted);
  padding: 0.22rem 0.45rem;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s ease;
  font-family: inherit;
}
.ai-action-icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}
.ai-action-icon-btn.active {
  background: rgba(37, 99, 235, 0.25);
  border-color: rgba(59, 130, 246, 0.5);
  color: #60a5fa;
}

/* Documentation / Source Badges (Feature 8) */
.ai-source-references {
  margin-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.ai-source-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(37, 99, 235, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
}
.ai-source-chip:hover {
  background: rgba(37, 99, 235, 0.25);
  border-color: #60a5fa;
  color: #ffffff;
}

/* Typing Indicator */
.ai-typing-box {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0.75rem 1rem;
  background: var(--ae-ai-surface);
  border: 1px solid var(--ae-ai-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  align-self: flex-start;
}
.ai-typing-box span {
  width: 6px;
  height: 6px;
  background: #60a5fa;
  border-radius: 50%;
  animation: aiPulse 1.4s infinite ease-in-out;
}
.ai-typing-box span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-box span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.15); opacity: 1; }
}

/* ========================================================
   5. BOTTOM INPUT BAR (Screenshot 1)
   ======================================================== */
.ai-card-footer {
  padding: 0.85rem 1.25rem 0.95rem;
  background: var(--ae-ai-bg);
  border-top: 1px solid var(--ae-ai-border);
}
.ai-input-wrapper {
  background: var(--ae-ai-surface);
  border: 1px solid var(--ae-ai-border);
  border-radius: 16px;
  padding: 0.65rem 0.8rem 0.65rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.ai-input-wrapper:focus-within {
  border-color: rgba(59, 130, 246, 0.5);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.ai-input-field {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-size: 0.92rem;
  font-family: inherit;
}
.ai-input-field::placeholder {
  color: var(--ae-ai-text-dim);
}
.ai-input-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ai-controls-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.ai-icon-tool-btn {
  background: transparent;
  border: none;
  color: var(--ae-ai-text-dim);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
}
.ai-icon-tool-btn:hover {
  color: #ffffff;
}
.ai-controls-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.ai-btn-mic {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--ae-ai-primary);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ai-btn-mic:hover {
  background: var(--ae-ai-primary-hover);
  transform: scale(1.05);
}
.ai-btn-mic.listening {
  background: #ef4444;
  animation: aiMicPulse 1.2s infinite ease-in-out;
}
@keyframes aiMicPulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.ai-btn-send {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--ae-ai-primary);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ai-btn-send:hover {
  background: var(--ae-ai-primary-hover);
  transform: scale(1.05);
}
.ai-footer-branding {
  text-align: center;
  font-size: 0.74rem;
  color: var(--ae-ai-text-dim);
  margin-top: 0.5rem;
}

/* ========================================================
   6. VOICE CONVERSATION MODE (Screenshot 2)
   ======================================================== */
.ai-voice-conversation-mode {
  position: absolute;
  inset: 0;
  background: var(--ae-ai-bg);
  border-radius: 20px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem;
  animation: aiVoiceFadeIn 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes aiVoiceFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}
.voice-mode-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.voice-mode-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
}
.voice-mode-close {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--ae-ai-text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.voice-mode-close:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

/* Center Live Audio Waveform Avatar (Screenshot 2) */
.voice-center-card {
  background: var(--ae-ai-surface);
  border: 1px solid var(--ae-ai-border);
  border-radius: 18px;
  padding: 2.2rem 1.5rem 1.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}
.voice-wave-circle {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: #1e3a5f;
  border: 2px solid rgba(59, 130, 246, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  box-shadow: 0 0 25px rgba(37, 99, 235, 0.45);
  transition: all 0.2s ease;
}
.voice-wave-circle.listening {
  background: #1d4ed8;
  box-shadow: 0 0 35px rgba(59, 130, 246, 0.7);
}
.voice-wave-circle.speaking {
  background: #7c3aed;
  border-color: rgba(168, 85, 247, 0.6);
  box-shadow: 0 0 35px rgba(124, 58, 237, 0.7);
}

/* Audio Waveform Bars */
.live-audio-bars {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 26px;
}
.audio-bar {
  width: 3.5px;
  background: #ffffff;
  border-radius: 9999px;
  height: 8px;
  animation: liveWavePulse 1.2s infinite ease-in-out;
}
.audio-bar:nth-child(1) { height: 10px; animation-delay: 0.1s; }
.audio-bar:nth-child(2) { height: 20px; animation-delay: 0.25s; }
.audio-bar:nth-child(3) { height: 26px; animation-delay: 0.4s; }
.audio-bar:nth-child(4) { height: 16px; animation-delay: 0.55s; }
.audio-bar:nth-child(5) { height: 9px;  animation-delay: 0.7s; }

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

.voice-status-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0 0 0.3rem;
}
.voice-status-sub {
  font-size: 0.84rem;
  color: var(--ae-ai-text-muted);
  margin: 0 0 1.25rem;
}

/* Live Voice Transcript Box */
.voice-live-transcript-box {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  color: #e2e8f0;
  line-height: 1.45;
  margin-bottom: 1.2rem;
  min-height: 48px;
  max-height: 90px;
  overflow-y: auto;
  text-align: left;
}

/* Bottom Control Icons (Screenshot 2: Mic, Speaker, Red End Call) */
.voice-action-icons-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}
.voice-ctrl-icon-btn {
  background: transparent;
  border: none;
  color: var(--ae-ai-text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.voice-ctrl-icon-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}
.voice-ctrl-icon-btn.active {
  color: #60a5fa;
}
.voice-ctrl-icon-btn.end-call {
  color: #ef4444;
}
.voice-ctrl-icon-btn.end-call:hover {
  background: rgba(239, 68, 68, 0.15);
}

.voice-footer-concept {
  text-align: center;
  font-size: 0.74rem;
  color: var(--ae-ai-text-dim);
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
  .aeitron-ai-backdrop {
    padding: 0;
  }
  .aeitron-ai-card {
    max-width: 100%;
    height: 90vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }
  .aeitron-floating-launcher {
    bottom: 18px;
    right: 18px;
  }
}
