/* ===================================
   AI Chatbot - Modern Design System
   =================================== */

/* Import Modern Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* CSS Variables - Design Tokens */
:root {
  /* Colors */
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --accent-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --dark-bg: #0f0f23;
  --darker-bg: #0a0a15;
  --card-bg: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.1);
  --text-primary: #ffffff;
  --text-secondary: #b4b4c8;
  --user-msg-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --ai-msg-bg: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(255, 255, 255, 0.05);
  --shadow-color: rgba(102, 126, 234, 0.3);

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 50px;

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--dark-bg);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Animated Background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(118, 75, 162, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 40% 20%, rgba(79, 172, 254, 0.1) 0%, transparent 50%);
  animation: backgroundPulse 15s ease-in-out infinite;
  z-index: -1;
}

@keyframes backgroundPulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.8;
  }
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--spacing-md);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  text-align: center;
  padding: var(--spacing-lg) 0;
  animation: fadeInDown 0.6s ease;
}

.header h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--spacing-xs);
  letter-spacing: -0.02em;
}

.header p {
  color: var(--text-secondary);
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  font-weight: 400;
}

.header .badge {
  display: inline-block;
  margin-top: var(--spacing-sm);
  padding: var(--spacing-xs) var(--spacing-md);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  color: var(--text-secondary);
  backdrop-filter: blur(10px);
  transition: all var(--transition-normal);
}

.header .badge:hover {
  border-color: rgba(102, 126, 234, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow-color);
}

/* Chat Container */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  animation: fadeInUp 0.6s ease;
  margin-bottom: var(--spacing-md);
}

/* Messages Area */
.messages {
  flex: 1;
  padding: var(--spacing-lg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  min-height: 500px;
  max-height: 70vh;
}

/* Custom Scrollbar */
.messages::-webkit-scrollbar {
  width: 8px;
}

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

.messages::-webkit-scrollbar-thumb {
  background: var(--card-border);
  border-radius: var(--radius-full);
  transition: background var(--transition-normal);
}

.messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Message Bubbles */
.message {
  display: flex;
  gap: var(--spacing-sm);
  animation: messageSlideIn 0.4s ease;
  opacity: 0;
  animation-fill-mode: forwards;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.message.user .message-avatar {
  background: var(--user-msg-bg);
}

.message.ai .message-avatar {
  background: var(--accent-gradient);
}

.message-content {
  max-width: 75%;
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-md);
  position: relative;
  word-wrap: break-word;
  line-height: 1.7;
  font-size: 0.95rem;
}

.message.user .message-content {
  background: var(--user-msg-bg);
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.message.ai .message-content {
  background: var(--ai-msg-bg);
  border: 1px solid var(--card-border);
  border-bottom-left-radius: 6px;
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.message-content p {
  margin: 0;
  margin-bottom: var(--spacing-sm);
  line-height: 1.8;
}

.message-content p:last-child {
  margin-bottom: 0;
}

/* Headings in Messages */
.message-content h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: var(--spacing-md) 0 var(--spacing-sm) 0;
  padding-bottom: var(--spacing-xs);
  border-bottom: 2px solid rgba(102, 126, 234, 0.3);
  line-height: 1.3;
}

.message-content h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: var(--spacing-md) 0 var(--spacing-sm) 0;
  padding-left: var(--spacing-xs);
  border-left: 3px solid #667eea;
  line-height: 1.3;
}

.message-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #4facfe;
  margin: var(--spacing-sm) 0 var(--spacing-xs) 0;
  line-height: 1.4;
}

/* Lists */
.message-content ul,
.message-content ol {
  margin: var(--spacing-sm) 0;
  padding-left: var(--spacing-lg);
}

.message-content li {
  margin: var(--spacing-xs) 0;
  line-height: 1.7;
  color: var(--text-primary);
}

.message-content ul li {
  list-style-type: none;
  position: relative;
}

.message-content ul li::before {
  content: '▸';
  position: absolute;
  left: -1.2rem;
  color: #667eea;
  font-weight: bold;
}

.message-content ol li {
  list-style-type: decimal;
  color: var(--text-primary);
}

