/* ==========================================
   FINDERS AI ASSISTANT - Premium UI v2
   CI: --fc-primary:#1e3c3c, --fc-accent:#ff6101
   ========================================== */

/* ==========================================
   FLOATING BUTTON
   ========================================== */
.ai-float-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--fc-primary, #1e3c3c) 0%, var(--fc-primary-dark, #163030) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(30, 60, 60, 0.35);
  z-index: 9998;
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.ai-float-btn:hover {
  transform: scale(1.1) translateY(-3px);
  box-shadow: 0 12px 32px rgba(30, 60, 60, 0.45);
}
.ai-float-btn.ai-btn-hidden {
  transform: scale(0) rotate(180deg);
  opacity: 0;
  pointer-events: none;
}
.ai-icon {
  color: white;
  font-size: 26px;
  animation: ai-bounce 2s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-dot-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}
.ai-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(30, 60, 60, 0.3);
  animation: ai-pulse 2s ease-out infinite;
}
@keyframes ai-pulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.8); opacity: 0; }
}
@keyframes ai-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ==========================================
   CHAT WINDOW
   ========================================== */
.ai-chat-window {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 440px;
  height: 620px;
  max-height: calc(100vh - 60px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: scale(0.85) translateY(20px);
  pointer-events: none;
  transition: all 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}
.ai-chat-window.ai-chat-open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}
.ai-chat-window.ai-chat-expanded {
  width: 90vw !important;
  height: 90vh !important;
  bottom: 5vh !important;
  right: 5vw !important;
  border-radius: 20px;
}

/* ==========================================
   HEADER
   ========================================== */
