/* Task Memory Space — v2.0 PREMIUM — style ProductiveApp dark green */

/* ===== CONTAINER ===== */
.tm-container {
  min-height: 100vh;
  background: var(--bg-primary, #0a0f0a);
  color: var(--text, #e2e8f0);
  padding-bottom: 40px;
}

/* ===== HEADER HERO ===== */
.tm-header {
  position: relative;
  padding: 36px 28px 28px;
  background: linear-gradient(135deg, rgba(34,197,94,0.12) 0%, rgba(16,185,129,0.06) 50%, transparent 100%);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 12%, transparent);
  overflow: hidden;
}

.tm-header::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 8%, transparent) 0%, transparent 70%);
  pointer-events: none;
}

.tm-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 30%, transparent), transparent);
}

.tm-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 20%, transparent), rgba(34,197,94,0.1));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 12px;
  font-size: 1.3rem;
  margin-bottom: 14px;
  box-shadow: 0 0 20px color-mix(in srgb, var(--accent) 15%, transparent);
}

.tm-header-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: #fff;
  margin: 0 0 6px;
  letter-spacing: -0.5px;
}

.tm-header-title span {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #60a5fa));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tm-header-sub {
  color: rgba(255,255,255,0.45);
  font-size: 0.88rem;
}

/* ===== STATS GRID ===== */
.tm-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  padding: 20px 20px 0;
}

.tm-stat-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 14px;
  padding: 16px 14px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  cursor: default;
}

.tm-stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 4%, transparent) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.2s;
}

.tm-stat-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3), 0 0 0 1px color-mix(in srgb, var(--accent) 10%, transparent);
}

.tm-stat-card:hover::before { opacity: 1; }

.tm-stat-value {
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #60a5fa));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 6px;
}

.tm-stat-label {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}

/* ===== SECTIONS ===== */
.tm-section {
  padding: 24px 20px 0;
}

.tm-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tm-section-title .tm-title-dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent);
  flex-shrink: 0;
}

/* ===== GRAPHIQUE BARRES ===== */
.tm-chart-wrap {
  background: rgba(255,255,255,0.02);
  border: 1px solid color-mix(in srgb, var(--accent) 8%, transparent);
  border-radius: 16px;
  padding: 18px 16px 14px;
  margin-bottom: 14px;
}

.tm-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.tm-chart-title {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.4);
  font-weight: 500;
}

.tm-chart-max {
  font-size: 0.72rem;
  color: color-mix(in srgb, var(--accent) 60%, transparent);
  font-weight: 600;
}

.tm-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 90px;
  padding: 0 2px;
}

.tm-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}

.tm-bar {
  width: 100%;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 90%, transparent) 0%, rgba(34,197,94,0.6) 100%);
  border-radius: 5px 5px 2px 2px;
  min-height: 3px;
  transition: height 0.8s cubic-bezier(0.34,1.56,0.64,1);
  position: relative;
  cursor: pointer;
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 20%, transparent);
}

.tm-bar::after {
  content: attr(data-count);
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
}

.tm-bar:hover {
  background: linear-gradient(180deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 80%, #000) 100%);
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 40%, transparent);
}

.tm-bar:hover::after { opacity: 1; }

.tm-bar-label {
  font-size: 0.58rem;
  color: rgba(255,255,255,0.3);
  text-align: center;
  white-space: nowrap;
  font-weight: 500;
}

/* ===== TOP PROJETS ===== */
.tm-projects-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.tm-project-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid color-mix(in srgb, var(--accent) 7%, transparent);
  border-radius: 10px;
  padding: 10px 14px;
  transition: border-color 0.15s, background 0.15s;
}

.tm-project-row:hover {
  background: color-mix(in srgb, var(--accent) 4%, transparent);
  border-color: color-mix(in srgb, var(--accent) 20%, transparent);
}

.tm-project-dot {
  width: 8px; height: 8px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #60a5fa));
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px color-mix(in srgb, var(--accent) 50%, transparent);
}

.tm-project-name {
  flex: 1;
  font-size: 0.84rem;
  color: rgba(255,255,255,0.8);
  font-weight: 500;
}

.tm-project-bar-wrap {
  width: 70px; height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}

