/* ===== AI CHAT WIDGET ===== */
#ai-chat-widget {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9000;
  display: none;
  flex-direction: column;
  width: 380px;
  max-width: calc(100vw - 48px);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.22), 0 2px 8px rgba(0,0,0,.12);
  overflow: hidden;
  font-family: 'Inter', sans-serif;
  transition: transform .3s cubic-bezier(.4,0,.2,1), opacity .3s;
}

#ai-chat-widget.ai-chat--visible {
  display: flex;
}

/* Slide-in animation */
#ai-chat-widget.ai-chat--open {
  animation: aiChatSlideIn .3s cubic-bezier(.4,0,.2,1) both;
}

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

/* ─── Header ─────────────────────────────────────────────── */
.ai-chat-header {
  background: #1976d2;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.ai-chat-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,.18);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-chat-avatar svg {
  width: 20px;
  height: 20px;
  stroke: #fff;
}

.ai-chat-header-info {
  flex: 1;
  min-width: 0;
}

.ai-chat-header-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-chat-header-sub {
  font-size: 11px;
  opacity: .7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-chat-header-btns {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.ai-chat-header-btns button {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  font-size: 14px;
  line-height: 1;
}

.ai-chat-header-btns button:hover {
  background: rgba(255,255,255,.28);
}

/* ─── Messages ───────────────────────────────────────────── */
.ai-chat-messages {
  background: #f4f6f8;
  padding: 16px 14px;
  height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

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

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

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: #c8d0db;
  border-radius: 2px;
}

/* ─── Message bubbles ────────────────────────────────────── */
.ai-msg {
  display: flex;
  max-width: 88%;
}

.ai-msg--ai {
  align-self: flex-start;
}

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

.ai-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.ai-msg--ai .ai-msg-bubble {
  background: #fff;
  color: #1a1a2e;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.ai-msg--user .ai-msg-bubble {
  background: #1976d2;
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ─── Typing indicator ───────────────────────────────────── */
.ai-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 18px;
}

.ai-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #1976d2;
  opacity: .4;
  animation: aiDotBounce 1.2s infinite ease-in-out;
}

.ai-dots span:nth-child(2) { animation-delay: .2s; }
.ai-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes aiDotBounce {
  0%, 80%, 100% { transform: scale(.8); opacity: .4; }
  40%           { transform: scale(1.2); opacity: 1; }
}

/* ─── Approved banner ────────────────────────────────────── */
.ai-approved-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
  margin-top: 4px;
}

.ai-approved-banner svg {
  width: 20px;
  height: 20px;
  stroke: #2e7d32;
  flex-shrink: 0;
}

/* ─── Input area ─────────────────────────────────────────── */
.ai-chat-footer {
  background: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border-top: 1px solid #e8ecf0;
  flex-shrink: 0;
}

#ai-chat-input {
  flex: 1;
  border: 1.5px solid #dde2ea;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  resize: none;
  line-height: 1.45;
  max-height: 90px;
  overflow-y: auto;
  color: #1a1a2e;
  transition: border-color .15s;
}

#ai-chat-input:focus {
  border-color: #1976d2;
}

#ai-chat-input::placeholder {
  color: #aab0bc;
}

#ai-chat-input:disabled {
  background: #f4f6f8;
  color: #999;
  cursor: not-allowed;
}

#ai-chat-send {
  width: 38px;
  height: 38px;
  background: #1976d2;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}

#ai-chat-send:hover:not(:disabled) {
  background: #1565c0;
}

#ai-chat-send:active:not(:disabled) {
  transform: scale(.94);
}

#ai-chat-send:disabled {
  background: #b0bec5;
  cursor: not-allowed;
}

#ai-chat-send svg {
  width: 18px;
  height: 18px;
  stroke: #fff;
}

/* ─── Minimized state ────────────────────────────────────── */
#ai-chat-widget.ai-chat--minimized .ai-chat-messages,
#ai-chat-widget.ai-chat--minimized .ai-chat-footer {
  display: none;
}

/* ─── Mobile ─────────────────────────────────────────────── */
@media (max-width: 440px) {
  #ai-chat-widget {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-width: none;
  }

  .ai-chat-messages {
    height: 260px;
  }
}
