/* ── Floating AI Button ────────────────────────────────────────────────── */
.ai-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--green, #4ade80);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(74, 222, 128, 0.45);
  z-index: 9998;
  border: none;
  outline: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.ai-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(74, 222, 128, 0.65);
}
.ai-fab:active { transform: scale(0.97); }

/* ── Chat Window ──────────────────────────────────────────────────────── */
.ai-window {
  position: fixed;
  bottom: 94px;
  right: 28px;
  width: 360px;
  max-width: calc(100vw - 48px);
  height: 500px;
  max-height: calc(100vh - 130px);
  background: #080808;
  border: 1px solid #1e1e1e;
  border-radius: 10px;
  display: flex;           /* always flex — animation handled by opacity/visibility */
  flex-direction: column;
  z-index: 9999;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.85);
  font-family: 'JetBrains Mono', monospace, sans-serif;
  overflow: hidden;

  /* Hidden state — use opacity + scale instead of display:none so transitions work */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(14px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0.25s;
}
.ai-window.open {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  transform: translateY(0) scale(1);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0s;
}

/* ── Header ───────────────────────────────────────────────────────────── */
.ai-header {
  background: #030303;
  padding: 13px 15px;
  border-bottom: 1px solid #1e1e1e;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.ai-title {
  color: #4ade80;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
}
.ai-close {
  background: transparent;
  border: none;
  color: #555;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
  transition: color 0.2s;
}
.ai-close:hover { color: #f87171; }

/* ── Message Body ─────────────────────────────────────────────────────── */
.ai-body {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #0a0a0a;
  scroll-behavior: smooth;
}
.ai-body::-webkit-scrollbar { width: 4px; }
.ai-body::-webkit-scrollbar-track { background: transparent; }
.ai-body::-webkit-scrollbar-thumb { background: #222; border-radius: 4px; }

/* ── Messages ──────────────────────────────────────────────────────────── */
.ai-msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 6px;
  font-size: 12.5px;
  line-height: 1.6;
  word-break: break-word;
  animation: msgIn 0.18s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ai-msg.bot {
  background: #111;
  color: #ddd;
  border-left: 2px solid #4ade80;
  align-self: flex-start;
}
.ai-msg.user {
  background: #171717;
  color: #f0f0f0;
  border-right: 2px solid #444;
  align-self: flex-end;
}
.ai-msg a {
  color: #4ade80;
  text-decoration: underline;
}
.ai-msg code {
  background: #1a1a1a;
  color: #4ade80;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11.5px;
}

/* ── Suggestion Chips ──────────────────────────────────────────────────── */
.ai-options {
  padding: 8px 12px;
  background: #080808;
  border-top: 1px solid #1a1a1a;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-shrink: 0;
}
.ai-options::-webkit-scrollbar { display: none; }
.ai-chip {
  background: #111;
  color: #888;
  border: 1px solid #2a2a2a;
  padding: 5px 11px;
  border-radius: 20px;
  font-size: 10.5px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  user-select: none;
}
.ai-chip:hover {
  background: rgba(74, 222, 128, 0.08);
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.5);
}

/* ── Input Row ─────────────────────────────────────────────────────────── */
.ai-input-area {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: #030303;
  border-top: 1px solid #1a1a1a;
  gap: 8px;
  flex-shrink: 0;
}
.ai-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #f0f0f0;
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  min-width: 0;
}
.ai-input::placeholder { color: #444; }
.ai-send {
  background: transparent;
  border: none;
  color: #4ade80;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0;
}
.ai-send:hover { transform: scale(1.15); }
.ai-send:active { transform: scale(0.95); }
.ai-send:disabled { color: #333; cursor: not-allowed; transform: none; }

/* ── Typing indicator ──────────────────────────────────────────────────── */
.ai-msg.typing {
  color: #555;
  font-size: 11.5px;
  font-style: italic;
  border-left-color: #333;
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .ai-window {
    bottom: 86px;
    right: 14px;
    left: 14px;
    width: auto;
    max-width: 100%;
    transform-origin: bottom center;
  }
  .ai-fab {
    bottom: 20px;
    right: 20px;
  }
}
