/* Hide floating widgets when on Login screen */
body:has(.login-page-wrapper) .ai-chat-trigger-btn,
body:has(.login-page-wrapper) #ai-chat-window,
body:has(.login-page-wrapper) .sidebar-theme-floating-btn {
  display: none !important;
}

/* Floating AI Assistant Trigger Button */
.ai-chat-trigger-btn {
  position: fixed !important;
  bottom: 84px !important;
  right: 24px !important;
  height: 48px !important;
  padding: 0 18px !important;
  border-radius: 24px !important;
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  color: #ffffff;
  border: none !important;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
  cursor: pointer !important;
  z-index: 99998 !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
  font-size: 13.5px !important;
  font-weight: 600 !important;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.ai-chat-trigger-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.ai-chat-trigger-btn .ai-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.ai-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #ffffff;
}

/* Chat Window Panel */
#ai-chat-window {
  position: fixed !important;
  bottom: 84px !important;
  right: 24px !important;
  width: 480px !important;
  height: 640px !important;
  max-width: calc(100vw - 32px) !important;
  max-height: calc(100vh - 100px) !important;
  background: #ffffff !important;
  border-radius: 16px !important;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.2), 0 6px 16px rgba(15, 23, 42, 0.1) !important;
  border: 1px solid #cbd5e1 !important;
  z-index: 100001 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Expanded / Large Mode */
#ai-chat-window.expanded {
  width: 640px !important;
  height: 86vh !important;
  max-height: 86vh !important;
}

#ai-chat-window.show {
  opacity: 1 !important;
  transform: translateY(0) scale(1) !important;
  pointer-events: auto !important;
}

/* Header */
.ai-chat-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-header-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.ai-header-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
}

.ai-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

.ai-header-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-status-online {
  font-size: 11px;
  color: #34d399;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-status-online::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  display: inline-block;
}

.ai-chat-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.ai-chat-close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

/* Chat Messages Area */
.ai-chat-messages {
  flex: 1 1 0% !important;
  min-height: 0 !important;
  height: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  padding: 16px !important;
  background: #f8fafc !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
}

/* Custom Scrollbar */
.ai-chat-messages::-webkit-scrollbar {
  width: 6px !important;
  display: block !important;
}

.ai-chat-messages::-webkit-scrollbar-track {
  background: #f1f5f9 !important;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1 !important;
  border-radius: 4px !important;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #94a3b8 !important;
}

.ai-message {
  display: flex;
  gap: 8px;
  animation: fadeIn 0.25s ease-out;
}

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

.ai-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: 85%;
}

.ai-message.assistant {
  align-self: flex-start;
  max-width: 98%;
  width: 100%;
}

.ai-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  color: #1e293b;
}

.ai-message.user .ai-msg-bubble {
  background: #2563eb;
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.ai-message.assistant .ai-msg-bubble {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}

/* Typewriter Cursor Effect */
.ai-msg-bubble.typing::after {
  content: '▋';
  display: inline-block;
  margin-left: 3px;
  color: #2563eb;
  opacity: 0.8;
  animation: aiCursorBlink 0.7s infinite;
  font-size: 0.85em;
  vertical-align: baseline;
}

@keyframes aiCursorBlink {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0; }
}

/* Compact Table Styles for AI Assistant Responses */
.ai-compact-table {
  width: 100% !important;
  border-collapse: collapse !important;
  font-size: 12px !important;
  margin-top: 6px !important;
  margin-bottom: 6px !important;
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 8px !important;
  overflow: hidden !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}

.ai-compact-table th {
  background: #f1f5f9 !important;
  color: #1e3a8a !important;
  font-weight: 700 !important;
  padding: 6px 10px !important;
  border-bottom: 1px solid #cbd5e1 !important;
  text-align: left !important;
  font-size: 12px !important;
}

.ai-compact-table td {
  padding: 6px 10px !important;
  border-bottom: 1px solid #f1f5f9 !important;
  color: #334155 !important;
  vertical-align: middle !important;
  font-size: 12px !important;
}

.ai-compact-table tr:last-child td {
  border-bottom: none !important;
}

.badge-amber {
  display: inline-block !important;
  padding: 2px 8px !important;
  border-radius: 12px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  background: #fef3c7 !important;
  color: #b45309 !important;
}

/* Structured Result Card */
.ai-result-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 14px;
  margin-top: 6px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
  animation: cardFadeIn 0.35s ease-out;
}

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

.ai-card-header {
  font-weight: 700;
  font-size: 13.5px;
  color: #1e3a8a;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 8px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-card-row {
  display: flex;
  margin-bottom: 6px;
  font-size: 12.5px;
}

.ai-card-label {
  font-weight: 600;
  color: #64748b;
  width: 145px;
  flex-shrink: 0;
  white-space: nowrap;
}

.ai-card-value {
  color: #0f172a;
  font-weight: 500;
  flex: 1;
}

.ai-card-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: #dcfce7;
  color: #15803d;
}

.ai-card-btn {
  display: inline-block;
  margin-top: 6px;
  width: 100%;
  padding: 8px 12px;
  background: rgba(59, 130, 246, 0.08);
  color: #2563eb;
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 8px;
  font-weight: 600;
  font-size: 12.5px;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.25s ease-in-out;
  box-sizing: border-box;
}

.ai-card-btn:hover {
  background: #2563eb !important;
  color: #ffffff !important;
  border-color: #2563eb !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  transform: translateY(-1px);
  text-decoration: none;
}

.ai-card-btn:active {
  transform: translateY(0);
}

.ai-card-btn.ai-btn-amber {
  background: rgba(245, 158, 11, 0.08);
  color: #d97706;
  border-color: rgba(245, 158, 11, 0.25);
}

.ai-card-btn.ai-btn-amber:hover {
  background: #d97706 !important;
  color: #ffffff !important;
  border-color: #d97706 !important;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
}

.ai-card-btn.ai-btn-emerald {
  background: rgba(16, 185, 129, 0.08);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.25);
}

.ai-card-btn.ai-btn-emerald:hover {
  background: #059669 !important;
  color: #ffffff !important;
  border-color: #059669 !important;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

/* Suggestion Chips */
.ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px;
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
}

.ai-chip {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #e2e8f0;
  padding: 5px 10px;
  border-radius: 16px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ai-chip:hover {
  background: #eff6ff;
  color: #2563eb;
  border-color: #bfdbfe;
}

/* Input Area */
.ai-chat-input-area {
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-chat-input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease;
}

.ai-chat-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.ai-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #2563eb;
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.ai-send-btn:hover {
  background: #1d4ed8;
  transform: scale(1.05);
}

/* Typing Indicator */
.ai-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
}

.ai-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: bounce 1.2s infinite ease-in-out;
}

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

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}
