/* AI Chatbot Widget - chatbot.css */

#aicw-root * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Toggle Button ── */
#aicw-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--aicw-accent);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,.22);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99998;
  transition: transform .2s, box-shadow .2s;
}
#aicw-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0,0,0,.28);
}
#aicw-toggle svg { transition: opacity .2s, transform .2s; }
#aicw-toggle .aicw-icon-chat  { position: absolute; }
#aicw-toggle .aicw-icon-close { position: absolute; opacity: 0; transform: rotate(-90deg); }
#aicw-root.open #aicw-toggle .aicw-icon-chat  { opacity: 0; transform: rotate(90deg); }
#aicw-root.open #aicw-toggle .aicw-icon-close { opacity: 1; transform: rotate(0deg); }

/* Unread badge */
#aicw-badge {
  position: absolute;
  top: -2px; right: -2px;
  width: 18px; height: 18px;
  background: #ef4444;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}
#aicw-badge.show { display: flex; }

/* ── Chat Window ── */
#aicw-window {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 360px;
  max-height: 540px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.16), 0 2px 8px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  z-index: 99997;
  overflow: hidden;
  transform: scale(.92) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform .22s cubic-bezier(.34,1.56,.64,1), opacity .18s ease;
}
#aicw-root.open #aicw-window {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Header */
#aicw-header {
  background: var(--aicw-accent);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#aicw-avatar {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.25);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
#aicw-header-info { flex: 1; }
#aicw-header-name { font-size: 14px; font-weight: 600; color: #fff; line-height: 1.2; }
#aicw-header-status { font-size: 11px; color: rgba(255,255,255,.75); display: flex; align-items: center; gap: 4px; }
.aicw-dot { width: 6px; height: 6px; background: #4ade80; border-radius: 50%; display: inline-block; }
#aicw-clear-btn {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: background .15s;
}
#aicw-clear-btn:hover { background: rgba(255,255,255,.25); }

/* Messages */
#aicw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8f9fb;
}
#aicw-messages::-webkit-scrollbar { width: 4px; }
#aicw-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.aicw-msg {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
  animation: aicw-pop .2s ease;
}
@keyframes aicw-pop {
  from { transform: scale(.95) translateY(4px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.aicw-msg.bot {
  background: #fff;
  color: #111;
  border-radius: 14px 14px 14px 4px;
  align-self: flex-start;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.aicw-msg.user {
  background: var(--aicw-accent);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
  align-self: flex-end;
}
.aicw-msg.error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  align-self: flex-start;
}

/* Typing indicator */
.aicw-typing {
  display: flex; gap: 4px; align-items: center;
  padding: 10px 14px;
  background: #fff;
  border-radius: 14px 14px 14px 4px;
  align-self: flex-start;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.aicw-typing span {
  width: 7px; height: 7px;
  background: #9ca3af;
  border-radius: 50%;
  animation: aicw-bounce 1.2s infinite;
}
.aicw-typing span:nth-child(2) { animation-delay: .2s; }
.aicw-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes aicw-bounce {
  0%,60%,100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Input row */
#aicw-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #f0f0f0;
  background: #fff;
  flex-shrink: 0;
}
#aicw-input {
  flex: 1;
  resize: none;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  line-height: 1.4;
  max-height: 100px;
  outline: none;
  transition: border .15s;
  color: #111;
  background: #fafafa;
}
#aicw-input:focus { border-color: var(--aicw-accent); background: #fff; }
#aicw-input::placeholder { color: #9ca3af; }
#aicw-send {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border: none;
  background: var(--aicw-accent);
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .15s, transform .15s;
}
#aicw-send:hover { opacity: .88; transform: scale(1.05); }
#aicw-send:disabled { opacity: .4; cursor: default; transform: none; }

/* Powered by */
#aicw-footer {
  text-align: center;
  padding: 6px;
  font-size: 10px;
  color: #9ca3af;
  background: #fff;
  border-top: 1px solid #f5f5f5;
}

/* Mobile */
@media (max-width: 480px) {
  #aicw-window {
    right: 8px;
    bottom: 80px;
    width: calc(100vw - 16px);
    max-height: 65vh;
  }
  #aicw-toggle { bottom: 16px; right: 16px; }
}
