/* ═══════════════════════════════════════════════════════════════════════
   CAMALARM CRM — TÂCHES T204
   ═══════════════════════════════════════════════════════════════════════
   Cohérent visuellement avec Agenda T203 (mêmes variables, même esprit)
   Scope : #tab-tasks-scope
   ═══════════════════════════════════════════════════════════════════════ */

#tab-tasks-scope {
  --tk-orange: #E65100;
  --tk-orange-soft: #FFF3E0;
  --tk-orange-border: #FFCC80;
  --tk-blue: #1565C0;
  --tk-blue-soft: #EFF6FF;
  --tk-text: #0F172A;
  --tk-text-2: #475569;
  --tk-text-3: #64748B;
  --tk-text-muted: #94A3B8;
  --tk-bg: #F8FAFC;
  --tk-card: #FFFFFF;
  --tk-card-soft: #FAFBFD;
  --tk-border: #E5E7EB;
  --tk-border-soft: #F1F5F9;
  --tk-success: #10B981;
  --tk-success-soft: #ECFDF5;
  --tk-success-text: #065F46;
  --tk-danger: #EF4444;
  --tk-danger-soft: #FEF2F2;
  --tk-danger-text: #991B1B;
  --tk-info: #3B82F6;
  --tk-info-soft: #EFF6FF;
  --tk-info-text: #1E40AF;
  --tk-purple: #8B5CF6;
  --tk-purple-soft: #F5F3FF;
  --tk-purple-text: #5B21B6;
  --tk-radius: 12px;
  --tk-radius-sm: 8px;
  --tk-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  --tk-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08);
  --tk-gap: 16px;

  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--tk-text);
}

#tab-tasks-scope * { box-sizing: border-box; }

/* ═══ HEADER ════════════════════════════════════════════════════════ */
#tab-tasks-scope .tk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--tk-gap);
  flex-wrap: wrap;
  gap: 12px;
}
#tab-tasks-scope .tk-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--tk-text);
  letter-spacing: -0.02em;
  margin: 0;
}
#tab-tasks-scope .tk-subtitle {
  font-size: 13px;
  color: var(--tk-text-3);
  margin: 4px 0 0 0;
}
#tab-tasks-scope .tk-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ═══ BOUTONS ═══════════════════════════════════════════════════════ */
#tab-tasks-scope .tk-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  border: 1px solid var(--tk-border);
  background: var(--tk-card);
  color: var(--tk-text-2);
  border-radius: var(--tk-radius-sm);
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
#tab-tasks-scope .tk-btn:hover {
  background: var(--tk-card-soft);
  border-color: var(--tk-text-muted);
  color: var(--tk-text);
}
#tab-tasks-scope .tk-btn-accent {
  background: var(--tk-orange);
  color: #fff;
  border-color: var(--tk-orange);
}
#tab-tasks-scope .tk-btn-accent:hover {
  background: #C44400;
  border-color: #C44400;
}
#tab-tasks-scope .tk-btn-ghost { background: transparent; }
#tab-tasks-scope .tk-btn-sm { padding: 6px 10px; font-size: 12px; }

/* ═══ KPI ══════════════════════════════════════════════════════════ */
#tab-tasks-scope .tk-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--tk-gap);
  margin-bottom: var(--tk-gap);
}
#tab-tasks-scope .tk-kpi {
  background: var(--tk-card);
  border: 1px solid var(--tk-border);
  border-top: 2px solid var(--tk-orange);
  border-radius: var(--tk-radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: all .15s ease;
  box-shadow: var(--tk-shadow);
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
}
#tab-tasks-scope .tk-kpi[data-kpi="urgent"] { border-top-color: var(--tk-danger); }
#tab-tasks-scope .tk-kpi[data-kpi="ongoing"] { border-top-color: var(--tk-info); }
#tab-tasks-scope .tk-kpi[data-kpi="waiting"] { border-top-color: var(--tk-orange); }
#tab-tasks-scope .tk-kpi[data-kpi="overdue"] { border-top-color: var(--tk-danger); }
#tab-tasks-scope .tk-kpi:hover { box-shadow: var(--tk-shadow-hover); }
#tab-tasks-scope .tk-kpi-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--tk-text-3);
}
#tab-tasks-scope .tk-kpi-value {
  font-family: 'JetBrains Mono', 'Menlo', monospace;
  font-size: 26px;
  font-weight: 700;
  color: var(--tk-text);
  letter-spacing: -0.02em;
  line-height: 1;
}
#tab-tasks-scope .tk-kpi-foot {
  font-size: 11px;
  color: var(--tk-text-muted);
}

