/* =========================================================================
   Kiwido Autonomous Risk Co-Pilot & Polyglot AI Agent Styling
   Neumorphic Soft UI Theme (Matching Uploaded Iconic Mobile & Plate Style)
   ========================================================================= */

/* Floating Launch Button (Soft UI Extruded Circular Pill) */
.copilot-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border-radius: 9999px;
  background: var(--bg-primary);
  border: 1px solid var(--border-glass);
  box-shadow: var(--neu-extruded), 0 0 16px var(--accent-indigo-glow);
  color: var(--text-primary);
  font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.copilot-fab:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--neu-extruded-lg), 0 0 24px var(--accent-indigo-glow);
  color: var(--accent-indigo);
}

.copilot-fab:active {
  transform: translateY(0) scale(0.99);
  box-shadow: var(--neu-inset);
}

.copilot-fab-pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bullish);
  box-shadow: 0 0 8px var(--bullish);
  animation: fabPulse 2s infinite;
}

@keyframes fabPulse {
  0% { transform: scale(0.95); opacity: 0.8; box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.6); }
  70% { transform: scale(1.15); opacity: 1; box-shadow: 0 0 0 8px rgba(5, 150, 105, 0); }
  100% { transform: scale(0.95); opacity: 0.8; box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

/* Copilot Window Container (Extruded Mobile Device Chassis like Uploaded Image) */
.copilot-window {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 440px;
  height: 640px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  z-index: 9005;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  border: 1px solid var(--border-glass);
  border-radius: 24px;
  box-shadow: var(--neu-extruded-lg);
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.copilot-window.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.96);
}

/* Header */
.copilot-header {
  padding: 16px 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), transparent);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.copilot-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.copilot-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-indigo));
  box-shadow: var(--neu-extruded-xs), 0 2px 8px var(--accent-indigo-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #FFF;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.copilot-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.copilot-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-primary);
  box-shadow: var(--neu-extruded-xs);
  color: var(--bullish);
  border: 1px solid var(--border-glass);
  text-transform: uppercase;
}

.copilot-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  margin: 2px 0 0 0;
}

.copilot-close-btn {
  background: var(--bg-primary);
  box-shadow: var(--neu-extruded-xs);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 8px;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.copilot-close-btn:hover {
  color: var(--text-primary);
  box-shadow: var(--neu-extruded-sm);
  transform: translateY(-1px);
}

.copilot-close-btn:active {
  box-shadow: var(--neu-inset-sm);
  transform: translateY(0);
}

.copilot-max-btn {
  background: var(--bg-primary);
  box-shadow: var(--neu-extruded-xs);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  padding: 5px 9px;
  border-radius: 8px;
  margin-right: 6px;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  line-height: 1;
}

.copilot-max-btn:hover {
  color: var(--accent-indigo);
  box-shadow: var(--neu-extruded-sm);
  transform: translateY(-1px);
}

.copilot-max-btn:active {
  box-shadow: var(--neu-inset-sm);
  transform: translateY(0);
}

/* Maximized State for Copilot Window */
.copilot-window.copilot-maximized {
  width: min(1080px, calc(100vw - 32px)) !important;
  height: min(850px, calc(100vh - 48px)) !important;
  bottom: 20px !important;
  right: 20px !important;
  border-radius: 20px !important;
}

/* Copilot Corner Resize Handle */
.copilot-resize-handle {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background: radial-gradient(circle, var(--text-muted) 1.5px, transparent 1.5px);
  background-size: 4px 4px;
  opacity: 0.5;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9999;
  border-radius: 3px;
}

.copilot-window:hover .copilot-resize-handle {
  opacity: 0.9;
}

.copilot-resize-handle:hover {
  opacity: 1;
  background: radial-gradient(circle, var(--accent-indigo) 1.5px, transparent 1.5px);
  background-size: 4px 4px;
  transform: scale(1.15);
}

/* Quick Action Chips (Soft Extruded Pills) */
.copilot-chips-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-sunken);
  box-shadow: inset 0 2px 4px var(--neu-shadow);
  border-bottom: 1px solid var(--border-glass);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.copilot-chips-bar::-webkit-scrollbar {
  display: none;
}

