/* ============================================
   AI Command Center - Elegant Split Panel Design
   ============================================ */

/* ===== Header Bar ===== */
.ai-header-bar {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  border-radius: 16px;
  padding: 20px 28px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.15);
  position: relative;
  overflow: visible;
}

.ai-header-bar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(
      ellipse at 20% 50%,
      rgba(99, 102, 241, 0.08) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse at 80% 50%,
      rgba(59, 130, 246, 0.06) 0%,
      transparent 50%
    );
  pointer-events: none;
  border-radius: inherit;
  overflow: hidden;
}

.ai-header-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #6366f1, #3b82f6);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.ai-header-title {
  color: #f1f5f9 !important;
  font-size: 1.25rem !important;
  font-weight: 700 !important;
  letter-spacing: -0.3px;
}

.ai-header-subtitle {
  color: #94a3b8 !important;
  font-size: 0.8rem !important;
  letter-spacing: 0.2px;
}

.ai-portfolio-label {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}

.ai-portfolio-dropdown .Select-control {
  border-radius: 10px !important;
  border: 1.5px solid #334155 !important;
  background-color: #1e293b !important;
  color: #f1f5f9 !important;
}

/* ===== Main Split Layout ===== */
.ai-main-row {
  min-height: calc(100vh - 220px);
}

/* ===== Left Panel: Chat ===== */
.ai-left-panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 220px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.ai-input-section {
  padding: 16px 18px;
  border-bottom: 1px solid #f1f5f9;
  background: #ffffff;
  flex-shrink: 0;
}

.ai-quick-actions {
  margin-bottom: 12px;
}

.ai-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #94a3b8;
}

.ai-toggle-btn {
  color: #94a3b8 !important;
  font-size: 12px !important;
  text-decoration: none !important;
}

.ai-toggle-btn:hover {
  color: #6366f1 !important;
}

.ai-suggestions-container {
  padding: 10px 0;
}

.ai-pill-category {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #94a3b8;
  margin-bottom: 8px;
}

.ai-suggestion-pill {
  border-radius: 20px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  padding: 5px 14px !important;
  border: 1.5px solid #e2e8f0 !important;
  background: #f8fafc !important;
  color: #475569 !important;
  transition: all 0.2s ease !important;
  white-space: nowrap;
}

.ai-suggestion-pill:hover {
  background: #eff6ff !important;
  border-color: #93c5fd !important;
  color: #1d4ed8 !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15) !important;
}

/* Input Area */
.ai-input-wrapper {
  position: relative;
}

.ai-chat-input {
  border-radius: 12px !important;
  border: 1.5px solid #e2e8f0 !important;
  background: #fafbfc !important;
  font-size: 14px !important;
  transition: all 0.2s ease !important;
}

.ai-chat-input:focus {
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1) !important;
  background: #ffffff !important;
}

.ai-send-btn {
  border-radius: 10px !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  padding: 8px 20px !important;
  background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
  border: none !important;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25) !important;
  transition: all 0.2s ease !important;
}

.ai-send-btn:hover:not(:disabled) {
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35) !important;
}

.ai-send-btn:disabled {
  opacity: 0.6 !important;
  cursor: not-allowed !important;
}

/* Chat History */
.ai-chat-history-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px 18px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.ai-chat-history-container::-webkit-scrollbar {
  width: 5px;
}

.ai-chat-history-container::-webkit-scrollbar-track {
  background: transparent;
}

.ai-chat-history-container::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 4px;
}

.ai-chat-history-container::-webkit-scrollbar-thumb:hover {
  background-color: #94a3b8;
}

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

/* Chat message bubbles */
.chat-message {
  animation: slideInUp 0.3s ease-out;
}

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

/* ===== Right Panel: Response ===== */
.ai-right-panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 220px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  min-height: 0;
}

/* Manual tab button hover effect */
#tab-btn-response:hover,
#tab-btn-workflows:hover,
#tab-btn-tools:hover {
  background: rgba(99, 102, 241, 0.04) !important;
}

