/* tresorerie-enrich.css — UI nouvelles fonctionnalités
   - Icônes mode paiement, jour J, urgence ligne
   - Sélection multiple + barre bulk
   - Modal relance
   - Vues résumées par fournisseur / client
   - Tri colonnes
*/

/* ─── Lignes : urgence ─────────────────────────────────── */
tr.tr-v2-row[data-urgency="normal"]        { background: transparent !important; }
tr.tr-v2-row[data-urgency="attention"]     { background: rgba(251, 191, 36, 0.07) !important; }
tr.tr-v2-row[data-urgency="urgent"]        { background: rgba(245, 158, 11, 0.10) !important; }
tr.tr-v2-row[data-urgency="critique"]      { background: rgba(239, 68, 68, 0.10) !important; }
tr.tr-v2-row[data-urgency="critique"] td:first-child { border-left: 3px solid #ef4444; }
tr.tr-v2-row[data-urgency="urgent"] td:first-child   { border-left: 3px solid #f59e0b; }
tr.tr-v2-row[data-urgency="attention"] td:first-child{ border-left: 3px solid #fbbf24; }

/* ─── Icône mode paiement ───────────────────────────────── */
.treso-mode-badge {
  display: inline-block;
  margin-left: 4px;
  font-size: 12px;
  cursor: help;
  vertical-align: middle;
}

/* ─── Jour J ────────────────────────────────────────────── */
.echeance-jour-j {
  display: inline-block;
  margin-top: 1px;
  font-size: 8px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.jourj-today      { background: #fef3c7; color: #92400e !important; }
.jourj-tomorrow   { background: #fef3c7; color: #92400e !important; }
.jourj-yesterday  { background: #fee2e2; color: #991b1b !important; }
.jourj-soon       { background: #dbeafe; color: #1e40af !important; }
.jourj-far        { background: #e5e7eb; color: #374151 !important; }
.jourj-overdue    { background: #fee2e2; color: #991b1b !important; font-weight: 800; }

/* ─── Promis pour le ────────────────────────────────────── */
.promis-badge {
  display: inline-block;
  margin-top: 2px;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  background: #fef3c7;
  color: #92400e !important;
  border: 1px solid #fcd34d;
  border-radius: 4px;
  cursor: help;
  line-height: 1.3;
}

.recurrence-badge {
  display: inline-block;
  margin-left: 3px;
  cursor: help;
  font-size: 10px;
  vertical-align: middle;
}

/* ─── Checkbox sélection ───────────────────────────────── */
.treso-select-cell {
  width: 28px;
  padding: 3px 4px !important;
  text-align: center;
}
.treso-select-cell input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: #dc2626;
}
.treso-select-all {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: #dc2626;
}

/* ─── Bulk actions bar ─────────────────────────────────── */
.treso-bulk-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  background: linear-gradient(180deg, #1f2937 0%, #0f172a 100%);
  color: #f8fafc;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.25);
  font-family: inherit;
  font-size: 13px;
}
.treso-bulk-bar.hidden { display: none; }
.treso-bulk-bar .bulk-count { font-weight: 700; color: #f8fafc; }
.treso-bulk-bar .bulk-total { color: #cbd5e1; }
.treso-bulk-bar .bulk-total strong { color: #fbbf24; font-weight: 800; font-size: 14px; }
.treso-bulk-bar .bulk-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.bulk-btn {
  background: #334155;
  color: #f8fafc !important;
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.bulk-btn:hover { background: #475569; border-color: #64748b; }
.bulk-btn.success { background: #16a34a; border-color: #16a34a; color: white !important; }
.bulk-btn.success:hover { background: #15803d; border-color: #15803d; }
.bulk-btn.danger  { background: #dc2626; border-color: #dc2626; color: white !important; }
.bulk-btn.danger:hover  { background: #b91c1c; border-color: #b91c1c; }
.bulk-btn.ghost   { background: transparent; border-color: #64748b; }
.bulk-btn:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 720px) {
  .treso-bulk-bar { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px; }
  .treso-bulk-bar .bulk-actions { margin-left: 0; justify-content: center; }
}

/* ─── Tri colonnes ─────────────────────────────────────── */
.treso-table th.sortable,
.treso-resume-table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 18px !important;
}
.treso-table th.sortable::after,
.treso-resume-table th.sortable::after {
  content: '⇅';
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.35;
  font-size: 10px;
}
.treso-table th.sort-asc::after,
.treso-resume-table th.sort-asc::after {
  content: '↑';
  opacity: 1;
  color: #dc2626;
}
.treso-table th.sort-desc::after,
.treso-resume-table th.sort-desc::after {
  content: '↓';
  opacity: 1;
  color: #dc2626;
}

/* ─── Modal ────────────────────────────────────────────── */
.treso-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 9500;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
.treso-modal-content {
  background: white;
  border-radius: 12px;
  max-width: 680px;
  width: 100%;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 18px 22px 22px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  color: #111827 !important;
}

/* ─── Relance modal ────────────────────────────────────── */
.treso-relance-modal header { margin-bottom: 14px; }
.treso-relance-modal h2 { margin: 0 0 6px; font-size: 18px; color: #111827; }
.relance-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; margin: 0; }
.badge-level, .badge-retard, .badge-precedente {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 11px;
}
.badge-level.level-PREMIERE { background: #dbeafe; color: #1e40af !important; }
.badge-level.level-DEUXIEME { background: #fef3c7; color: #92400e !important; }
.badge-level.level-FINALE   { background: #fee2e2; color: #991b1b !important; }
.badge-retard               { background: #fee2e2; color: #991b1b !important; }
.badge-precedente           { background: #f3f4f6; color: #374151 !important; }

.relance-history-section, .relance-new-section, .relance-email-section {
  margin-top: 14px;
  border-top: 1px solid #e5e7eb;
  padding-top: 12px;
}
.relance-history-section h3, .relance-new-section h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280 !important;
}
.relance-empty { color: #9ca3af !important; font-style: italic; font-size: 13px; margin: 0; }
.relance-history { list-style: none; margin: 0; padding: 0; max-height: 180px; overflow-y: auto; }
.relance-history li { padding: 8px 10px; border-left: 3px solid #d1d5db; background: #f9fafb; margin-bottom: 6px; border-radius: 0 6px 6px 0; font-size: 12px; color: #374151 !important; }
.relance-h-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.relance-tag { display: inline-block; padding: 1px 6px; background: #e5e7eb; color: #374151 !important; border-radius: 3px; font-size: 10px; font-weight: 600; }
.relance-tag.result-promesse { background: #fef3c7; color: #92400e !important; }
.relance-tag.result-contestation { background: #fed7aa; color: #7c2d12 !important; }
.relance-tag.result-pas_de_reponse { background: #fee2e2; color: #991b1b !important; }
.relance-tag.result-paye { background: #d1fae5; color: #065f46 !important; }
.relance-promesse { font-weight: 700; color: #92400e !important; font-size: 12px; margin-top: 3px; }
.relance-contenu { margin: 4px 0 0; font-size: 12px; white-space: pre-wrap; }
.relance-author { font-size: 10px; color: #9ca3af !important; margin-top: 3px; }

.relance-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.relance-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: #374151 !important; }
.relance-form label.relance-contenu-wrap { grid-column: span 2; }
.relance-form select, .relance-form input, .relance-form textarea {
  padding: 7px 9px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px;
  background: white; color: #111827 !important;
  font-family: inherit;
}
.relance-form select:focus, .relance-form input:focus, .relance-form textarea:focus {
  outline: 2px solid #dc2626; outline-offset: -1px; border-color: #dc2626;
}

.relance-email-section summary { cursor: pointer; font-weight: 700; color: #1e40af !important; font-size: 13px; }
.relance-email-preview { margin-top: 8px; background: #f9fafb; padding: 10px 12px; border-radius: 8px; }
.relance-email-preview p { margin: 0 0 4px; font-size: 12px; color: #374151 !important; }
.relance-email-preview pre {
  background: white; padding: 8px 10px; border: 1px solid #e5e7eb; border-radius: 6px;
  font-family: -apple-system, "Segoe UI", sans-serif; white-space: pre-wrap; font-size: 12px;
  margin: 6px 0;
  color: #111827 !important;
}

.relance-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

@media (max-width: 600px) {
  .relance-form { grid-template-columns: 1fr; }
  .relance-form label.relance-contenu-wrap { grid-column: span 1; }
}

/* ─── Vues résumées ────────────────────────────────────── */
.treso-resume { padding: 4px 0 80px; color: #111827 !important; }
.treso-resume-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}
.treso-resume-head h2 { margin: 0; font-size: 18px; }
.treso-resume-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.treso-resume-filters label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: #374151 !important; }
.treso-resume-filters input[type="date"] {
  padding: 5px 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 12px;
  background: white; color: #111827 !important;
}

.treso-resume-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.treso-resume-kpis .kpi-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 14px;
}
.treso-resume-kpis .kpi-card.success { border-left: 4px solid #16a34a; }
.treso-resume-kpis .kpi-card.danger  { border-left: 4px solid #dc2626; }
.treso-resume-kpis .kpi-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #6b7280 !important; }
.treso-resume-kpis .kpi-value { font-size: 18px; font-weight: 800; color: #111827 !important; margin-top: 2px; font-variant-numeric: tabular-nums; }

.treso-resume-table-wrap {
  overflow-x: auto;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}
.treso-resume-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.treso-resume-table th, .treso-resume-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
.treso-resume-table th {
  background: #f9fafb;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280 !important;
  font-weight: 700;
}
.treso-resume-table td { color: #111827 !important; }
.treso-resume-table tbody tr:hover { background: #f9fafb; }
.treso-resume-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.treso-resume-table .muted { color: #9ca3af !important; }
.treso-resume-table .text-success { color: #16a34a !important; font-weight: 600; }
.treso-resume-table .text-danger { color: #dc2626 !important; }
.treso-resume-table .strong { font-weight: 700; }
.treso-resume-table button.btn-link {
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  padding: 4px 10px;
  color: #1e40af !important;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}
.treso-resume-table button.btn-link:hover { background: #eff6ff; border-color: #1e40af; }

.treso-resume-empty, .treso-error, .treso-loading {
  padding: 24px;
  text-align: center;
  color: #6b7280 !important;
  font-style: italic;
  background: #f9fafb;
  border-radius: 10px;
}
.treso-error { color: #991b1b !important; background: #fee2e2; border: 1px solid #fca5a5; font-style: normal; }

/* ─── Detail modal ─────────────────────────────────────── */
.treso-resume-detail header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.treso-resume-detail h2 { margin: 0; font-size: 17px; }
.treso-resume-detail-body { overflow-x: auto; }
.treso-resume-detail-body table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.treso-resume-detail-body th, .treso-resume-detail-body td {
  padding: 6px 10px; border-bottom: 1px solid #f3f4f6;
}
.treso-resume-detail-body th {
  background: #f9fafb; text-align: left;
  font-size: 10px; text-transform: uppercase; color: #6b7280 !important; font-weight: 700;
}
.treso-resume-detail-body td { color: #111827 !important; }
.treso-resume-detail-body .num { text-align: right; font-variant-numeric: tabular-nums; }
