/* CSS Variables for theming */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-chat: #f9fafb;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --border-color: #e5e7eb;
  --accent-color: #2563eb;
  --accent-hover: #1d4ed8;
  --user-message-bg: #2563eb;
  --user-message-text: #ffffff;
  --bot-message-bg: #ffffff;
  --bot-message-text: #1f2937;
  --error-color: #dc2626;
  --success-color: #16a34a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
  --bg-primary: #1f2937;
  --bg-secondary: #111827;
  --bg-chat: #1a1f2e;
  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --border-color: #374151;
  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --user-message-bg: #3b82f6;
  --user-message-text: #ffffff;
  --bot-message-bg: #374151;
  --bot-message-text: #f9fafb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  min-height: 100vh;
}

/* Login Screen */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  padding: 20px;
}

.login-container {
  background: var(--bg-primary);
  padding: 48px;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  max-width: 420px;
  width: 100%;
}

.login-logo {
  width: 120px;
  height: auto;
  margin-bottom: 24px;
}

.login-container h1 {
  font-size: 2rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.login-subtitle {
  color: var(--accent-color);
  font-weight: 600;
  margin-bottom: 16px;
}

.login-description {
  color: var(--text-secondary);
  margin-bottom: 32px;
  line-height: 1.6;
}

.login-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--text-primary);
  color: var(--bg-primary);
  border: none;
  padding: 14px 28px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  justify-content: center;
}

.login-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.login-note {
  margin-top: 24px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Main Container */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 16px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  width: 48px;
  height: auto;
}

.header-text h1 {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.header-text p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-name {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.logout-button {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-button:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.theme-toggle {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  background: var(--border-color);
}

.theme-toggle-icon {
  font-size: 1.25rem;
}

/* Chat Container */
.chat-container {
  flex: 1;
  background: var(--bg-primary);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-chat);
}

/* Messages */
.message {
  margin-bottom: 16px;
  max-width: 85%;
}

.user-message {
  margin-left: auto;
}

.bot-message {
  margin-right: auto;
}

.message-content {
  padding: 12px 16px;
  border-radius: 12px;
  line-height: 1.6;
}

.user-message .message-content {
  background: var(--user-message-bg);
  color: var(--user-message-text);
  border-bottom-right-radius: 4px;
}

.bot-message .message-content {
  background: var(--bot-message-bg);
  color: var(--bot-message-text);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}

.message-content ul {
  margin: 8px 0;
  padding-left: 20px;
}

.message-content li {
  margin: 4px 0;
}

.message-content code {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.9em;
}

.message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.9em;
}

.message-content th,
.message-content td {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  text-align: left;
}

.message-content th {
  background: var(--bg-secondary);
  font-weight: 600;
}

/* Error and Clarification Messages */
.error-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--error-color);
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.clarification-message {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

/* Chat Input */
.chat-input-container {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-primary);
}

.input-wrapper {
  display: flex;
  gap: 12px;
}

#chatInput {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  resize: none;
  font-family: inherit;
}

#chatInput:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#chatInput:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#sendButton {
  padding: 12px 24px;
  background: var(--accent-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

#sendButton:hover:not(:disabled) {
  background: var(--accent-hover);
}

#sendButton:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Loading Indicator */
.loading {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.loading-dots {
  display: flex;
  gap: 4px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  background: var(--accent-color);
  border-radius: 50%;
  animation: bounce 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Quick Actions */
.quick-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.quick-action {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
}

.quick-action:hover {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 12px;
  }

  header {
    padding: 12px 16px;
  }

  .header-content {
    flex-direction: column;
    gap: 12px;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .chat-messages {
    padding: 16px;
  }

  .message {
    max-width: 95%;
  }

  .quick-actions {
    justify-content: center;
  }

  .login-container {
    padding: 32px 24px;
  }
}