/* Response Panel */
.ai-response-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.ai-response-header {
  padding: 14px 20px;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.ai-response-icon {
  color: #6366f1;
  font-size: 18px;
}

.ai-response-title {
  font-weight: 700;
  font-size: 15px;
  color: #1e293b;
  letter-spacing: -0.2px;
}

.ai-response-body {
  flex: 1 1 auto;
  padding: 20px;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: auto;
  scrollbar-color: #94a3b8 #f1f5f9;
}

.ai-response-body::-webkit-scrollbar {
  width: 8px;
}

.ai-response-body::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.ai-response-body::-webkit-scrollbar-thumb {
  background-color: #94a3b8;
  border-radius: 4px;
  border: 1px solid #f1f5f9;
}

.ai-response-body::-webkit-scrollbar-thumb:hover {
  background-color: #64748b;
}

.ai-workflows-body {
  flex: 1;
  padding: 16px 20px;
  overflow-y: scroll !important;
  max-height: calc(100vh - 420px);
  min-height: 0;
  scrollbar-width: auto;
  scrollbar-color: #94a3b8 #f1f5f9;
}

.ai-workflows-body::-webkit-scrollbar {
  width: 8px;
}
.ai-workflows-body::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}
.ai-workflows-body::-webkit-scrollbar-thumb {
  background-color: #94a3b8;
  border-radius: 4px;
  border: 1px solid #f1f5f9;
}
.ai-workflows-body::-webkit-scrollbar-thumb:hover {
  background-color: #64748b;
}

.ai-tools-body {
  flex: 1;
  padding: 16px 20px;
  overflow-y: scroll !important;
  max-height: calc(100vh - 420px);
  min-height: 0;
  scrollbar-width: auto;
  scrollbar-color: #94a3b8 #f1f5f9;
}

.ai-tools-body::-webkit-scrollbar {
  width: 8px;
}
.ai-tools-body::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}
.ai-tools-body::-webkit-scrollbar-thumb {
  background-color: #94a3b8;
  border-radius: 4px;
  border: 1px solid #f1f5f9;
}
.ai-tools-body::-webkit-scrollbar-thumb:hover {
  background-color: #64748b;
}

.ai-refresh-btn {
  border-radius: 8px !important;
  font-size: 12px !important;
  padding: 4px 12px !important;
  border: 1.5px solid #e2e8f0 !important;
  color: #64748b !important;
  transition: all 0.2s ease !important;
}

.ai-refresh-btn:hover {
  border-color: #6366f1 !important;
  color: #6366f1 !important;
  background: #f5f3ff !important;
}

/* ===== AI Response Rendered Content ===== */
.ai-response-rendered {
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.ai-response-meta {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 8px;
  border-left: 3px solid #6366f1;
}

.ai-response-tools-used .badge {
  font-weight: 500 !important;
  letter-spacing: 0;
}

.ai-response-markdown {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
}

.ai-response-markdown h1,
.ai-response-markdown h2,
.ai-response-markdown h3 {
  color: #1e293b;
  font-weight: 700;
  margin-top: 1.2em;
  margin-bottom: 0.5em;
}

.ai-response-markdown h1 {
  font-size: 1.3rem;
}
.ai-response-markdown h2 {
  font-size: 1.15rem;
}
.ai-response-markdown h3 {
  font-size: 1.05rem;
}

.ai-response-markdown p {
  margin-bottom: 0.8em;
}

.ai-response-markdown ul,
.ai-response-markdown ol {
  padding-left: 1.5em;
  margin-bottom: 0.8em;
}

.ai-response-markdown li {
  margin-bottom: 0.3em;
}

.ai-response-markdown code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: #e11d48;
}

.ai-response-markdown pre {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  font-size: 13px;
  overflow-x: auto;
  margin: 12px 0;
}

.ai-response-markdown pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.ai-response-markdown table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 12px 0;
  border-radius: 8px;
  overflow: hidden;
  font-size: 13px;
}

.ai-response-markdown th {
  background: #f8fafc;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  border-bottom: 2px solid #e2e8f0;
}

.ai-response-markdown td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}

.ai-response-markdown tr:hover td {
  background: #f8fafc;
}

.ai-response-markdown blockquote {
  border-left: 3px solid #6366f1;
  padding: 8px 16px;
  margin: 12px 0;
  background: #f5f3ff;
  border-radius: 0 8px 8px 0;
  color: #4338ca;
  font-size: 13px;
}

.ai-response-markdown strong {
  color: #0f172a;
  font-weight: 700;
}

/* ===== Welcome State ===== */
.ai-welcome-state {
  padding: 12px 20px 20px;
  animation: fadeIn 0.5s ease-out;
}

