:root {
  --bg-color: #f4f4f4;
  --text-color: #333;
  --navbar-bg: rgba(255, 255, 255, 0.9);
  --chatbox-bg: rgba(255, 255, 255, 0.9);
  --input-bg: rgba(255, 255, 255, 0.9);
  --border-color: rgba(204, 204, 204, 0.5);
  --button-bg: rgba(0, 123, 255, 0.9);
  --button-hover: rgba(0, 86, 179, 0.9);
  --scrollbar-track: rgba(255, 255, 255, 0.1);
  --scrollbar-thumb: rgba(0, 123, 255, 0.5);
}

body.dark {
  --bg-color: #121212;
  --text-color: #ffffff;
  --navbar-bg: rgba(30, 30, 30, 0.9);
  --chatbox-bg: rgba(30, 30, 30, 0.9);
  --input-bg: rgba(45, 45, 45, 0.9);
  --border-color: rgba(68, 68, 68, 0.5);
  --button-bg: rgba(44, 62, 80, 0.9);
  --button-hover: rgba(52, 73, 94, 0.9);
  --scrollbar-track: rgba(0, 0, 0, 0.2);
  --scrollbar-thumb: rgba(255, 255, 255, 0.2);
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background-color 0.3s ease, color 0.3s ease;
}

#particleCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.navbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 30px;
  background-color: var(--navbar-bg);
  backdrop-filter: blur(10px);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
}

.dark-mode-btn {
  font-size: 20px;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  margin-right: 15px;
}

.logo {
  font-size: 1.2em;
  font-weight: bold;
}

body.dark .logo {
  color: #ffffff;
}

.profile-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.container {
  position: relative;
  z-index: 2;
  max-width: 600px;
  margin: 30px auto;
  padding: 0 20px;
}

.chatbox {
  border: 1px solid var(--border-color);
  padding: 10px;
  height: 400px;
  overflow-y: auto;
  background-color: var(--chatbox-bg);
  backdrop-filter: blur(10px);
  margin-bottom: 15px;
  border-radius: 10px;
}

.user-msg,
.ai-msg,
.error-msg {
  margin: 8px 0;
  padding: 10px;
  border-radius: 5px;
  word-wrap: break-word;
  background-color: var(--chatbox-bg);
  backdrop-filter: blur(5px);
}

.user-msg {
  background-color: rgba(204, 229, 255, 0.9);
  color: #004085;
}

body.dark .user-msg {
  background-color: rgba(44, 62, 80, 0.9);
  color: #ffffff;
}

.ai-msg {
  background-color: rgba(212, 237, 218, 0.9);
  color: #155724;
}

body.dark .ai-msg {
  background-color: rgba(26, 71, 42, 0.9);
  color: #ffffff;
}

.error-msg {
  background-color: rgba(248, 215, 218, 0.9);
  color: #721c24;
}

body.dark .error-msg {
  background-color: rgba(74, 28, 28, 0.9);
  color: #ff6b6b;
}

.input-area {
  display: flex;
  gap: 10px;
  position: relative;
  z-index: 2;
}

input[type="text"] {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border-color);
  background-color: var(--input-bg);
  backdrop-filter: blur(5px);
  color: var(--text-color);
  border-radius: 5px;
}

button {
  padding: 10px;
  cursor: pointer;
  border: none;
  background-color: var(--button-bg);
  color: white;
  border-radius: 5px;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
}

button:hover {
  background-color: var(--button-hover);
  transform: translateY(-2px);
}

.action-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
  position: relative;
  z-index: 2;
}

.action-buttons button {
  padding: 8px 12px;
  border-radius: 5px;
  background-color: var(--button-bg);
  color: white;
  border: none;
  cursor: pointer;
}

/* Add styles for the typing indicator */
#typing {
  color: #666;
}

body.dark #typing {
  color: #aaa;
}

/* Microphone Popup Styles */
.mic-popup {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.mic-popup-content {
  background-color: var(--chatbox-bg);
  padding: 30px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  animation: popupFadeIn 0.3s ease-out;
  color: var(--text-color);
}

.mic-icon {
  font-size: 48px;
  margin-bottom: 15px;
  animation: pulse 1.5s infinite;
}

.mic-status {
  margin-top: 10px;
  font-size: 14px;
  font-weight: bold;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--button-hover);
}

/* Animations */
@keyframes popupFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

/* Add these new styles after the existing styles */

.main-container {
  display: flex;
  height: calc(100vh - 60px); /* Subtract navbar height */
  position: relative;
  z-index: 2;
}