.copilot-chip {
  padding: 6px 14px;
  border-radius: 9999px;
  background: var(--bg-primary);
  box-shadow: var(--neu-extruded-xs);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

.copilot-chip:hover {
  box-shadow: var(--neu-extruded-sm);
  color: var(--accent-indigo);
  transform: translateY(-1px);
}

.copilot-chip:active {
  box-shadow: var(--neu-inset-sm);
  transform: translateY(0);
}

/* Messages Container */
.copilot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 12.5px;
  line-height: 1.5;
  background: var(--bg-primary);
  box-shadow: var(--neu-inset-sm);
}

.copilot-msg {
  display: flex;
  flex-direction: column;
  max-width: 90%;
  animation: fadeIn 0.2s ease;
}

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

.copilot-msg.user {
  align-self: flex-end;
}

.copilot-msg.user .copilot-bubble {
  background: linear-gradient(135deg, var(--accent-indigo), #1D4ED8);
  color: #FFFFFF;
  border-radius: 18px 18px 4px 18px;
  padding: 11px 16px;
  box-shadow: var(--neu-extruded-xs), 0 4px 12px var(--accent-indigo-glow);
  font-weight: 500;
}

.copilot-msg.agent {
  align-self: flex-start;
  max-width: 94%;
}

.copilot-msg.agent .copilot-bubble {
  background: var(--neu-gradient-convex);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  border-radius: 18px 18px 18px 4px;
  padding: 13px 16px;
  box-shadow: var(--neu-extruded-sm);
}

/* Proposal Card (Rule 1 Soft Extruded Box) */
.copilot-proposal-card {
  margin-top: 10px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  border: 1px solid rgba(5, 150, 105, 0.4);
  box-shadow: var(--neu-extruded-sm), 0 0 16px var(--bullish-glow);
}

.copilot-proposal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 700;
  color: var(--bullish);
  font-size: 11.5px;
}

.copilot-proposal-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.copilot-stat-box {
  background: var(--bg-sunken);
  box-shadow: var(--neu-inset-sm);
  padding: 7px 10px;
  border-radius: 8px;
}

.copilot-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  display: block;
}

.copilot-stat-val {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono, monospace);
}

.copilot-proposal-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn-confirm-buy {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  background: linear-gradient(145deg, #10B981, #059669);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.4);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--neu-extruded-xs), 0 2px 10px var(--bullish-glow);
}

.btn-confirm-buy:hover {
  box-shadow: var(--neu-extruded-sm), 0 4px 14px var(--bullish-glow);
  transform: translateY(-1px);
}

.btn-confirm-buy:active {
  box-shadow: var(--neu-inset-sm);
  transform: translateY(0);
}

.btn-reject-proposal {
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--bg-primary);
  box-shadow: var(--neu-extruded-xs);
  color: var(--text-secondary);
  border: 1px solid var(--border-glass);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-reject-proposal:hover {
  color: var(--bearish);
  box-shadow: var(--neu-extruded-sm);
  transform: translateY(-1px);
}

.btn-reject-proposal:active {
  box-shadow: var(--neu-inset-sm);
  transform: translateY(0);
}

/* Emergency Sell Alert Banner (Rule 2) */
.copilot-emergency-banner {
  margin-top: 10px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, rgba(225, 29, 72, 0.15), rgba(244, 63, 94, 0.08));
  border: 1px solid rgba(225, 29, 72, 0.5);
  box-shadow: var(--neu-extruded-sm), 0 0 16px var(--bearish-glow);
  animation: shakeAlert 0.4s ease;
}

