/* ============================================================
   ReWoo Agent — AI Costing Copilot (Production Grade)
   Tool-grounded, audited deterministic costing intelligence
   ============================================================ */

/* Agent Floating Action Button */
.rewoo-agent-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0071e3 0%, #005bb5 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 8px 28px rgba(0, 113, 227, 0.38), 0 2px 8px rgba(0, 0, 0, 0.12);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

.rewoo-agent-fab:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 14px 36px rgba(0, 113, 227, 0.48), 0 4px 12px rgba(0, 0, 0, 0.16);
}

.rewoo-agent-fab:active {
  transform: scale(0.96);
}

.rewoo-agent-fab svg {
  width: 24px;
  height: 24px;
  stroke: #ffffff;
  transition: transform 0.25s ease;
}

.rewoo-agent-fab.is-open svg.icon-bot {
  display: none;
}
.rewoo-agent-fab svg.icon-close {
  display: none;
}
.rewoo-agent-fab.is-open svg.icon-close {
  display: block;
}

/* Online Pulse Dot */
.rewoo-agent-ping {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
}

.rewoo-agent-ping-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #34c759;
  opacity: 0.65;
  animation: agentPing 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.rewoo-agent-ping-dot {
  position: absolute;
  inset: 2.5px;
  border-radius: 50%;
  background: #34c759;
  border: 2px solid #ffffff;
}

@keyframes agentPing {
  0% { transform: scale(0.8); opacity: 0.9; }
  75%, 100% { transform: scale(2.2); opacity: 0; }
}

/* Agent Drawer / Modal Container */
.rewoo-agent-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 9995;
  width: 440px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 20px;
  box-shadow: 0 24px 64px -12px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.rewoo-agent-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Agent Header */
.agent-header {
  padding: 14px 18px;
  background: rgba(251, 251, 253, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.agent-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agent-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0071e3, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 113, 227, 0.25);
}

.agent-header-title {
  display: flex;
  flex-direction: column;
}

.agent-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1d1d1f;
  display: flex;
  align-items: center;
  gap: 6px;
}

.agent-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 113, 227, 0.1);
  color: #0071e3;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.agent-subtitle {
  font-size: 0.7rem;
  color: #86868b;
}

.agent-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.agent-btn-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6e6e73;
  cursor: pointer;
  transition: all 0.15s;
}

.agent-btn-icon:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #1d1d1f;
}

/* Engine Audit Bar */
.agent-audit-bar {
  background: #f8fafc;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  padding: 6px 16px;
  font-size: 0.68rem;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.agent-audit-bar span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.agent-audit-bar .green-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34c759;
}

/* Messages Body */
.agent-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #ffffff;
}

/* Message Bubble */
.agent-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  font-size: 0.84rem;
  line-height: 1.5;
  animation: msgFadeIn 0.22s ease forwards;
}

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

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

.agent-msg.user .agent-msg-bubble {
  background: #0071e3;
  color: #ffffff;
  border-radius: 16px 16px 4px 16px;
  padding: 9px 14px;
}

.agent-msg.bot {
  align-self: flex-start;
}

.agent-msg.bot .agent-msg-bubble {
  background: #f5f5f7;
  color: #1d1d1f;
  border-radius: 16px 16px 16px 4px;
  padding: 11px 15px;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.agent-msg-time {
  font-size: 0.65rem;
  color: #a1a1a6;
  margin-top: 4px;
  align-self: flex-end;
}

.agent-msg.bot .agent-msg-time {
  align-self: flex-start;
}

/* Tool Call Visual Container */
.tool-call-card {
  margin: 8px 0;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #0071e3;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.76rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.tool-call-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: #0071e3;
  margin-bottom: 4px;
  font-size: 0.72rem;
}

.tool-call-badge {
  background: rgba(0, 113, 227, 0.1);
  color: #0071e3;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.65rem;
}

.tool-call-output {
  background: #f8fafc;
  padding: 6px 8px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: #334155;
  margin-top: 4px;
  white-space: pre-wrap;
}

/* Typing Indicator */
.agent-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #f5f5f7;
  border-radius: 16px 16px 16px 4px;
  width: fit-content;
}

.agent-typing span {
  width: 6px;
  height: 6px;
  background: #86868b;
  border-radius: 50%;
  animation: typingBounce 1.3s infinite ease-in-out;
}

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

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* Suggested Prompts / Chips */
.agent-suggestions {
  padding: 8px 14px;
  background: #fafafc;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.agent-suggestions::-webkit-scrollbar {
  display: none;
}

.suggestion-chip {
  padding: 5px 10px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  color: #515154;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.suggestion-chip:hover {
  background: #0071e3;
  color: #ffffff;
  border-color: #0071e3;
}

/* Agent Input Bar */
.agent-input-container {
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.agent-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f5f5f7;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.agent-input-form:focus-within {
  border-color: #0071e3;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

.agent-input-field {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.84rem;
  color: #1d1d1f;
  font-family: inherit;
}

.agent-input-field::placeholder {
  color: #a1a1a6;
}

.agent-send-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #0071e3;
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.agent-send-btn:hover {
  background: #0077ed;
  transform: scale(1.04);
}

.agent-send-btn:disabled {
  background: #d2d2d7;
  cursor: not-allowed;
  transform: none;
}

.agent-send-btn svg {
  width: 14px;
  height: 14px;
  stroke: #ffffff;
}

/* Mobile Responsiveness */
@media (max-width: 900px) {
  .rewoo-agent-fab {
    bottom: 76px; /* sits comfortably above mobile bottom nav */
    right: 16px;
    width: 50px;
    height: 50px;
  }
  .rewoo-agent-panel {
    bottom: 72px; /* sits right above mobile bottom nav */
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
    height: calc(100vh - 150px);
    max-height: calc(100vh - 150px);
    border-radius: 16px;
  }
}