/* Blockquotes */
.message-content blockquote {
  margin: var(--spacing-sm) 0;
  padding: var(--spacing-sm) var(--spacing-md);
  background: rgba(79, 172, 254, 0.1);
  border-left: 4px solid #4facfe;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--text-secondary);
}

/* Horizontal Rule */
.message-content hr {
  margin: var(--spacing-md) 0;
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

/* Strong and Emphasis */
.message-content strong {
  font-weight: 700;
  color: var(--text-primary);
}

.message-content em {
  font-style: italic;
  color: var(--text-secondary);
}


/* Links */
.message-content a {
  color: #4facfe;
  text-decoration: none;
  border-bottom: 1px solid rgba(79, 172, 254, 0.3);
  transition: all var(--transition-fast);
}

.message-content a:hover {
  color: #00f2fe;
  border-bottom-color: #00f2fe;
  background: rgba(79, 172, 254, 0.1);
  padding: 2px 4px;
  margin: -2px -4px;
  border-radius: 4px;
}

/* Images in Chat */
.message-content .chat-image {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin: var(--spacing-sm) 0;
  border: 1px solid var(--card-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
  cursor: pointer;
  display: block;
}

.message-content .chat-image:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}

/* Inline Code */
.message-content code {
  background: rgba(0, 0, 0, 0.4);
  padding: 3px 8px;
  border-radius: 5px;
  font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9em;
  color: #ffd700;
  font-weight: 600;
  border: 1px solid rgba(255, 215, 0, 0.2);
}

/* Code Blocks */
.message-content pre {
  background: #1e1e2e;
  padding: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: var(--spacing-md) 0;
  border: 1px solid rgba(102, 126, 234, 0.2);
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.code-header {
  background: rgba(0, 0, 0, 0.4);
  padding: var(--spacing-sm) var(--spacing-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(102, 126, 234, 0.2);
}

.code-language {
  font-size: 0.75rem;
  color: #4facfe;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 1px;
}

.copy-btn {
  background: rgba(79, 172, 254, 0.2);
  border: 1px solid rgba(79, 172, 254, 0.4);
  color: #4facfe;
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-weight: 600;
}

.copy-btn:hover {
  background: rgba(79, 172, 254, 0.4);
  border-color: #4facfe;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(79, 172, 254, 0.3);
}

.copy-btn.copied {
  background: rgba(76, 175, 80, 0.3);
  border-color: #4caf50;
  color: #4caf50;
}

.message-content pre code {
  background: none;
  padding: var(--spacing-md);
  display: block;
  overflow-x: auto;
  color: #e0e0e0;
  line-height: 1.6;
  font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.95em;
  font-weight: 500;
  border: none;
}

/* Syntax Highlighting */
.message-content pre code .keyword {
  color: #c792ea;
  font-weight: 700;
}

.message-content pre code .string {
  color: #c3e88d;
  font-weight: 500;
}

.message-content pre code .comment {
  color: #676e95;
  font-style: italic;
  font-weight: 400;
}

.message-content pre code .function {
  color: #82aaff;
  font-weight: 600;
}

.message-content pre code .number {
  color: #f78c6c;
  font-weight: 600;
}

/* Typing Indicator */
.typing-indicator {
  display: none;
  gap: 4px;
  padding: var(--spacing-sm);
}

.typing-indicator.active {
  display: flex;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typingAnimation 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingAnimation {

  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }

  30% {
    opacity: 1;
    transform: translateY(-10px);
  }
}

/* Input Area */
.input-area {
  padding: var(--spacing-lg);
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--card-border);
  backdrop-filter: blur(10px);
}

.input-form {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

.input-wrapper {
  flex: 1;
  position: relative;
}

#userInput {
  width: 100%;
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--input-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: all var(--transition-normal);
  backdrop-filter: blur(10px);
}

#userInput:focus {
  border-color: rgba(102, 126, 234, 0.5);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  background: rgba(255, 255, 255, 0.08);
}

#userInput::placeholder {
  color: var(--text-secondary);
}

#sendBtn {
  padding: var(--spacing-md) var(--spacing-xl);
  background: var(--primary-gradient);
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: 0 4px 12px var(--shadow-color);
  position: relative;
  overflow: hidden;
}

#sendBtn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

