:root {
  /* Light Theme */
  --bg-color: #f5f7fa;
  --chat-bg: #ffffff;
  --text-color: #333;
  --primary-color: #0077cc;
  --user-bubble: #e3f2fd;
  --bot-bubble: #f1f1f1;
  --error-color: #ff4444;
  --border-color: #e0e0e0;
  --footer-bg: #f1f1f1;
}

.dark-mode {
  /* Dark Theme */
  --bg-color: #1a1a1a;
  --chat-bg: #2d2d2d;
  --text-color: #f0f0f0;
  --primary-color: #4dabf7;
  --user-bubble: #2c3e50;
  --bot-bubble: #34495e;
  --error-color: #ff7675;
  --border-color: #444;
  --footer-bg: #252525;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  transition: background 0.3s, color 0.3s;
}

html, body {
  font-family: 'Exo', sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  height: 100%;
  overflow-x: hidden;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

#theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  cursor: pointer;
  font-size: 1.5rem;
  color: var(--primary-color);
  z-index: 100;
}

#chat {
  width: 100%;
  max-width: 90%;
  height: 90vh;
  background: var(--chat-bg);
  border-radius: 15px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#chat-box {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 15px;
  overscroll-behavior: contain;
}

/* MESAJ BALONLARI - TAM ÇÖZÜM */
.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  min-width: 0;
}

.message.user {
  justify-content: flex-end;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bubble {
  max-width: 90%;
  width: fit-content;
  min-width: min-content;
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: visible;
  display: inline-block;
  box-sizing: border-box;
  hyphens: auto;
}

.user .bubble {
  background: var(--user-bubble);
  border-top-right-radius: 5px;
}

.bot .bubble {
  background: var(--bot-bubble);
  border-top-left-radius: 5px;
}

.error .bubble {
  background: var(--error-color);
  color: white;
}

.typing .bubble {
  background: transparent;
  display: flex;
  gap: 5px;
}

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

.dot:nth-child(2) {
  animation-delay: 0.2s;
}

.dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

#input-area {
  display: flex;
  padding: 15px;
  border-top: 1px solid var(--border-color);
  background: var(--chat-bg);
}

#user-input {
  flex: 1;
  padding: 12px 15px;
  border: none;
  border-radius: 25px;
  background: var(--bg-color);
  color: var(--text-color);
  font-size: 16px;
  outline: none;
}

#send-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: var(--primary-color);
  color: white;
  margin-left: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

footer {
  text-align: center;
  padding: 10px;
  font-size: 12px;
  background: var(--footer-bg);
  color: var(--text-color);
}

/* SCROLLBAR */
#chat-box::-webkit-scrollbar {
  width: 8px;
}
#chat-box::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}

/* MOBİL UYUMLULUK */
@media (max-width: 600px) {
  #chat {
    height: 75vh;
    max-width: 95%;
  }
  
  .bubble {
    max-width: 95%;
    padding: 10px 14px;
    font-size: 15px;
  }
  
  #chat-box {
    padding: 15px;
  }
}