@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-surface: rgba(30, 41, 59, 0.7);
  --bg-surface-hover: rgba(51, 65, 85, 0.8);
  --bg-input: rgba(15, 23, 42, 0.85);

  --accent-gold: #f59e0b;
  --accent-gold-glow: rgba(245, 158, 11, 0.35);
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.3);
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --border-light: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(245, 158, 11, 0.3);
  
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(245, 158, 11, 0.15);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

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

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(245, 158, 11, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.08) 0%, transparent 40%);
}

/* APP SHELL */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  position: relative;
  overflow: hidden;
}

/* SIDEBAR */
.sidebar {
  width: 290px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
  backdrop-filter: blur(12px);
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-light);
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #d97706, #f59e0b, #fbbf24);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #090d16;
  font-weight: 800;
  box-shadow: 0 0 15px var(--accent-gold-glow);
}

.brand-info h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-info span {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-gold);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 7px;
  height: 7px;
  background-color: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

.sidebar-action {
  padding: 16px 20px;
}

.btn-new-chat {
  width: 100%;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.05));
  border: 1px solid var(--border-highlight);
  color: var(--accent-gold);
  border-radius: var(--radius-md);
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-new-chat:hover {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(245, 158, 11, 0.1));
  box-shadow: 0 0 16px var(--accent-gold-glow);
  transform: translateY(-1px);
}

.history-section {
  flex: 1;
  overflow-y: auto;
  padding: 10px 16px;
}

.history-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 12px;
}

.session-item {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.88rem;
  transition: all 0.15s ease;
  margin-bottom: 4px;
}

.session-item:hover, .session-item.active {
  background: var(--bg-surface);
  color: var(--text-main);
}

.session-item.active {
  border-left: 3px solid var(--accent-gold);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
  background: rgba(15, 23, 42, 0.95);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.server-metric {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.server-metric span.badge {
  color: var(--accent-cyan);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}

/* MAIN CHAT VIEW */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
}

/* TOPBAR */
.topbar {
  height: 68px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border-light);
  background: rgba(9, 13, 22, 0.7);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1.3rem;
  cursor: pointer;
}

.agent-title-group h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

.agent-title-group p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.select-model {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.select-model:focus {
  border-color: var(--accent-gold);
}

.btn-icon {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  color: var(--text-main);
  border-color: var(--border-highlight);
  background: var(--bg-surface-hover);
}

/* CHAT MESSAGES */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  scroll-behavior: smooth;
}

/* WELCOME BANNER */
.welcome-hero {
  max-width: 680px;
  margin: 40px auto;
  text-align: center;
  padding: 36px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  backdrop-filter: blur(10px);
  animation: fadeIn 0.5s ease;
}

.welcome-logo {
  font-size: 3.5rem;
  margin-bottom: 12px;
  display: inline-block;
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.welcome-hero h3 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #ffffff, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-hero p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 24px;
}

.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  text-align: left;
}

.suggestion-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-light);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.suggestion-card:hover {
  border-color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.08);
  transform: translateY(-2px);
}

.suggestion-card strong {
  display: block;
  font-size: 0.88rem;
  color: var(--text-main);
  margin-bottom: 4px;
}

.suggestion-card span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* MESSAGE BUBBLES */
.message-row {
  display: flex;
  gap: 14px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-row.user {
  flex-direction: row-reverse;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.message-row.agent .avatar {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #090d16;
  box-shadow: 0 0 12px var(--accent-gold-glow);
}

.message-row.user .avatar {
  background: linear-gradient(135deg, #0284c7, #06b6d4);
  color: #ffffff;
  box-shadow: 0 0 12px var(--accent-cyan-glow);
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 78%;
}

.message-row.user .message-content {
  align-items: flex-end;
}

.message-bubble {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 0.94rem;
  line-height: 1.65;
  word-break: break-word;
}

.message-row.user .message-bubble {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.message-row.agent .message-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.message-meta {
  font-size: 0.72rem;
  color: var(--text-subtle);
  padding: 0 4px;
}

/* TOOL EXECUTION ACCORDION */
.tool-pill {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--accent-gold);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--accent-gold);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* CODE BLOCKS */
pre {
  background: #060910 !important;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  margin: 10px 0;
  position: relative;
}

pre code {
  color: #e2e8f0;
}

.copy-code-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.copy-code-btn:hover {
  background: var(--accent-gold);
  color: #090d16;
}

/* CHAT INPUT AREA */
.chat-input-wrapper {
  padding: 20px 28px 24px;
  background: linear-gradient(180deg, transparent, rgba(9, 13, 22, 0.9) 30%);
  position: relative;
}

.input-box {
  max-width: 860px;
  margin: 0 auto;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-box:focus-within {
  border-color: var(--accent-gold);
  box-shadow: 0 0 20px var(--accent-gold-glow);
}

.input-textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: 'Outfit', sans-serif;
  font-size: 0.98rem;
  line-height: 1.5;
  resize: none;
  max-height: 160px;
  min-height: 24px;
}

.input-textarea::placeholder {
  color: var(--text-subtle);
}

.input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.input-hints {
  font-size: 0.74rem;
  color: var(--text-subtle);
}

.btn-send {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  border: none;
  color: #090d16;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px var(--accent-gold-glow);
}

.btn-send:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--accent-gold-glow);
}

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

/* TYPING INDICATOR */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 8px 14px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-gold);
  border-radius: 50%;
  animation: typing-bounce 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-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* RESPONSIVE DESIGN */
@media (max-width: 820px) {
  .sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -100%;
  }

  .sidebar.open {
    left: 0;
  }

  .mobile-toggle {
    display: block;
  }

  .suggestions-grid {
    grid-template-columns: 1fr;
  }

  .message-content {
    max-width: 90%;
  }
}
