/* ============================================================
   TaskFlow — Design System
   Police : Syne (titres) + DM Sans (corps)
   Thème : sombre/slate avec accents indigo/vert/ambre
   ============================================================ */

:root {
  /* Couleurs principales */
  --bg:          #0f172a;
  --bg-card:     #1e293b;
  --bg-hover:    #263248;
  --border:      #334155;
  --border-light:#2d3f55;
  --text:        #e2e8f0;
  --text-muted:  #94a3b8;
  --text-faint:  #64748b;

  /* Accents */
  --accent:      #6366f1;
  --accent-glow: rgba(99,102,241,.18);
  --green:       #10b981;
  --amber:       #f59e0b;
  --red:         #ef4444;
  --slate:       #94a3b8;

  /* Sidebar */
  --sidebar-w:   240px;
  --sidebar-bg:  #0a1628;

  /* Misc */
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 4px 24px rgba(0,0,0,.35);
  --transition:  .18s cubic-bezier(.4,0,.2,1);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea, button { font-family: inherit; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  padding: 1.5rem 1rem;
}

.sidebar-brand {
  font-family: 'Syne', sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .25rem .5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.sidebar-brand .brand-icon {
  color: var(--accent);
  font-size: 1.4rem;
  line-height: 1;
}

.sidebar-nav { list-style: none; flex: 1; }
.sidebar-nav li { margin-bottom: .25rem; }

.nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 500;
  transition: var(--transition);
}
.nav-link:hover { background: var(--bg-hover); color: var(--text); }
.nav-link.active {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}
.nav-icon { font-size: 1rem; width: 1.2em; text-align: center; }

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.user-pill { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; }
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .75rem; color: var(--text-faint); }

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: .35rem .5rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  transition: var(--transition);
  display: flex; align-items: center;
  text-decoration: none;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1400px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
}
.page-header h2 {
  font-family: 'Syne', sans-serif;
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.2;
}
.accent { color: var(--accent); }
.subtitle { color: var(--text-muted); font-size: .9rem; margin-top: .25rem; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.card-header h3 {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
}
.link-sm { font-size: .85rem; color: var(--accent); }
.link-sm:hover { text-decoration: underline; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 900px) { .stats-grid { grid-template-columns: repeat(2,1fr); } }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--border-light); }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.stat-body { display: flex; flex-direction: column; flex: 1; }
.stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .2rem; }

.stat-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--border);
}
.stat-bar::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--pct, 0%);
  background: var(--clr, var(--accent));
  border-radius: 2px;
  transition: width .5s ease;
}

/* ============================================================
   CHARTS
   ============================================================ */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 900px) { .charts-grid { grid-template-columns: 1fr; } }

.chart-wrap {
  height: 240px;
  padding: 1.25rem 1.5rem;
  position: relative;
}

/* ============================================================
   TASK LIST (dashboard recent)
   ============================================================ */
.task-list { padding: .5rem 0; }
.task-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .8rem 1.5rem;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}
.task-row:last-child { border-bottom: none; }
.task-row:hover { background: var(--bg-hover); }

.task-row-info { flex: 1; display: flex; align-items: center; gap: .75rem; min-width: 0; }
.task-title {
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color var(--transition);
}
.task-title:hover { color: var(--accent); }
.task-user { display: flex; align-items: center; gap: .35rem; font-size: .82rem; color: var(--text-muted); }
.task-date { font-size: .8rem; color: var(--text-faint); white-space: nowrap; }

/* ============================================================
   STATUS DOTS / BADGES
   ============================================================ */
