@font-face {
  font-family: 'Cal Sans';
  src: url('https://cdn.jsdelivr.net/npm/@fontsource/cal-sans@5.0.1/files/cal-sans-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
}

:root {
  --accent: #6b63e6;
  --accent-light: #ede9ff;
  --accent-mid: #a78bfa;
  --surface: #ffffff;
  --bg: #f7f7fb;
  --border: #eeeef6;
  --text-primary: #1a1a2e;
  --text-secondary: #7a7a95;
  --text-muted: #9898b0;
  --done: #2db36b;
  --done-bg: #e8f8f0;
  --progress-color: #f2a23a;
  --progress-bg: #fff4e5;
  --todo-bg: #f0f0f7;
  --radius: 14px;
}

#sama-projects-app {
  width: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text-primary);
  background: var(--bg);
  border-radius: 20px;
  overflow: hidden;
  padding: 0 0 8px;
}

/* ── HEADER ── */
.sama-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 32px 32px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.sama-greeting { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }

.sama-title {
  font-family: 'Cal Sans', sans-serif;
  font-size: 26px;
  color: var(--text-primary);
  margin: 0 0 6px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.sama-subtitle { font-size: 13px; color: var(--text-muted); margin: 0; }
.sama-header-right { display: flex; gap: 10px; flex-wrap: wrap; }

.sama-stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  gap: 2px;
}

.stat-number { font-family: 'Cal Sans', sans-serif; font-size: 22px; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 11px; color: var(--text-muted); letter-spacing: 0.04em; text-transform: uppercase; }

/* ── LOADING BAR ── */
.sama-loading-bar { height: 3px; background: var(--border); overflow: hidden; transition: opacity 0.4s ease; }
.sama-loading-bar.hidden { opacity: 0; pointer-events: none; }

.sama-loading-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-mid), var(--accent));
  background-size: 200% 100%;
  animation: loadingSlide 1.6s ease infinite;
  width: 100%;
}

@keyframes loadingSlide {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── TICKER ── */
.sama-status-ticker {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  min-height: 38px;
}
.sama-status-ticker.hidden { display: none; }

.ticker-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease infinite; flex-shrink: 0; }
.ticker-dot.done { background: var(--done); animation: none; }
.ticker-dot.error { background: #e05252; animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.ticker-text { transition: opacity 0.2s; }

/* ── TABS ── */
.sama-tabs-wrap { background: var(--surface); border-bottom: 1px solid var(--border); }
.sama-tabs { display: flex; padding: 0 32px; }

.sama-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 14px 16px 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  margin-bottom: -1px;
}
.sama-tab:hover:not(:disabled) { color: var(--text-primary); }
.sama-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.sama-tab:disabled { opacity: 0.4; cursor: not-allowed; }
.sama-tab svg { flex-shrink: 0; opacity: 0.7; }
.sama-tab.active svg { opacity: 1; }

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 20px;
  background: var(--todo-bg);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.sama-tab.active .tab-count { background: var(--accent-light); color: var(--accent); }

