/* styles.css */

:root {
  --bg-light: #f0f0f0;
  --bg-dark: #121212;
  --text-light: #222;
  --text-dark: #eee;
  --primary-color: #0066cc;
  --border-color-light: #cccccc;
  --border-color-dark: #444444;
  --bot-bg-light: #e1e7f0;
  --bot-bg-dark: #1e2a3a;
  --user-bg-light: #d1ecf1;
  --user-bg-dark: #254759;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-light);
  color: var(--text-light);
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 1rem;
}

body.dark {
  background-color: var(--bg-dark);
  color: var(--text-dark);
}

.container {
  max-width: 700px;
  width: 100%;
  background-color: inherit;
  display: flex;
  flex-direction: column;
  height: 90vh;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border-color-light);
  flex-shrink: 0;
}

body.dark header {
  border-color: var(--border-color-dark);
}

header h1 {
  font-size: 1.4rem;
  margin: 0;
  flex: 1 1 0;
  min-width: 0;
  /* To prevent overflow on small screens */
  word-break: break-word;
}

#themeToggle {
  background-color: var(--primary-color);
  border: none;
  color: white;
  font-weight: 600;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  flex-shrink: 0;
  white-space: nowrap;
}

#themeToggle:hover,
#themeToggle:focus {
  background-color: #004a99;
  outline: none;
}

#chat {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background-color: inherit;
  word-break: break-word;
}

.message {
  max-width: 75%;
  padding: 1rem;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 1rem;
  word-wrap: break-word;
  white-space: pre-line;
}

.bot-message {
  background-color: var(--bot-bg-light);
  color: var(--text-light);
  align-self: flex-start;
}

body.dark .bot-message {
  background-color: var(--bot-bg-dark);
  color: var(--text-dark);
}

.user-message {
  background-color: var(--user-bg-light);
  color: var(--text-light);
  align-self: flex-end;
}

body.dark .user-message {
  background-color: var(--user-bg-dark);
  color: var(--text-dark);
}

#quick-questions {
  background-color: inherit;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border-color-light);
  border-bottom: 1px solid var(--border-color-light);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

body.dark #quick-questions {
  border-color: var(--border-color-dark);
}

.quick-btn {
  cursor: pointer;
  background-color: var(--primary-color);
  border: none;
  color: white;
  font-size: 0.9rem;
  padding: 0.4rem 0.75rem;
  border-radius: 16px;
  transition: background-color 0.25s ease;
  flex-grow: 1;
  min-width: 170px;
  max-width: calc(50% - 0.5rem);
  white-space: normal;
  word-break: break-word;
  text-align: center;
}

.quick-btn:hover,
.quick-btn:focus {
  background-color: #004a99;
  outline: none;
}

#chat-form {
  display: flex;
  border-top: 1px solid var(--border-color-light);
  padding: 0.75rem 1rem;
  background-color: inherit;
  flex-shrink: 0;
}

body.dark #chat-form {
  border-color: var(--border-color-dark);
}

#userInput {
  flex-grow: 1;
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border-color-light);
  transition: border-color 0.3s ease;
  background-color: #fff;
  color: #000;
  min-width: 0;
}

body.dark #userInput {
  background-color: #232323;
  border-color: var(--border-color-dark);
  color: var(--text-dark);
}

#userInput:focus {
  outline: none;
  border-color: var(--primary-color);
}

#chat-form button {
  margin-left: 0.5rem;
  font-size: 1rem;
  background-color: var(--primary-color);
  border: none;
  color: white;
  padding: 0 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  flex-shrink: 0;
  white-space: nowrap;
}

#chat-form button:hover,
#chat-form button:focus {
  background-color: #004a99;
  outline: none;
}

/* Scrollbar styling for chat */
#chat::-webkit-scrollbar {
  width: 8px;
}

#chat::-webkit-scrollbar-track {
  background: transparent;
}

#chat::-webkit-scrollbar-thumb {
  background-color: rgba(0,0,0,0.2);
  border-radius: 4px;
}

body.dark #chat::-webkit-scrollbar-thumb {
  background-color: rgba(255,255,255,0.3);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .container {
    height: 95vh;
    max-width: 100%;
  }

  header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  header h1 {
    font-size: 1.2rem;
    flex-basis: 100%;
    text-align: center;
  }

  #themeToggle {
    flex-basis: auto;
    align-self: center;
  }

  .message {
    max-width: 90%;
    font-size: 0.95rem;
  }

  #quick-questions {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    justify-content: center;
  }

  .quick-btn {
    max-width: 100%;
    flex-grow: 1;
    min-width: 0;
  }

  #chat-form {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
  }

  #userInput {
    flex-basis: 100%;
    font-size: 1rem;
  }

  #chat-form button {
    margin-left: 0;
    flex-basis: 100%;
    font-size: 1rem;
  }
}

@media (max-width: 400px) {
  body {
    padding: 0.5rem;
  }
  
  header h1 {
    font-size: 1rem;
  }
  
  #themeToggle {
    padding: 0.3rem 0.6rem;
    font-size: 0.9rem;
  }

  .message {
    font-size: 0.9rem;
    padding: 0.75rem;
  }

  #chat-form {
    padding: 0.5rem;
  }

  #userInput {
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
  }

  #chat-form button {
    font-size: 0.9rem;
    padding: 0 0.8rem;
  }
}