.status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot-xs { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.status-todo        { background: var(--slate); }
.status-in_progress { background: var(--amber); box-shadow: 0 0 6px rgba(245,158,11,.5); }
.status-done        { background: var(--green); }

.badge {
  display: inline-flex; align-items: center;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-low    { background: rgba(148,163,184,.15); color: var(--slate); }
.badge-medium { background: rgba(245,158,11,.15);  color: var(--amber); }
.badge-high   { background: rgba(239,68,68,.15);   color: var(--red); }
.badge-admin  { background: rgba(239,68,68,.15); color: var(--red); font-size: .8rem; }
.badge-admin-sm { background: rgba(239,68,68,.15); color: var(--red); font-size: .7rem; padding: .1rem .4rem; border-radius: 4px; margin-left: .25rem; }
.badge-sm { border-radius: 6px; padding: .15rem .5rem; }

.badge-status { border-radius: 6px; }
.badge-todo        { background: rgba(148,163,184,.15); color: var(--slate); }
.badge-in_progress { background: rgba(245,158,11,.15);  color: var(--amber); }
.badge-done        { background: rgba(16,185,129,.15);  color: var(--green); }

/* ============================================================
   AVATARS
   ============================================================ */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: .85rem;
  color: #fff;
  flex-shrink: 0;
}
.avatar-xs {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: .65rem;
  color: #fff;
  flex-shrink: 0;
}

/* ============================================================
   KANBAN BOARD
   ============================================================ */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  align-items: start;
}
@media (max-width: 800px) { .kanban-board { grid-template-columns: 1fr; } }

.kanban-col {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.kanban-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: .9rem;
}
.col-count {
  margin-left: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .1rem .5rem;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.kanban-cards { padding: .75rem; display: flex; flex-direction: column; gap: .6rem; min-height: 80px; }

.task-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem;
  cursor: default;
  transition: var(--transition);
}
.task-card:hover { border-color: var(--border-light); transform: translateY(-1px); box-shadow: var(--shadow); }
.task-card.card-moved { animation: pulse .5s ease; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(99,102,241,0); } 50% { box-shadow: 0 0 0 4px rgba(99,102,241,.3); } }

.task-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .5rem;
}
.task-card-actions { display: flex; gap: .25rem; opacity: 0; transition: opacity var(--transition); }
.task-card:hover .task-card-actions { opacity: 1; }

.action-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: .2rem .4rem;
  border-radius: 5px;
  font-size: .8rem;
  transition: var(--transition);
}
.action-btn:hover { background: var(--bg-hover); color: var(--text); }
.action-btn--danger:hover { border-color: var(--red); color: var(--red); background: rgba(239,68,68,.1); }

.task-card-title {
  font-family: 'Syne', sans-serif;
  font-size: .9rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: .35rem;
}
.task-card-desc { font-size: .8rem; color: var(--text-muted); line-height: 1.5; margin-bottom: .5rem; }

.task-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .6rem; }
.tag {
  background: rgba(99,102,241,.12);
  color: #a5b4fc;
  border: 1px solid rgba(99,102,241,.2);
  border-radius: 4px;
  padding: .1rem .4rem;
  font-size: .72rem;
  font-weight: 500;
}

.task-card-footer {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .5rem;
  padding-top: .5rem;
  border-top: 1px solid var(--border);
}
.due-date { font-size: .75rem; color: var(--text-faint); }
.due-overdue { color: var(--red) !important; }

.status-switcher { margin-left: auto; display: flex; gap: .25rem; }
.status-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.status-btn:hover { background: var(--bg-hover); border-color: var(--border-light); }

.col-empty {
  text-align: center;
  color: var(--text-faint);
  font-size: .82rem;
  padding: 1.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

/* ============================================================
   FILTERS
   ============================================================ */
.filters-card { padding: 1rem 1.25rem; margin-bottom: 1rem; }
.filters-form {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
}
.filter-search {
  flex: 1; min-width: 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: .5rem .85rem;
  font-size: .875rem;
}
.filter-search::placeholder { color: var(--text-faint); }
.filter-select, .filter-date {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: .5rem .75rem;
  font-size: .875rem;
}
.filter-select:focus, .filter-search:focus, .filter-date:focus {
  outline: none;
  border-color: var(--accent);
}

/* ============================================================
   FORMS
   ============================================================ */
.form-card { padding: 1.75rem; }
.form-row { display: flex; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: .4rem; flex: 1; margin-bottom: 1.1rem; }
.form-group--wide { flex: 2; }
.form-group label { font-size: .85rem; font-weight: 600; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: .65rem .9rem;
  font-size: .9rem;
  transition: border-color var(--transition);
}
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-faint); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-group textarea { resize: vertical; }
.form-group select option { background: var(--bg-card); }

