/* ChatAI Main Styles - Enhanced Version 2.0 */

* {
  box-sizing: border-box;
}

.chatai-module {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 0;
  min-height: calc(100vh - 200px);
}

.chat-container {
  max-width: 1200px;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  min-height: 800px;
  position: relative;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Beta Badge */
.beta-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 8px rgba(245, 158, 11, 0.3);
  z-index: 10;
}

/* Inline Beta Badge - For titles */
.beta-badge-inline {
  color: white;
  padding: 0.4rem 0.5rem;
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-left: 0.5rem;
  display: inline-block;
  vertical-align: middle;
  box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
}

/* Disclaimer Bar */
.disclaimer-bar {
  background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%);
  border-bottom: 1px solid #f59e0b;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: #92400e;
}

.disclaimer-bar i {
  color: #f59e0b;
  font-size: 1rem;
}

.disclaimer-bar button {
  margin-left: auto;
  background: transparent;
  border: 1px solid #f59e0b;
  color: #92400e;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s ease;
}

.disclaimer-bar button:hover {
  background: #f59e0b;
  color: white;
}

/* Enhanced Header */
.chat-header {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-bottom: 1px solid #e2e8f0;
  position: relative;
}

.header-content {
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.ai-avatar {
  width: 52px;
  height: 52px;
  background: #165cab;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  box-shadow: 0 8px 25px -5px rgba(79, 70, 229, 0.3);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-4px);
  }
}

.header-info h2 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  background: linear-gradient(135deg, #1e293b 0%, #475569 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #6b7280;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
}

.status-indicator.loading {
  background: #f59e0b;
  animation: pulse 2s infinite;
}

.streaming-indicator {
  margin-left: 1rem;
  padding: 0.25rem 0.75rem;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 12px;
  color: #dc2626;
  font-size: 0.75rem;
  font-weight: 600;
  animation: pulse 2s infinite;
}

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

/* Messages Area */
.chat-messages {
  height: 650px;
  overflow-y: auto;
  padding: 2rem;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  position: relative;
}

.message {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 2rem;
  animation: slideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  flex-shrink: 0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.message.assistant .message-avatar {
  background: #165cab;
  color: white;
  box-shadow: 0 8px 25px -5px rgba(79, 70, 229, 0.3);
}

.message.user .message-avatar {
  background: #165cab;
  color: white;
  box-shadow: 0 8px 25px -5px rgba(6, 182, 212, 0.3);
}

.message-bubble {
  max-width: 75%;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
}

.message-bubble:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.15);
}

.message.user .message-bubble {
  background: #165cab;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Enhanced Thinking Display (Claude/ChatGPT style) */
.thinking-display {
  margin-bottom: 1rem;
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.02) 0%, rgba(251, 191, 36, 0.03) 100%);
  border-radius: 14px;
  border: 1px solid rgba(249, 115, 22, 0.15);
  overflow: hidden;
}