/* ═══ FILTRES ══════════════════════════════════════════════════════ */
#tab-tasks-scope .tk-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: var(--tk-card);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius);
  padding: 12px 14px;
  margin-bottom: var(--tk-gap);
  box-shadow: var(--tk-shadow);
}
#tab-tasks-scope .tk-search {
  flex: 1;
  min-width: 240px;
  position: relative;
}
#tab-tasks-scope .tk-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--tk-text-muted);
  pointer-events: none;
}
#tab-tasks-scope .tk-search input {
  width: 100%;
  padding: 8px 10px 8px 32px;
  border: 1px solid var(--tk-border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: var(--tk-card-soft);
  color: var(--tk-text);
  transition: border-color .15s ease;
}
#tab-tasks-scope .tk-search input:focus {
  outline: 0;
  border-color: var(--tk-orange);
  background: var(--tk-card);
  box-shadow: 0 0 0 3px rgba(230, 81, 0, 0.08);
}
#tab-tasks-scope .tk-filter-select {
  padding: 8px 10px;
  border: 1px solid var(--tk-border);
  border-radius: 6px;
  font-size: 12.5px;
  font-family: inherit;
  background: var(--tk-card);
  color: var(--tk-text);
  min-width: 130px;
  cursor: pointer;
  transition: border-color .15s ease;
}
#tab-tasks-scope .tk-filter-select:focus {
  outline: 0;
  border-color: var(--tk-orange);
}

/* ═══ TABS DE VUE ═══════════════════════════════════════════════════ */
#tab-tasks-scope .tk-view-tabs {
  display: inline-flex;
  background: var(--tk-card);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius-sm);
  padding: 4px;
  margin-bottom: var(--tk-gap);
  gap: 2px;
}
#tab-tasks-scope .tk-view-tab {
  padding: 6px 16px;
  font-size: 12.5px;
  font-weight: 500;
  background: transparent;
  border: none;
  color: var(--tk-text-3);
  border-radius: 6px;
  cursor: pointer;
  transition: all .12s ease;
  font-family: 'Inter', sans-serif;
}
#tab-tasks-scope .tk-view-tab:hover {
  color: var(--tk-text);
  background: var(--tk-card-soft);
}
#tab-tasks-scope .tk-view-tab.is-active {
  background: var(--tk-orange-soft);
  color: var(--tk-orange);
  font-weight: 600;
}

/* ═══ VUE HOST ══════════════════════════════════════════════════════ */
#tab-tasks-scope .tk-view-host {
  background: transparent;
  min-height: 320px;
}
#tab-tasks-scope .tk-view-loading,
#tab-tasks-scope .tk-view-empty {
  background: var(--tk-card);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius);
  padding: 60px 20px;
  text-align: center;
  color: var(--tk-text-muted);
  font-size: 13px;
  box-shadow: var(--tk-shadow);
}
#tab-tasks-scope .tk-view-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--tk-text-2);
  margin-bottom: 6px;
}

/* ═══ KANBAN — 4 COLONNES ═════════════════════════════════════════ */
#tab-tasks-scope .tk-kanban {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
#tab-tasks-scope .tk-kanban-col {
  background: var(--tk-card);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius);
  display: flex;
  flex-direction: column;
  min-height: 320px;
  max-height: calc(100vh - 320px);
  box-shadow: var(--tk-shadow);
  overflow: hidden;
}
#tab-tasks-scope .tk-kanban-col-header {
  padding: 12px 14px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--tk-border-soft);
  background: var(--tk-card-soft);
  flex-shrink: 0;
}
#tab-tasks-scope .tk-kanban-col[data-col="a_faire"] .tk-kanban-col-header { border-top: 3px solid var(--tk-info); }
#tab-tasks-scope .tk-kanban-col[data-col="en_cours"] .tk-kanban-col-header { border-top: 3px solid var(--tk-orange); }
#tab-tasks-scope .tk-kanban-col[data-col="en_attente"] .tk-kanban-col-header { border-top: 3px solid var(--tk-purple); }
#tab-tasks-scope .tk-kanban-col[data-col="termine"] .tk-kanban-col-header { border-top: 3px solid var(--tk-success); }
#tab-tasks-scope .tk-kanban-col-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--tk-text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 8px;
}
#tab-tasks-scope .tk-kanban-col-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--tk-text-3);
  padding: 2px 7px;
  background: var(--tk-card);
  border-radius: 9999px;
  font-family: 'JetBrains Mono', monospace;
}
#tab-tasks-scope .tk-kanban-col-add {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--tk-text-3);
  cursor: pointer;
  transition: all 0.12s ease;
  font-size: 16px;
  line-height: 1;
}
#tab-tasks-scope .tk-kanban-col-add:hover {
  background: var(--tk-orange-soft);
  border-color: var(--tk-orange-border);
  color: var(--tk-orange);
}
#tab-tasks-scope .tk-kanban-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#tab-tasks-scope .tk-kanban-col-empty {
  padding: 30px 10px;
  text-align: center;
  font-size: 11.5px;
  color: var(--tk-text-muted);
  font-style: italic;
}