.required { color: var(--red); }
.hint { font-weight: 400; color: var(--text-faint); font-size: .8rem; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  margin-top: .5rem;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: var(--transition);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: #4f52e0; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,.3); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: .4rem .85rem; font-size: .8rem; }
.select-sm {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: .35rem .7rem;
  font-size: .8rem;
}

/* ============================================================
   DATA TABLE
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.data-table th {
  text-align: left;
  padding: .75rem 1.5rem;
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: .8rem 1.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }
.data-table a:hover { color: var(--accent); }

/* ============================================================
   ADMIN — User progress
   ============================================================ */
.user-progress-list { padding: .5rem 0; }
.user-progress-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.user-progress-row:last-child { border-bottom: none; }
.user-progress-row:hover { background: var(--bg-hover); }

.user-progress-info { display: flex; align-items: center; gap: .75rem; min-width: 200px; }
.up-name { font-weight: 600; font-size: .9rem; display: block; }
.up-email { font-size: .78rem; color: var(--text-faint); }

.user-progress-bar-wrap { display: flex; align-items: center; gap: .75rem; flex: 1; }
.user-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}
.user-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 3px;
  transition: width .5s ease;
}
.up-pct { font-size: .82rem; color: var(--text-muted); width: 38px; text-align: right; }
.up-counts { display: flex; gap: .4rem; }

/* ============================================================
   HISTORY
   ============================================================ */
.history-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
}
.history-row:last-child { border-bottom: none; }
.history-user { font-weight: 600; min-width: 100px; }
.history-arrow { color: var(--text-faint); }
.history-date { margin-left: auto; font-size: .78rem; color: var(--text-faint); }
.loading-text, .empty-text { padding: 1.5rem; color: var(--text-faint); text-align: center; font-size: .875rem; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: .85rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: .9rem;
  font-weight: 500;
}
.alert-error   { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.25); color: #fca5a5; }
.alert-success { background: rgba(16,185,129,.12); border: 1px solid rgba(16,185,129,.25); color: #6ee7b7; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 2rem; right: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1.25rem;
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  transform: translateY(10px);
  opacity: 0;
  transition: all .3s ease;
  z-index: 9999;
}
.toast-show { transform: translateY(0); opacity: 1; }
.toast-success { border-color: rgba(16,185,129,.4); color: var(--green); }
.toast-error   { border-color: rgba(239,68,68,.4);  color: var(--red); }

/* ============================================================
   AUTH PAGE
   ============================================================ */
.auth-body {
  background:
    radial-gradient(ellipse 60% 50% at 70% 30%, rgba(99,102,241,.15) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 20% 80%, rgba(16,185,129,.08) 0%, transparent 70%),
    var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
}
.auth-container {
  width: 100%;
  max-width: 400px;
  padding: 1rem;
}
.auth-brand {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-brand .brand-icon {
  font-size: 2.5rem;
  color: var(--accent);
  display: block;
  margin-bottom: .5rem;
}
.auth-brand h1 {
  font-family: 'Syne', sans-serif;
  font-size: 2.25rem;
  font-weight: 800;
  margin-bottom: .25rem;
}
.auth-brand p { color: var(--text-muted); }

.auth-tabs {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 1.5rem;
}
.tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: .6rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 6px;
  transition: var(--transition);
}
.tab-btn.active { background: var(--accent); color: #fff; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.auth-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}
.auth-hint { text-align: center; margin-top: 1rem; font-size: .8rem; color: var(--text-faint); }
.auth-hint code { background: var(--bg); border: 1px solid var(--border); padding: .1rem .35rem; border-radius: 4px; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.empty-state p { color: var(--text-muted); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; padding: 1.25rem; }
  .form-row { flex-direction: column; }
  .kanban-board { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .user-progress-row { flex-wrap: wrap; }
  .page-header { flex-direction: column; }
}

/* ============================================================
   MISC
   ============================================================ */
::selection { background: var(--accent-glow); color: var(--accent); }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
