:root {
  /* Light theme colors */
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary-color: #64748b;
  --accent-color: #06b6d4;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-chat: #ffffff;
  --bg-user-message: #2563eb;
  --bg-bot-message: #f1f5f9;
  --bg-input: #ffffff;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --text-on-primary: #ffffff;
  
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Layout heights */
  --header-height: 4.5rem;
  --input-section-height: 8rem;
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-chat: #1e293b;
  --bg-user-message: #2563eb;
  --bg-bot-message: #334155;
  --bg-input: #1e293b;
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-tertiary: #64748b;
  
  --border-color: #334155;
  --border-light: #475569;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: var(--transition);
  overflow-x: hidden;
  height: 100vh;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 100vw;
  overflow: hidden;
}

/* Header Styles */
.header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: var(--transition);
  height: var(--header-height);
  flex-shrink: 0;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  height: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 2.5rem;
  height: 2.5rem;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.25rem;
  box-shadow: var(--shadow-md);
}

.logo-text {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-icon {
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.875rem;
}

.btn-icon:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  transform: translateY(-1px);
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: calc(100vh - var(--header-height));
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  overflow: hidden;
  height: 100%;
}

/* Welcome Section */
.welcome-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  opacity: 1;
  transition: var(--transition-slow);
  height: calc(100vh - var(--header-height) - var(--input-section-height));
  overflow-y: auto;
}

.welcome-section.hidden {
  opacity: 0;
  pointer-events: none;
  position: absolute;
  visibility: hidden;
}

.welcome-content {
  text-align: center;
  max-width: 600px;
}

.welcome-icon {
  width: 4rem;
  height: 4rem;
  background: linear-gradient(135deg, var(--primary-light), var(--accent-color));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  font-size: 1.5rem;
  color: var(--primary-color);
  box-shadow: var(--shadow-lg);
}

.welcome-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.welcome-subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  line-height: 1.5;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.chip:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: none;
  height: calc(100vh - var(--header-height) - var(--input-section-height));
  min-height: 0;
}

.messages-container.visible {
  display: flex;
  flex-direction: column;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
  padding-bottom: 1rem;
}

.message {
  display: flex;
  gap: 1rem;
  opacity: 0;
  transform: translateY(20px);
  animation: messageSlideIn 0.3s ease-out forwards;
  width: 100%;
}

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

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

.message-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  margin-top: 0.25rem;
}

.message.user .message-avatar {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: white;
}

.message.bot .message-avatar {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.message-content {
  flex: 1;
  min-width: 0;
  max-width: calc(100% - 3.5rem);
}

.message-bubble {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  line-height: 1.6;
  word-wrap: break-word;
  position: relative;
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 100%;
}

.message.user .message-bubble {
  background: var(--bg-user-message);
  color: var(--text-on-primary);
  border-bottom-right-radius: var(--radius-sm);
}

.message.bot .message-bubble {
  background: var(--bg-bot-message);
  color: var(--text-primary);
  border-bottom-left-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.message-time {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 0.5rem;
  text-align: right;
}

.message.bot .message-time {
  text-align: left;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--bg-bot-message);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.typing-dots {
  display: flex;
  gap: 0.25rem;
}

.typing-dot {
  width: 0.5rem;
  height: 0.5rem;
  background: var(--text-tertiary);
  border-radius: 50%;
  animation: typingPulse 1.4s infinite ease-in-out;
}

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

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

@keyframes typingPulse {
  0%, 60%, 100% {
    transform: scale(1);
    opacity: 0.5;
  }
  30% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* Input Section */
.input-section {
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: 1.5rem;
  flex-shrink: 0;
  height: var(--input-section-height);
  display: flex;
  align-items: center;
}

.input-container {
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 0.75rem 1rem;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.input-wrapper:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

#messageInput {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.9375rem;
  line-height: 1.5;
  resize: none;
  min-height: 1.5rem;
  max-height: 4rem;
  font-family: inherit;
}

#messageInput::placeholder {
  color: var(--text-tertiary);
}

.input-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-send {
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  background: var(--primary-color);
  color: white;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.875rem;
}

.btn-send:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-send:disabled {
  background: var(--text-tertiary);
  cursor: not-allowed;
  transform: none;
}

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.character-count {
  font-variant-numeric: tabular-nums;
}

.powered-by {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.loading-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.loading-spinner {
  background: var(--bg-primary);
  padding: 2rem;
  border-radius: var(--radius-xl);
  text-align: center;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
}

.spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-spinner p {
  color: var(--text-secondary);
  font-weight: 500;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 300px;
  transform: translateX(100%);
  transition: var(--transition);
}

.toast.visible {
  transform: translateX(0);
}

.toast.success {
  border-left: 4px solid var(--success-color);
}

.toast.error {
  border-left: 4px solid var(--error-color);
}

.toast.warning {
  border-left: 4px solid var(--warning-color);
}

.toast-icon {
  font-size: 1.125rem;
}

.toast.success .toast-icon {
  color: var(--success-color);
}

.toast.error .toast-icon {
  color: var(--error-color);
}

.toast.warning .toast-icon {
  color: var(--warning-color);
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.125rem;
}

.toast-message {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 768px) {
  :root {
    --header-height: 4rem;
    --input-section-height: 7rem;
  }
  
  .header-content {
    padding: 1rem;
  }
  
  .logo-text {
    font-size: 1.25rem;
  }
  
  .welcome-title {
    font-size: 1.5rem;
  }
  
  .welcome-subtitle {
    font-size: 1rem;
  }
  
  .suggestion-chips {
    flex-direction: column;
    align-items: center;
  }
  
  .chip {
    width: 100%;
    max-width: 280px;
    justify-content: center;
  }
  
  .messages-container {
    padding: 1rem;
  }
  
  .messages {
    gap: 1rem;
  }
  
  .message {
    gap: 0.75rem;
  }
  
  .message-content {
    max-width: calc(100% - 3rem);
  }
  
  .input-section {
    padding: 1rem;
  }
  
  .toast {
    min-width: auto;
    margin: 0 1rem;
  }
}

@media (max-width: 480px) {
  :root {
    --header-height: 3.5rem;
    --input-section-height: 6.5rem;
  }
  
  .welcome-content {
    padding: 0 1rem;
  }
  
  .input-wrapper {
    padding: 0.625rem 0.875rem;
  }
  
  .btn-send {
    width: 2rem;
    height: 2rem;
  }
  
  .messages-container {
    padding: 0.75rem;
  }
  
  .message-bubble {
    padding: 0.875rem 1rem;
  }
}

/* Scrollbar Styling */
.messages-container::-webkit-scrollbar {
  width: 6px;
}

.messages-container::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Focus Styles */
.btn-icon:focus-visible,
.btn-send:focus-visible,
.chip:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Animation for smooth transitions */
.messages-container,
.welcome-section {
  transition: var(--transition-slow);
}

/* Dark mode specific adjustments */
[data-theme="dark"] .welcome-icon {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: white;
}

[data-theme="dark"] .chip:hover {
  background: var(--primary-color);
  color: white;
}

[data-theme="dark"] .loading-overlay {
  background: rgba(0, 0, 0, 0.7);
}