.thinking-display-header {
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.thinking-display-header:hover {
  background: rgba(255, 255, 255, 0.7);
}

.thinking-display-header-left {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #ea580c;
}

.thinking-display-toggle {
  color: #f97316;
  transition: transform 0.2s ease;
}

.thinking-display-toggle.rotated {
  transform: rotate(180deg);
}

.thinking-display-content {
  padding: 1rem;
  max-height: 600px;
  overflow-y: auto;
}

/* Thinking Steps */
.thinking-step {
  margin-bottom: 0.75rem;
  animation: slideInLeft 0.3s ease;
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.thinking-step-main {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 10px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.thinking-step-main:hover {
  background: rgba(255, 255, 255, 0.8);
  transform: translateX(4px);
}

.thinking-step-icon {
  width: 32px;
  height: 32px;
  background: rgba(249, 115, 22, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #f97316;
  font-size: 0.875rem;
}

.thinking-step.llm-call .thinking-step-icon {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

.thinking-step.llm-response .thinking-step-icon {
  background: rgba(37, 99, 235, 0.15);
  color: #2563eb;
}

.thinking-step.tool-call .thinking-step-icon {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
}

.thinking-step.dataset-found .thinking-step-icon {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.thinking-step-content {
  flex: 1;
}

.thinking-step-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.375rem;
}

.thinking-step-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #ea580c;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.thinking-step-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: #64748b;
}

.thinking-step-text {
  font-size: 0.875rem;
  color: #475569;
  line-height: 1.5;
}

/* Raw Data Display */
.raw-data-container {
  margin-top: 0.5rem;
  background: #1e293b;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.raw-data-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #94a3b8;
  font-size: 0.8rem;
  font-weight: 600;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.raw-data-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.raw-data-header .fa-terminal {
  color: #10b981;
}

.copy-btn {
  padding: 0.375rem 0.75rem;
  background: rgba(148, 163, 184, 0.1);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.copy-btn:hover {
  background: rgba(148, 163, 184, 0.2);
  border-color: rgba(148, 163, 184, 0.3);
  transform: translateY(-1px);
}

.raw-data-content {
  padding: 1rem;
  max-height: 400px;
  overflow: auto;
  background: #0f172a;
}

.raw-data-content pre {
  margin: 0;
  background: transparent;
  border: none;
  padding: 0;
}

.raw-data-content code {
  font-family: 'Monaco', 'Courier New', 'Consolas', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Enhanced Markdown Content */
.answer-content {
  line-height: 1.7;
  color: #1e293b;
  font-size: 0.95rem;
}

.answer-content h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #0f172a;
  margin: 1.5rem 0 1rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e2e8f0;
  line-height: 1.3;
  display: block;
}

.answer-content h2 {
  font-size: 1.4rem;
  font-weight: 600;
  color: #0f172a;
  margin: 1.25rem 0 0.75rem 0;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid #f1f5f9;
  line-height: 1.4;
  display: block;
}

.answer-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: #1e293b;
  margin: 1rem 0 0.5rem 0;
  line-height: 1.5;
  display: block;
}

.answer-content h4 {
  font-size: 1rem;
  font-weight: 600;
  color: #334155;
  margin: 0.875rem 0 0.5rem 0;
  line-height: 1.5;
}

.answer-content p {
  margin: 0.75rem 0;
  line-height: 1.7;
  display: block;
}

.answer-content ul,
.answer-content ol {
  margin: 0.5rem 0;
  padding-left: 1.75rem;
  line-height: 1.6;
  display: block;
}

.answer-content ul ul,
.answer-content ol ol,
.answer-content ul ol,
.answer-content ol ul {
  margin: 0.25rem 0;
  padding-left: 1.25rem;
}

.answer-content ul {
  list-style-type: disc;
}

.answer-content ul ul {
  list-style-type: circle;
}

.answer-content ul ul ul {
  list-style-type: square;
}

.answer-content ol {
  list-style-type: decimal;
}

.answer-content li {
  margin: 0.25rem 0;
  padding-left: 0.25rem;
  display: list-item;
}

.answer-content li > ul,
.answer-content li > ol {
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

.answer-content strong {
  font-weight: 600;
  color: #0f172a;
}

.answer-content em {
  font-style: italic;
  color: #374151;
}

.answer-content del {
  text-decoration: line-through;
  color: #6b7280;
}

.answer-content a {
  color: #3b82f6;
  text-decoration: underline;
  text-decoration-color: rgba(59, 130, 246, 0.3);
  text-underline-offset: 2px;
  transition: all 0.2s ease;
}

.answer-content a:hover {
  color: #2563eb;
  text-decoration-color: #2563eb;
}

.answer-content code {
  background: rgba(79, 70, 229, 0.08);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-family: 'Monaco', 'Courier New', 'Consolas', monospace;
  font-size: 0.875em;
  color: #4f46e5;
  font-weight: 500;
}

.answer-content blockquote {
  border-left: 4px solid #3b82f6;
  padding-left: 1rem;
  margin: 1rem 0;
  color: #475569;
  font-style: italic;
  background: rgba(59, 130, 246, 0.05);
  padding: 0.75rem 1rem;
  border-radius: 0 8px 8px 0;
}

.answer-content hr {
  border: none;
  border-top: 2px solid #e2e8f0;
  margin: 1.5rem 0;
}

/* Code Block Wrapper */
.code-block-wrapper {
  margin: 1rem 0;
  border-radius: 8px;
  overflow: hidden;
  background: #1e293b;
  border: 1px solid #334155;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.code-block-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  padding: 0.5rem 1rem;
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #334155;
}

.code-block-wrapper pre {
  margin: 0;
  padding: 1rem;
  background: transparent;
  overflow-x: auto;
}

.code-block-wrapper code {
  background: none;
  padding: 0;
  color: #e2e8f0;
  font-size: 0.875rem;
  line-height: 1.6;
  font-weight: 400;
}

/* Tables */
.answer-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.answer-content th {
  background: #f8fafc;
  font-weight: 600;
  text-align: left;
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
  color: #0f172a;
}

.answer-content td {
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
}

.answer-content tr:nth-child(even) {
  background: #f8fafc;
}

/* Dataset Discovery Display */
.datasets-section {
  margin: 1rem 0;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(14, 165, 233, 0.2);
}

.datasets-section-header {
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: #0369a1;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.datasets-section-header:hover {
  background: rgba(255, 255, 255, 0.7);
}

.datasets-section-content {
  padding: 1rem;
}

.dataset-card {
  background: white;
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  border: 1px solid rgba(14, 165, 233, 0.2);
  transition: all 0.3s ease;
}

.dataset-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px -5px rgba(14, 165, 233, 0.15);
  border-color: rgba(14, 165, 233, 0.4);
}

.dataset-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.dataset-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.4;
}

.dataset-card-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 0.5rem;
}

.dataset-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.btn-dataset {
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  border: none;
}

.btn-dataset-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
}

.btn-dataset-primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.btn-dataset-secondary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
}

.btn-dataset-secondary:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

/* Visualizations Section */
.visualizations-section {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.visualizations-section h4 {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.chart-card {
  position: relative;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.chart-image {
  width: 100%;
  height: auto;
  cursor: pointer;
  transition: transform 0.2s;
}

.chart-image:hover {
  transform: scale(1.02);
}

.chart-actions {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.25rem;
}

.btn-icon {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Message Footer */
.message-footer {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(226, 232, 240, 0.5);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: #6b7280;
}

.message-time {
  color: #94a3b8;
  font-size: 0.75rem;
}

.message-meta {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.meta-tag {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  background: #f3f4f6;
  border-radius: 4px;
}

.meta-tag.cost {
  background: #fef3c7;
  color: #92400e;
}

.meta-tag.cached {
  background: #d1fae5;
  color: #065f46;
}

/* Input Form */
.chat-input-container {
  padding: 2rem;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-top: 1px solid rgba(226, 232, 240, 0.8);
  backdrop-filter: blur(10px);
}

.chat-form {
  position: relative;
}

.input-wrapper {
  position: relative;
}

.chat-input {
  width: 100%;
  padding: 1.25rem;
  border: 2px solid rgba(79, 70, 229, 0.2);
  border-radius: 16px;
  resize: none;
  font-family: inherit;
  font-size: 1rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.chat-input:focus {
  outline: none;
  border-color: #165cab;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1), 0 8px 25px -5px rgba(79, 70, 229, 0.2);
  transform: translateY(-1px);
}

.chat-input:disabled {
  background: rgba(248, 250, 252, 0.8);
  cursor: not-allowed;
  opacity: 0.7;
}

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
  padding: 0 0.125rem;
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.char-count {
  font-size: 0.75rem;
  color: #64748b;
  padding: 0.25rem 0.5rem;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 6px;
  backdrop-filter: blur(10px);
}

.char-count.warning {
  color: #f59e0b;
  background: rgba(251, 191, 36, 0.1);
}

.send-btn {
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  background: #165cab;
  border: none;
  border-radius: 12px;
  color: white;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.4);
  cursor: pointer;
}

.send-btn:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.5);
}

.send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 2px 4px -1px rgba(79, 70, 229, 0.2);
}

/* Enhanced Chart Modal - Hidden by default */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999999;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
}

/* Force modal to be visible when chartModal.isOpen is true */
.modal[x-show="chartModal.isOpen"] {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

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

.modal-dialog {
  background: #1f2937;
  border-radius: 12px;
  width: 95vw;
  height: 95vh;
  max-width: 95vw;
  max-height: 95vh;
  min-width: 600px;
  min-height: 400px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  border: 1px solid #374151;
  position: relative;
}

.modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #2a2a2a;
  flex-shrink: 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.125rem;
  color: #fff;
  font-weight: 600;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: #fff;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.chart-modal-content {
  flex: 1 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  position: relative !important;
  overflow: hidden !important;
  min-height: 400px !important;
  height: 100% !important;
  width: 100% !important;
  background: #1a1a1a !important;
}

/* Ensure proper hiding when modal is closed */
.modal[style*="display: none"] {
  display: none !important;
}

.chart-modal-image-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  cursor: grab;
  user-select: none;
  overflow: hidden;
}

.chart-modal-image-container.dragging {
  cursor: grabbing;
}

.chart-modal-image {
  max-width: none;
  max-height: none;
  transition: transform 0.1s ease-out;
  transform-origin: center center;
  display: block;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.chart-modal-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  text-align: center;
}

.chart-modal-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #ef4444;
  text-align: center;
  padding: 2rem;
}