.tm-project-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #60a5fa));
  border-radius: 2px;
  transition: width 1s ease;
}

.tm-project-count {
  font-size: 0.75rem;
  color: color-mix(in srgb, var(--accent) 70%, transparent);
  font-weight: 700;
  min-width: 28px;
  text-align: right;
}

/* ===== FILTRES ===== */
.tm-filters {
  display: flex;
  gap: 6px;
  padding: 20px 20px 0;
  flex-wrap: wrap;
  align-items: center;
}

.tm-filter-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.1);
  background: transparent;
  color: rgba(255,255,255,0.45);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.3px;
}

.tm-filter-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--accent);
}

.tm-filter-btn.active {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 20%, transparent), rgba(34,197,94,0.1));
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  color: var(--accent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 15%, transparent);
}

.tm-search {
  flex: 1;
  min-width: 140px;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  color: rgba(255,255,255,0.8);
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.15s;
}

.tm-search::placeholder { color: rgba(255,255,255,0.25); }
.tm-search:focus { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

/* ===== LISTE DES TÂCHES ===== */
.tm-list {
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.tm-task-item {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 13px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}

.tm-task-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 80%, #000));
  opacity: 0;
  transition: opacity 0.15s;
  border-radius: 3px 0 0 3px;
}

.tm-task-item:hover {
  border-color: color-mix(in srgb, var(--accent) 20%, transparent);
  background: color-mix(in srgb, var(--accent) 3%, transparent);
  transform: translateX(3px);
}

.tm-task-item:hover::before { opacity: 1; }

.tm-task-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 20%, transparent), rgba(34,197,94,0.1));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 5px;
  flex-shrink: 0;
  margin-right: 10px;
  margin-top: 2px;
}

.tm-task-check svg { width: 10px; height: 10px; }

.tm-task-header {
  display: flex;
  align-items: flex-start;
  gap: 0;
}

.tm-task-title {
  font-size: 0.88rem;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  margin-bottom: 6px;
  line-height: 1.3;
}

.tm-task-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.tm-badge {
  font-size: 0.67rem;
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.tm-badge-urgent { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.tm-badge-high { background: rgba(249,115,22,0.12); color: #fb923c; border: 1px solid rgba(249,115,22,0.2); }
.tm-badge-medium { background: rgba(234,179,8,0.1); color: #fbbf24; border: 1px solid rgba(234,179,8,0.15); }
.tm-badge-low { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent); }
.tm-badge-project { background: rgba(99,102,241,0.12); color: #818cf8; border: 1px solid rgba(99,102,241,0.2); }

.tm-task-date {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.25);
  font-weight: 400;
}

.tm-task-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.tm-xp-badge {
  font-size: 0.68rem;
  font-weight: 800;
  color: #fbbf24;
  background: rgba(251,191,36,0.1);
  border: 1px solid rgba(251,191,36,0.2);
  padding: 2px 8px;
  border-radius: 8px;
}

/* ===== AI CARD ===== */
.tm-ai-card {
  background: rgba(99,102,241,0.06);
  border: 1px solid rgba(99,102,241,0.18);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
}

.tm-ai-card::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 120px; height: 120px;
  background: radial-gradient(circle, rgba(168,85,247,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.tm-ai-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.tm-ai-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}

.tm-ai-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  margin-bottom: 2px;
}

.tm-ai-subtitle {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.35);
}

.tm-ai-narrative {
  font-size: 0.84rem;
  color: rgba(255,255,255,0.65);
  line-height: 1.6;
  margin-bottom: 14px;
  font-style: italic;
  padding: 12px 14px;
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
  border-left: 3px solid rgba(99,102,241,0.4);
}

.tm-ai-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.tm-ai-pill-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
  margin-top: 10px;
}

.tm-ai-pill {
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(99,102,241,0.25);
  color: rgba(129,140,248,0.9);
  background: rgba(99,102,241,0.08);
  font-weight: 500;
}

.tm-ai-pill.growth {
  border-color: rgba(245,158,11,0.25);
  color: rgba(251,191,36,0.9);
  background: rgba(245,158,11,0.07);
}

.tm-ai-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.tm-ai-generate-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  background: linear-gradient(135deg, rgba(99,102,241,0.3), rgba(168,85,247,0.2));
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(99,102,241,0.35);
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.tm-ai-generate-btn:hover {
  background: linear-gradient(135deg, rgba(99,102,241,0.5), rgba(168,85,247,0.35));
  border-color: rgba(99,102,241,0.6);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(99,102,241,0.25);
}

.tm-ai-generate-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.tm-ai-meta {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.2);
  margin-top: 10px;
}

