/* CSS Variable Tokens */
:root {
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --bg-color: #0f172a;
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.08);
  --primary-accent: #4facfe;
  --secondary-accent: #00f2fe;
}

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

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  position: relative;
}

/* Background animated orbs for a premium dynamic feel */
.background-orbs {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  animation: float 20s infinite alternate;
}

.orb-1 { width: 400px; height: 400px; background: rgba(79, 172, 254, 0.15); top: -100px; left: -100px; }
.orb-2 { width: 500px; height: 500px; background: rgba(139, 92, 246, 0.15); bottom: -150px; right: -100px; animation-delay: -5s; }
.orb-3 { width: 300px; height: 300px; background: rgba(56, 189, 248, 0.1); top: 40%; left: 60%; animation-duration: 25s; }

@keyframes float {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-50px) scale(1.1); }
}

/* App Container Layout */
.app-container {
  width: 100%;
  max-width: 900px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 10;
  padding: 20px;
}

/* Glassmorphism Styles */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Header */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 30px;
  border-radius: 24px 24px 0 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-bottom: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h2 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.brand h2 span {
  font-size: 0.8rem;
  background: linear-gradient(90deg, var(--primary-accent), var(--secondary-accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-left: 8px;
  padding: 4px 10px;
  border-radius: 12px;
  background-color: rgba(79, 172, 254, 0.1);
}

.pulse-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Main Chat Area */
.chat-main {
  flex-grow: 1;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(10px);
  border-left: 1px solid var(--glass-border);
  border-right: 1px solid var(--glass-border);
  padding: 30px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.chat-main::-webkit-scrollbar { width: 6px; }
.chat-main::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 10px; }

.message {
  display: flex;
  max-width: 85%;
  animation: fadeUp 0.4s ease-out forwards;
}

.message.user {
  align-self: flex-end;
}

.message.system {
  align-self: flex-start;
}

.message-content {
  padding: 16px 20px;
  border-radius: 20px;
  line-height: 1.6;
  font-size: 0.95rem;
  letter-spacing: 0.2px;
}

.message.user .message-content {
  background: linear-gradient(135deg, rgba(79, 172, 254, 0.2) 0%, rgba(0, 242, 254, 0.1) 100%);
  border-bottom-right-radius: 4px;
  color: #fff;
}

.message.system .message-content {
  background: rgba(30, 41, 59, 0.8);
  border-bottom-left-radius: 4px;
}

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

@keyframes fadeUp {
  0% { opacity: 0; transform: translateY(15px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Input Section */
.chat-input-area {
  padding: 24px 30px;
  border-radius: 0 0 24px 24px;
}

#chatForm {
  display: flex;
  gap: 16px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 8px;
  border-radius: 16px;
  transition: border-color 0.3s ease;
}

#chatForm:focus-within {
  border-color: rgba(79, 172, 254, 0.5);
  box-shadow: 0 0 15px rgba(79, 172, 254, 0.15);
}

#userInput {
  flex-grow: 1;
  background: transparent;
  border: none;
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
}

#userInput:focus { outline: none; }
#userInput::placeholder { color: var(--text-secondary); opacity: 0.6; }

#sendBtn {
  background: linear-gradient(135deg, var(--primary-accent) 0%, var(--secondary-accent) 100%);
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#sendBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(79, 172, 254, 0.4);
}

#sendBtn:active { transform: translateY(0); }

/* Generating indicator */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}
.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Responsiveness */
@media (max-width: 768px) {
  .app-container { height: 100vh; padding: 0; max-width: 100%; border-radius: 0; }
  .chat-header, .chat-input-area { border-radius: 0; padding: 15px 20px; }
  .message { max-width: 95%; }
}
