/* ========================================
   AI ASSISTANT FLOATING WIDGET
   Matches cyprus-tax-calculator style,
   adapted for abasis.ai design tokens
   ======================================== */

/* ---------- Floating Action Button ---------- */
.assistant-fab {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-color, #4f46e5), var(--secondary-color, #2563eb), #7c3aed);
  color: #fff;
  box-shadow:
    0 6px 24px rgba(79, 70, 229, 0.35),
    0 0 0 0 rgba(79, 70, 229, 0.4);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s ease,
    opacity 0.3s ease;
  animation: assistant-pulse 3s ease-in-out infinite;
}

.assistant-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 32px rgba(79, 70, 229, 0.5);
}

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

.assistant-fab.is-open {
  animation: none;
  background: var(--neutral-100, #f1f5f9);
  color: var(--neutral-900, #0f172a);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--neutral-200, #e2e8f0);
  transform: rotate(90deg);
}

.assistant-fab svg {
  width: 24px;
  height: 24px;
  transition: transform 0.3s ease;
}

.assistant-fab .fab-glow {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(79, 70, 229, 0.4);
  filter: blur(12px);
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.assistant-fab.is-open .fab-glow {
  opacity: 0;
}

@keyframes assistant-pulse {
  0%, 100% {
    box-shadow:
      0 6px 24px rgba(79, 70, 229, 0.35),
      0 0 0 0 rgba(79, 70, 229, 0.4);
  }
  50% {
    box-shadow:
      0 6px 24px rgba(79, 70, 229, 0.35),
      0 0 0 12px rgba(79, 70, 229, 0);
  }
}

/* ---------- Chat Window ---------- */
.assistant-modal {
  position: fixed;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
  transition:
    opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0;
  pointer-events: none;

  /* Desktop placement */
  right: 1.5rem;
  bottom: 5.5rem;
  width: 380px;
  height: 620px;
  max-height: 80vh;
  border-radius: 1.75rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow:
    0 20px 50px rgba(8, 112, 184, 0.1),
    0 0 0 1px var(--neutral-200, #e2e8f0);
  transform-origin: calc(100% - 28px) calc(100% + 60px);
  transform: scale(0.5) translateY(20px);
}

.assistant-modal.is-visible {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

/* Mobile: full-screen */
@media (max-width: 767px) {
  .assistant-modal {
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    transform-origin: center bottom;
    transform: translateY(100%);
  }

  .assistant-modal.is-visible {
    transform: translateY(0);
  }

  .assistant-fab {
    bottom: 1.25rem;
  }

  .assistant-fab.is-open {
    display: none;
  }
}

/* ---------- Header ---------- */
.assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--neutral-100, #f1f5f9);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.assistant-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.assistant-header-close {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--neutral-500, #64748b);
  padding: 0.25rem;
  margin-left: -0.5rem;
}

@media (max-width: 767px) {
  .assistant-header-close {
    display: flex;
  }
}

.assistant-header-close svg {
  width: 24px;
  height: 24px;
}

.assistant-avatar {
  position: relative;
}

.assistant-avatar-glow {
  position: absolute;
  inset: 0;
  background: var(--primary-color, #4f46e5);
  border-radius: 0.75rem;
  filter: blur(8px);
  opacity: 0.2;
  transition: opacity 0.5s ease;
}

.assistant-avatar:hover .assistant-avatar-glow {
  opacity: 0.4;
}

.assistant-avatar-icon {
  position: relative;
  background: linear-gradient(135deg, var(--primary-color, #4f46e5), var(--secondary-color, #2563eb));
  padding: 0.5rem;
  border-radius: 0.75rem;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.assistant-avatar-icon svg {
  width: 18px;
  height: 18px;
  color: #fff;
}

.assistant-name {
  font-family: var(--font-heading, 'Outfit', sans-serif);
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text-primary, #0f172a);
  letter-spacing: -0.01em;
}

.assistant-status {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.assistant-status-dot {
  position: relative;
  width: 8px;
  height: 8px;
}

.assistant-status-dot::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #22c55e;
  animation: status-ping 2s ease-in-out infinite;
}

.assistant-status-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #22c55e;
}

@keyframes status-ping {
  0%, 100% { opacity: 0.75; transform: scale(1); }
  50% { opacity: 0; transform: scale(2); }
}

.assistant-status-text {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--neutral-400, #94a3b8);
}

.assistant-header-actions {
  display: flex;
  gap: 0.25rem;
}

.assistant-header-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  color: var(--neutral-400, #94a3b8);
  transition: color 0.2s, background 0.2s;
}

.assistant-header-btn:hover {
  color: var(--neutral-600, #475569);
  background: var(--neutral-100, #f1f5f9);
}

.assistant-header-btn svg {
  width: 16px;
  height: 16px;
}

/* ---------- Messages Area ---------- */
.assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  scroll-behavior: smooth;
}

.assistant-messages::-webkit-scrollbar {
  width: 4px;
}

.assistant-messages::-webkit-scrollbar-thumb {
  background: var(--neutral-200, #e2e8f0);
  border-radius: 99px;
}

.assistant-messages::-webkit-scrollbar-track {
  background: transparent;
}

/* Empty state */
.assistant-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 2rem;
  animation: fade-in-up 0.7s ease forwards;
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.assistant-empty-icon {
  position: relative;
  margin-bottom: 1.5rem;
}

.assistant-empty-icon-bg {
  position: absolute;
  inset: 0;
  background: var(--primary-color, #4f46e5);
  border-radius: 50%;
  filter: blur(20px);
  opacity: 0.15;
}

.assistant-empty-icon-inner {
  position: relative;
  background: var(--neutral-50, #f8fafc);
  border: 1px solid var(--neutral-200, #e2e8f0);
  padding: 1.5rem;
  border-radius: 1.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.assistant-empty-icon-inner svg {
  width: 40px;
  height: 40px;
  color: var(--primary-color, #4f46e5);
}

.assistant-empty h4 {
  font-family: var(--font-heading, 'Outfit', sans-serif);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-primary, #0f172a);
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.assistant-empty p {
  font-size: 0.85rem;
  color: var(--neutral-500, #64748b);
  line-height: 1.6;
  max-width: 260px;
  margin-bottom: 1rem;
}

/* Starter prompts */
.assistant-starters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  max-width: 300px;
}

.assistant-starter-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: var(--font-body, 'Inter', sans-serif);
  background: var(--neutral-50, #f8fafc);
  border: 1px solid var(--neutral-200, #e2e8f0);
  border-radius: 999px;
  color: var(--neutral-600, #475569);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.assistant-starter-btn:hover {
  background: rgba(79, 70, 229, 0.06);
  border-color: rgba(79, 70, 229, 0.3);
  color: var(--primary-color, #4f46e5);
}

/* Message: user */
.assistant-msg {
  display: flex;
  animation: msg-in 0.4s ease forwards;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.assistant-msg.is-user {
  justify-content: flex-end;
}

.assistant-msg.is-user .assistant-bubble {
  background: linear-gradient(135deg, var(--primary-color, #4f46e5), var(--secondary-color, #2563eb));
  color: #fff;
  border-radius: 1.25rem 1.25rem 0.25rem 1.25rem;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25);
}

/* Message: assistant */
.assistant-msg.is-bot {
  justify-content: flex-start;
}

.assistant-msg.is-bot .assistant-bubble {
  background: #fff;
  color: var(--text-primary, #0f172a);
  border: 1px solid var(--neutral-200, #e2e8f0);
  border-radius: 1.25rem 1.25rem 1.25rem 0.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.assistant-bubble {
  max-width: 82%;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  line-height: 1.65;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Markdown inside assistant bubbles */
.assistant-msg.is-bot .assistant-bubble p {
  margin: 0 0 0.5em 0;
}

.assistant-msg.is-bot .assistant-bubble p:last-child {
  margin-bottom: 0;
}

.assistant-msg.is-bot .assistant-bubble ul,
.assistant-msg.is-bot .assistant-bubble ol {
  padding-left: 1.2em;
  margin: 0.4em 0;
}

.assistant-msg.is-bot .assistant-bubble code {
  background: var(--neutral-100, #f1f5f9);
  padding: 0.15em 0.35em;
  border-radius: 0.25rem;
  font-size: 0.85em;
}

.assistant-msg.is-bot .assistant-bubble a {
  color: var(--primary-color, #4f46e5);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.assistant-msg.is-bot .assistant-bubble strong {
  font-weight: 600;
}

/* Typing indicator */
.assistant-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0.5rem 0;
}

.assistant-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--neutral-400, #94a3b8);
  animation: typing-bounce 1.4s ease-in-out infinite;
}

.assistant-typing span:nth-child(1) { animation-delay: -0.32s; }
.assistant-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* ---------- Composer ---------- */
.assistant-composer {
  padding: 0.75rem 1rem 1rem;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.6));
  backdrop-filter: blur(4px);
  flex-shrink: 0;
}

.assistant-input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.375rem;
  background: var(--neutral-50, #f8fafc);
  border: 1px solid var(--neutral-200, #e2e8f0);
  border-radius: 1.5rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.assistant-input-row:focus-within {
  border-color: rgba(79, 70, 229, 0.4);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}

.assistant-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 0.9rem;
  color: var(--text-primary, #0f172a);
  padding: 0.65rem 0.75rem;
  resize: none;
  line-height: 1.45;
}

.assistant-input::placeholder {
  color: var(--neutral-400, #94a3b8);
}

.assistant-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--primary-color, #4f46e5);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
  margin-bottom: 0.125rem;
}

.assistant-send-btn:hover {
  background: var(--primary-dark, #3730a3);
}

.assistant-send-btn:active {
  transform: scale(0.92);
}

.assistant-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.assistant-send-btn svg {
  width: 16px;
  height: 16px;
  margin-left: 2px;
}

.assistant-disclaimer {
  font-size: 0.625rem;
  text-align: center;
  color: var(--neutral-400, #94a3b8);
  margin-top: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
}