@keyframes shakeAlert {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

.copilot-emergency-header {
  font-size: 12px;
  font-weight: 800;
  color: var(--bearish);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

/* Input Area (Neumorphic Lower Well) */
.copilot-footer {
  padding: 14px 18px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-glass);
  box-shadow: 0 -4px 12px var(--neu-shadow);
}

.copilot-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.copilot-input {
  flex: 1;
  background: var(--bg-primary);
  box-shadow: var(--neu-inset-sm);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 12.5px;
  outline: none;
  transition: all 0.2s ease;
}

.copilot-input:focus {
  border-color: var(--accent-indigo);
  box-shadow: var(--neu-inset-sm), 0 0 0 1px var(--accent-indigo);
}

.copilot-send-btn {
  background: linear-gradient(145deg, var(--accent-indigo), #1D4ED8);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 10px;
  color: white;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--neu-extruded-xs);
}

.copilot-send-btn:hover {
  box-shadow: var(--neu-extruded-sm), 0 2px 10px var(--accent-indigo-glow);
  transform: translateY(-1px);
}

.copilot-send-btn:active {
  box-shadow: var(--neu-inset-sm);
  transform: translateY(0);
}

.copilot-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 10.5px;
  color: var(--text-muted);
}

.copilot-lang-tag {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* =========================================================================
   Voice Command & Microphone Controls (Matching Uploaded Image Circular Dial)
   ========================================================================= */

/* Voice Microphone Button (Extruded Tactile Push Button) */
.copilot-mic-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  color: var(--accent-indigo);
  padding: 9px 13px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: var(--neu-extruded-xs);
}

.copilot-mic-btn:hover {
  box-shadow: var(--neu-extruded-sm);
  color: var(--accent-cyan);
  transform: translateY(-1px);
}

.copilot-mic-btn:active {
  box-shadow: var(--neu-inset-sm);
  transform: translateY(0);
}

.copilot-mic-btn.listening {
  background: linear-gradient(145deg, #EF4444, #DC2626) !important;
  color: #FFFFFF !important;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.6), var(--neu-extruded-sm) !important;
  animation: micPulseGlow 1.4s infinite;
}

@keyframes micPulseGlow {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1.06); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Speaker Mute/Unmute Toggle */
.copilot-speaker-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: var(--neu-extruded-xs);
}

.copilot-speaker-btn:hover {
  color: var(--text-primary);
  box-shadow: var(--neu-extruded-sm);
}

.copilot-speaker-btn.active {
  color: var(--bullish);
  box-shadow: var(--neu-inset-sm);
}

/* Voice Equalizer Visualizer Bar (Recessed Sound Bay like "Credit limit" Groove) */
.copilot-voice-wave-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  background: var(--bg-sunken);
  box-shadow: var(--neu-inset-sm);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  margin-bottom: 8px;
  animation: fadeIn 0.2s ease;
}

.copilot-voice-wave-bar.hidden {
  display: none !important;
}

.voice-bars-group {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 16px;
}

.voice-bar {
  width: 3px;
  border-radius: 2px;
  background: var(--accent-indigo);
  animation: voiceBarWave 0.9s ease-in-out infinite alternate;
}

.voice-bar:nth-child(1) { height: 6px; animation-delay: 0.1s; }
.voice-bar:nth-child(2) { height: 14px; animation-delay: 0.3s; }
.voice-bar:nth-child(3) { height: 18px; animation-delay: 0.2s; }
.voice-bar:nth-child(4) { height: 10px; animation-delay: 0.4s; }
.voice-bar:nth-child(5) { height: 5px; animation-delay: 0.15s; }

@keyframes voiceBarWave {
  0% { transform: scaleY(0.3); opacity: 0.5; }
  100% { transform: scaleY(1.3); opacity: 1; }
}

.voice-status-text {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-indigo);
}

.voice-transcript-interim {
  font-size: 11px;
  color: var(--text-secondary);
  font-style: italic;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
