/* taskpane.css — TaskPane unifiée FDWeb Pack 5 v1.4 */

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #F1F5F9;
  color: #0A2540;
  font-size: 13px;
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Sections de contenu prennent l'espace dispo, footer en bas */
.tab-section { flex: 1 0 auto; }
.app-footer { flex-shrink: 0; }

/* ===========================================================================
 * HEADER + BARRE DE NAVIGATION
 * ========================================================================= */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 2px solid #00B8D9;
  padding: 0;
  box-shadow: 0 1px 3px rgba(10, 37, 64, 0.06);
}

.nav-tabs {
  display: flex;
  gap: 0;
  padding: 0 8px;
}
.nav-tab {
  flex: 1;
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 8px 4px;
  font-family: inherit;
  font-size: 11px;
  color: #64748B;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: color 0.15s, border-color 0.15s;
}
.nav-tab:hover { color: #0A2540; }
.nav-tab.active {
  color: #00B8D9;
  border-bottom-color: #00B8D9;
  font-weight: 600;
}
.nav-tab-icon { font-size: 16px; }
.nav-tab-label { font-size: 10px; }

/* ===========================================================================
 * SECTIONS PAR ONGLET
 * ========================================================================= */
.tab-section {
  padding: 12px;
}

/* ===========================================================================
 * ÉCRAN D'ACCUEIL
 * ========================================================================= */
.welcome {
  padding: 4px 4px 0;
}
.welcome-title {
  font-size: 16px;
  margin: 4px 0 8px;
  color: #0A2540;
}
.welcome-intro {
  margin: 0 0 12px;
  font-size: 12px;
  color: #475569;
}
.welcome-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}
.welcome-list li {
  background: #F8FAFC;
  border-left: 3px solid #00B8D9;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.45;
  color: #0A2540;
}
.welcome-list li strong { color: #0A2540; }
.welcome-icon {
  display: inline-block;
  margin-right: 6px;
  font-size: 14px;
}
.welcome-tip {
  font-size: 11px;
  color: #64748B;
  font-style: italic;
  margin: 0;
  padding: 8px 10px;
  background: #F0F9FF;
  border-radius: 4px;
}

/* ===========================================================================
 * BOUTONS
 * ========================================================================= */
.btn {
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: #00B8D9; color: #fff; }
.btn-secondary { background: #E2E8F0; color: #0A2540; }
.btn-ghost { background: transparent; color: #94A3B8; padding: 4px 8px; font-size: 11px; }
.btn-ghost:hover { color: #DC2626; opacity: 1; }
.btn-sm { padding: 4px 8px; font-size: 11px; }

/* ===========================================================================
 * LOADER
 * ========================================================================= */
.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 12px;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #E2E8F0;
  border-top-color: #00B8D9;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { color: #64748B; font-size: 12px; }

/* ===========================================================================
 * STATUS / RESULT
 * ========================================================================= */
.status {
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 13px;
  border-left: 4px solid #00B8D9;
}
.status-success { background: #ECFDF5; border-color: #65A30D; color: #14532D; }
.status-error { background: #FEF2F2; border-color: #DC2626; color: #991B1B; }
.status-info { background: #F0F9FF; border-color: #0284C7; color: #075985; }

.result-zone {
  background: transparent;
  padding: 0;
}

/* ===========================================================================
 * MODE PRIMO : extraction LLM + candidats BCE
 * ========================================================================= */
.primo-extract {
  background: #F0F9FF;
  border-left: 4px solid #00B8D9;
  padding: 10px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
}
.primo-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94A3B8;
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.primo-extract-name {
  font-size: 14px;
  font-weight: 600;
  color: #0A2540;
}
.primo-extract-meta {
  font-size: 11px;
  color: #64748B;
  margin-top: 2px;
}
.primo-extract-context {
  font-size: 11px;
  color: #475569;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #CBD5E1;
  font-style: italic;
}
.primo-strategy {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: #94A3B8;
}

/* Badge score qualification BANT */
.lead-score {
  position: relative;
  margin-top: 8px;
  border-radius: 6px;
  font-size: 11px;
  border: 1px solid;
  cursor: help;
}
.lead-score-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
}
.lead-score-hot {
  background: #FEF2F2;
  border-color: #DC2626;
  color: #991B1B;
}
.lead-score-warm {
  background: #FEF3C7;
  border-color: #FB923C;
  color: #9A3412;
}
.lead-score-cold {
  background: #F1F5F9;
  border-color: #94A3B8;
  color: #475569;
}
.lead-score-num {
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}
.lead-score-label {
  font-weight: 600;
  flex-shrink: 0;
}
.lead-score-bant {
  font-size: 10px;
  font-family: 'Courier New', monospace;
  margin-left: auto;
  opacity: 0.8;
  flex-shrink: 0;
}
.lead-score-info {
  font-size: 12px;
  opacity: 0.7;
  flex-shrink: 0;
}

/* Tooltip riche au hover */
.lead-score-tooltip {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #0A2540;
  color: #fff;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.4;
  z-index: 100;
  box-shadow: 0 6px 18px rgba(10, 37, 64, 0.25);
  cursor: default;
}
.lead-score:hover .lead-score-tooltip,
.lead-score:focus-within .lead-score-tooltip {
  display: block;
}
.tip-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
  color: #00B8D9;
}
.tip-summary {
  background: rgba(255,255,255,0.08);
  padding: 6px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
  font-style: italic;
}
.tip-bant {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
}
.tip-bant li {
  padding: 4px 0;
  border-bottom: 1px dashed rgba(255,255,255,0.12);
  font-size: 10.5px;
}
.tip-bant li:last-child {
  border-bottom: none;
}
.tip-bant strong {
  color: #fff;
}
.tip-pts {
  background: rgba(0, 184, 217, 0.25);
  color: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 9px;
  margin-left: 4px;
  font-family: 'Courier New', monospace;
  font-weight: 600;
}
.tip-legend {
  border-top: 1px solid rgba(255,255,255,0.15);
  padding-top: 6px;
  margin-bottom: 6px;
  font-size: 10px;
  line-height: 1.6;
}
.tip-tier-hot { color: #FCA5A5; font-weight: 600; }
.tip-tier-warm { color: #FCD34D; font-weight: 600; }
.tip-tier-cold { color: #94A3B8; font-weight: 600; }
.tip-foot {
  font-size: 9.5px;
  color: #94A3B8;
  text-align: center;
  font-style: italic;
}

.primo-candidate-btn {
  display: block;
  width: 100%;
  background: #0A2540;
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 6px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.15s;
}
.primo-candidate-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}
.primo-cand-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 3px;
}
.primo-cand-form {
  color: #00B8D9;
  font-weight: 400;
  font-size: 11px;
  margin-left: 4px;
}
.primo-cand-score {
  background: #65A30D;
  color: #fff;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  margin-left: 6px;
}
.primo-cand-meta {
  font-size: 11px;
  color: #94A3B8;
}
.primo-reject-btn {
  display: block;
  width: 100%;
  background: #fff;
  border: 2px solid #FB923C;
  color: #FB923C;
  border-radius: 8px;
  padding: 9px 12px;
  margin-top: 8px;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
}
.primo-reject-btn:hover { background: #FFF7ED; }
.primo-no-candidate {
  text-align: center;
  padding: 12px;
  color: #94A3B8;
  font-style: italic;
  font-size: 12px;
}

/* ===========================================================================
 * ONGLET CLIENT 360° — recherche
 * ========================================================================= */
.client-search-wrap { padding: 4px 0; }
.client-not-found {
  text-align: center;
  background: #FEF3C7;
  border-left: 4px solid #FB923C;
  padding: 12px;
  border-radius: 4px;
  margin-bottom: 14px;
}
.client-not-found-icon {
  width: 36px; height: 36px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: #FB923C;
  color: #fff;
  font-weight: 700;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.client-not-found h2 {
  font-size: 15px;
  margin: 0 0 4px;
  color: #0A2540;
}
.client-not-found-sub {
  font-size: 11px;
  margin: 0 0 8px;
  color: #475569;
}
.client-not-found-sub code {
  background: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  word-break: break-all;
}
.client-not-found-hint {
  font-size: 11px;
  color: #475569;
  margin: 0;
  line-height: 1.4;
}
.client-search-intro {
  background: #F0F9FF;
  border-left: 4px solid #00B8D9;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 11px;
  color: #475569;
  margin-bottom: 12px;
  line-height: 1.4;
}
.client-search-box {
  margin-top: 8px;
}
.client-search-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94A3B8;
  font-weight: 600;
  margin-bottom: 4px;
}
#client-search-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 12px;
  font-family: inherit;
  border: 1px solid #CBD5E1;
  border-radius: 4px;
  background: #F8FAFC;
  color: #0A2540;
  margin-bottom: 8px;
}
#client-search-input:focus {
  outline: none;
  border-color: #00B8D9;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(0, 184, 217, 0.15);
}
#client-search-results {
  max-height: 60vh;
  overflow-y: auto;
}
.client-search-loading,
.client-search-empty,
.client-search-error {
  text-align: center;
  padding: 12px;
  color: #94A3B8;
  font-size: 11px;
  font-style: italic;
}
.client-search-error { color: #DC2626; }
.client-search-result {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 4px;
  padding: 8px 10px;
  margin-bottom: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.client-search-result:hover {
  background: #F0F9FF;
  border-color: #00B8D9;
  transform: translateX(2px);
}
.client-search-name {
  font-size: 12px;
  font-weight: 600;
  color: #0A2540;
  margin-bottom: 2px;
}
.client-search-meta {
  font-size: 10px;
  color: #64748B;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.client-search-meta span {
  word-break: break-word;
}

/* ===========================================================================
 * ONGLET FACTURE FOURNISSEUR
 * ========================================================================= */
.invoice-wrap {
  background: #fff;
  border-radius: 6px;
  padding: 4px 0;
}
.invoice-help {
  font-size: 11px;
  color: #64748B;
  margin: 4px 0 8px;
  line-height: 1.4;
}
.invoice-from {
  background: #F0F9FF;
  border-left: 3px solid #00B8D9;
  padding: 6px 10px;
  border-radius: 4px;
  margin-bottom: 10px;
  font-size: 11px;
  color: #475569;
  word-break: break-word;
}
.invoice-pdf-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: #fff;
  border: 1px solid #CBD5E1;
  border-left: 4px solid #FB923C;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 6px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.invoice-pdf-btn:hover {
  background: #FFF7ED;
  border-left-color: #C2410C;
  transform: translateX(2px);
}
.invoice-pdf-icon {
  font-size: 24px;
  flex-shrink: 0;
}
.invoice-pdf-info {
  flex: 1;
  min-width: 0;
}
.invoice-pdf-name {
  font-size: 12px;
  font-weight: 600;
  color: #0A2540;
  word-break: break-word;
  line-height: 1.3;
  margin-bottom: 2px;
}
.invoice-pdf-size {
  font-size: 10px;
  color: #94A3B8;
}
.invoice-pdf-arrow {
  color: #FB923C;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ===========================================================================
 * FORMULAIRE CRÉATION MANUELLE
 * ========================================================================= */
.manual-form-wrap {
  background: #fff;
  border-radius: 6px;
  padding: 4px 0;
}
.manual-form-help {
  font-size: 11px;
  color: #64748B;
  margin: 4px 0 12px;
}
.manual-form fieldset {
  border: 1px solid #E2E8F0;
  border-radius: 6px;
  padding: 8px 10px 10px;
  margin-bottom: 10px;
}
.manual-form legend {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #00B8D9;
  font-weight: 600;
  padding: 0 6px;
}
.manual-form label {
  display: block;
  font-size: 11px;
  color: #475569;
  font-weight: 500;
  margin-bottom: 8px;
}
.manual-form label:last-child { margin-bottom: 2px; }
.manual-form .req { color: #DC2626; }
.manual-form input,
.manual-form textarea {
  display: block;
  width: 100%;
  margin-top: 3px;
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  border: 1px solid #CBD5E1;
  border-radius: 4px;
  background: #F8FAFC;
  color: #0A2540;
  box-sizing: border-box;
}
.manual-form input:focus,
.manual-form textarea:focus {
  outline: none;
  border-color: #00B8D9;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(0, 184, 217, 0.15);
}
.manual-form textarea {
  resize: vertical;
  min-height: 60px;
  line-height: 1.4;
}
.manual-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.manual-form-actions .btn {
  flex: 1;
  padding: 9px 12px;
  font-size: 12px;
}

/* ===========================================================================
 * ONGLET HISTORIQUE
 * ========================================================================= */
.history-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.history-subtabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #E2E8F0;
}
.history-subtab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  color: #64748B;
  cursor: pointer;
  font-weight: 500;
}
.history-subtab.active {
  color: #00B8D9;
  border-bottom-color: #00B8D9;
}
.history-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
#history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: calc(100vh - 280px);
  overflow-y: auto;
}
.history-item {
  border-left: 3px solid #94A3B8;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: #F8FAFC;
  border-radius: 4px;
}
.history-success { border-left-color: #65A30D; }
.history-not_found { border-left-color: #FB923C; background: #FFF7ED; }
.history-config_error,
.history-server_error,
.history-exception { border-left-color: #DC2626; background: #FEF2F2; }
.history-primo_pending { border-left-color: #0284C7; background: #F0F9FF; }
.history-rejected { border-left-color: #94A3B8; }

.history-subject {
  font-weight: 600;
  font-size: 12px;
  color: #0A2540;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-meta {
  font-size: 10px;
  color: #94A3B8;
  margin-bottom: 4px;
}
.history-meta a {
  color: #00B8D9;
  text-decoration: none;
}
.history-summary {
  font-size: 11px;
  color: #64748B;
}
.history-empty {
  text-align: center;
  padding: 16px;
  color: #94A3B8;
  font-size: 11px;
  font-style: italic;
}

/* ===========================================================================
 * ONGLET CONFIGURATION
 * ========================================================================= */
.config-title {
  font-size: 16px;
  margin: 0 0 12px;
  color: #0A2540;
}
.config-form label {
  display: block;
  font-size: 12px;
  color: #475569;
  font-weight: 500;
  margin-bottom: 12px;
}
.config-form .req { color: #DC2626; }
.config-form input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  font-size: 12px;
  font-family: inherit;
  border: 1px solid #CBD5E1;
  border-radius: 4px;
  background: #F8FAFC;
  color: #0A2540;
  box-sizing: border-box;
}
.config-form input:focus {
  outline: none;
  border-color: #00B8D9;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(0, 184, 217, 0.15);
}
.field-hint {
  display: block;
  margin-top: 3px;
  color: #94A3B8;
  font-size: 10px;
  font-style: italic;
  font-weight: 400;
}
.config-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  margin-bottom: 12px;
}
.config-actions .btn {
  flex: 1;
}
#config-status {
  margin-top: 4px;
}

/* ===========================================================================
 * FOOTER (toujours en bas grâce au flex sur body)
 * ========================================================================= */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  font-size: 10px;
  color: #94A3B8;
  padding: 8px 12px;
  border-top: 1px solid #E2E8F0;
  background: #fff;
}
.footer-text { color: #64748B; }
.footer-logo-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.footer-logo {
  height: 14px;
  width: auto;
  vertical-align: middle;
  display: block;
}