/* ═══ CARTE TÂCHE (kanban + liste) ═══════════════════════════════ */
#tab-tasks-scope .tk-card {
  position: relative;
  background: var(--tk-card);
  border: 1px solid var(--tk-border);
  border-left: 3px solid var(--tk-text-muted);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.12s ease;
}
#tab-tasks-scope .tk-card:hover {
  border-color: var(--tk-text-muted);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}
/* Couleur de stripe selon priorité */
#tab-tasks-scope .tk-card.is-priority-urgente { border-left-color: var(--tk-danger); }
#tab-tasks-scope .tk-card.is-priority-haute { border-left-color: var(--tk-orange); }
#tab-tasks-scope .tk-card.is-priority-normale { border-left-color: var(--tk-info); }
#tab-tasks-scope .tk-card.is-priority-basse { border-left-color: var(--tk-text-muted); }
#tab-tasks-scope .tk-card.is-overdue { background: linear-gradient(to right, #FEF2F2 0%, #FFFFFF 30%); }

#tab-tasks-scope .tk-card-row1 {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 6px;
}
#tab-tasks-scope .tk-card-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--tk-text);
  letter-spacing: -0.005em;
  line-height: 1.35;
}
#tab-tasks-scope .tk-card-kebab {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--tk-text-3);
  cursor: pointer;
  transition: all 0.12s ease;
  margin-top: -2px;
}
#tab-tasks-scope .tk-card-kebab:hover {
  background: var(--tk-card-soft);
  border-color: var(--tk-border);
  color: var(--tk-text);
}
#tab-tasks-scope .tk-card-kebab svg { width: 13px; height: 13px; }

#tab-tasks-scope .tk-card-row2 {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

#tab-tasks-scope .tk-card-row3 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--tk-text-3);
  margin-top: 6px;
}
#tab-tasks-scope .tk-card-row3 svg {
  width: 11px;
  height: 11px;
  stroke-width: 1.75;
  color: var(--tk-text-muted);
  vertical-align: -1px;
  margin-right: 2px;
}
#tab-tasks-scope .tk-card-due.is-overdue {
  color: var(--tk-danger-text);
  font-weight: 600;
}
#tab-tasks-scope .tk-card-due.is-soon {
  color: var(--tk-orange);
  font-weight: 600;
}

/* Type badges */
#tab-tasks-scope .tk-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
#tab-tasks-scope .tk-type-badge.is-commercial    { background: var(--tk-purple-soft); color: var(--tk-purple-text); }
#tab-tasks-scope .tk-type-badge.is-devis         { background: var(--tk-orange-soft); color: var(--tk-orange); }
#tab-tasks-scope .tk-type-badge.is-commande      { background: var(--tk-blue-soft); color: var(--tk-info-text); }
#tab-tasks-scope .tk-type-badge.is-installation  { background: var(--tk-blue-soft); color: var(--tk-info-text); }
#tab-tasks-scope .tk-type-badge.is-maintenance   { background: var(--tk-success-soft); color: var(--tk-success-text); }
#tab-tasks-scope .tk-type-badge.is-paiement      { background: var(--tk-success-soft); color: var(--tk-success-text); }
#tab-tasks-scope .tk-type-badge.is-facture       { background: var(--tk-info-soft); color: var(--tk-info-text); }
#tab-tasks-scope .tk-type-badge.is-peppol        { background: var(--tk-purple-soft); color: var(--tk-purple-text); }
#tab-tasks-scope .tk-type-badge.is-client        { background: #E0E7FF; color: #3730A3; }
#tab-tasks-scope .tk-type-badge.is-fournisseur   { background: var(--tk-border-soft); color: var(--tk-text-2); }

/* Priority pills (texte) */
#tab-tasks-scope .tk-prio-pill {
  display: inline-flex;
  align-items: center;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
#tab-tasks-scope .tk-prio-pill.is-urgente { background: var(--tk-danger); color: #fff; }
#tab-tasks-scope .tk-prio-pill.is-haute { background: var(--tk-orange); color: #fff; }
#tab-tasks-scope .tk-prio-pill.is-normale { background: var(--tk-info-soft); color: var(--tk-info-text); }
#tab-tasks-scope .tk-prio-pill.is-basse { background: var(--tk-border-soft); color: var(--tk-text-3); }

