/* SQL Agent chat panel — styles for the Agent tab in the left panel */

.agent-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Status bar at the top */
.agent-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--surface);
  flex-shrink: 0;
}

.agent-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.agent-status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 4px var(--success);
}

.agent-status-dot.unavailable {
  background: #fbbf24;
  box-shadow: 0 0 4px #fbbf24;
}

.agent-status-dot.auth-required {
  background: var(--error);
  box-shadow: 0 0 4px var(--error);
}

.agent-status-dot.disconnected {
  background: var(--text-muted);
}

.agent-status-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Message list — scrollable area */
.agent-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Empty state when no messages yet */
.agent-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  gap: 8px;
  padding: 20px;
}

.agent-empty-icon {
  font-size: 24px;
  opacity: 0.4;
}

.agent-empty-hint {
  font-size: 11.5px;
  line-height: 1.5;
  max-width: 200px;
  color: var(--text-muted);
}

/* Individual message bubbles */
.agent-message {
  display: flex;
  flex-direction: column;
  max-width: 92%;
  animation: msgIn 0.15s ease-out;
}

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

/* User message — right-aligned, accent color */
.agent-message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.agent-message.user .agent-bubble {
  background: var(--accent);
  color: #fff;
  border-radius: 12px 12px 4px 12px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

/* Agent message — left-aligned, surface-2 background */
.agent-message.agent {
  align-self: flex-start;
  align-items: flex-start;
}

.agent-message.agent .agent-bubble {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

/* System message — centered, italic, dimmed */
.agent-message.system {
  align-self: center;
  align-items: center;
  max-width: 90%;
}

.agent-message.system .agent-bubble {
  background: transparent;
  color: var(--text-dim);
  font-style: italic;
  font-size: 12px;
  padding: 4px 8px;
  text-align: center;
}

/* Error system message */
.agent-message.system.error .agent-bubble {
  color: var(--error);
}

/* Code blocks inside agent messages */
.agent-bubble code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.2);
  padding: 1px 4px;
  border-radius: 3px;
  white-space: pre-wrap;
}

/* Typing indicator */
.agent-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
}

.agent-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: typingBounce 1.2s ease-in-out infinite;
}

.agent-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.agent-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Input area — sticky at the bottom */
.agent-input-wrap {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  align-items: flex-end;
}

.agent-input {
  flex: 1;
  resize: none;
  min-height: 38px;
  max-height: 120px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.15s;
  overflow-y: auto;
}

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

.agent-input::placeholder {
  color: var(--text-muted);
}

.agent-send-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
  color: #fff;
  font-size: 16px;
}

.agent-send-btn:hover {
  opacity: 0.85;
}

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

/* Live mode gate overlay */
.agent-live-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
  text-align: center;
  gap: 10px;
  color: var(--text-dim);
}

.agent-live-gate h3 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 400;
  color: var(--text);
  margin: 0;
}

.agent-live-gate p {
  font-size: 12.5px;
  line-height: 1.6;
  max-width: 220px;
  margin: 0;
}

.agent-live-gate .kbd {
  font-family: var(--font-mono);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

/* Scrollbar styling */
.agent-messages::-webkit-scrollbar {
  width: 6px;
}

.agent-messages::-webkit-scrollbar-track {
  background: transparent;
}

.agent-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.agent-messages::-webkit-scrollbar-thumb:hover {
  background: var(--border-bright);
}

/* Execution results table — rendered below agent bubbles */
.agent-results {
  align-self: flex-start;
  width: 100%;
  margin-top: 4px;
  overflow-x: auto;
}

.agent-results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 4px;
}

.agent-results-table th {
  background: var(--surface-2);
  color: var(--text-dim);
  font-weight: 600;
  text-align: left;
  padding: 4px 8px;
  border: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.agent-results-table td {
  padding: 3px 8px;
  border: 1px solid var(--border);
  color: var(--text);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-results-table tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.05);
}

.agent-results-table tbody tr:hover {
  background: rgba(0, 0, 0, 0.08);
}

/* Results summary footer message */
.agent-results-summary {
  display: inline-block;
  margin-top: 2px;
  color: var(--success) !important;
  font-size: 11.5px !important;
  font-style: normal !important;
}