.ai-chat-header {
  background: linear-gradient(135deg, var(--fc-primary, #1e3c3c) 0%, #163030 100%);
  padding: 12px 16px;
  border-radius: 16px 16px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ai-avatar {
  width: 34px;
  height: 34px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 15px;
  overflow: hidden;
}
.ai-dot-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}
.ai-header-btn {
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  font-size: 12px;
}
.ai-header-btn:hover { background: rgba(255, 255, 255, 0.2); transform: scale(1.1); }
.ai-close-btn:hover { transform: rotate(90deg) scale(1.1); }

/* ==========================================
   QUICK PROMPTS
   ========================================== */
.ai-quick-prompts {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  background: #fafbfc;
  flex-shrink: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
}
.ai-quick-toggle {
  display: none;
  width: 100%;
  padding: 8px 12px;
  background: #fafbfc;
  border: none;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-align: left;
  flex-shrink: 0;
  align-items: center;
  gap: 6px;
}
.ai-quick-toggle i { transition: transform 0.3s; font-size: 10px; }
.ai-quick-toggle.open i { transform: rotate(180deg); }
.ai-quick-row {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.ai-quick-row::-webkit-scrollbar { display: none; }
.quick-prompt-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 11px;
  font-weight: 500;
  color: #475569;
  white-space: nowrap;
  flex-shrink: 0;
}
.quick-prompt-btn:hover {
  background: var(--fc-primary, #1e3c3c);
  color: white;
  border-color: var(--fc-primary, #1e3c3c);
  box-shadow: 0 2px 8px rgba(30, 60, 60, 0.15);
}
.quick-prompt-btn:active { transform: scale(0.95); }
.quick-prompt-btn i { font-size: 11px; }

/* ==========================================
   MESSAGES AREA
   ========================================== */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #f8fafc;
  min-height: 0;
}
.ai-chat-messages::-webkit-scrollbar { width: 4px; }
.ai-chat-messages::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.1); border-radius: 3px; }

/* ==========================================
   MESSAGE BUBBLES
   ========================================== */
.ai-message {
  display: flex;
  gap: 8px;
  animation: msg-appear 0.35s ease-out;
}
@keyframes msg-appear {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-msg-avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: linear-gradient(135deg, var(--fc-primary, #1e3c3c), #163030);
  color: white;
  flex-shrink: 0;
  overflow: hidden;
}
.ai-dot-msg {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
}
.ai-msg-avatar-user {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  order: 2;
}
.ai-message-user { flex-direction: row-reverse; }

.ai-msg-bubble {
  flex: 1;
  min-width: 0;
  background: white;
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid #f1f5f9;
}
.ai-msg-user-bubble {
  background: linear-gradient(135deg, var(--fc-primary, #1e3c3c), #163030);
  color: white;
  border: none;
}
.ai-msg-error { border-color: #fecaca; background: #fef2f2; }

.ai-msg-text {
  font-size: 13px;
  line-height: 1.65;
  word-break: break-word;
}
.ai-msg-text p { margin-bottom: 6px; }
.ai-msg-text p:last-child { margin-bottom: 0; }
.ai-msg-text ul { margin: 4px 0; padding-left: 16px; }
.ai-msg-text li { margin: 2px 0; }
.ai-msg-text strong { font-weight: 600; }
.ai-msg-text h3, .ai-msg-text h4 { color: var(--fc-primary, #1e3c3c); }

/* Clickable Candidate Links */
.ai-candidate-link {
  color: var(--fc-accent, #ff6101);
  font-weight: 600;
  cursor: pointer;
  border-bottom: 1px dashed var(--fc-accent, #ff6101);
  transition: all 0.2s;
  white-space: nowrap;
}
.ai-candidate-link:hover {
  color: #e55800;
  border-bottom-style: solid;
}
.ai-candidate-link i {
  font-size: 9px;
  margin-left: 2px;
  opacity: 0.7;
}

/* ==========================================
   TOOL BADGES
   ========================================== */
.ai-tools-used {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f1f5f9;
}
.ai-tool-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  color: #065f46;
  white-space: nowrap;
}
.ai-tool-badge i { font-size: 9px; }

/* ==========================================
   THINKING INDICATOR
   ========================================== */
.ai-thinking {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
}
.ai-thinking-steps { display: flex; flex-direction: column; gap: 4px; }
.ai-thinking-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #64748b;
  padding: 4px 0;
}
.ai-thinking-step.active { color: var(--fc-primary, #1e3c3c); font-weight: 500; }
.ai-thinking-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #e2e8f0;
  border-top: 2px solid var(--fc-primary, #1e3c3c);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================
   RICH CARDS
   ========================================== */
.ai-rich-cards {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}
.ai-cards-candidates { grid-template-columns: 1fr; }
.ai-cards-mandates { grid-template-columns: 1fr; }
.ai-cards-events { grid-template-columns: 1fr; }

.ai-rich-card {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fafbfc;
  transition: all 0.2s;
  cursor: default;
}
.ai-card-candidate { cursor: pointer; position: relative; }
.ai-card-candidate::after {
  content: '\f35d';
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 10px;
  color: #94a3b8;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
}
.ai-card-candidate:hover::after {
  opacity: 1;
  color: var(--fc-accent, #ff6101);
}
.ai-card-candidate:hover {
  border-color: var(--fc-accent, #ff6101);
  box-shadow: 0 2px 8px rgba(255, 97, 1, 0.15);
  transform: translateY(-1px);
  background: #fff;
}
.ai-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.ai-card-name {
  font-weight: 600;
  font-size: 12.5px;
  color: #1e293b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-card-subtitle {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-card-meta {
  font-size: 10.5px;
  color: #94a3b8;
  margin-top: 3px;
}
.ai-card-meta i { margin-right: 3px; width: 12px; text-align: center; }
.ai-card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.ai-card-score {
  font-size: 12px;
  font-weight: 700;
  color: var(--fc-primary, #1e3c3c);
  background: #ecfdf5;
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
}
.ai-card-status {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  text-transform: capitalize;
}
.status-new { background: #eff6ff; color: #1d4ed8; }
.status-contacted { background: #fef3c7; color: #92400e; }
.status-interview { background: #ecfdf5; color: #065f46; }
.status-offer { background: #faf5ff; color: #7c3aed; }
.status-placed { background: #dcfce7; color: #166534; }
.status-rejected { background: #fef2f2; color: #991b1b; }
.status-onhold { background: #f1f5f9; color: #475569; }
.status-default { background: #f1f5f9; color: #475569; }
.status-open { background: #eff6ff; color: #1d4ed8; }
.status-in_progress { background: #fef3c7; color: #92400e; }
.status-filled { background: #dcfce7; color: #166534; }

.ai-card-prio {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  text-transform: uppercase;
}
.prio-urgent { background: #fef2f2; color: #dc2626; }
.prio-high { background: #fff7ed; color: #ea580c; }
.prio-default { background: #f1f5f9; color: #64748b; }

.ai-card-mandate {
  font-size: 10px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}
.ai-card-more {
  text-align: center;
  font-size: 11px;
  color: #94a3b8;
  padding: 4px;
  font-weight: 500;
}
.ai-mini-stars {
  display: inline-flex;
  gap: 1px;
  font-size: 8px;
  color: #fbbf24;
}

/* ==========================================
   STATS CARD
   ========================================== */
.ai-stats-card {
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
  border: 1px solid #a7f3d0;
}
.ai-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
}
.ai-stat-item { padding: 4px; }
.ai-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--fc-primary, #1e3c3c);
}
.ai-stat-label {
  font-size: 10px;
  color: #64748b;
  font-weight: 500;
  margin-top: 2px;
}
.ai-stat-conversion {
  text-align: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #a7f3d0;
  font-size: 12px;
  color: #475569;
}

/* ==========================================
   ACTION CARD
   ========================================== */
.ai-action-card {
  margin-top: 8px;
  padding: 8px 12px;
  background: #f0fdf4;
  border-radius: 8px;
  font-size: 12px;
  display: flex;
  align-items: center;
  border: 1px solid #bbf7d0;
}

/* ==========================================
   PROCESSING STATE
   ========================================== */
.ai-processing {
  opacity: 0.5;
  pointer-events: none;
}

/* ==========================================
   CHAT INPUT
   ========================================== */
.ai-chat-input {
  padding: 10px 12px;
  background: white;
  border-top: 1px solid #f1f5f9;
  border-radius: 0 0 16px 16px;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.ai-chat-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 0;
}
.ai-chat-input input:focus {
  border-color: var(--fc-primary, #1e3c3c);
  box-shadow: 0 0 0 3px rgba(30, 60, 60, 0.08);
}
.ai-send-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
  background: linear-gradient(135deg, var(--fc-primary, #1e3c3c), #163030);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.ai-send-btn:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(30, 60, 60, 0.25); }
.ai-send-btn:active { transform: scale(0.95); }

/* ==========================================
   MOBILE RESPONSIVE
   ========================================== */
@media (max-width: 768px) {
  .ai-float-btn {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }
  .ai-icon { font-size: 22px; }

  .ai-chat-window {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }
  .ai-chat-header { padding: 12px 14px; border-radius: 0; }
  .ai-avatar { width: 30px; height: 30px; font-size: 13px; }

  .ai-quick-toggle { display: flex; }
  .ai-quick-prompts {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-bottom: none;
  }
  .ai-quick-prompts.mobile-open {
    max-height: 120px;
    padding: 8px 12px;
    border-bottom: 1px solid #f1f5f9;
    overflow-y: auto;
  }
  .quick-prompt-btn { padding: 4px 8px; font-size: 10px; gap: 3px; border-radius: 12px; }
  .quick-prompt-btn i { font-size: 10px; }

  .ai-chat-messages { padding: 10px; gap: 10px; }
  .ai-msg-avatar { width: 24px; height: 24px; min-width: 24px; font-size: 10px; }
  .ai-msg-bubble { padding: 8px 12px; border-radius: 12px; }
  .ai-msg-text { font-size: 13px; }
  .ai-message { gap: 6px; }

  .ai-chat-input {
    padding: 8px 10px;
    gap: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    border-radius: 0;
  }
  .ai-chat-input input { padding: 10px 14px; font-size: 14px; }

  .ai-chat-window.ai-chat-expanded {
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    bottom: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
  }

  /* Stats grid on mobile */
  .ai-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .ai-stat-value { font-size: 18px; }

  /* Rich cards */
  .ai-rich-card { padding: 8px 10px; }
  .ai-card-name { font-size: 12px; }
}

@media (max-width: 480px) {
  .quick-prompt-btn span {
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ==========================================
   EXPANDED MODE - Better cards grid
   ========================================== */
.ai-chat-expanded .ai-cards-candidates { grid-template-columns: repeat(2, 1fr); }
.ai-chat-expanded .ai-cards-mandates { grid-template-columns: repeat(2, 1fr); }
.ai-chat-expanded .ai-cards-events { grid-template-columns: repeat(2, 1fr); }

/* ==========================================
   MISC LEGACY SUPPORT
   ========================================== */

/* ==========================================
   AI RESPONSE FORMATTING
   ========================================== */
.ai-h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--fc-primary, #1e3c3c);
  margin: 12px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #f1f5f9;
}
.ai-h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--fc-primary, #1e3c3c);
  margin: 10px 0 4px;
}
.ai-h5 {
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  margin: 8px 0 3px;
}
.ai-p {
  margin: 0 0 4px;
  line-height: 1.6;
}
.ai-spacer {
  height: 6px;
}
.ai-list {
  margin: 4px 0 6px;
  padding-left: 18px;
}
.ai-list li {
  margin: 3px 0;
  line-height: 1.55;
  font-size: 12.5px;
}
.ai-list-ol {
  list-style-type: decimal;
}
.ai-code {
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  color: #e11d48;
}
.ai-hr {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 8px 0;
}

/* Markdown Table */
.ai-table-wrap {
  overflow-x: auto;
  margin: 8px 0;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}
.ai-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}
.ai-table th {
  background: var(--fc-primary, #1e3c3c);
  color: white;
  font-weight: 600;
  padding: 6px 10px;
  text-align: left;
  white-space: nowrap;
}
.ai-table td {
  padding: 5px 10px;
  border-top: 1px solid #f1f5f9;
  color: #334155;
}
.ai-table tr:nth-child(even) td {
  background: #f8fafc;
}
.ai-table tr:hover td {
  background: #f0fdf4;
}

/* Candidate link in formatted response */
.ai-msg-text .ai-candidate-link {
  display: inline;
  font-weight: 600;
  color: var(--fc-accent, #ff6101);
  cursor: pointer;
  border-bottom: 1px dashed var(--fc-accent, #ff6101);
  transition: all 0.2s;
}
.ai-msg-text .ai-candidate-link:hover {
  color: #c44e00;
  border-bottom-style: solid;
}

/* Emoji KPIs in text */
.ai-msg-text strong {
  color: #1e293b;
}

/* ==========================================
   LEGACY SUPPORT
   ========================================== */
.stage-filter.active,
.event-filter.active {
  background: var(--fc-primary, #1e3c3c);
  color: white;
  border-color: var(--fc-primary, #1e3c3c);
}
.kanban-card { transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.kanban-card:hover { transform: translateY(-4px); }
.fade-in { animation: fadeIn 0.5s ease-out; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Feedback (thumbs) + guard markers ---- */
.ai-feedback { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; padding-top: 8px; border-top: 1px solid #f1f5f9; font-size: 12px; color: #94a3b8; }
.ai-fb-btn { width: 28px; height: 28px; border-radius: 8px; border: 1px solid #e2e8f0; background: #fff; color: #94a3b8; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all .15s; }
.ai-fb-btn:hover { color: #475569; border-color: #cbd5e1; }
.ai-fb-btn.active-up { background: #dcfce7; color: #15803d; border-color: #86efac; }
.ai-fb-btn.active-down { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.ai-fb-comment { flex-basis: 100%; display: flex; gap: 6px; margin-top: 4px; }
.ai-fb-comment textarea { flex: 1; font-size: 12px; padding: 6px 8px; border: 1px solid #e2e8f0; border-radius: 8px; resize: vertical; color: #334155; }
.ai-fb-comment button { font-size: 12px; padding: 6px 12px; border: none; border-radius: 8px; background: var(--fc-primary, #1e3c3c); color: #fff; cursor: pointer; align-self: flex-end; }
.ai-fb-thanks { color: #15803d; font-weight: 600; }
.ai-removed { color: #b91c1c; }
.ai-guard-note { margin-top: 8px; padding: 6px 10px; border-radius: 8px; background: #fff7ed; color: #9a3412; font-size: 12px; border: 1px solid #fed7aa; }
