@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;500;600;800&display=swap");

:root {
  --text-dark: #1a1a1a;
  --text-light: #666666;
  --bg-color: #f8f9fc;
  --white: #ffffff;
  --brand-gradient: linear-gradient(135deg, #8E78FF 0%, #B465DA 100%);
  --brand-primary: #B465DA;
  --brand-secondary: #8E78FF;
  --msg-user-bg: #ffffff;
  --msg-ai-text: #ffffff;
}

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

body {
  font-family: Inter, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-dark);
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

.app-container {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  z-index: 10;
}

.chat-header {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  background: #f8f9fccc;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  z-index: 20;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: var(--brand-gradient);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  background: #fff;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 2px 5px #00000005;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  background: var(--brand-primary);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.chat-window {
  flex-grow: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

.chat-window::-webkit-scrollbar {
  width: 6px;
}

.chat-window::-webkit-scrollbar-thumb {
  background-color: #0000001a;
  border-radius: 10px;
}

.message {
  max-width: 80%;
  padding: 14px 20px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.5;
  position: relative;
  animation: popIn 0.3s ease-out;
  /* Ensure word wrapping for code blocks */
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Markdown Specific Styles */
.message p {
  margin-bottom: 10px;
}

.message p:last-child {
  margin-bottom: 0;
}

.message code {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.9em;
}

.message pre {
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: 10px;
  margin: 10px 0;
  overflow-x: auto;
}

.message pre code {
  background: transparent;
  padding: 0;
}

.message ul, .message ol {
  padding-left: 20px;
  margin: 10px 0;
}

.message.ai a {
  color: #ffffff;
  text-decoration: underline;
}

.message.user a {
  color: var(--brand-primary);
}

.message strong {
  font-weight: 800;
}

.message.user {
  align-self: flex-end;
  background: var(--msg-user-bg);
  color: var(--text-dark);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 10px #00000008;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.message.ai {
  align-self: flex-start;
  background: var(--brand-gradient);
  color: var(--msg-ai-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 15px #b465da33;
}

.input-area {
  padding: 20px;
  background: transparent;
  display: flex;
  justify-content: center;
}

.input-container {
  width: 100%;
  max-width: 700px;
  background: #fff;
  padding: 8px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  box-shadow: 0 5px 20px #0000000d;
  border: 1px solid rgba(0, 0, 0, 0.05);
  transition: 0.3s;
}

.input-container:focus-within {
  box-shadow: 0 5px 25px #b465da26;
  border-color: #b465da4d;
}

input {
  flex-grow: 1;
  border: none;
  outline: none;
  padding: 10px 20px;
  font-size: 1rem;
  font-family: Inter, sans-serif;
  color: var(--text-dark);
  background: transparent;
}

button.send-btn {
  background: var(--brand-gradient);
  border: none;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}

button.send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px #b465da66;
}

button.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.background-effects {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.glow-orb {
  position: absolute;
  top: -20%;
  right: -10%;
  width: 60vw;
  height: 60vw;
  background: radial-gradient(circle, #8e78ff14, #fff0 70%);
  border-radius: 50%;
}

.star-line {
  position: absolute;
  width: 2px;
  height: 150px;
  background: linear-gradient(to bottom, #b465da00, #b465da, #b465da00);
  opacity: 0;
  border-radius: 50%;
}

.star-line:nth-child(2) {
  left: 80%;
  top: -20%;
  animation: shoot 4s linear infinite;
}

.star-line:nth-child(3) {
  left: 95%;
  top: -30%;
  animation: shoot 6s linear infinite;
  animation-delay: 2s;
}

.star-line:nth-child(4) {
  left: 60%;
  top: -40%;
  animation: shoot 5s linear infinite;
  animation-delay: 1s;
}

.star-line:nth-child(5) {
  left: 20%;
  top: -50%;
  animation: shoot 7s linear infinite;
  animation-delay: 3s;
}

@keyframes shoot {
  0% {
    transform: translateY(-100%) rotate(45deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  80% {
    opacity: 0;
  }
  to {
    transform: translate(-100vh, 100vh) rotate(45deg);
    opacity: 0;
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 #b465dab3;
  }
  70% {
    box-shadow: 0 0 0 6px #b465da00;
  }
  to {
    box-shadow: 0 0 #b465da00;
  }
}

@keyframes popIn {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.typing-dots {
  font-style: italic;
  opacity: 0.8;
  font-size: 0.85rem;
}

.message.loading {
  background: rgba(180, 101, 218, 0.2);
  border: 1px dashed var(--brand-primary);
  color: var(--text-dark);
}

@media (max-width: 768px) {
  .star-line {
    display: none;
  }
  .message {
    max-width: 90%;
  }
  .logo {
    font-size: 1.2rem;
  }
}