/* ── FILTRES ── */
.sama-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 32px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.filter-label { font-size: 11px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
.filter-group { display: flex; gap: 4px; }

.filter-btn {
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.filter-btn:hover { background: var(--border); color: var(--text-primary); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.filter-divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

/* ── TABLE ── */
.sama-projects-table-wrap { width: 100%; overflow-x: auto; padding: 16px 16px 0; }

.sama-projects-table {
  min-width: 1060px;
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* Grid projets : sans colonne début */
.sama-projects-row {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 1.7fr 1.1fr 0.85fr 1fr 40px;
  align-items: center;
  column-gap: 20px;
}

/* Grid SAV : avec colonne début */
.sama-projects-row-sav {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 1.5fr 1fr 0.75fr 0.75fr 1fr 40px;
  align-items: center;
  column-gap: 20px;
}

.sama-projects-head {
  padding: 14px 20px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  background: #fafafd;
  border-bottom: 1px solid var(--border);
}

/* ── ROWS ── */
.sama-project-item {
  padding: 16px 20px;
  border-bottom: 1px solid #f3f3f8;
  background: var(--surface);
  transition: background 0.15s;
  animation: fadeInRow 0.3s ease both;
}
.sama-project-item:hover { background: #fafafd; }
.sama-project-item:last-child { border-bottom: 0; }

@keyframes fadeInRow {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.project-name-wrap { display: flex; align-items: center; gap: 10px; }

.project-state-icon { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.state-todo .project-state-icon { background: #c8cad6; }
.state-progress .project-state-icon { background: var(--progress-color); box-shadow: 0 0 0 3px var(--progress-bg); }
.state-done .project-state-icon { background: var(--done); box-shadow: 0 0 0 3px var(--done-bg); }

.project-name { font-family: 'Cal Sans', sans-serif; font-size: 15px; color: var(--text-primary); margin: 0; line-height: 1.3; letter-spacing: -0.01em; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.status-badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.status-badge.todo { background: var(--todo-bg); color: #6b6b85; }
.status-badge.todo::before { background: var(--text-muted); }
.status-badge.progress { background: var(--progress-bg); color: #b96e0b; }
.status-badge.progress::before { background: var(--progress-color); }
.status-badge.done { background: var(--done-bg); color: #1a7a48; }
.status-badge.done::before { background: var(--done); }

.project-description { font-size: 13px; line-height: 1.55; color: var(--text-secondary); margin: 0; }

.progress-wrap { display: flex; align-items: center; gap: 8px; }
.progress-track { flex: 1; max-width: 110px; height: 5px; border-radius: 999px; background: var(--border); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-mid)); width: 0%; transition: width 0.6s cubic-bezier(0.4,0,0.2,1); }
.progress-text { font-size: 13px; font-weight: 500; color: var(--accent); min-width: 36px; font-family: 'Cal Sans', sans-serif; }

.start-date { font-size: 13px; color: var(--text-muted); }
.due-date { font-size: 13px; color: var(--text-secondary); }
.due-date.overdue { color: #e05252; font-weight: 500; }
.due-date.soon { color: var(--progress-color); font-weight: 500; }

.project-owner-wrap { display: flex; align-items: center; gap: 8px; }

.owner-avatar {
  width: 27px; height: 27px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-mid));
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff;
  flex-shrink: 0;
  font-family: 'Cal Sans', sans-serif;
}

.owner-name { font-size: 13px; color: var(--text-primary); }
.owner-link { text-decoration: none; transition: opacity 0.15s; }
.owner-link:hover { opacity: 0.75; }
.owner-link:hover .owner-name { text-decoration: underline; text-underline-offset: 2px; }

.col-actions { display: flex; justify-content: flex-end; }

.sp-dots-btn {
  width: 32px; height: 32px;
  border-radius: 8px; border: none;
  background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.sp-dots-btn:hover { background: var(--border); color: var(--text-primary); }

/* ── SKELETON ── */
.skeleton-row {
  padding: 16px 20px;
  border-bottom: 1px solid #f3f3f8;
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 1.7fr 1.1fr 0.85fr 1fr 40px;
  column-gap: 20px;
  align-items: center;
}
.skeleton-row:last-child { border-bottom: 0; }

.sk {
  border-radius: 6px;
  background: linear-gradient(90deg, #f0f0f7 25%, #e8e8f3 50%, #f0f0f7 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  height: 13px;
}
.sk.sm { height: 10px; width: 55%; }
.sk.md { height: 13px; width: 78%; }
.sk.lg { height: 13px; width: 92%; }
.sk.badge { height: 24px; width: 66px; border-radius: 8px; }
.sk.progress { height: 5px; width: 100px; border-radius: 999px; }
.sk.avatar { width: 27px; height: 27px; border-radius: 50%; flex-shrink: 0; }
.sk.circle { width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.sama-empty, .sama-error {
  padding: 48px 24px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}
.sama-error { color: #e05252; }

/* ── PAGINATION ── */
.sama-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.pagination-info { font-size: 12px; color: var(--text-muted); }

.pagination-controls { display: flex; align-items: center; gap: 4px; }

.pg-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 6px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
}
.pg-btn:hover:not(:disabled) { background: var(--accent-light); border-color: var(--accent-light); color: var(--accent); }
.pg-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pg-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.pg-ellipsis {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ── POPUP ── */
.sp-overlay { display: none; position: fixed; inset: 0; background: rgba(10,10,30,0.45); backdrop-filter: blur(4px); z-index: 1000; animation: fadeOverlay 0.2s ease; }
.sp-overlay.active { display: block; }

@keyframes fadeOverlay { from { opacity: 0; } to { opacity: 1; } }

.sp-popup {
  display: none; position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%,-46%) scale(0.97);
  width: min(600px, calc(100vw - 32px));
  max-height: 90vh; overflow-y: auto;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.06);
  z-index: 1001;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease;
  opacity: 0;
}
.sp-popup.active { display: block; transform: translate(-50%,-50%) scale(1); opacity: 1; }

.sp-close {
  position: absolute; top: 16px; right: 16px;
  width: 34px; height: 34px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: background 0.15s, color 0.15s; z-index: 2;
}
.sp-close:hover { background: var(--bg); color: var(--text-primary); }

.sp-popup-inner { padding: 28px 28px 24px; }
.sp-popup-top { padding-bottom: 20px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.sp-popup-badge { margin-bottom: 10px; }
.sp-popup-title { font-family: 'Cal Sans', sans-serif; font-size: 22px; color: var(--text-primary); margin: 0 0 6px; line-height: 1.2; letter-spacing: -0.01em; padding-right: 40px; }
.sp-popup-meta { font-size: 13px; color: var(--text-muted); margin: 0; }
.sp-popup-section { margin-bottom: 20px; }
.sp-section-label { font-size: 11px; font-weight: 500; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.sp-popup-desc { font-size: 14px; line-height: 1.7; color: var(--text-secondary); margin: 0; }

.sp-popup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.sp-info-block { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.sp-info-label { font-size: 11px; color: var(--text-muted); font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 4px; }
.sp-info-value { font-size: 14px; color: var(--text-primary); font-weight: 500; font-family: 'Cal Sans', sans-serif; }

.sp-progress-track { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; margin-bottom: 6px; }
.sp-progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-mid)); width: 0%; transition: width 0.6s cubic-bezier(0.4,0,0.2,1); }
.sp-progress-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); }

.sp-popup-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

.sp-btn { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 20px; border-radius: 11px; font-size: 14px; font-weight: 500; text-decoration: none; transition: all 0.15s; cursor: pointer; }
.sp-btn-primary { background: var(--accent); color: #fff; box-shadow: 0 2px 12px rgba(107,99,230,0.3); }
.sp-btn-primary:hover { background: #5a52d5; transform: translateY(-1px); }
.sp-btn-secondary { background: var(--bg); color: var(--text-primary); border: 1px solid var(--border); }
.sp-btn-secondary:hover { background: var(--border); transform: translateY(-1px); }

/* ── RESPONSIVE ── */
@media (max-width: 991px) {
  .sama-header { padding: 24px 20px 16px; }
  .sama-title { font-size: 20px; }
  .sama-status-ticker { padding: 10px 20px; }
  .sama-tabs { padding: 0 16px; }
  .sama-tab { font-size: 12px; padding: 12px 10px 10px; gap: 5px; }
  .sama-filters { padding: 8px 16px; gap: 6px; }
  .sama-projects-table-wrap { padding: 12px 12px 0; }
  .sama-pagination { padding: 12px 16px; }
  .sp-popup-grid { grid-template-columns: 1fr; }
  .sp-popup-inner { padding: 20px; }
}