/* ============================================================
   TaskForge — Design system
   Préfixe .tf- | thèmes via [data-theme]
   ============================================================ */
:root, [data-theme="light"] {
  --tf-bg: #f1f5f9;
  --tf-surface: #ffffff;
  --tf-surface-2: #f8fafc;
  --tf-border: #e2e8f0;
  --tf-text: #0f172a;
  --tf-text-muted: #64748b;
  --tf-primary: #6d5ef1;
  --tf-primary-soft: #eef2ff;
  --tf-sidebar-bg: #111827;
  --tf-sidebar-text: #cbd5e1;
  --tf-shadow: 0 1px 3px rgba(15, 23, 42, .08);
  --tf-radius: 12px;
}
[data-theme="dark"] {
  --tf-bg: #0b1220;
  --tf-surface: #111a2c;
  --tf-surface-2: #16213a;
  --tf-border: #24324f;
  --tf-text: #e2e8f0;
  --tf-text-muted: #8ea0bd;
  --tf-primary: #8b7ff7;
  --tf-primary-soft: #1d2440;
  --tf-sidebar-bg: #0a0f1c;
  --tf-sidebar-text: #9fb0cc;
  --tf-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
[data-theme="dark"] body { color-scheme: dark; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--tf-bg);
  color: var(--tf-text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: .925rem;
}
a { color: var(--tf-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- Structure */
.tf-shell { display: flex; min-height: 100vh; }
.tf-sidebar {
  width: 232px; flex: 0 0 232px;
  background: var(--tf-sidebar-bg); color: var(--tf-sidebar-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  transition: margin-left .2s;
}
.tf-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tf-content { padding: 1.25rem 1.5rem 3rem; }
@media (max-width: 991px) {
  .tf-sidebar { position: fixed; z-index: 1040; margin-left: -232px; }
  .tf-sidebar.open { margin-left: 0; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
}

/* ---------------- Sidebar */
.tf-logo {
  display: flex; align-items: center; gap: .6rem;
  color: #fff; font-weight: 700; font-size: 1.1rem;
  padding: 1.1rem 1.2rem; text-decoration: none;
}
.tf-logo:hover { color: #fff; text-decoration: none; }
.tf-logo i { color: var(--tf-primary); }
.tf-nav { padding: .5rem .7rem 2rem; display: flex; flex-direction: column; gap: 2px; }
.tf-nav-link {
  display: flex; align-items: center; gap: .7rem;
  color: var(--tf-sidebar-text); padding: .55rem .8rem;
  border-radius: 8px; font-size: .9rem;
}
.tf-nav-link i { width: 18px; text-align: center; }
.tf-nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.tf-nav-link.active { background: var(--tf-primary); color: #fff; }
.tf-nav-sep {
  margin: 1rem .8rem .3rem; font-size: .7rem; letter-spacing: .08em;
  text-transform: uppercase; color: #64748b;
}

/* ---------------- Topbar */
.tf-topbar {
  display: flex; align-items: center; gap: .8rem;
  background: var(--tf-surface); border-bottom: 1px solid var(--tf-border);
  padding: .55rem 1.25rem; position: sticky; top: 0; z-index: 1020;
}
.tf-icon-btn {
  border: 1px solid var(--tf-border); background: var(--tf-surface);
  color: var(--tf-text); width: 36px; height: 36px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
}
.tf-icon-btn:hover { background: var(--tf-surface-2); }
.tf-user-btn {
  display: flex; align-items: center; gap: .5rem;
  background: none; border: none; color: var(--tf-text);
}

/* Recherche */
.tf-search { position: relative; flex: 0 1 420px; }
.tf-search > i {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--tf-text-muted); font-size: .85rem;
}
.tf-search input {
  width: 100%; border: 1px solid var(--tf-border); background: var(--tf-surface-2);
  color: var(--tf-text); border-radius: 9px; padding: .45rem .8rem .45rem 2.1rem;
}
.tf-search input:focus { outline: 2px solid var(--tf-primary); border-color: transparent; }
.tf-search-results {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--tf-surface); border: 1px solid var(--tf-border);
  border-radius: 10px; box-shadow: var(--tf-shadow); overflow: hidden; z-index: 1050;
}
.tf-search-results.show { display: block; }
.tf-search-item { display: block; padding: .55rem .9rem; color: var(--tf-text); border-bottom: 1px solid var(--tf-border); }
.tf-search-item:last-child { border-bottom: 0; }
.tf-search-item:hover { background: var(--tf-surface-2); text-decoration: none; }
.tf-search-group { padding: .35rem .9rem; font-size: .72rem; text-transform: uppercase; color: var(--tf-text-muted); background: var(--tf-surface-2); }

/* Timer */
.tf-timer {
  display: flex; align-items: center; gap: .5rem;
  background: var(--tf-primary-soft); border: 1px solid var(--tf-primary);
  border-radius: 10px; padding: .25rem .6rem;
}
.tf-timer-dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; animation: tfblink 1.2s infinite; }
@keyframes tfblink { 50% { opacity: .25; } }
.tf-timer-task { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; }
.tf-timer-clock { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Notifications */
.tf-notif-badge {
  position: absolute; top: -4px; right: -4px;
  background: #ef4444; color: #fff; font-size: .62rem; font-weight: 700;
  border-radius: 999px; padding: 1px 5px;
}
.tf-notif-menu { width: 360px; max-width: 92vw; }
.tf-notif-head { display: flex; justify-content: space-between; align-items: center; padding: .7rem 1rem; border-bottom: 1px solid var(--tf-border); }
.tf-notif-list { max-height: 380px; overflow-y: auto; }
.tf-notif-item { display: block; padding: .6rem 1rem; border-bottom: 1px solid var(--tf-border); color: var(--tf-text); }
.tf-notif-item:hover { background: var(--tf-surface-2); text-decoration: none; }
.tf-notif-item.unread { background: var(--tf-primary-soft); }

/* ---------------- Composants */
.tf-card {
  background: var(--tf-surface); border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius); box-shadow: var(--tf-shadow);
  padding: 1.1rem 1.25rem; margin-bottom: 1.25rem;
}
.tf-card h2, .tf-card h5 { font-size: 1rem; font-weight: 600; margin-bottom: .9rem; }
.tf-page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem; margin-bottom: 1.1rem; }
.tf-page-head h1 { font-size: 1.3rem; font-weight: 700; margin: 0; }

.tf-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .74rem; font-weight: 600; padding: .18rem .55rem;
  border-radius: 999px; color: var(--bc, #64748b);
  background: color-mix(in srgb, var(--bc, #64748b) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--bc, #64748b) 35%, transparent);
  white-space: nowrap;
}
.tf-avatar { border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.tf-avatar--txt {
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: .68rem; font-weight: 700;
}
.tf-avatar-stack { display: inline-flex; }
.tf-avatar-stack > * { margin-left: -8px; border: 2px solid var(--tf-surface); }
.tf-avatar-stack > *:first-child { margin-left: 0; }

.tf-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.tf-kpi-card {
  background: var(--tf-surface); border: 1px solid var(--tf-border); border-radius: var(--tf-radius);
  padding: 1rem 1.2rem; display: flex; align-items: center; gap: .9rem; box-shadow: var(--tf-shadow);
}
.tf-kpi-icon {
  width: 42px; height: 42px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: #fff; background: var(--tf-primary); flex-shrink: 0;
}
.tf-kpi-value { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.tf-kpi-label { color: var(--tf-text-muted); font-size: .8rem; }

/* Tables */
.tf-table { width: 100%; border-collapse: collapse; }
.tf-table th {
  text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--tf-text-muted); padding: .55rem .7rem; border-bottom: 1px solid var(--tf-border);
}
.tf-table td { padding: .6rem .7rem; border-bottom: 1px solid var(--tf-border); vertical-align: middle; }
.tf-table tbody tr:hover { background: var(--tf-surface-2); }
.tf-table a.tf-row-link { color: var(--tf-text); font-weight: 500; }

/* Progress */
.tf-progress { height: 7px; border-radius: 999px; background: var(--tf-border); overflow: hidden; }
.tf-progress > div { height: 100%; border-radius: 999px; background: var(--tf-primary); }
.tf-progress.warn > div { background: #f59e0b; }
.tf-progress.danger > div { background: #ef4444; }

/* Filtres */
.tf-filters {
  display: flex; flex-wrap: wrap; gap: .55rem; align-items: center;
  background: var(--tf-surface); border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius); padding: .7rem .9rem; margin-bottom: 1.1rem;
}
.tf-filters select, .tf-filters input {
  border: 1px solid var(--tf-border); background: var(--tf-surface-2); color: var(--tf-text);
  border-radius: 8px; padding: .35rem .55rem; font-size: .85rem; max-width: 170px;
}
.tf-filters select[multiple] {
  min-width: 170px; min-height: 72px; padding: .2rem;
}

/* Kanban */
.tf-kanban { display: flex; gap: .9rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.tf-kanban-col {
  flex: 0 0 290px; background: var(--tf-surface-2);
  border: 1px solid var(--tf-border); border-radius: var(--tf-radius);
}
.tf-kanban-head {
  display: flex; align-items: center; gap: .5rem; padding: .7rem .9rem;
  font-weight: 600; font-size: .88rem; border-bottom: 1px solid var(--tf-border);
}
.tf-kanban-count { margin-left: auto; font-size: .75rem; color: var(--tf-text-muted); }
.tf-kanban-cards { min-height: 60px; padding: .7rem; display: flex; flex-direction: column; gap: .6rem; }
.tf-kcard {
  background: var(--tf-surface); border: 1px solid var(--tf-border); border-radius: 10px;
  padding: .65rem .75rem; box-shadow: var(--tf-shadow); cursor: grab;
}
.tf-kcard.sortable-ghost { opacity: .4; }
.tf-kcard-title { font-weight: 500; font-size: .87rem; margin: .25rem 0 .45rem; }
.tf-kcard-meta { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; font-size: .74rem; color: var(--tf-text-muted); }
.tf-kcard .overdue { color: #ef4444; font-weight: 600; }

/* Divers */
.tf-timeline { list-style: none; margin: 0; padding: 0; }
.tf-timeline li { display: flex; gap: .7rem; padding: .55rem 0; border-bottom: 1px dashed var(--tf-border); font-size: .85rem; }
.tf-timeline li:last-child { border-bottom: 0; }
.tf-checklist li { display: flex; align-items: center; gap: .55rem; padding: .3rem 0; }
.tf-checklist .done { text-decoration: line-through; color: var(--tf-text-muted); }
.tf-comment { display: flex; gap: .7rem; padding: .8rem 0; border-bottom: 1px solid var(--tf-border); }
.tf-comment:last-child { border-bottom: 0; }
.tf-comment-body { background: var(--tf-surface-2); border-radius: 10px; padding: .6rem .85rem; flex: 1; }
.tf-login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--tf-bg); padding: 1rem; }
.tf-login-card { width: 400px; max-width: 100%; }
.tf-brand-big { font-size: 1.5rem; font-weight: 800; text-align: center; margin-bottom: 1.2rem; }
.tf-brand-big i { color: var(--tf-primary); }

.form-label { font-size: .82rem; font-weight: 600; }
.form-control, .form-select {
  background: var(--tf-surface-2); border-color: var(--tf-border); color: var(--tf-text);
}
.form-control:focus, .form-select:focus {
  background: var(--tf-surface-2); color: var(--tf-text);
  border-color: var(--tf-primary); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--tf-primary) 25%, transparent);
}
.btn-primary { --bs-btn-bg: var(--tf-primary); --bs-btn-border-color: var(--tf-primary);
  --bs-btn-hover-bg: #5a4be0; --bs-btn-hover-border-color: #5a4be0; }
.card, .modal-content, .dropdown-menu { background: var(--tf-surface); color: var(--tf-text); border-color: var(--tf-border); }
.dropdown-item { color: var(--tf-text); }
.dropdown-item:hover { background: var(--tf-surface-2); color: var(--tf-text); }
.table { color: var(--tf-text); }
.text-muted { color: var(--tf-text-muted) !important; }

/* Impression (export PDF) */
@media print {
  .tf-sidebar, .tf-topbar, .tf-filters, .no-print { display: none !important; }
  .tf-content { padding: 0; }
  body { background: #fff; }
}
