/* ─────────────────────────────────────────────────────────────
   Sparkhes CRM — Notion AI-Style Floating Agent Stylesheet
   Compatible with Desktop & Mobile (/m)
   ───────────────────────────────────────────────────────────── */

:root {
  --agent-bg: rgba(8, 8, 8, 0.96);
  --agent-card: #0d0d0d;
  --agent-border: rgba(255, 255, 255, 0.08);
  --agent-border-glow: rgba(255, 255, 255, 0.15);
  --agent-text: #ffffff;
  --agent-text-muted: #888888;
  --agent-accent: #ffffff;
  --agent-accent-hover: rgba(255, 255, 255, 0.85);
}

/* 1. Floating Action Button (FAB) */
.sparkhes-ai-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.85), 0 0 16px rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9999;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.sparkhes-ai-fab:hover {
  transform: scale(1.06) translateY(-2px);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.95), 0 0 24px rgba(255, 255, 255, 0.12);
}

.sparkhes-ai-fab:active {
  transform: scale(0.95);
}

.sparkhes-ai-fab svg {
  width: 24px;
  height: 24px;
  color: #ffffff;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.4));
}

/* 2. Floating Agent Window / Drawer */
.sparkhes-ai-modal {
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 440px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 110px);
  background: var(--agent-bg);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid var(--agent-border);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.92), 0 0 1px rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 10000;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.sparkhes-ai-modal.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Modal Header */
.agent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(10, 10, 10, 0.8);
}

.agent-title-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agent-icon-badge {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}

.agent-icon-badge svg {
  width: 17px;
  height: 17px;
  color: #ffffff;
}

.agent-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.agent-model-tag {
  font-size: 0.68rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  letter-spacing: 0.02em;
}

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

.agent-btn-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--agent-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.agent-btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.agent-btn-icon svg {
  width: 16px;
  height: 16px;
}

/* 3. Suggestions Pill Strip */
.agent-suggestions-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  white-space: nowrap;
  background: rgba(12, 12, 14, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  scrollbar-width: none;
}

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

.agent-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  color: #e4e4e7;
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.agent-chip:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

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

/* 4. Chat Messages Scroll Area */
.agent-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.agent-messages-container::-webkit-scrollbar {
  width: 5px;
}

.agent-messages-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

/* Welcome Hero in empty state */
.agent-welcome-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  padding: 18px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.agent-welcome-card h4 {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
}

.agent-welcome-card p {
  font-size: 0.82rem;
  color: var(--agent-text-muted);
  line-height: 1.4;
}

/* Message Bubbles */
.agent-msg-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: fadeIn 0.18s ease;
}

.agent-msg-row.user {
  justify-content: flex-end;
}

.agent-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: #141414;
  border: 1px solid rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  flex-shrink: 0;
  margin-top: 2px;
}

.agent-msg-avatar svg {
  width: 15px;
  height: 15px;
}

.agent-msg-bubble {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #f4f4f5;
  word-break: break-word;
}

.agent-msg-row.user .agent-msg-bubble {
  background-color: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-top-right-radius: 2px;
  color: #ffffff;
}

.agent-msg-row.assistant .agent-msg-bubble {
  background-color: rgba(14, 14, 14, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-top-left-radius: 2px;
}

.agent-msg-bubble p {
  margin-bottom: 6px;
}

.agent-msg-bubble p:last-child {
  margin-bottom: 0;
}

.agent-msg-bubble ul, .agent-msg-bubble ol {
  padding-left: 18px;
  margin-bottom: 6px;
}

.agent-msg-bubble li {
  margin-bottom: 3px;
}

.agent-msg-bubble strong {
  color: #ffffff;
}

.agent-msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.agent-action-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.agent-action-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.28);
  color: #ffffff;
}

/* Thinking Indicator */
.agent-thinking {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(14, 14, 14, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  font-size: 0.82rem;
  color: var(--agent-text-muted);
}

.agent-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}

.agent-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: #ffffff;
  animation: agentPulse 1.2s infinite ease-in-out;
}

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

@keyframes agentPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* 5. Input Bar */
.agent-input-container {
  padding: 12px 16px;
  background: rgba(10, 10, 10, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.agent-input-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #111111;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 8px 12px;
  transition: border-color 0.15s ease;
}

.agent-input-box:focus-within {
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.agent-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.4;
  resize: none;
  max-height: 100px;
  min-height: 24px;
}

.agent-textarea::placeholder {
  color: #71717a;
}

.agent-input-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.agent-btn-send:disabled {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.4);
  cursor: not-allowed;
}

.agent-btn-send svg {
  width: 16px;
  height: 16px;
}

.agent-btn-voice {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--agent-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.agent-btn-voice.recording {
  color: #ff5252;
  animation: agentPulse 1s infinite ease-in-out;
}

.agent-btn-voice svg {
  width: 16px;
  height: 16px;
}

/* 6. Responsive Mobile Customizations */
@media (max-width: 767px) {
  .sparkhes-ai-fab {
    bottom: calc(var(--m-bottom-nav-height, 64px) + env(safe-area-inset-bottom, 0px) + 14px);
    right: 14px;
    width: 48px;
    height: 48px;
  }

  .sparkhes-ai-fab svg {
    width: 22px;
    height: 22px;
  }

  .sparkhes-ai-modal {
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    max-width: 100%;
    height: 85vh;
    height: 85dvh;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateY(100%);
  }

  .sparkhes-ai-modal.active {
    transform: translateY(0);
  }
}

/* 7. Action Confirmation Cards */
.agent-confirm-card {
  margin-top: 10px;
  padding: 12px 14px;
  background: #0f0f11;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  animation: agentFadeIn 0.2s ease-out;
}

.agent-confirm-card.destructive {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(24, 10, 12, 0.95);
}

.agent-confirm-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #f3f4f6;
  margin-bottom: 8px;
}

.agent-confirm-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.agent-confirm-card.destructive .agent-confirm-badge {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
}

.agent-confirm-details {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: 12px;
  color: #a1a1aa;
  line-height: 1.5;
}

.agent-confirm-details strong {
  color: #ffffff;
}

.agent-confirm-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.agent-btn-confirm {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: #ffffff;
  color: #000000;
  transition: all 0.15s ease;
}

.agent-btn-confirm:hover:not(:disabled) {
  background: #e4e4e7;
  transform: translateY(-1px);
}

.agent-confirm-card.destructive .agent-btn-confirm {
  background: #dc2626;
  color: #ffffff;
}

.agent-confirm-card.destructive .agent-btn-confirm:hover:not(:disabled) {
  background: #ef4444;
}

.agent-btn-cancel {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.06);
  color: #a1a1aa;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.15s ease;
}

.agent-btn-cancel:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.agent-btn-confirm:disabled,
.agent-btn-cancel:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.agent-confirm-result {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  margin-top: 8px;
}

.agent-confirm-result.success {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #4ade80;
}

.agent-confirm-result.cancelled {
  background: rgba(156, 163, 175, 0.12);
  border: 1px solid rgba(156, 163, 175, 0.2);
  color: #9ca3af;
}

.agent-confirm-result.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* 8. Interactive Entity Pills in Chat */
.agent-entity-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f3f4f6;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  vertical-align: middle;
}

.agent-entity-pill:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.28);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.agent-entity-pill:active {
  transform: scale(0.97);
}

.agent-entity-pill svg {
  width: 12px;
  height: 12px;
  color: #ffffff;
}

.agent-chip svg {
  width: 12px;
  height: 12px;
  color: rgba(255, 255, 255, 0.75);
  vertical-align: middle;
}


