/* ==========================================================================
   Root Variables & Theming
   Defines the core Google Material 3 color palette, backgrounds, and borders.
   ========================================================================== */
:root {
  --bg-color: #f8f9fa;
  --text-color: #1f1f1f;
  --text-muted: #5f6368;
  --sidebar-bg: #f0f4f9;
  --chat-bg: #ffffff;
  --message-user-bg: #d3e3fd;
  --message-user-text: #041e49;
  --message-agent-bg: #f1f3f4;
  --message-agent-text: #1f1f1f;
  --border-color: #dadce0;
}

/* ==========================================================================
   Global Resets & Base Layout
   Establishes box-sizing, typography, and the full-bleed application container.
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Google Sans', 'Segoe UI', Roboto, sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  overflow: hidden;
  height: 100vh;
}

.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* ==========================================================================
   Sidebar Configuration Panel
   Styles the pinned left navigation drawer housing agent and user settings.
   ========================================================================== */
.sidebar {
  width: 320px;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
}

.sidebar-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
  font-size: 1.15rem;
  font-weight: 500;
}

.settings-form {
  padding: 24px;
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#remote-settings {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.btn-full {
  width: 100%;
}

/* ==========================================================================
   Main Chat Playground Area
   Configures the primary chat interface, header, and dynamic message history feed.
   ========================================================================== */
.chat-container {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--chat-bg);
  height: 100%;
  min-width: 0;
}

.chat-header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--chat-bg);
}

.agent-info h1 {
  font-size: 1.15rem;
  font-weight: 500;
}

.messages-container {
  flex-grow: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ==========================================================================
   Message Bubbles & Formatting
   Provides distinct visual styling for user, agent, system, and error bubbles.
   ========================================================================== */
.message {
  max-width: 75%;
  padding: 12px 18px;
  border-radius: 18px;
  line-height: 1.55;
  word-wrap: break-word;
  font-size: 0.92rem;
}

.system-message {
  align-self: center;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  text-align: center;
  max-width: 85%;
  border-radius: 12px;
}

.user-message {
  align-self: flex-end;
  background-color: var(--message-user-bg);
  color: var(--message-user-text);
  border-bottom-right-radius: 4px;
}

.agent-message {
  align-self: flex-start;
  background-color: var(--message-agent-bg);
  color: var(--message-agent-text);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.error-message {
  align-self: center;
  background-color: #fce8e6;
  color: #c5221f;
  border: 1px solid rgba(197, 34, 31, 0.25);
  border-radius: 12px;
}

.error-header {
  font-weight: 600;
}

.error-traceback {
  margin-top: 8px;
  background-color: #fce8e6;
  border: 1px solid rgba(197, 34, 31, 0.2);
  color: #c5221f;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  overflow-x: auto;
  font-family: Consolas, Courier, monospace;
}

/* ==========================================================================
   Input Bar & Actions
   Designs the bottom prompt bar and send button.
   ========================================================================== */
.input-container {
  padding: 18px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 16px;
  background-color: var(--chat-bg);
}

.input-container input {
  flex-grow: 1;
  padding: 14px 18px;
  border-radius: 24px;
  background-color: #f1f3f4;
  border: 1px solid #transparent;
  color: var(--text-color);
  font-size: 0.95rem;
  outline: none;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.input-container input:focus {
  background-color: var(--chat-bg);
  border-color: var(--border-color);
  box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.15);
}

/* Material symbols loading spins */
.agent-loader {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.icon-spin {
  display: inline-block;
  animation: spin 2s linear infinite;
}

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

/* Active Agent Profile configurations */
.agent-info-pane {
  margin-top: 20px;
  padding: 16px;
  border-radius: 12px;
  background-color: var(--chat-bg);
  border: 1px solid var(--border-color);
}

.agent-info-pane h4 {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.info-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  gap: 8px;
}

.info-label {
  color: var(--text-muted);
  font-weight: 500;
}

.info-value {
  color: var(--text-color);
  font-weight: 600;
  word-break: break-all;
}

/* Custom scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: rgba(60, 64, 67, 0.2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: rgba(60, 64, 67, 0.35);
}