.chart-modal-controls {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 12px;
  padding: 0.75rem;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.chart-control-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: #fff;
  font-size: 1rem;
}

.chart-control-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.chart-control-btn:active {
  transform: scale(0.95);
}

.chart-control-btn.primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.chart-control-btn.primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #333;
  background: #2a2a2a;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chart-info {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: #9ca3af;
}

.chart-info span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.chart-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-chart {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-chart.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-chart.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.btn-chart.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
}

.btn-chart.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Keyboard shortcuts help */
.keyboard-shortcuts {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 1rem;
  border-radius: 8px;
  font-size: 0.75rem;
  line-height: 1.4;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.modal:hover .keyboard-shortcuts {
  opacity: 1;
}

.keyboard-shortcuts h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.8rem;
  color: #3b82f6;
}

.shortcut-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.25rem 0;
}

.shortcut-key {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.7rem;
}

/* Welcome Message */
.welcome-message .message-bubble {
  max-width: 95%;
  padding: 2rem;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.95) 100%);
  border: 1px solid rgba(79, 70, 229, 0.1);
}

.capabilities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.capability {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: rgba(79, 70, 229, 0.05);
  border-radius: 12px;
  font-size: 0.875rem;
  border: 1px solid rgba(79, 70, 229, 0.1);
  transition: all 0.3s ease;
}

