
:root {
  --sidebar-w: 290px;
  --sidebar-collapsed-w: 54px;
  --sidebar-bg: #1a2332;
  --sidebar-hover: #263447;
  --sidebar-active: #3b82f6;
  --sidebar-text: #cbd5e1;
  --accent: #3b82f6;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --success: #22c55e;
  --gray: #94a3b8;
  --transition: 0.25s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  height: 100vh;
  display: flex;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

/* ── SIDEBAR ── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  transition: width var(--transition), min-width var(--transition);
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 2px 0 8px rgba(0,0,0,0.25);
  z-index: 100;
}
#sidebar.collapsed {
  width: 0;
  min-width: 0;
}

#sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  gap: 8px;
}
.sidebar-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  flex: 1;
}
#toggle-btn {
  background: none;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: 4px 7px;
  border-radius: 4px;
  font-size: 0.75rem;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
  line-height: 1;
}
#toggle-btn:hover { background: var(--sidebar-hover); }

#competitions-list { overflow-y: auto; flex: 1; padding: 6px 0; }

.comp-item {}
.comp-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
  white-space: nowrap;
}
.comp-header:hover { background: var(--sidebar-hover); }
.comp-icon { font-size: 0.9rem; flex-shrink: 0; }
.comp-name {
  font-size: 0.82rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.comp-arrow {
  font-size: 0.65rem;
  transition: transform var(--transition);
  flex-shrink: 0;
}
.comp-item.expanded .comp-arrow { transform: rotate(90deg); }

.series-list { display: none; background: rgba(0,0,0,0.18); }
.comp-item.expanded .series-list { display: block; }

.serie-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 26px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
  white-space: nowrap;
}
.serie-item:hover { background: var(--sidebar-hover); }
.serie-item.active { background: var(--sidebar-active); color: #fff; }
.serie-icon { font-size: 0.8rem; flex-shrink: 0; }
.serie-label { font-size: 0.8rem; flex: 1; }

/* compteur PDF dans la sidebar */
.pdf-count {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 99px;
  flex-shrink: 0;
  font-weight: 600;
  background: #334155;
  color: #94a3b8;
}
.pdf-count.complete { background: #14532d; color: #86efac; }

/* ── CONTENT ── */
#content { flex: 1; overflow-y: auto; padding: 32px 40px; }

#welcome-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--muted);
}
#welcome-msg .welcome-icon { font-size: 3rem; }
#welcome-msg p { font-size: 1rem; }

#serie-view { display: none; }

#back-home-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 18px;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
#back-home-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

#serie-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 24px;
}

/* ── TABLE ── */
.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
#shooters-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  min-width: 480px;
}
#shooters-table th {
  background: var(--accent);
  color: #fff;
  padding: 11px 16px;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}
#shooters-table td {
  padding: 10px 16px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
}
#shooters-table tr:last-child td { border-bottom: none; }
#shooters-table tbody tr:hover { background: #f8fafc; }

.pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  border: none;
  cursor: pointer;
}
.pdf-btn.available { background: #dcfce7; color: #16a34a; }
.pdf-btn.available:hover { background: #bbf7d0; }
.pdf-btn.unavailable { background: #f1f5f9; color: var(--gray); cursor: default; font-style: italic; }

/* ── HOME VIEW — CARDS ── */
#home-view { padding: 0; }

.home-header {
  margin-bottom: 28px;
}
.home-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.home-header p { font-size: 0.88rem; color: var(--muted); }

.comp-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.comp-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px 18px;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  display: flex;
  flex-direction: column;
  gap: 14px;
  user-select: none;
}
.comp-card:hover {
  box-shadow: 0 6px 24px rgba(59,130,246,0.13);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.comp-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.comp-card-icon {
  font-size: 1.8rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}
.comp-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
}

.comp-card-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.comp-card-stat {
  font-size: 0.74rem;
  background: #f1f5f9;
  border-radius: 6px;
  padding: 4px 10px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.comp-card-series {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.comp-card-serie-badge {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 99px;
  font-weight: 500;
  background: #e2e8f0;
  color: var(--muted);
}
.comp-card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.comp-card-cta {
  font-size: 0.77rem;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 4px;
}

.comp-cards-empty {
  grid-column: 1/-1;
  text-align: center;
  color: var(--muted);
  padding: 48px 0;
  font-size: 0.95rem;
}

#generated-at {
  position: fixed;
  bottom: 8px;
  right: 14px;
  font-size: 0.68rem;
  color: var(--muted);
  opacity: 0.55;
  pointer-events: none;
}

/* ── SIDEBAR TAB (bouton réouvrir, visible quand sidebar cachée) ── */
#sidebar-tab {
  display: none;
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 200;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border: none;
  border-radius: 0 8px 8px 0;
  padding: 18px 9px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  box-shadow: 2px 0 10px rgba(0,0,0,0.3);
  transition: background var(--transition);
  align-items: center;
  justify-content: center;
}
#sidebar-tab:hover { background: var(--sidebar-hover); }
#sidebar-tab.visible { display: flex; }

/* ── RESPONSIVE ── */
@media (max-width: 640px) {
  :root { --sidebar-w: 260px; }
  #content { padding: 16px; }
  #serie-title { font-size: 1.1rem; }
  #sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 200;
  }
  .overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 150;
  }
  .overlay.visible { display: block; }
}
