/* Floating AI Assistant Styles */

.floating-ai-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
  transition: all 0.3s ease;
  z-index: 9998;
}

.floating-ai-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(102, 126, 234, 0.6);
}

.ai-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(102, 126, 234, 0.4);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.3);
    opacity: 0;
  }
}

.floating-ai-panel {
  position: fixed;
  bottom: 100px;
  right: 30px;
  width: 380px;
  height: 500px;
  background: var(--bg-primary);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  display: none;
  flex-direction: column;
  z-index: 9999;
  animation: slideIn 0.3s ease-out;
}

.floating-ai-panel.active {
  display: flex;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.floating-ai-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.floating-ai-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.floating-ai-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}

.floating-ai-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.floating-ai-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.floating-ai-tab {
  flex: 1;
  padding: 8px 16px;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.floating-ai-tab.active {
  background: var(--primary);
  color: white;
}

.floating-ai-tab:hover:not(.active) {
  background: var(--bg-tertiary);
}

.floating-ai-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.ai-quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.ai-quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.ai-quick-action-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.ai-action-icon {
  font-size: 32px;
}

.ai-action-label {
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}

.floating-ai-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.floating-ai-message {
  display: flex;
  gap: 8px;
  animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.floating-ai-message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.message-text {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
}

.floating-ai-message.user .message-text {
  background: var(--primary);
  color: white;
}

/* Chart message styles */
.floating-ai-message.chart-message {
  flex-direction: column;
  align-items: flex-start;
}

.message-chart-container {
  width: 100%;
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 12px;
  margin-top: 8px;
  overflow: hidden;
}

.floating-ai-message.loading .message-text {
  opacity: 0.6;
  font-style: italic;
}

/* Table formatting in messages */
.message-table {
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  font-size: 13px;
}

.table-row {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.table-row:last-child {
  border-bottom: none;
}

.table-row:first-child {
  background: var(--bg-tertiary);
  font-weight: 600;
}

.table-cell {
  flex: 1;
  padding: 8px 12px;
  border-right: 1px solid var(--border);
  word-break: break-word;
}

.table-cell:last-child {
  border-right: none;
}

.table-row:hover {
  background: var(--bg-secondary);
}

/* Markdown headings */
.message-text h1.message-h1,
.message-text .message-h1 {
  font-size: 18px;
  font-weight: bold;
  margin: 16px 0 8px 0;
  color: var(--primary);
}

.message-text h2.message-h2,
.message-text .message-h2 {
  font-size: 16px;
  font-weight: bold;
  margin: 14px 0 6px 0;
  color: var(--text-primary);
}

.message-text h3.message-h3,
.message-text .message-h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 12px 0 4px 0;
  color: var(--text-primary);
}

/* Lists */
.list-item {
  margin: 4px 0 4px 8px;
  line-height: 1.6;
}

.floating-ai-input-area {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.floating-ai-input-area input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.floating-ai-input-area input:focus {
  outline: none;
  border-color: var(--primary);
}

.floating-ai-input-area button {
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.floating-ai-input-area button:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

/* Responsive */
@media (max-width: 768px) {
  .floating-ai-panel {
    right: 10px;
    left: 10px;
    width: auto;
    bottom: 90px;
  }
  
  .floating-ai-btn {
    right: 20px;
    bottom: 20px;
    width: 50px;
    height: 50px;
    font-size: 24px;
  }
}

/* Dark mode adjustments */
body.dark-mode .floating-ai-btn {
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.6);
}

body.dark-mode .floating-ai-panel {
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
