/* Global Variables & Theme */
:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #131a2e;
  --bg-tertiary: #1b2541;
  
  --accent-color: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.45);
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --glass-bg: rgba(19, 26, 46, 0.6);
  --glass-border: rgba(255, 255, 255, 0.05);
}

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

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

/* App Container Layout */
.app-container {
  width: 100%;
  max-width: 900px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

/* Header */
.app-header {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background-color: var(--glass-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
}

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

.logo {
  width: 36px;
  height: 36px;
  background: var(--accent-gradient);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.5px;
  box-shadow: 0 0 15px var(--accent-glow);
}

.header-left h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

.status-indicator {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-indicator::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background-color: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
}

/* Chat Workspace */
.chat-workspace {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background-image: radial-gradient(circle at 50% 50%, rgba(27, 37, 65, 0.3) 0%, rgba(11, 15, 25, 0) 80%);
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: slideIn 0.25s ease-out;
}

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

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

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

.message.system {
  align-self: center;
  max-width: 90%;
  text-align: center;
}

.msg-content {
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.5;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.message.user .msg-content {
  background: var(--accent-gradient);
  border-bottom-right-radius: 4px;
}

.message.agent .msg-content {
  background-color: var(--bg-tertiary);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--glass-border);
}

.message.system .msg-content {
  background-color: rgba(27, 37, 65, 0.4);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.message.system strong {
  color: var(--text-primary);
  display: block;
  margin-bottom: 4px;
}

/* Console logs drawer */
.console-drawer {
  border-top: 1px solid var(--border-color);
  background-color: #05070c;
  display: flex;
  flex-direction: column;
  transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.console-drawer.collapsed {
  height: 45px;
}

.console-drawer.expanded {
  height: 250px;
}

.toggle-console-btn {
  height: 45px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.console-content {
  flex: 1;
  padding: 15px;
  overflow: auto;
  font-family: monospace;
}

#console-output {
  font-size: 0.8rem;
  color: #10b981;
  white-space: pre-wrap;
  line-height: 1.4;
}

/* Footer / Inputs */
.app-footer {
  padding: 15px;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  padding: 6px 12px;
  border-radius: 24px;
}

.chat-form:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

#prompt-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  max-height: 100px;
  padding: 8px 0;
  outline: none;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.send-btn {
  background: var(--accent-gradient);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.send-btn:hover {
  transform: scale(1.05);
}

/* File Upload Pills */
.upload-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.pill {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.pill .remove {
  cursor: pointer;
  font-weight: 800;
  color: #ef4444;
}

/* Login Page Styles */
.login-body {
  align-items: center;
  justify-content: center;
  background-image: radial-gradient(circle at center, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px 30px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
  text-align: center;
  animation: slideIn 0.35s ease-out;
}

.login-header .logo {
  margin: 0 auto 20px auto;
  width: 48px;
  height: 48px;
  font-size: 1.3rem;
}

.login-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-header p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 30px;
}

.form-group {
  text-align: left;
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent-color);
}

.btn {
  width: 100%;
  padding: 12px;
  background: var(--accent-gradient);
  border: none;
  border-radius: 12px;
  color: white;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.btn:hover {
  opacity: 0.95;
}

.error-msg {
  color: #ef4444;
  font-size: 0.85rem;
  margin-bottom: 15px;
  text-align: left;
}

.hidden {
  display: none !important;
}

/* Mobile-first Media Queries */
@media (max-width: 600px) {
  body {
    height: 100dvh;
    padding: 0;
  }
  
  .app-container {
    height: 100dvh;
    border: none;
    max-width: 100%;
    border-radius: 0;
    box-shadow: none;
  }
  
  .app-header {
    height: 60px;
    padding: 0 15px;
  }
  
  .header-left h2 {
    font-size: 0.95rem;
  }
  
  .chat-workspace {
    padding: 15px;
  }
  
  .msg-content {
    font-size: 0.9rem;
    padding: 10px 14px;
    border-radius: 16px;
  }
  
  .message {
    max-width: 90%;
  }
  
  #prompt-input {
    font-size: 16px; /* Prevents auto-zoom on iOS Safari */
    padding: 6px 0;
  }
  
  .console-drawer.expanded {
    height: 180px;
  }
  
  .console-content {
    padding: 10px;
  }
  
  .chat-form {
    padding: 4px 10px;
    gap: 8px;
  }
  
  .send-btn, .icon-btn {
    width: 36px;
    height: 36px;
  }
  
  .login-card {
    border: none;
    box-shadow: none;
    background: transparent;
    padding: 20px;
  }
}