.capability:hover {
  background: rgba(79, 70, 229, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px -5px rgba(79, 70, 229, 0.2);
}

.capability i {
  color: #165cab;
  font-size: 1.25rem;
}

.quick-actions {
  margin-top: 1.5rem;
}

.quick-actions h4 {
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  color: #4b5563;
}

.example-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.75rem;
}

.example-btn {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(79, 70, 229, 0.2);
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  backdrop-filter: blur(10px);
}

.example-btn:hover {
  background: #165cab;
  color: white;
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.4);
}

.example-btn i {
  color: #165cab;
  font-size: 1.1rem;
  transition: color 0.3s ease;
}

.example-btn:hover i {
  color: white;
}

/* Login Required Message */
.login-required-message {
  text-align: center;
  padding: 2rem;
  background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%);
  border-radius: 12px;
  border: 1px solid #f59e0b;
}

.login-required-message i.fa-lock {
  font-size: 3rem;
  color: #f59e0b;
  margin-bottom: 1rem;
  display: block;
}

.login-required-message p {
  font-size: 1.1rem;
  color: #92400e;
  margin-bottom: 1.5rem;
}

.login-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s ease;
  cursor: pointer;
}

.login-btn:hover {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px -5px rgba(245, 158, 11, 0.4);
  color: white;
  text-decoration: none;
}

/* Sidebar Styles */
.module-narrow {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  margin-bottom: 1.5rem;
  overflow: hidden;
  transition: all 0.3s ease;
}

.module-narrow:hover {
  box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.module-narrow .module-heading {
  background: #165cab;
  color: white;
  font-size: 1rem;
  font-weight: 600;
  padding: 1rem 1.25rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: none;
}

.module-narrow .module-content {
  padding: 1.25rem;
  font-size: 0.875rem;
}

.feature-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.feature-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.75rem;
  background: #f1f5f9;
  border-radius: 8px;
  border-left: 3px solid #165cab;
  transition: all 0.2s ease;
}

.feature-item:hover {
  background: #e0f7fa;
  transform: translateX(4px);
}

