/* JARVIS AI Assistant — floating launcher + chat panel. Reuses the
   ERP's own --ao-* brand tokens (see app.css :root) rather than
   introducing a second color system. */

.jarvis-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ao-primary);
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px rgba(61, 33, 29, 0.35);
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1050;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.jarvis-launcher:hover { transform: scale(1.06); }
.jarvis-launcher .jarvis-launcher-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ao-success);
  border: 2px solid #fff;
}

.jarvis-panel {
  position: fixed;
  right: 24px;
  bottom: 92px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 140px);
  background: var(--ao-card-bg);
  border: 1px solid var(--ao-border);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(61, 33, 29, 0.25);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 1050;
  font-family: var(--ao-font-sans);
}
.jarvis-panel.jarvis-open { display: flex; }
.jarvis-panel.jarvis-minimized { height: auto; }
.jarvis-panel.jarvis-minimized .jarvis-body,
.jarvis-panel.jarvis-minimized .jarvis-quick-actions,
.jarvis-panel.jarvis-minimized .jarvis-input-row { display: none; }

.jarvis-header {
  background: var(--ao-primary);
  color: #fff;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.jarvis-header-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.jarvis-header-text { flex-grow: 1; line-height: 1.15; }
.jarvis-header-title { font-weight: 700; font-size: 0.92rem; }
.jarvis-header-status { font-size: 0.72rem; opacity: 0.85; display: flex; align-items: center; gap: 4px; }
.jarvis-header-status .dot { width: 6px; height: 6px; border-radius: 50%; background: #6FE38A; display: inline-block; }
.jarvis-header-actions button {
  background: none;
  border: none;
  color: #fff;
  opacity: 0.85;
  font-size: 0.95rem;
  padding: 2px 6px;
  cursor: pointer;
}
.jarvis-header-actions button:hover { opacity: 1; }

/* Voice stage — the primary, voice-first surface: avatar + status +
   live transcript. Sits above the scrollable text log (.jarvis-body),
   which now serves as secondary conversation history, not the main
   interaction surface. */
.jarvis-voice-stage {
  flex-shrink: 0;
  padding: 14px 12px 10px;
  text-align: center;
  background: var(--ao-content-bg);
  border-bottom: 1px solid var(--ao-border);
}
.jarvis-avatar-ring {
  width: 56px;
  height: 56px;
  margin: 0 auto 6px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--ao-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.jarvis-avatar-ring.jarvis-listening { border-color: #C83A36; box-shadow: 0 0 0 6px rgba(200, 58, 54, 0.15); animation: jarvis-pulse-ring 1.4s infinite; }
.jarvis-avatar-ring.jarvis-speaking { border-color: var(--ao-primary); box-shadow: 0 0 0 6px rgba(142, 102, 57, 0.15); animation: jarvis-pulse-ring 1.4s infinite; }
.jarvis-avatar-ring.jarvis-thinking { border-color: var(--ao-warning); }
@keyframes jarvis-pulse-ring {
  0% { box-shadow: 0 0 0 4px rgba(200, 58, 54, 0.18); }
  50% { box-shadow: 0 0 0 10px rgba(200, 58, 54, 0.06); }
  100% { box-shadow: 0 0 0 4px rgba(200, 58, 54, 0.18); }
}
.jarvis-status-label { font-size: 0.78rem; font-weight: 600; color: var(--ao-text-color); }
.jarvis-transcript { font-size: 0.78rem; color: var(--ao-text-muted); min-height: 1.1em; margin-top: 4px; font-style: italic; }

.jarvis-body {
  flex-grow: 1;
  min-height: 60px;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--ao-content-bg);
}
.jarvis-msg { max-width: 85%; padding: 8px 12px; border-radius: 12px; font-size: 0.86rem; line-height: 1.35; white-space: pre-line; }
.jarvis-msg-bot { align-self: flex-start; background: #fff; border: 1px solid var(--ao-border); color: var(--ao-text-color); border-bottom-left-radius: 4px; }
.jarvis-msg-user { align-self: flex-end; background: var(--ao-primary); color: #fff; border-bottom-right-radius: 4px; }
.jarvis-typing { align-self: flex-start; font-size: 0.78rem; color: var(--ao-text-muted); padding: 2px 6px; }
.jarvis-typing .jarvis-dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--ao-text-muted); margin: 0 1px; animation: jarvis-bounce 1s infinite; }
.jarvis-typing .jarvis-dot:nth-child(2) { animation-delay: 0.15s; }
.jarvis-typing .jarvis-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes jarvis-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-3px); opacity: 1; } }

.jarvis-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--ao-border);
  background: var(--ao-card-bg);
}
.jarvis-quick-btn {
  border: 1px solid var(--ao-border);
  background: #fff;
  color: var(--ao-text-color);
  border-radius: 999px;
  font-size: 0.74rem;
  padding: 4px 10px;
  cursor: pointer;
}
.jarvis-quick-btn:hover { background: var(--ao-teal-soft); border-color: var(--ao-primary); }

.jarvis-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--ao-border);
  background: #fff;
}
.jarvis-input-row textarea {
  flex-grow: 1;
  resize: none;
  border: 1px solid var(--ao-border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.85rem;
  max-height: 80px;
  font-family: inherit;
}
.jarvis-input-row textarea:focus { outline: none; border-color: var(--ao-primary); }
.jarvis-send-btn {
  background: var(--ao-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  cursor: pointer;
}
.jarvis-send-btn:disabled { opacity: 0.5; cursor: default; }

.jarvis-mic-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px 4px;
  background: #fff;
  border-top: 1px solid var(--ao-border);
}
.jarvis-lang-toggle { display: flex; gap: 3px; }
.jarvis-lang-toggle button {
  border: 1px solid var(--ao-border);
  background: #fff;
  color: var(--ao-text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
  cursor: pointer;
}
.jarvis-lang-toggle button.active { background: var(--ao-primary); border-color: var(--ao-primary); color: #fff; }

.jarvis-mic-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background: var(--ao-primary);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(61, 33, 29, 0.3);
  flex-shrink: 0;
}
.jarvis-mic-btn.jarvis-listening { background: #C83A36; animation: jarvis-mic-pulse 1.2s infinite; }
.jarvis-mic-btn:disabled { opacity: 0.6; cursor: default; }
@keyframes jarvis-mic-pulse {
  0% { box-shadow: 0 0 0 0 rgba(200, 58, 54, 0.45); }
  70% { box-shadow: 0 0 0 12px rgba(200, 58, 54, 0); }
  100% { box-shadow: 0 0 0 0 rgba(200, 58, 54, 0); }
}
.jarvis-mic-label { font-size: 0.72rem; color: var(--ao-text-muted); text-align: center; }

.jarvis-type-toggle-btn {
  border: none;
  background: none;
  color: var(--ao-text-muted);
  font-size: 0.72rem;
  padding: 4px 12px 8px;
  cursor: pointer;
  text-align: center;
  width: 100%;
}
.jarvis-type-toggle-btn:hover { color: var(--ao-primary); }

@media (max-width: 480px) {
  .jarvis-panel { right: 16px; left: 16px; width: auto; bottom: 84px; }
  .jarvis-launcher { right: 16px; bottom: 16px; }
}