.left-panel {
  width: 300px;
  background-color: var(--navbar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  margin-bottom: 20px;
  background-color: var(--button-bg);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.new-chat-btn:hover {
  background-color: var(--button-hover);
  transform: translateY(-2px);
}

.plus-icon {
  font-size: 20px;
  font-weight: bold;
}

.chat-history {
  flex: 1;
  overflow-y: auto;
}

.history-title {
  font-size: 14px;
  font-weight: bold;
  color: var(--text-color);
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-item {
  padding: 12px;
  background-color: var(--chatbox-bg);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid var(--border-color);
}

.chat-item:hover {
  background-color: var(--button-bg);
  color: white;
  transform: translateX(5px);
}

.chat-item.active {
  background-color: var(--button-bg);
  color: white;
  border-color: var(--button-bg);
}

.chat-item-title {
  font-weight: bold;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-preview {
  font-size: 12px;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow: hidden;
}

/* Update existing chatbox styles */
.chatbox {
  flex: 1;
  margin-bottom: 15px;
  height: auto;
}

/* Update existing input-area styles */
.input-area {
  margin-top: auto;
}

/* Add styles for the left panel scrollbar */
.left-panel::-webkit-scrollbar {
  width: 6px;
}

.left-panel::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

.left-panel::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

.left-panel::-webkit-scrollbar-thumb:hover {
  background: var(--button-hover);
}

/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
  .main-container {
    flex-direction: column;
    height: calc(100vh - 50px);
  }

  .left-panel {
    width: 100%;
    height: auto;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 10px;
  }

  .chat-container {
    padding: 10px;
    height: calc(100vh - 270px); /* Adjust for left panel and navbar */
  }

  .chatbox {
    height: calc(100% - 120px); /* Adjust for input area and action buttons */
  }

  .input-area {
    flex-wrap: wrap;
    gap: 5px;
  }

  .input-area input {
    width: 100%;
    margin-bottom: 5px;
  }

  .input-area button {
    flex: 1;
    min-width: 80px;
  }

  .action-buttons {
    flex-wrap: wrap;
    gap: 5px;
  }

  .action-buttons button {
    flex: 1;
    min-width: 120px;
    font-size: 14px;
    padding: 8px;
  }

  /* Mobile Navigation */
  .navbar {
    padding: 10px 15px;
  }

  .logo {
    font-size: 1.1em;
  }

  /* Mobile Chat History */
  .chat-history {
    max-height: 150px;
  }

  .chat-item {
    padding: 8px;
  }

  .chat-item-title {
    font-size: 14px;
  }

  .chat-item-preview {
    font-size: 11px;
  }

  /* Mobile Message Styles */
  .user-msg,
  .ai-msg,
  .error-msg {
    padding: 8px;
    font-size: 14px;
  }

  /* Mobile Input Styles */
  input[type="text"] {
    font-size: 14px;
    padding: 8px;
  }

  button {
    font-size: 14px;
    padding: 8px;
  }

  /* Mobile Popup Styles */
  .mic-popup-content {
    width: 90%;
    max-width: 300px;
    padding: 20px;
  }

  .mic-icon {
    font-size: 36px;
  }

  /* Touch-friendly adjustments */
  .chat-item,
  button,
  input[type="text"] {
    min-height: 44px; /* Minimum touch target size */
  }

  /* Improve scrolling on mobile */
  .chatbox,
  .left-panel {
    -webkit-overflow-scrolling: touch;
  }
}

/* Small Mobile Devices */
@media screen and (max-width: 480px) {
  .navbar {
    padding: 8px 12px;
  }

  .logo {
    font-size: 1em;
  }

  .dark-mode-btn {
    font-size: 18px;
  }

  .chat-container {
    padding: 8px;
  }

  .input-area button {
    min-width: 60px;
    font-size: 12px;
  }

  .action-buttons button {
    min-width: 100px;
    font-size: 12px;
  }

  .user-msg,
  .ai-msg,
  .error-msg {
    font-size: 13px;
  }
}

/* Landscape Mode */
@media screen and (max-height: 500px) and (orientation: landscape) {
  .main-container {
    flex-direction: row;
  }

  .left-panel {
    width: 250px;
    max-height: none;
    height: 100%;
  }

  .chat-container {
    height: 100%;
  }

  .chatbox {
    height: calc(100% - 100px);
  }
}

/* Add smooth transitions for responsive changes */
.main-container,
.left-panel,
.chat-container,
.chatbox,
.input-area,
.action-buttons {
  transition: all 0.3s ease;
}

.user-msg,
.ai-msg {
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 8px;
  max-width: 80%;
  line-height: 1.5;
}

.user-msg {
  background-color: #d1e7dd;
  align-self: flex-end;
}

.ai-msg {
  background-color: #f8d7da;
  align-self: flex-start;
}

.typing {
  font-style: italic;
  opacity: 0.7;
}

/* Add these styles for the thinking animation */
.thinking-animation {
  display: inline-flex;
  align-items: center;
  margin: 0 8px;
  height: 20px;
}

.thinking-animation .dot {
  width: 8px;
  height: 8px;
  margin: 0 2px;
  background-color: var(--text-color);
  border-radius: 50%;
  opacity: 0.6;
  animation: thinking 1.4s infinite ease-in-out;
}

.thinking-animation .dot:nth-child(1) {
  animation-delay: 0s;
}

.thinking-animation .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.thinking-animation .dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes thinking {
  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.6;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Update AI message styles to accommodate the animation */
.ai-msg {
  display: flex;
  flex-direction: column;
  padding: 15px;
  background-color: var(--chatbox-bg);
  border-radius: 12px;
  margin-bottom: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ai-response {
  margin-top: 8px;
  line-height: 1.5;
}

/* AI Message and Animation Styles */
.ai-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.ai-avatar {
  width: 60px;
  height: 60px;
  position: relative;
}

.searching-animation {
  width: 100%;
  height: 100%;
}

.ai-name {
  font-weight: bold;
  color: var(--text-color);
}

/* Animation Keyframes */
@keyframes searchLight {
  0% {
    transform: translateX(-100px) rotate(-15deg);
  }
  50% {
    transform: translateX(100px) rotate(15deg);
  }
  100% {
    transform: translateX(-100px) rotate(-15deg);
  }
}

@keyframes bookPull {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes humanMove {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-20px);
  }
  75% {
    transform: translateX(20px);
  }
}

@keyframes armMove {
  0%,
  100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-15deg);
  }
  75% {
    transform: rotate(15deg);
  }
}

/* Apply animations */
.searching-animation .light-beam {
  animation: searchLight 3s infinite ease-in-out;
  transform-origin: 240 100;
}

.searching-animation .books .book {
  animation: bookPull 2s infinite ease-in-out;
}

.searching-animation .books .book:nth-child(1) {
  animation-delay: 0s;
}
.searching-animation .books .book:nth-child(2) {
  animation-delay: 0.1s;
}
.searching-animation .books .book:nth-child(3) {
  animation-delay: 0.2s;
}
.searching-animation .books .book:nth-child(4) {
  animation-delay: 0.3s;
}
.searching-animation .books .book:nth-child(5) {
  animation-delay: 0.4s;
}
.searching-animation .books .book:nth-child(6) {
  animation-delay: 0.5s;
}
.searching-animation .books .book:nth-child(7) {
  animation-delay: 0.6s;
}
.searching-animation .books .book:nth-child(8) {
  animation-delay: 0.7s;
}
.searching-animation .books .book:nth-child(9) {
  animation-delay: 0.8s;
}
.searching-animation .books .book:nth-child(10) {
  animation-delay: 0.9s;
}
.searching-animation .books .book:nth-child(11) {
  animation-delay: 1s;
}
.searching-animation .books .book:nth-child(12) {
  animation-delay: 1.1s;
}
.searching-animation .books .book:nth-child(13) {
  animation-delay: 1.2s;
}

.searching-animation .human {
  animation: humanMove 4s infinite ease-in-out;
}

.searching-animation .arm-right {
  animation: armMove 2s infinite ease-in-out;
  transform-origin: 200 80;
}

/* Update AI message container */
.ai-msg {
  display: flex;
  flex-direction: column;
  padding: 15px;
  background-color: var(--chatbox-bg);
  border-radius: 12px;
  margin-bottom: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ai-response {
  margin-top: 8px;
  line-height: 1.5;
}

/* Dark mode adjustments */
body.dark .searching-animation .light-beam,
body.dark .searching-animation .light-source {
  stroke: #ffd700;
  fill: #ffd700;
}

body.dark .searching-animation .shelf {
  fill: #654321;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* Add these styles at the beginning of the file */
.auth-forms {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 60px);
  padding: 20px;
}

.form-container {
  background-color: var(--chatbox-bg);
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
}

.form-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background-color: var(--input-bg);
  color: var(--text-color);
  cursor: pointer;
  border-radius: 5px;
  transition: all 0.3s ease;
}

.tab-btn.active {
  background-color: var(--button-bg);
  color: white;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.auth-form input {
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  background-color: var(--input-bg);
  color: var(--text-color);
}

.auth-form button {
  padding: 12px;
  background-color: var(--button-bg);
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.auth-form button:hover {
  background-color: var(--button-hover);
  transform: translateY(-2px);
}

.nav-buttons {
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-info span {
  color: var(--text-color);
}

.user-info button {
  padding: 8px 12px;
  background-color: var(--button-bg);
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.user-info button:hover {
  background-color: var(--button-hover);
}

/* Mobile Responsive Styles for Auth Forms */
@media screen and (max-width: 768px) {
  .form-container {
    padding: 20px;
  }

  .auth-form input,
  .auth-form button {
    padding: 10px;
  }

  .user-info {
    font-size: 14px;
  }

  .user-info button {
    padding: 6px 10px;
  }
}