.feature-item i {
  color: #165cab;
  font-size: 1.25rem;
  margin-top: 0.125rem;
  min-width: 20px;
}

.feature-item strong {
  display: block;
  margin-bottom: 0.25rem;
  color: #1e293b;
  font-weight: 600;
}

.feature-item p {
  margin: 0;
  color: #64748b;
  font-size: 0.8rem;
  line-height: 1.4;
}

/* Help Links */
.help-links {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.help-link {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  background: #f1f5f9;
  border-radius: 8px;
  border: 1px solid rgba(79, 70, 229, 0.2);
  border-left: 4px solid #165cab;
  text-decoration: none;
  color: inherit;
  transition: all 0.3s ease;
  position: relative;
}

.help-link:hover {
  background: #e0f7fa;
  border-color: rgba(79, 70, 229, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
  text-decoration: none;
  color: inherit;
}

.help-link:focus {
  outline: 2px solid #165cab;
  outline-offset: 2px;
  text-decoration: none;
  color: inherit;
}

.help-link > i:first-child {
  color: #165cab;
  font-size: 1.5rem;
  min-width: 24px;
  flex-shrink: 0;
}

.help-link > div {
  flex: 1;
}

.help-link strong {
  display: block;
  margin-bottom: 0.25rem;
  color: #1e40af;
  font-weight: 600;
  font-size: 0.9rem;
}

.help-link p {
  margin: 0;
  color: #64748b;
  font-size: 0.8rem;
  line-height: 1.4;
  opacity: 0.9;
}

.help-link > i:last-child {
  color: #64748b;
  font-size: 0.8rem;
  opacity: 0.6;
  transition: all 0.2s ease;
}

.help-link:hover > i:last-child {
  opacity: 1;
  transform: translateX(2px);
}

.tips-list {
  margin: 0;
  padding: 0;
  list-style: none;
  color: #475569;
}

.tips-list li {
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  background: #f1f5f9;
  border-radius: 8px;
  border-left: 3px solid #165cab;
  transition: all 0.2s ease;
}

.tips-list li:hover {
  background: #e0f7fa;
  transform: translateX(4px);
}

.tips-list li:last-child {
  margin-bottom: 0;
}

.tips-list strong {
  color: #0f172a;
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar,
.raw-data-content::-webkit-scrollbar,
.thinking-display-content::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.chat-messages::-webkit-scrollbar-track {
  background: rgba(241, 245, 249, 0.5);
  border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
  border-radius: 4px;
  transition: all 0.3s ease;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
}

.raw-data-content::-webkit-scrollbar-track {
  background: rgba(30, 41, 59, 0.5);
  border-radius: 4px;
}

.raw-data-content::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 4px;
}

.raw-data-content::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.5);
}

/* Utility */
[x-cloak] {
  display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
  .chatai-module {
    background: #f8fafc;
  }
  
  .chat-container {
    border-radius: 0;
    margin: 0;
    box-shadow: none;
    border: none;
    min-height: calc(100vh - 200px);
  }
  
  .beta-badge {
    right: 8px;
    top: 8px;
    font-size: 0.7rem;
  }
  
  .chat-messages {
    height: 60vh;
    padding: 1rem;
  }
  
  .message-bubble {
    max-width: 85%;
    padding: 1rem;
  }
  
  .header-content {
    padding: 1rem;
  }
  
  .ai-avatar {
    width: 44px;
    height: 44px;
  }
  
  .header-info h2 {
    font-size: 1.5rem;
  }
  
  .example-grid {
    grid-template-columns: 1fr;
  }
  
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  .chat-input-container {
    padding: 1rem;
  }
  
  .chat-input {
    padding: 1rem;
    padding-right: 120px;
    font-size: 0.95rem;
  }
  
  .send-btn {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
  }
  
  .capabilities-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
  }
  
  .capability {
    padding: 0.75rem;
  }
  
  .thinking-display-content {
    max-height: 400px;
  }
  
  .raw-data-content {
    max-height: 300px;
  }

  /* Enhanced Modal Mobile Support */
  .modal-dialog {
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .chart-modal-controls {
    bottom: 10px;
    gap: 0.25rem;
    padding: 0.5rem;
  }

  .chart-control-btn {
    width: 36px;
    height: 36px;
    font-size: 0.875rem;
  }

  .keyboard-shortcuts {
    display: none;
  }

  .modal-footer {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }

  .chart-info {
    justify-content: center;
  }

  .chart-actions {
    justify-content: center;
  }

  .chart-modal-content {
    min-height: 300px;
  }
}

