/* ============================================
   PSI CRM — AI Features Styles
   Uses CRM design tokens: --color-bg, --color-surface,
   --color-border, --color-text, --color-text-muted,
   --color-text-faint, --color-surface-offset
   ============================================ */

/* ── AI Slide Panel ──────────────────────────── */
.ai-panel {
  position: fixed;
  top: 0;
  right: -480px;
  width: 460px;
  max-width: 90vw;
  height: 100vh;
  background: var(--color-surface-2, #fafafa);
  box-shadow: -4px 0 24px rgba(0,0,0,0.18);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transition: right 0.25s ease;
  border-left: 3px solid #A69565;
}
.ai-panel.visible { right: 0; }

.ai-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border, #c2c0bb);
  flex-shrink: 0;
  background: var(--color-surface, #f2f2f0);
}
.ai-panel-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, #1C3C55, #3B4363);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.ai-panel-badge svg { stroke: #A69565; }
.ai-panel-title {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text, #1C3C55);
}
.ai-panel-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--color-text-faint, #8b8f9e);
  border-radius: 4px;
}
.ai-panel-close:hover { background: var(--color-surface-offset, #e8e6e2); }

.ai-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
}

/* ── Loading state ───────────────────────────── */
.ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
}
.ai-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border, #c2c0bb);
  border-top-color: #A69565;
  border-radius: 50%;
  animation: ai-spin 0.7s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-loading-text {
  font-size: 0.85rem;
  color: var(--color-text-muted, #3B4363);
}

/* ── Error & Empty ───────────────────────────── */
.ai-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #fef2f2;
  color: #991b1b;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.5;
}
.ai-empty {
  text-align: center;
  color: var(--color-text-muted, #3B4363);
  padding: 40px 20px;
  font-size: 0.88rem;
}

.ai-results-count {
  font-size: 0.75rem;
  color: var(--color-text-muted, #3B4363);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* ── Feature 1: Match Cards ──────────────────── */
.ai-match-list { display: flex; flex-direction: column; gap: 8px; }
.ai-match-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--color-border, #c2c0bb);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ai-match-card:hover { border-color: #A69565; }
.ai-match-rank {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: #1C3C55;
  border-radius: 50%;
  flex-shrink: 0;
}
.ai-match-info { flex: 1; min-width: 0; }
.ai-match-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text, #1C3C55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-match-reason {
  font-size: 0.78rem;
  color: var(--color-text-muted, #3B4363);
  margin-top: 2px;
  line-height: 1.4;
}
.ai-match-score {
  font-size: 1.1rem;
  font-weight: 700;
  min-width: 32px;
  text-align: center;
}

/* ── Feature 2: Nudge Cards ──────────────────── */
.ai-nudge-card {
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--color-border, #c2c0bb);
  border-radius: 8px;
  margin-bottom: 10px;
  border-left: 4px solid var(--color-border, #c2c0bb);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.ai-nudge-high { border-left-color: #c0392b; }
.ai-nudge-med  { border-left-color: #A69565; }
.ai-nudge-low  { border-left-color: #3B4363; }

.ai-nudge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.ai-nudge-type {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--color-text-faint, #8b8f9e);
}
.ai-nudge-prio {
  font-size: 0.65rem;
  text-transform: uppercase;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--color-surface-offset, #e8e6e2);
  color: var(--color-text-muted, #3B4363);
}
.ai-nudge-entity {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text, #1C3C55);
  margin-bottom: 4px;
}
.ai-nudge-action {
  font-size: 0.8rem;
  color: var(--color-text-muted, #3B4363);
  margin-bottom: 10px;
  line-height: 1.45;
}
.ai-nudge-draft {
  background: var(--color-surface, #f2f2f0);
  border: 1px solid var(--color-border, #c2c0bb);
  border-radius: 6px;
  padding: 10px 12px;
}
.ai-nudge-draft-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--color-text-faint, #8b8f9e);
  margin-bottom: 6px;
}
.ai-nudge-draft-text {
  font-size: 0.82rem;
  color: var(--color-text, #1C3C55);
  line-height: 1.55;
  margin-bottom: 8px;
  white-space: pre-wrap;
}

/* ── Feature 3: Summary ──────────────────────── */
.ai-summary-section {
  margin-bottom: 18px;
}
.ai-summary-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--color-text-faint, #8b8f9e);
  margin-bottom: 6px;
}
.ai-summary-tagline {
  font-size: 1rem;
  font-weight: 600;
  color: #1C3C55;
  font-style: italic;
  padding: 10px 14px;
  background: #ffffff;
  border-radius: 6px;
  border-left: 3px solid #A69565;
}
.ai-summary-text {
  font-size: 0.88rem;
  color: var(--color-text, #1C3C55);
  line-height: 1.65;
  padding: 10px 14px;
  background: #ffffff;
  border-radius: 6px;
  border: 1px solid var(--color-border, #c2c0bb);
}
.ai-strength-list { display: flex; flex-direction: column; gap: 6px; }
.ai-strength-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--color-text-muted, #3B4363);
}
.ai-strength-item svg { color: var(--color-success, #437a22); flex-shrink: 0; margin-top: 2px; }

/* ── Feature 4: NL Search ────────────────────── */
.ai-nl-intro {
  font-size: 0.85rem;
  color: var(--color-text-muted, #3B4363);
  margin-bottom: 16px;
  line-height: 1.5;
}
.ai-nl-search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.ai-nl-search-bar .form-input { flex: 1; }
.ai-nl-interpret {
  font-size: 0.82rem;
  font-style: italic;
  color: var(--color-text-muted, #3B4363);
  margin-bottom: 12px;
  padding: 8px 12px;
  background: #ffffff;
  border-radius: 6px;
  border: 1px solid var(--color-border, #c2c0bb);
}
.ai-nl-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.ai-nl-suggest-label {
  font-size: 0.75rem;
  color: var(--color-text-faint, #8b8f9e);
  font-weight: 600;
}
.ai-nl-chip {
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid var(--color-border, #c2c0bb);
  background: #ffffff;
  color: var(--color-text-muted, #3B4363);
  cursor: pointer;
  transition: all 0.15s;
}
.ai-nl-chip:hover {
  border-color: #A69565;
  color: #A69565;
}
.ai-nl-results { display: flex; flex-direction: column; gap: 4px; }
.ai-nl-result {
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--color-border, #c2c0bb);
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: all 0.15s;
}
.ai-nl-result:hover {
  border-color: #A69565;
  background: var(--color-surface-offset, #e8e6e2);
}
.ai-nl-result-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text, #1C3C55);
}
.ai-nl-result-detail {
  font-size: 0.78rem;
  color: var(--color-text-muted, #3B4363);
  margin-top: 2px;
}

/* ── Feature 5: Outreach ─────────────────────── */
.ai-outreach-section { margin-bottom: 18px; }
.ai-outreach-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--color-text-faint, #8b8f9e);
  margin-bottom: 6px;
}
.ai-outreach-text {
  font-size: 0.85rem;
  color: var(--color-text, #1C3C55);
  line-height: 1.6;
  padding: 12px 14px;
  background: #ffffff;
  border-radius: 6px;
  border: 1px solid var(--color-border, #c2c0bb);
  white-space: pre-wrap;
}
.ai-outreach-channels {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.ai-outreach-picker { padding: 8px 0; }

/* ── Feature 6: BD Scoring ───────────────────── */
.ai-bd-list { display: flex; flex-direction: column; gap: 8px; }
.ai-bd-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--color-border, #c2c0bb);
  border-radius: 8px;
  border-left: 4px solid var(--color-border, #c2c0bb);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.ai-bd-hot { border-left-color: #c0392b; }
.ai-bd-warm { border-left-color: #A69565; }
.ai-bd-cold { border-left-color: #3B4363; }
.ai-bd-rank {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-text-muted, #3B4363);
  background: var(--color-surface-offset, #e8e6e2);
  border-radius: 50%;
  flex-shrink: 0;
}
.ai-bd-info { flex: 1; min-width: 0; }
.ai-bd-company {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text, #1C3C55);
}
.ai-bd-rec {
  font-size: 0.78rem;
  color: var(--color-text-muted, #3B4363);
  margin-top: 2px;
}
.ai-bd-score-wrap { text-align: center; flex-shrink: 0; }
.ai-bd-score {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1C3C55;
}
.ai-bd-prio {
  font-size: 0.6rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ── Health Check ────────────────────────────── */
.ai-health {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  border-radius: 8px;
}
.ai-health-ok { background: #f0fdf4; }
.ai-health-err { background: #fef2f2; }
.ai-health-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  border-radius: 50%;
}
.ai-health-ok .ai-health-icon { background: #dcfce7; color: #166534; }
.ai-health-err .ai-health-icon { background: #fecaca; color: #991b1b; }
.ai-health-status { font-size: 0.92rem; font-weight: 600; color: var(--color-text, #1C3C55); }
.ai-health-detail { font-size: 0.78rem; color: var(--color-text-muted, #3B4363); margin-top: 2px; }

/* ── AI Button used in toolbar ───────────────── */
.ai-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, #1C3C55, #3B4363);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.2px;
}
.ai-btn:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(28,60,85,0.25);
}
.ai-btn svg { stroke: #A69565; }
.ai-btn-sm { padding: 4px 10px; font-size: 0.72rem; }
.ai-btn-outline {
  background: transparent;
  color: #1C3C55;
  border: 1px solid #1C3C55;
}
.ai-btn-outline:hover {
  background: #1C3C55;
  color: #fff;
}
.ai-btn-outline svg { stroke: #1C3C55; }
.ai-btn-outline:hover svg { stroke: #A69565; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 600px) {
  .ai-panel { width: 100vw; max-width: 100vw; }
}
