.ai-chat-widget {
  position: fixed;
  bottom: 18px;
  right: 18px;
  width: min(360px, 92vw);
  max-height: 75vh;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

.ai-chat-widget * {
  box-sizing: border-box;
}

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: linear-gradient(90deg, #f8fafc 0%, #eef2ff 100%);
  cursor: grab;
  gap: 8px;
}

.ai-chat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: #0f172a;
  font-size: 14px;
}

.ai-chat-icon {
  display: inline-flex;
}

.ai-chat-actions {
  display: flex;
  gap: 4px;
}

.ai-chat-btn {
  border: none;
  background: transparent;
  color: #475569;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.ai-chat-btn:hover {
  background: rgba(148, 163, 184, 0.2);
}

.ai-chat-body {
  display: flex;
  flex-direction: column;
  padding: 12px 12px 14px;
  gap: 8px;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding-right: 2px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

.ai-chat-message {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  color: #0f172a;
  background: #f8fafc;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
  border: 1px solid #e2e8f0;
}

.ai-chat-user {
  margin-left: auto;
  background: #dbeafe;
  border: 1px solid #bfdbfe;
}

.ai-chat-bot {
  border: 1px solid #e2e8f0;
}

.ai-chat-info {
  background: #ecfeff;
  border: 1px dashed #67e8f9;
  color: #0f172a;
}

.ai-chat-error {
  background: #fef2f2;
  border: 1px solid #fecdd3;
  color: #b91c1c;
}

.ai-chat-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-chat-input-wrap {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, #fff 60%);
  padding-top: 8px;
}

.ai-chat-input {
  width: 100%;
  min-height: 42px;
  max-height: 120px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  font-size: 14px;
  outline: none;
  transition: border 0.15s ease, box-shadow 0.15s ease;
}

.ai-chat-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.ai-chat-send {
  background: linear-gradient(90deg, #6366f1 0%, #3b82f6 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.35);
}

.ai-chat-send:hover {
  opacity: 0.92;
}

.ai-chat-hint {
  font-size: 12px;
  color: #64748b;
  min-height: 16px;
}

.ai-chat-launcher {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 28px rgba(14,165,233,0.35);
  cursor: pointer;
}

.ai-chat-launcher svg {
  width: 22px;
  height: 22px;
}

.ai-chat-widget.ai-chat-collapsed .ai-chat-body,
.ai-chat-widget.ai-chat-collapsed .ai-chat-header {
  display: none;
}

.ai-chat-widget.ai-chat-collapsed .ai-chat-launcher {
  display: inline-flex;
}

.ai-chat-widget.ai-chat-collapsed {
  width: 56px;
  height: 56px;
  min-height: 56px;
  border-radius: 50%;
  padding: 0;
  border-width: 0;
}

.ai-chat-widget.ai-chat-collapsed .ai-chat-launcher {
  position: static;
  width: 100%;
  height: 100%;
}

@media (max-width: 640px) {
  .ai-chat-widget {
    left: 8px;
    right: 8px;
    bottom: 12px;
    width: auto;
  }
}
