/* ── SG2 Data Agent — 3-Panel Layout ──────────────────────────── */

/* Left Sidebar */
#sg2-left-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  background: #0f172a;
  color: #e2e8f0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid #1e293b;
}

#sg2-left-panel .panel-header {
  padding: 20px 20px 12px;
  border-bottom: 1px solid #1e293b;
}

#sg2-left-panel .panel-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: #f8fafc;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

#sg2-left-panel .panel-header .subtitle {
  font-size: 12px;
  color: #94a3b8;
  margin: 0;
}

#sg2-left-panel .panel-header .db-status {
  font-size: 11px;
  color: #4ade80;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

#sg2-left-panel .model-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: #1e293b;
  color: #93c5fd;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
  border-bottom: 1px solid #1e293b;
}

#sg2-left-panel .model-link:hover {
  background: #334155;
}

/* Copy Conversation button — above chat input */
#sg2-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
  align-self: flex-end;
}

#sg2-copy-btn:hover {
  background: #e2e8f0;
  color: #1e293b;
  border-color: #cbd5e1;
}

#sg2-copy-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

#sg2-left-panel .questions-section {
  padding: 16px 20px 8px;
  flex: 1;
}

#sg2-left-panel .questions-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin: 0 0 12px;
  font-weight: 600;
}

/* Expandable category sections */
#sg2-left-panel .question-category {
  margin-bottom: 2px;
}

#sg2-left-panel .category-header {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  color: #94a3b8;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

#sg2-left-panel .category-header:hover {
  background: #1e293b;
  color: #e2e8f0;
}

#sg2-left-panel .category-header .cat-icon {
  font-size: 14px;
}

#sg2-left-panel .category-header .cat-arrow {
  margin-left: auto;
  font-size: 9px;
  transition: transform 0.2s;
}

#sg2-left-panel .question-category.expanded .cat-arrow {
  transform: rotate(90deg);
}

#sg2-left-panel .category-list {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease-out;
  padding-left: 8px;
}

#sg2-left-panel .question-category.expanded .category-list {
  max-height: 600px;
  transition: max-height 0.35s ease-in;
}

#sg2-left-panel .question-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 12px;
  margin-bottom: 2px;
  background: transparent;
  color: #cbd5e1;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.4;
  transition: background 0.15s, color 0.15s;
}

#sg2-left-panel .question-btn:hover {
  background: #1e293b;
  color: #f8fafc;
}

#sg2-left-panel .panel-footer {
  padding: 12px 20px;
  border-top: 1px solid #1e293b;
  font-size: 11px;
  color: #475569;
  line-height: 1.5;
}

/* Right Panel — Execution Log */
#sg2-right-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  background: #fafbfc;
  color: #334155;
  z-index: 100;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #e2e8f0;
  overflow-y: auto;
}

#sg2-right-panel .panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

#sg2-right-panel .panel-header h2 {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

#sg2-right-panel .exec-log {
  flex: 1;
  padding: 12px 16px;
  overflow-y: auto;
}

#sg2-right-panel .exec-entry {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
}

#sg2-right-panel .exec-entry:last-child {
  border-bottom: none;
}

#sg2-right-panel .exec-entry .exec-question {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 10px;
  padding: 6px 10px;
  background: #eff6ff;
  border-radius: 6px;
  border-left: 3px solid #3b82f6;
}

#sg2-right-panel .exec-step {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  line-height: 1.5;
}

#sg2-right-panel .exec-step .step-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  margin-top: 1px;
}

#sg2-right-panel .exec-step .step-icon.pending {
  background: #fef3c7;
  color: #92400e;
}

#sg2-right-panel .exec-step .step-icon.running {
  background: #dbeafe;
  color: #1d4ed8;
  animation: pulse 1.5s ease-in-out infinite;
}

#sg2-right-panel .exec-step .step-icon.done {
  background: #d1fae5;
  color: #065f46;
}

#sg2-right-panel .exec-step .step-icon.error {
  background: #fee2e2;
  color: #991b1b;
}

#sg2-right-panel .exec-step .step-label {
  color: #475569;
}

#sg2-right-panel .exec-step .step-label strong {
  color: #1e293b;
}

#sg2-right-panel .exec-step .step-time {
  color: #94a3b8;
  font-size: 11px;
  margin-left: auto;
  flex-shrink: 0;
}

#sg2-right-panel .exec-step .step-detail {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: #e0e7ff;
  color: #3730a3;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

#sg2-right-panel .exec-sql {
  margin: 8px 0;
  padding: 8px 10px;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 6px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  line-height: 1.5;
  overflow-x: auto;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

#sg2-right-panel .exec-result {
  font-size: 12px;
  padding: 4px 10px;
  background: #f0fdf4;
  color: #166534;
  border-radius: 4px;
  margin-top: 6px;
}

#sg2-right-panel .exec-empty {
  padding: 40px 20px;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Push Chainlit's main content to center column ────────────── */
.group\/sidebar-wrapper {
  padding-left: 280px !important;
  padding-right: 320px !important;
}

/* Hide Chainlit's default header new-chat button to avoid confusion */
#header {
  padding-left: 8px !important;
  padding-right: 8px !important;
}

/* Hide the default welcome message since we have the left panel */
/* Wider chat input */
#chat-input {
  font-size: 14px;
}

/* Better message styling */
.step {
  max-width: 100% !important;
}

/* Hide execution step markers from main chat (they go to right panel) */
.exec-marker {
  display: none !important;
}

/* Make tables in chat look better */
.prose table {
  font-size: 13px;
}

.prose th {
  background: #f8fafc;
  font-weight: 600;
}

/* Collapsible SQL details styling */
.prose details {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0;
  margin: 8px 0;
}

.prose details summary {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
}

.prose details pre {
  margin: 0;
  border-radius: 0 0 8px 8px;
}

/* Toast notification */
#sg2-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  color: #f8fafc;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 9999;
  pointer-events: none;
}

#sg2-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* New chat button in header — style as icon */
#new-chat-button, [id*="new-chat"] {
  opacity: 0.7;
}