.ai-welcome-section {
  background: #f8fafc;
  border-radius: 14px;
  padding: 18px 20px;
  border: 1px solid #f1f5f9;
}

.ai-question-card {
  text-align: left !important;
  border: 1.5px solid #e2e8f0 !important;
  border-radius: 12px !important;
  background: #ffffff !important;
  padding: 12px 14px !important;
  transition: all 0.2s ease !important;
  box-shadow: none !important;
  height: 100%;
}

.ai-question-card:hover {
  border-color: #818cf8 !important;
  background: #f5f3ff !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.12) !important;
}

.ai-question-card:active {
  transform: translateY(0) !important;
  box-shadow: 0 1px 4px rgba(99, 102, 241, 0.15) !important;
}

/* ===== Chat Message Improvements ===== */
.chat-message .card-body {
  padding: 14px 18px !important;
}

.chat-message p,
.chat-message .markdown-text p {
  color: #1e293b !important;
  font-size: 14px !important;
  line-height: 1.6 !important;
}

#chat-history .text-muted {
  color: #94a3b8 !important;
  opacity: 1 !important;
}

#chat-history .text-primary {
  color: #4f46e5 !important;
}

#chat-history .text-success {
  color: #16a34a !important;
}

/* Empty state for right panel - collapse when no content */
.ai-response-body:empty {
  padding: 0;
  flex: 0 0 0;
  overflow: hidden;
}

/* ===== Loading / Processing States ===== */
.processing-card {
  animation: none;
}

@keyframes pulse-glow {
  from {
    box-shadow: 0 4px 6px rgba(99, 102, 241, 0.1);
  }
  to {
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
  }
}

/* Status pulse */
.status-pulse {
  animation: none;
}

@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}

/* ===== Tool Calls Accordion ===== */
.tool-calls-accordion .accordion-button {
  font-size: 13px !important;
  padding: 8px 12px !important;
  border-radius: 8px !important;
}

.tool-calls-accordion .accordion-body {
  padding: 12px !important;
  background-color: #f8fafc !important;
  font-size: 13px;
}

/* ===== Workflow Cards ===== */
.workflow-card {
  transition: all 0.3s ease !important;
  border-radius: 12px !important;
}

.workflow-card:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1) !important;
}

.workflow-timeline {
  position: relative;
}
.timeline-line {
  transition: all 0.3s ease;
}
.timeline-connector {
  position: relative;
  margin-bottom: -40px;
  z-index: 1;
}

.workflow-timeline .card {
  transition: all 0.2s ease;
}
.workflow-timeline .card:hover {
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.state-transition {
  border-left: 2px solid #e2e8f0;
  padding-left: 1rem;
  margin-left: 0.5rem;
}

/* ===== Progress Bars ===== */
.progress {
  border-radius: 10px !important;
  overflow: hidden;
}

.progress-bar {
  transition: width 0.6s ease !important;
}

.progress-step {
  transition: all 0.3s ease;
}
.progress-step.completed {
  color: #22c55e !important;
}
.progress-step.active {
  color: #6366f1 !important;
}

/* ===== Badges ===== */
.badge {
  font-weight: 500 !important;
  letter-spacing: 0.3px;
}

/* ===== Technical Details ===== */
.workflow-card pre {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.workflow-card pre:hover {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

/* ===== Collapse Animation ===== */
.collapse {
  transition: height 0.35s ease !important;
}

/* ===== Responsive ===== */
@media (max-width: 992px) {
  .ai-main-row {
    flex-direction: column !important;
  }
  .ai-main-row > .col-5,
  .ai-main-row > .col-7 {
    max-width: 100% !important;
    flex: 0 0 100% !important;
    width: 100% !important;
  }
  .ai-left-panel,
  .ai-right-panel {
    height: auto;
    min-height: 400px;
  }
  .ai-right-panel {
    margin-top: 16px;
  }
}

@media (max-width: 768px) {
  .ai-header-bar {
    padding: 14px 18px;
  }
  .ai-header-title {
    font-size: 1.1rem !important;
  }
  .ai-suggestion-pill {
    font-size: 11px !important;
    padding: 4px 10px !important;
  }
  .workflow-card {
    margin-bottom: 1rem;
  }
  .workflow-timeline .card {
    font-size: 0.9rem;
  }
  .timeline-connector {
    margin-bottom: -30px;
  }
}

/* Custom scrollbar for legacy chat-history id */
#chat-history {
  max-height: 600px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

#chat-history::-webkit-scrollbar {
  width: 5px;
}
#chat-history::-webkit-scrollbar-track {
  background: transparent;
}
#chat-history::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
#chat-history::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ===== History Items (Left Panel Question List) ===== */
.ai-history-item {
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  margin-bottom: 4px;
}

.ai-history-item:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.ai-history-item:active {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.ai-history-item.selected {
  background: #f5f3ff;
  border-color: #c7d2fe;
  border-left: 3px solid #6366f1;
}

/* ===== Suggestions Panel (Right Panel Cards) ===== */
.ai-suggestions-panel {
  padding: 16px 20px;
  background: #fafbfc;
  border-radius: 12px;
  border: 1px solid #f1f5f9;
}

/* ===== Suggestions Footer (Persistent Bottom) ===== */
.ai-suggestions-footer {
  flex: 1 1 auto;
  padding: 16px 20px;
  border-top: 1px solid #f1f5f9;
  background: #ffffff;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.ai-suggestions-footer::-webkit-scrollbar {
  width: 4px;
}

.ai-suggestions-footer::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 4px;
}

/* ===== Portfolio Dropdown Fix ===== */
.ai-portfolio-dropdown .Select-value-label,
.ai-portfolio-dropdown .Select-placeholder {
  color: #f1f5f9 !important;
}

.ai-portfolio-dropdown .Select-menu-outer {
  background: #1e293b !important;
  border: 1px solid #334155 !important;
  border-radius: 8px !important;
  z-index: 9999 !important;
  position: absolute !important;
  width: 100% !important;
  top: 100% !important;
  left: 0 !important;
  margin-top: 4px !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4) !important;
}