/* ===== PAGINATION ===== */
.tm-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 24px 20px 0;
}

.tm-page-btn {
  padding: 6px 16px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 15%, transparent);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  color: color-mix(in srgb, var(--accent) 70%, transparent);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.15s;
}

.tm-page-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--accent);
}

.tm-page-btn:disabled { opacity: 0.25; cursor: not-allowed; }

.tm-page-info {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.3);
  padding: 0 8px;
}

/* ===== EMPTY STATE ===== */
.tm-empty {
  text-align: center;
  padding: 50px 20px;
}

.tm-empty-icon {
  font-size: 3rem;
  margin-bottom: 14px;
  opacity: 0.4;
  display: block;
}

.tm-empty-title {
  font-size: 1rem;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
  margin-bottom: 8px;
}

.tm-empty-desc {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.25);
  line-height: 1.5;
}

/* ===== LOADING ===== */
.tm-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 14px;
  color: rgba(255,255,255,0.3);
  font-size: 0.85rem;
}

.tm-spinner {
  width: 28px; height: 28px;
  border: 2px solid color-mix(in srgb, var(--accent) 10%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: tm-spin 0.7s linear infinite;
}

@keyframes tm-spin { to { transform: rotate(360deg); } }

/* ===== SECTION TITLE avec séparateur ===== */
.tm-section-head {
  padding: 24px 20px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
}

.tm-section-head-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}

.tm-section-head-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 15%, transparent), transparent);
}

.tm-section-count {
  font-size: 0.72rem;
  color: color-mix(in srgb, var(--accent) 50%, transparent);
  font-weight: 700;
}

/* ===== DASHBOARD WIDGET ===== */
.tm-widget {
  background: rgba(255,255,255,0.02);
  border: 1px solid color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 16px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.tm-widget::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #60a5fa));
  opacity: 0.5;
}

.tm-widget:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3), 0 0 0 1px color-mix(in srgb, var(--accent) 8%, transparent);
}

.tm-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.tm-widget-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  gap: 7px;
}

.tm-widget-link {
  font-size: 0.7rem;
  color: color-mix(in srgb, var(--accent) 60%, transparent);
  text-decoration: none;
  font-weight: 600;
}

.tm-widget-mini-stats {
  display: flex;
  gap: 0;
  margin-bottom: 14px;
  background: rgba(255,255,255,0.02);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.04);
}

.tm-widget-mini-stat {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  border-right: 1px solid rgba(255,255,255,0.04);
}

.tm-widget-mini-stat:last-child { border-right: none; }

.tm-widget-mini-val {
  font-size: 1.3rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #60a5fa));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 3px;
}

.tm-widget-mini-lbl {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.25);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.tm-widget-recent {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tm-widget-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  color: rgba(255,255,255,0.45);
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.tm-widget-item:last-child { border-bottom: none; }

.tm-widget-item-check {
  width: 14px; height: 14px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.55rem;
  color: var(--accent);
}

.tm-widget-item-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255,255,255,0.55);
}

.tm-widget-item-date {
  color: rgba(255,255,255,0.2);
  flex-shrink: 0;
  font-size: 0.68rem;
}

/* ===== BOUTON IMPORT ===== */
#tm-backfill-btn {
  padding: 6px 12px;
  background: rgba(99,102,241,0.1);
  border-color: rgba(99,102,241,0.2);
  color: rgba(129,140,248,0.7);
  font-size: 0.74rem;
}

#tm-backfill-btn:hover {
  background: rgba(99,102,241,0.2);
  border-color: rgba(99,102,241,0.4);
  color: #818cf8;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .tm-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .tm-bars { height: 70px; }
  .tm-task-item { grid-template-columns: 1fr; }
  .tm-header-title { font-size: 1.4rem; }
}
