/* AI Assistant Core Variables */
:root {
  --ai-primary: #ff2033; /* Using the existing red accent */
  --ai-bg: rgba(10, 10, 10, 0.85); /* Glassmorphism dark background */
  --ai-surface: rgba(25, 25, 25, 0.95);
  --ai-border: rgba(255, 255, 255, 0.08);
  --ai-text: #ffffff;
  --ai-text-muted: #a0a0a0;
  --ai-radius-lg: 20px;
  --ai-radius-md: 12px;
  --ai-radius-sm: 8px;
  --ai-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  --ai-font: 'Plus Jakarta Sans', sans-serif;
  --ai-transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Floating Button with Spinning Gradient Border */
#ai-floating-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: transparent;
  color: var(--ai-text);
  padding: 2px; /* Border thickness */
  border-radius: 30px;
  font-family: var(--ai-font);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 25px rgba(139, 92, 246, 0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: ai-float-in 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* The spinning gradient background */
#ai-floating-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150%;
  height: 300%;
  background: conic-gradient(from 0deg, transparent 0%, transparent 40%, #ff2033 50%, #8b5cf6 60%, #3b82f6 70%, transparent 80%);
  transform: translate(-50%, -50%);
  animation: ai-border-spin 3s linear infinite;
  z-index: 0;
}

/* The inner pill */
.ai-btn-inner {
  position: relative;
  background: rgba(15, 15, 15, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 10px 20px;
  border-radius: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 1;
  width: 100%;
  height: 100%;
}

#ai-floating-btn:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), 0 0 40px rgba(139, 92, 246, 0.6);
}

#ai-floating-btn:active {
  transform: scale(0.94);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 20px rgba(139, 92, 246, 0.5);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

/* Ripple burst on click */
#ai-floating-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 30px;
  background: conic-gradient(from 0deg, #8b5cf6, #3b82f6, #ff2033, #8b5cf6);
  opacity: 0;
  z-index: -1;
  transition: opacity 0.2s ease;
}

#ai-floating-btn:active::after {
  opacity: 0.4;
  animation: ai-ripple-burst 0.5s ease forwards;
}

@keyframes ai-ripple-burst {
  0%   { transform: scale(1);   opacity: 0.5; }
  100% { transform: scale(1.6); opacity: 0; }
}

#ai-floating-btn .ai-star {
  background: linear-gradient(135deg, #ff2033, #8b5cf6, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: ai-hue-rotate 4s linear infinite;
}

/* Logo image - mix-blend-mode removes black bg, only white NG shows */
.ai-logo-img {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  mix-blend-mode: screen;
  filter: brightness(1.15);
}

/* AI label */
.ai-btn-label {
  font-family: var(--ai-font);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: linear-gradient(135deg, #a78bfa, #60a5fa, #a78bfa);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
  animation: ai-shimmer 3s linear infinite;
}

@keyframes ai-shimmer {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

@keyframes ai-border-spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes ai-pulse-glow {
  0% { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 15px rgba(139, 92, 246, 0.1); }
  100% { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 25px rgba(139, 92, 246, 0.35); }
}

@keyframes ai-hue-rotate {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

/* Chat Panel */
#ai-chat-panel {
  position: fixed;
  bottom: 90px;
  right: 30px;
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 120px);
  background: var(--ai-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius-lg);
  box-shadow: var(--ai-shadow);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--ai-font);
  pointer-events: none;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: var(--ai-transition);
}

#ai-chat-panel.active {
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Header */
.ai-header {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--ai-border);
  background: rgba(0, 0, 0, 0.2);
}

.ai-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--ai-text);
  display: flex;
  flex-direction: column;
}

.ai-subtitle {
  font-size: 12px;
  color: var(--ai-text-muted);
  font-weight: 400;
}