#sendBtn:hover::before {
  left: 100%;
}

#sendBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--shadow-color);
}

#sendBtn:active {
  transform: translateY(0);
}

#sendBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Welcome Message */
.welcome-message {
  text-align: center;
  padding: var(--spacing-xl);
  color: var(--text-secondary);
}

.welcome-message h2 {
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
  font-size: 1.5rem;
}

.welcome-message p {
  margin-bottom: var(--spacing-md);
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  justify-content: center;
  margin-top: var(--spacing-lg);
}

.suggestion-chip {
  padding: var(--spacing-xs) var(--spacing-md);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-normal);
  backdrop-filter: blur(10px);
}

.suggestion-chip:hover {
  background: var(--primary-gradient);
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow-color);
}

/* Animations */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: var(--spacing-xs);
  }

  .header {
    padding: var(--spacing-sm) 0;
  }

  .header h1 {
    font-size: 1.8rem;
  }

  .messages {
    padding: var(--spacing-sm);
    min-height: 350px;
    max-height: 60vh;
  }

  .message-content {
    max-width: 90%;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.9rem;
  }

  .message-content pre {
    font-size: 0.8rem;
    overflow-x: auto;
  }

  .message-content pre code {
    padding: var(--spacing-sm);
    font-size: 0.8rem;
  }

  .message-content .chat-image {
    max-width: 100%;
  }

  .code-header {
    padding: var(--spacing-xs) var(--spacing-sm);
  }

  .input-area {
    padding: var(--spacing-sm);
  }

  .input-form {
    gap: var(--spacing-xs);
  }

  #userInput {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 1rem;
  }

  #sendBtn {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.9rem;
  }

  .suggestions {
    flex-direction: column;
    gap: var(--spacing-xs);
  }

  .suggestion-chip {
    width: 100%;
    text-align: center;
    padding: var(--spacing-sm);
    font-size: 0.85rem;
  }

  .message-avatar {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }

  .welcome-message {
    padding: var(--spacing-md);
  }

  .welcome-message h2 {
    font-size: 1.2rem;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0;
  }

  .header {
    padding: var(--spacing-xs) var(--spacing-sm);
  }

  .header h1 {
    font-size: 1.4rem;
  }

  .header p {
    font-size: 0.8rem;
  }

  .header .badge {
    font-size: 0.75rem;
    padding: 4px 10px;
  }

  .chat-container {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .messages {
    min-height: 300px;
    max-height: 55vh;
    padding: var(--spacing-xs);
  }

  .message {
    gap: var(--spacing-xs);
  }

  .message-content {
    max-width: 85%;
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.85rem;
    line-height: 1.5;
  }

  .message-content h1 {
    font-size: 1.2rem;
  }

  .message-content h2 {
    font-size: 1.1rem;
  }

  .message-content h3 {
    font-size: 1rem;
  }

  .message-content pre {
    margin: var(--spacing-xs) 0;
    border-radius: var(--radius-sm);
  }

  .message-content pre code {
    font-size: 0.75rem;
    padding: var(--spacing-xs);
  }

  .message-content ul,
  .message-content ol {
    padding-left: var(--spacing-md);
  }

  .message-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
  }

  .input-area {
    padding: var(--spacing-xs) var(--spacing-sm);
  }

  #userInput {
    padding: var(--spacing-sm);
    font-size: 0.95rem;
    border-radius: var(--radius-md);
  }

  #sendBtn {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.85rem;
    border-radius: var(--radius-md);
  }

  .suggestion-chip {
    font-size: 0.8rem;
    padding: var(--spacing-xs) var(--spacing-sm);
  }

  .copy-btn {
    padding: 3px 8px;
    font-size: 0.7rem;
  }

  .code-language {
    font-size: 0.65rem;
  }
}

/* Loading State */
.loading {
  pointer-events: none;
  opacity: 0.7;
}

/* Error Message */
.error-message {
  background: rgba(245, 87, 108, 0.1);
  border: 1px solid rgba(245, 87, 108, 0.3);
  color: #f5576c;
  padding: var(--spacing-sm);
  border-radius: var(--radius-sm);
  margin-top: var(--spacing-sm);
  font-size: 0.9rem;
  animation: shake 0.5s;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}