@media (max-width: 480px) {
  .chat-messages {
    height: 55vh;
    padding: 0.75rem;
  }
  
  .message {
    gap: 0.75rem;
    margin-bottom: 1.5rem;
  }
  
  .message-avatar {
    width: 36px;
    height: 36px;
  }
  
  .input-actions {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .send-btn {
    width: 100%;
    justify-content: center;
  }

  /* Ultra-compact modal for very small screens */
  .chart-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .btn-chart {
    width: 100%;
    justify-content: center;
  }

  .modal-header {
    padding: 0.75rem 1rem;
  }

  .modal-footer {
    padding: 0.75rem 1rem;
  }
}

.header-controls {
  display: flex;
  gap: 0.5rem;
}

.header-btn {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(79, 70, 229, 0.2);
  background: rgba(255, 255, 255, 0.8);
  color: #165cab;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  font-size: 1.1rem;
}

.header-btn:hover {
  background: #165cab;
  color: white;
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.4);
}

.header-btn.active {
  background: #165cab;
  color: white;
  border-color: #165cab;
  box-shadow: 0 8px 25px -5px rgba(79, 70, 229, 0.3);
}

/* Cost Bar */
.cost-bar {
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  color: #6b7280;
}

.cost-progress {
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.cost-progress-bar {
  height: 100%;
  background: #10b981;
  transition: width 0.3s ease;
}

.cost-details {
  display: flex;
  justify-content: space-between;
}

/* Autocomplete/Suggestions Styles */
.suggestions-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  z-index: 1000;
  margin-bottom: 0.5rem;
  max-height: 400px;
  overflow: hidden;
}

.suggestions-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.875rem;
  font-weight: 600;
  color: #475569;
}

.suggestions-header i {
  color: #fbbf24;
}

.suggestions-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  font-size: 0.75rem;
}

.suggestions-close:hover {
  background: #e2e8f0;
  color: #475569;
}

.suggestions-list {
  max-height: 300px;
  overflow-y: auto;
}

.suggestion-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: none;
  border: none;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.suggestion-item:hover .suggestion-arrow,
.suggestion-item.active .suggestion-arrow {
  opacity: 1;
  transform: translateX(0);
}

.suggestion-content {
  flex: 1;
}

.suggestion-text {
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  line-height: 1.4;
  margin-bottom: 0.25rem;
}

.suggestion-category {
  font-size: 0.75rem;
  color: #6b7280;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.suggestion-arrow {
  color: #9ca3af;
  opacity: 0;
  transform: translateX(-0.5rem);
  transition: all 0.2s ease;
  font-size: 0.875rem;
}

.suggestions-footer {
  padding: 0.5rem 1rem;
  background: #f9fafb;
  border-top: 1px solid #f3f4f6;
  text-align: center;
  font-size: 0.75rem;
  color: #6b7280;
  font-style: italic;
}

/* Quick Suggestions Pills */
.quick-suggestions {
  margin-top: 0.75rem;
  padding: 0 0.125rem;
}

.quick-suggestions-label {
  font-size: 0.75rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.suggestions-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.suggestion-pill {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.suggestion-pill:hover {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px -2px rgba(59, 130, 246, 0.3);
}

/* Suggestions Button */
.suggestions-btn {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #64748b;
  padding: 0.625rem;
  border-radius: 8px;
  margin-right: 0.5rem;
}

.suggestions-btn:hover {
  background: #fbbf24;
  color: white;
  border-color: #fbbf24;
  transform: translateY(-1px);
}

/* Input wrapper position relative for dropdown positioning */
.input-wrapper {
  position: relative;
}

/* Responsive adjustments for suggestions */
@media (max-width: 768px) {
  .suggestions-dropdown {
    max-height: 250px;
  }
  
  .suggestions-pills {
    gap: 0.375rem;
  }
  
  .suggestion-pill {
    font-size: 0.6875rem;
    padding: 0.25rem 0.5rem;
  }
}