/* ============================================================
   assets/css/ai-widget.css
   Floating AI Assistant button + slide-up chat panel.
   Classes are prefixed "aiw-" so this is safe to load on ANY page
   (including the standalone login page) without colliding with
   that page's own styles.
   ============================================================ */

.aiw-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  z-index: 1050;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.aiw-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(99, 102, 241, 0.55); }
.aiw-fab:active { transform: translateY(0); }
.aiw-fab .aiw-fab-close-icon { display: none; }
.aiw-fab.open .aiw-fab-chat-icon { display: none; }
.aiw-fab.open .aiw-fab-close-icon { display: block; }

.aiw-fab-dot {
  position: absolute; top: 2px; right: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #ef4444; border: 2px solid #fff; display: none;
}

.aiw-panel {
  position: fixed;
  right: 20px;
  bottom: 88px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1049;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.aiw-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
[data-theme="dark"] .aiw-panel { background: #1e293b; }

.aiw-header {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.aiw-header-icon {
  width: 32px; height: 32px; border-radius: 9px;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 14px;
}
.aiw-header-text { flex: 1; min-width: 0; }
.aiw-header-title { font-weight: 700; font-size: 14px; line-height: 1.3; }
.aiw-header-sub { font-size: 11.5px; opacity: 0.85; line-height: 1.3; }
.aiw-header-close {
  background: none; border: none; color: #fff; opacity: 0.85;
  font-size: 16px; cursor: pointer; padding: 4px; flex-shrink: 0;
}
.aiw-header-close:hover { opacity: 1; }

.aiw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fafc;
}
[data-theme="dark"] .aiw-messages { background: #0f172a; }

.aiw-msg {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 13px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.aiw-msg-bot {
  background: #fff;
  color: #0f172a;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
[data-theme="dark"] .aiw-msg-bot { background: #1e293b; color: #f1f5f9; }
.aiw-msg-user {
  background: #6366f1;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.aiw-msg-error {
  background: #fef2f2; color: #b91c1c;
  align-self: center; text-align: center; font-size: 12.5px;
}

.aiw-typing { display: flex; gap: 4px; padding: 10px 12px; align-self: flex-start; }
.aiw-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: #9ca3af;
  display: inline-block; animation: aiwTyping 1.2s infinite ease-in-out;
}
.aiw-typing span:nth-child(2) { animation-delay: 0.2s; }
.aiw-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiwTyping {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.aiw-composer {
  flex-shrink: 0;
  border-top: 1px solid #e5e7eb;
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #fff;
}
[data-theme="dark"] .aiw-composer { background: #1e293b; border-top-color: #334155; }
.aiw-input {
  flex: 1;
  resize: none;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  max-height: 90px;
  outline: none;
  background: #fff;
  color: #0f172a;
}
.aiw-input:focus { border-color: #6366f1; }
[data-theme="dark"] .aiw-input { background: #0f172a; border-color: #334155; color: #f1f5f9; }
.aiw-send {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: #6366f1; color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; transition: background 0.15s;
}
.aiw-send:hover { background: #4f46e5; }
.aiw-send:disabled { opacity: 0.5; cursor: not-allowed; }

.aiw-guest-note {
  font-size: 11px; color: #94a3b8; text-align: center;
  padding: 6px 12px 10px; flex-shrink: 0;
}

/* Mobile: panel becomes a near-fullscreen sheet */
@media (max-width: 480px) {
  .aiw-panel {
    right: 12px; left: 12px; width: auto;
    bottom: 84px; height: min(70vh, 560px);
  }
  .aiw-fab { right: 16px; bottom: 16px; }
}
