:root {
  /* HSL Color Palette */
  --bg-primary: #0b0f19;
  --bg-secondary: rgba(17, 24, 39, 0.7);
  --bg-tertiary: rgba(31, 41, 55, 0.4);
  
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-glow: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dark: #4b5563;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(59, 130, 246, 0.2);
  
  --shadow-main: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  
  --font-family-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-family-mono: 'JetBrains Mono', Courier New, monospace;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-family-sans);
  height: 100vh;
  overflow: hidden;
  display: flex;
  background-image: radial-gradient(circle at 10% 20%, rgba(90, 80, 250, 0.05) 0%, transparent 40%),
                    radial-gradient(circle at 90% 80%, rgba(50, 150, 255, 0.05) 0%, transparent 40%);
}

.app-container {
  display: grid;
  grid-template-columns: 280px 1fr 380px;
  width: 100vw;
  height: 100vh;
  backdrop-filter: blur(10px);
}

/* --- SIDEBAR --- */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
}

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

.brand h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: var(--accent-glow);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-icon {
  font-size: 1.8rem;
}

.settings-card, .info-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-main);
}

.settings-card h3, .info-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.input-group input {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  color: #white;
  color: var(--text-main);
  font-family: var(--font-family-sans);
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px var(--border-glow);
}

.password-wrapper {
  display: flex;
  position: relative;
}

.password-wrapper input {
  width: 100%;
  padding-right: 40px;
}

#toggle-key-visibility {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
}

.helper-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

.info-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-card code {
  font-family: var(--font-family-mono);
  background: rgba(0,0,0,0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--accent-blue);
}

.footer-info {
  margin-top: auto;
  font-size: 0.75rem;
  color: var(--text-dark);
  text-align: center;
}

/* --- MAIN CONTENT / CHAT --- */
.main-content {
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid var(--border-color);
  background: rgba(10, 15, 29, 0.3);
}

.chat-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.chat-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: row-reverse;
  justify-content: space-between;
  align-items: center;
  background: rgba(17, 24, 39, 0.4);
}

.chat-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
  transition: background-color 0.3s ease;
}

.pulse-dot.active {
  background-color: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulse 1.5s infinite;
}

.pulse-dot.thinking {
  background-color: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: fadeIn 0.3s ease forwards;
}

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

.message-content {
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

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

.system-message .message-content {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85rem;
}

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

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

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

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

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

.thought-message .message-content {
  background: rgba(245, 158, 11, 0.05);
  border: 1px dashed rgba(245, 158, 11, 0.3);
  color: #f59e0b;
  font-family: var(--font-family-mono);
  font-size: 0.85rem;
  border-radius: 8px;
}

.input-area {
  padding: 24px;
  background: rgba(17, 24, 39, 0.5);
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 16px;
}

#prompt-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
  color: var(--text-main);
  font-family: var(--font-family-sans);
  font-size: 0.95rem;
  resize: none;
  transition: all 0.3s ease;
}

#prompt-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px var(--border-glow);
}

#send-btn {
  background: var(--accent-glow);
  border: none;
  border-radius: 12px;
  color: white;
  padding: 0 24px;
  font-family: var(--font-family-sans);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

#send-btn:hover {
  transform: translateY(-2px);
  opacity: 0.95;
}

#send-btn:active {
  transform: translateY(0);
}

#send-btn:disabled {
  background: var(--text-dark);
  cursor: not-allowed;
  transform: none;
}

/* --- CONSOLE / TERMINAL (RIGHT PANEL) --- */
.console-section {
  background: #050811;
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.console-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(17, 24, 39, 0.6);
}

.console-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

#clear-console-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-muted);
  padding: 4px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

#clear-console-btn:hover {
  border-color: var(--text-muted);
  color: var(--text-main);
}

.console-output {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  font-family: var(--font-family-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.console-line {
  word-break: break-all;
  white-space: pre-wrap;
}

.system-line { color: var(--text-muted); }
.thought-line { color: #f59e0b; }
.tool-call-line { color: var(--accent-purple); font-weight: 500; }
.tool-result-line { color: #10b981; }
.error-line { color: #ef4444; }

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Utility */
.hidden {
  display: none !important;
}

/* --- LOGIN MODAL OVERLAY --- */
.login-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 8, 17, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.login-card {
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 40px 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(59, 130, 246, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  text-align: center;
  animation: modalSlideUp 0.4s ease-out forwards;
}

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

.login-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.login-logo {
  font-size: 3rem;
  margin-bottom: 4px;
}

.login-header h2 {
  font-size: 1.45rem;
  font-weight: 700;
  background: var(--accent-glow);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.security-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.85rem;
  color: var(--text-main);
}

.security-badge strong {
  color: #60a5fa;
}

.auth-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.4;
  text-align: left;
  width: 100%;
}

.google-auth-box {
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  align-items: center;
}

.client-id-config {
  width: 100%;
  text-align: left;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.client-id-config summary {
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  font-weight: 500;
}

.client-id-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.client-id-input-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.client-id-input-group input {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 0.85rem;
}

.client-id-input-group button {
  background: var(--accent-blue);
  border: none;
  border-radius: 8px;
  color: white;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.client-id-input-group button:hover {
  background: #2563eb;
}

/* --- USER CARD (SIDEBAR) --- */
.user-card {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--accent-blue);
  object-fit: cover;
  background-color: var(--bg-tertiary);
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-email {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.logout-btn {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  color: white;
}