.ai-status-dot {
  width: 8px;
  height: 8px;
  background-color: #22c55e;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.ai-close-btn {
  background: none;
  border: none;
  color: var(--ai-text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: var(--ai-transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ai-text);
}

/* Chat Body */
.ai-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Custom Scrollbar */
.ai-body::-webkit-scrollbar {
  width: 4px;
}
.ai-body::-webkit-scrollbar-track {
  background: transparent;
}
.ai-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

/* Messages */
.ai-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--ai-radius-md);
  font-size: 14px;
  line-height: 1.5;
  animation: ai-msg-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transform-origin: bottom left;
}

.ai-message.ai {
  background: transparent;
  border: none;
  color: var(--ai-text);
  align-self: flex-start;
  max-width: 100%;
  padding: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

/* NG logo avatar beside AI messages */
.ai-message.ai .ai-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

.ai-message.ai .ai-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  mix-blend-mode: screen;
  filter: brightness(1.15);
}

/* Thin animated left border on avatar */
.ai-message.ai .ai-msg-avatar::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  border: 1px solid rgba(139, 92, 246, 0.5);
  z-index: 2;
}

/* The actual bubble */
.ai-message.ai .ai-msg-bubble {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 4px 14px 14px 14px;
  padding: 11px 15px;
  font-size: 14px;
  line-height: 1.6;
  max-width: calc(100% - 38px);
  color: var(--ai-text);
}

.ai-message.user {
  background: var(--ai-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  transform-origin: bottom right;
}

/* Action/Link Buttons inside AI message */
.ai-action-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius-sm);
  color: var(--ai-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  transition: var(--ai-transition);
}

.ai-action-btn:hover {
  background: var(--ai-primary);
  border-color: var(--ai-primary);
}

/* Suggestion Buttons */
.ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  animation: ai-msg-in 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.ai-suggestion-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--ai-border);
  color: var(--ai-text-muted);
  padding: 8px 12px;
  border-radius: 30px;
  font-size: 12px;
  cursor: pointer;
  transition: var(--ai-transition);
  font-family: var(--ai-font);
}

.ai-suggestion-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ai-text);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Input Area */
.ai-input-wrapper {
  padding: 16px 20px;
  border-top: 1px solid var(--ai-border);
  background: rgba(0, 0, 0, 0.3);
}

.ai-input-container {
  display: flex;
  align-items: flex-end;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--ai-border);
  border-radius: var(--ai-radius-lg);
  padding: 8px 12px;
  transition: var(--ai-transition);
}

.ai-input-container:focus-within {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
}

.ai-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--ai-text);
  font-family: var(--ai-font);
  font-size: 14px;
  resize: none;
  padding: 8px 0;
  max-height: 100px;
  outline: none;
}

.ai-input::placeholder {
  color: var(--ai-text-muted);
}

.ai-submit-btn {
  background: var(--ai-primary);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  transition: var(--ai-transition);
  opacity: 0.5;
  pointer-events: none;
  margin-bottom: 4px;
}

.ai-submit-btn.active {
  opacity: 1;
  pointer-events: auto;
}

.ai-submit-btn.active:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(255, 32, 51, 0.4);
}

/* Typing Indicator */
.ai-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
}

.ai-dot {
  width: 6px;
  height: 6px;
  background: var(--ai-text-muted);
  border-radius: 50%;
  animation: ai-bounce 1.4s infinite ease-in-out both;
}

.ai-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-dot:nth-child(2) { animation-delay: -0.16s; }

/* Inline Project AI Button */
.inline-ai-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 32, 51, 0.1);
  border: 1px solid rgba(255, 32, 51, 0.3);
  color: var(--ai-text);
  padding: 10px 20px;
  border-radius: 30px;
  font-family: var(--ai-font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--ai-transition);
  margin-top: 15px;
}

.inline-ai-btn:hover {
  background: rgba(255, 32, 51, 0.2);
  border-color: var(--ai-primary);
}

/* Animations */
@keyframes ai-float-in {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes ai-msg-in {
  0% { opacity: 0; transform: translateY(10px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ai-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  #ai-chat-panel {
    top: auto;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 85vh;
    border-radius: 20px 20px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
  
  #ai-floating-btn {
    bottom: 20px;
    right: 20px;
  }
}
