/* AI Assistant chat widget - minimalist, mobile-first */

/* FAB button */
.assistant-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 1000;
  width: 52px; height: 52px; border-radius: 14px; border: none; cursor: pointer;
  background: var(--n900, #111827);
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.assistant-fab:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.assistant-fab svg { width: 22px; height: 22px; fill: #fff; }
.assistant-fab.open svg.icon-chat { display: none; }
.assistant-fab:not(.open) svg.icon-close { display: none; }

/* Chat panel - desktop */
.assistant-panel {
  position: fixed; bottom: 92px; right: 24px; z-index: 999;
  width: 400px; max-height: 560px; border-radius: 16px;
  background: #fff; box-shadow: 0 4px 32px rgba(0,0,0,0.12);
  border: 1px solid var(--n200, #e5e7eb);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: translateY(12px) scale(0.97);
  pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.assistant-panel.visible {
  opacity: 1; transform: translateY(0) scale(1); pointer-events: auto;
}

/* Header */
.assistant-header {
  padding: 14px 20px; border-bottom: 1px solid var(--n200, #e5e7eb);
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.assistant-header-logo {
  font-family: var(--font-display, 'Sora', sans-serif);
  font-weight: 700; font-size: 15px; letter-spacing: 0.06em;
  color: var(--n900, #111827);
}
.assistant-header-info { flex: 1; }
.assistant-header-name {
  font-family: var(--font-display, 'Sora', sans-serif);
  font-weight: 600; font-size: 13px; color: var(--n900, #111827);
}
.assistant-header-status { font-size: 11px; color: var(--n400, #9ca3af); }
.assistant-clear-btn {
  background: none; border: none; cursor: pointer; padding: 4px 8px;
  color: var(--n400, #9ca3af); font-size: 11px;
  border-radius: 6px; transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.assistant-clear-btn:hover {
  color: var(--n600, #4b5563); background: var(--n100, #f3f4f6);
}

/* Close button - visible on mobile, hidden on desktop */
.assistant-close-btn {
  display: none; background: none; border: none; cursor: pointer;
  padding: 6px; border-radius: 8px; color: var(--n400, #9ca3af);
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.assistant-close-btn svg { fill: currentColor; }
.assistant-close-btn:hover {
  color: var(--n600, #4b5563); background: var(--n100, #f3f4f6);
}

/* Messages area */
.assistant-messages {
  flex: 1; overflow-y: auto; padding: 16px; min-height: 0;
  display: flex; flex-direction: column; gap: 10px;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}

/* Message bubbles */
.assistant-msg {
  max-width: 85%; padding: 10px 14px; border-radius: 12px;
  font-size: 13.5px; line-height: 1.6;
  word-wrap: break-word; overflow-wrap: break-word;
}
.assistant-msg.user {
  align-self: flex-end; background: var(--n900, #111827);
  color: #fff; border-bottom-right-radius: 4px;
}
.assistant-msg.bot {
  align-self: flex-start; background: var(--n50, #f9fafb);
  border: 1px solid var(--n200, #e5e7eb);
  color: var(--n800, #1f2937); border-bottom-left-radius: 4px;
}

/* Markdown inside bot messages */
.assistant-msg.bot p { margin: 0 0 8px; }
.assistant-msg.bot p:last-child { margin: 0; }
.assistant-msg.bot ul, .assistant-msg.bot ol { padding-left: 18px; margin: 4px 0 8px; }
.assistant-msg.bot li { margin: 2px 0; }
.assistant-msg.bot code {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  background: rgba(0,0,0,0.05); padding: 1px 5px; border-radius: 3px;
}
.assistant-msg.bot pre {
  background: var(--n900, #111827); color: #e5e7eb; padding: 10px;
  border-radius: 6px; overflow-x: auto; margin: 6px 0;
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
}
.assistant-msg.bot pre code { background: none; padding: 0; color: inherit; }
.assistant-msg.bot strong { font-weight: 600; }
.assistant-msg.bot a { color: var(--n900, #111827); text-decoration: underline; }

/* Typing indicator */
.assistant-typing {
  align-self: flex-start; padding: 10px 14px;
  background: var(--n50, #f9fafb); border: 1px solid var(--n200, #e5e7eb);
  border-radius: 12px; display: none; gap: 4px; align-items: center;
}
.assistant-typing.visible { display: flex; }
.assistant-typing span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--n400, #9ca3af); animation: assistantBounce 1.2s infinite;
}
.assistant-typing span:nth-child(2) { animation-delay: 0.2s; }
.assistant-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes assistantBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-3px); }
}

/* Input area */
.assistant-input-area {
  padding: 12px 16px; border-top: 1px solid var(--n200, #e5e7eb);
  display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0;
}
.assistant-input {
  flex: 1; border: 1px solid var(--n200, #e5e7eb); border-radius: 10px;
  padding: 10px 14px; font-size: 16px; font-family: 'Inter', sans-serif;
  resize: none; max-height: 100px; line-height: 1.4;
  outline: none; transition: border-color 0.15s;
  color: var(--n800, #1f2937); min-width: 0;
}
.assistant-input:focus { border-color: var(--n500, #6b7280); }
.assistant-input::placeholder { color: var(--n400, #9ca3af); }

/* Send button */
.assistant-send-btn {
  width: 36px; height: 36px; border-radius: 10px; border: none;
  background: var(--n900, #111827); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.assistant-send-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.assistant-send-btn svg { width: 16px; height: 16px; fill: #fff; }

/* Welcome message */
.assistant-welcome {
  text-align: center; padding: 24px 16px; color: var(--n500, #6b7280);
  font-size: 13px; line-height: 1.6;
}
.assistant-welcome strong {
  display: block; font-size: 14px;
  color: var(--n800, #1f2937); margin-bottom: 4px;
}

/* Mobile responsive - fullscreen on small screens */
@media (max-width: 640px) {
  .assistant-fab {
    bottom: 16px; right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .assistant-fab.open { display: none; }
  .assistant-close-btn { display: flex; align-items: center; justify-content: center; }
  .assistant-panel {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; max-width: 100%; max-height: 100%;
    border-radius: 0; border: none; box-shadow: none;
  }
  .assistant-header {
    border-radius: 0; padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }
  .assistant-messages { flex: 1; min-height: 0; padding: 12px; }
  .assistant-input-area {
    border-radius: 0; padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .assistant-input { font-size: 16px; }
}