.ai-portfolio-dropdown .Select-option {
  color: #e2e8f0 !important;
  background: #1e293b !important;
  padding: 10px 14px !important;
  line-height: 1.4 !important;
  min-height: 40px !important;
  display: flex !important;
  align-items: center !important;
  border-bottom: 1px solid #334155 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  box-sizing: border-box !important;
}

.ai-portfolio-dropdown .Select-option:last-child {
  border-bottom: none !important;
}

.ai-portfolio-dropdown .Select-option:hover,
.ai-portfolio-dropdown .Select-option.is-focused {
  background: #334155 !important;
  color: #ffffff !important;
}

.ai-portfolio-dropdown .Select-option.is-selected {
  background: #4f46e5 !important;
  color: #ffffff !important;
}

/* Dash-specific dropdown overrides */
.ai-portfolio-dropdown .dash-dropdown .Select-control {
  background-color: #1e293b !important;
  border-color: #334155 !important;
}

.ai-portfolio-dropdown .dash-dropdown .Select-input input {
  color: #f1f5f9 !important;
}

.ai-portfolio-dropdown .dash-dropdown .Select-arrow {
  border-color: #94a3b8 transparent transparent !important;
}

/* Dash core dropdown dark styling - VirtualizedSelect */
.ai-portfolio-dropdown .VirtualizedSelectOption {
  color: #e2e8f0 !important;
  background: #1e293b !important;
  padding: 10px 14px !important;
  line-height: 1.4 !important;
  height: auto !important;
  min-height: 40px !important;
  display: flex !important;
  align-items: center !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  box-sizing: border-box !important;
  cursor: pointer !important;
}

.ai-portfolio-dropdown .VirtualizedSelectOption:hover,
.ai-portfolio-dropdown .VirtualizedSelectFocusedOption {
  background: #334155 !important;
  color: #ffffff !important;
}

.ai-portfolio-dropdown .VirtualizedSelectSelectedOption {
  background: #4f46e5 !important;
  color: #ffffff !important;
}

.ai-portfolio-dropdown .Select-menu {
  background: #1e293b !important;
  max-height: 300px !important;
  overflow-y: auto !important;
}

/* Fix virtualized list row height */
.ai-portfolio-dropdown .VirtualizedSelectFocusedOption,
.ai-portfolio-dropdown .VirtualizedSelectOption {
  font-size: 13px !important;
}

.ai-portfolio-dropdown .Select-noresults {
  color: #94a3b8 !important;
  background: #1e293b !important;
  padding: 10px 14px !important;
}
