/* Reset & Global */
* {
  box-sizing: border-box;
}

/* Body & Background */
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
  /* Using dynamic viewport height (100dvh) to address mobile keyboard issues */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* Fallback background color */
  background-color: #f0f0f0;
  /* Background image with dark overlay for better readability on desktops & tablets */
  background-image: linear-gradient(
      rgba(0, 0, 0, 0.3), 
      rgba(0, 0, 0, 0.3)
    ),
    url('https://www.getstellar.ai/uploads/transforms/featureImage/_1792x896_crop_center-center_94_none/chat-bots.webp');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

/* Header */
header {
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 1rem;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 600;
  backdrop-filter: blur(10px);
}

/* Navigation Link */
.nav-link {
  display: inline-block;
  margin-top: 10px;
  margin-left: 20px;
  padding: 6px 12px;
  font-size: 1rem;
  color: #4f46e5;
  background-color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease-in-out;
}

.nav-link:hover {
  background-color: #eef2ff;
  color: #3730a3;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

/* Chat Container */
#chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
  margin: 16px;
  border-radius: 16px;
  backdrop-filter: blur(5px);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  scroll-behavior: smooth;
}

/* Chat Messages */
.message {
  max-width: 80%;
  padding: 14px 18px;
  margin: 10px 0;
  border-radius: 20px;
  font-size: 1rem;
  line-height: 1.5;
  word-wrap: break-word;
  animation: fadeIn 0.3s ease-in-out;
}

.user {
  align-self: flex-end;
  background-color: #6366f1;
  color: #fff;
  border-bottom-right-radius: 0;
}

.bot {
  align-self: flex-start;
  background-color: rgba(255, 255, 255, 0.8);
  border-bottom-left-radius: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Input Area */
#input-area {
  display: flex;
  gap: 10px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  border-top: 1px solid #ddd;
  flex-wrap: wrap;
}

/* Input Field */
#user-input {
  flex: 1;
  min-width: 0;
  padding: 14px;
  font-size: 16px; /* Set to 16px to avoid mobile zoom */
  border: 1px solid #ccc;
  border-radius: 10px;
  outline: none;
  background: #fff;
  transition: border 0.2s ease-in-out;
}

#user-input:focus {
  border-color: #6366f1;
}

/* Send Button */
#send-btn {
  padding: 14px 20px;
  font-size: 16px; /* Set to 16px to avoid mobile zoom */
  background-color: #4f46e5;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.3s;
}

#send-btn:hover {
  background-color: #4338ca;
}

/* Keyframes for fade-in effect */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-thumb {
  background: #aaa;
  border-radius: 8px;
}

/* === Mobile Devices (width <= 600px) === */
@media (max-width: 600px) {
  body {
    /* Use a simpler background for mobile to boost performance and readability */
    background-color: #f4f4f4;
  }

  header {
    font-size: 1.3rem;
    padding: 0.8rem;
  }

  #chat-container {
    margin: 8px;
    padding: 10px;
  }

  .message {
    max-width: 95%;
    font-size: 0.95rem;
    padding: 12px;
  }

  #input-area {
    flex-direction: column;
    padding: 12px;
    gap: 8px;
  }

  #user-input,
  #send-btn {
    width: 100%;
    font-size: 16px; /* For preventing zoom on focus */
  }

  .nav-link {
    font-size: 0.95rem;
    margin-left: 0;
    margin-top: 10px;
    padding: 8px 10px;
  }
}

/* === Tablets (width 601px–1024px) === */
@media (min-width: 601px) and (max-width: 1024px) {
  #chat-container {
    margin: 12px;
    padding: 14px;
  }

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

  header {
    font-size: 1.5rem;
  }

  #input-area {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
  }

  #user-input {
    flex: 1;
    font-size: 16px;
  }

  #send-btn {
    flex-shrink: 0;
    font-size: 16px;
  }
}