/* Liaisons (devis/client/agenda) */
#tab-tasks-scope .tk-link-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--tk-card-soft);
  border: 1px solid var(--tk-border);
  color: var(--tk-text-2);
}
#tab-tasks-scope .tk-link-tag svg {
  width: 10px;
  height: 10px;
  stroke-width: 2;
}
#tab-tasks-scope .tk-link-tag.is-agenda {
  background: var(--tk-orange-soft);
  border-color: var(--tk-orange-border);
  color: var(--tk-orange);
}

/* ═══ MENU KEBAB ═══════════════════════════════════════════════════ */
#tab-tasks-scope .tk-kebab-wrapper {
  position: relative;
  display: inline-flex;
}
#tab-tasks-scope .tk-kebab-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 200px;
  background: var(--tk-card);
  border: 1px solid var(--tk-border);
  border-radius: 10px;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.04),
    0 12px 32px rgba(15, 23, 42, 0.12);
  padding: 6px;
  z-index: 50;
  display: none;
  animation: tkKebab-fade 0.12s ease;
}
@keyframes tkKebab-fade {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
#tab-tasks-scope .tk-kebab-menu.is-open { display: block; }
#tab-tasks-scope .tk-kebab-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  font-family: 'Inter', sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--tk-text);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s ease;
  text-align: left;
}
#tab-tasks-scope .tk-kebab-item:hover { background: var(--tk-card-soft); }
#tab-tasks-scope .tk-kebab-item.is-danger { color: var(--tk-danger-text); }
#tab-tasks-scope .tk-kebab-item.is-danger:hover { background: var(--tk-danger-soft); }
#tab-tasks-scope .tk-kebab-item.is-success:hover { background: var(--tk-success-soft); color: var(--tk-success-text); }
#tab-tasks-scope .tk-kebab-item svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  stroke-width: 1.75;
  color: var(--tk-text-3);
}
#tab-tasks-scope .tk-kebab-item.is-danger svg { color: var(--tk-danger); }
#tab-tasks-scope .tk-kebab-divider {
  height: 1px;
  margin: 4px 0;
  background: var(--tk-border-soft);
}

/* ═══ VUE LISTE (alternative à Kanban) ════════════════════════════ */
#tab-tasks-scope .tk-list {
  background: var(--tk-card);
  border: 1px solid var(--tk-border);
  border-radius: var(--tk-radius);
  box-shadow: var(--tk-shadow);
  overflow: hidden;
}
#tab-tasks-scope .tk-list-group + .tk-list-group {
  border-top: 1px solid var(--tk-border-soft);
}
#tab-tasks-scope .tk-list-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--tk-card-soft);
  border-bottom: 1px solid var(--tk-border-soft);
}
#tab-tasks-scope .tk-list-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tk-text-2);
}
#tab-tasks-scope .tk-list-group-count {
  font-size: 11px;
  color: var(--tk-text-muted);
  font-family: 'JetBrains Mono', monospace;
}
#tab-tasks-scope .tk-list-items {
  padding: 4px 6px;
}
#tab-tasks-scope .tk-list-items .tk-card { margin: 4px 0; }

/* ═══ MODALE ACCEPTATION DEVIS ═══════════════════════════════════ */
.tk-accept-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
  background: var(--ag-card-soft, #FAFBFD);
  border: 1px solid var(--ag-border, #E5E7EB);
  border-radius: 8px;
  margin-bottom: 16px;
}
.tk-accept-info strong {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--ag-orange, #E65100);
  letter-spacing: -0.01em;
}
.tk-accept-info span {
  font-size: 13px;
  color: var(--ag-text-2, #475569);
}
.tk-accept-checks {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ═══ RESPONSIVE ═══════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  #tab-tasks-scope .tk-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  #tab-tasks-scope .tk-kanban { grid-template-columns: repeat(2, 1fr); }
  #tab-tasks-scope .tk-kanban-col { max-height: 500px; }
}
@media (max-width: 768px) {
  #tab-tasks-scope .tk-header { flex-direction: column; align-items: stretch; }
  #tab-tasks-scope .tk-kanban { grid-template-columns: 1fr; }
  #tab-tasks-scope .tk-kanban-col { max-height: 400px; }
}
@media (max-width: 480px) {
  #tab-tasks-scope .tk-kpi-grid { grid-template-columns: 1fr 1fr; }
}
