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

/* Root font & smooth scroll */
html, body {
  height: 100%;
  font-family: 'Segoe UI', Roboto, Tahoma, sans-serif;
  scroll-behavior: smooth;
  background: #0f0f0f;
  color: #fff;
  transition: background 0.4s ease, color 0.4s ease;
  -webkit-font-smoothing: antialiased;
  -webkit-overflow-scrolling: touch;
  overflow-x: hidden;
}

body.light-mode {
  background: #f0f0f0;
  color: #000;
}

/* Top Bar */
#top-box {
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 15px 20px;
  background: rgba(20, 20, 20, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.4s ease;
}

body.light-mode #top-box {
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid #ddd;
}

/* Logo Title */
#top-box h1 {
  font-size: 26px;
  font-weight: 610;
}

/* Settings + Theme Switch */
.top-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

#settings-btn {
  background: linear-gradient(135deg, #28a745, #218838);
  color: #fff;
  padding: 6px 12px;
  font-size: 13px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  text-decoration: none;
}

#theme-switch {
  font-size: 26px;
  background: none;
  border: none;
  color: gold;
  cursor: pointer;
}

body.light-mode #settings-btn {
  background: linear-gradient(135deg, #16a34a, #15803d);
}

body.light-mode #theme-switch {
  color: #333;
}

/* App Container */
#app-container {
max-width: 1000px;
margin: auto;
padding: 80px 15px 100px;
display: flex;
flex-direction: column;
height: 100vh;
overflow: hidden;
opacity: 0;
transition: opacity 0.8s ease;
}

/* Chat Area */
#chat-box {
flex: 1;
overflow-y: auto;
background: #111;
border-radius: 12px;
padding: 20px;
display: flex;
flex-direction: column;
gap: 16px;
scroll-behavior: smooth;
will-change: scroll-position;
transition: background 0.3s ease;
max-width: 700px;
margin: auto;
}

body.light-mode #chat-box {
  background: rgba(255,255,255,0.9);
  color: #000;
}

/* Message Styles */
.user-message, .bot-message {
  max-width: 85%;
  padding: 14px 20px;
  font-size: 1rem;
  border-radius: 18px;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
  animation: fadeIn 0.25s ease-out;
  transition: all 0.5s ease;
}

.user-message {
  align-self: flex-end;
  background: linear-gradient(135deg, #0d6efd, #0b5ed7);
  color: #fff;
}

.bot-message {
  align-self: flex-start;
  background: linear-gradient(135deg, #444, #222);
  color: #fff;
}

body.light-mode .bot-message {
  background: #eeeeee;
  color: #111;
}

body.light-mode .user-message {
  background: #cce5ff;
  color: #000;
}

/* Typing Effect */
.bot-message.typing {
  opacity: 0.6;
  font-style: italic;
  animation: typingPulse 1.2s infinite ease-in-out;
  pointer-events: none;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes typingPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.25; }
}

/* Input Area */
#input-form {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  background: rgba(20,20,20,0.9);
  border-top: 1px solid #333;
  z-index: 999;
  backdrop-filter: blur(6px);
}

body.light-mode #input-form {
  background: rgba(255, 255, 255, 0.85);
  border-top: 1px solid #ccc;
}

/* Input Field */
#user-input {
  flex: 1;
  padding: 12px 14px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  background: #222;
  color: #fff;
}

#user-input::placeholder {
  color: #aaa;
}

body.light-mode #user-input {
  background: #f0f0f0;
  color: #000;
}

/* Send Button */
#send-btn {
  background: linear-gradient(135deg, #0d6efd, #084298);
  color: #fff;
  padding: 12px 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,123,255,0.3);
  transition: background 0.3s ease;
}

#send-btn:hover {
  background: #06367c;
}

/* Scroll to Bottom */
#scroll-to-bottom {
  position: fixed;
  bottom: 80px;
  right: 10px;
  background: #333;
  color: #fff;
  padding: 8px 10px;
  font-size: 18px;
  border: none;
  border-radius: 50%;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  display: none;
  z-index: 999;
}

#scroll-to-bottom:hover {
  background: #0d6efd;
}

body.light-mode #scroll-to-bottom {
  background: #aaa;
  color: #000;
}

/* Loading Screen */
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 6px solid #333;
  border-top: 6px solid #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 10px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.blinking {
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* Responsive */
@media (max-width: 600px) {
  #chat-box {
    font-size: 14px;
    padding: 12px;
  }

  #user-input, #send-btn {
    font-size: 14px;
  }

  #top-box h1 {
    font-size: 18px;
  }
}

@media (min-width: 768px) {
  #app-container {
    width: 600px;
  }
}

@media (min-width: 1024px) {
  #app-container {
    width: 700px;
  }
  }
