/* =========================================================
   COURS — LISTE / GRILLE / FILTRES
   ========================================================= */

/* ----------------------------
   Section et grille
   ---------------------------- */
.courses-grid-section {
  padding: 60px 0;
  background: #ffffff;
}

/* 4 colonnes fixes sur desktop => même si < 4 cours, largeur identique */
.courses-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(260px, 1fr));
  gap: 2rem;
}

/* ----------------------------
   Carte Cours (version épurée)
   ---------------------------- */
.course-card {
  background: #ffffff;
  border: 1px solid #e6e9ee;
  border-radius: 16px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  min-height: 220px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  position: relative;
  color: inherit;
  text-decoration: none;
}
.course-card::before { content: none; }

.course-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 40px rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.22);
}

/* En-tête : niveau + matière */
.course-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .5rem;
}

/* Badge Niveau */
.course-level-badge {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  letter-spacing: 0.2px;
  line-height: 1;
}

/* Badge matière */
.course-subject-badge {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  border: 1px solid transparent;
}

/* Titre / Description */
.course-title {
  font-size: 1.125rem;
  font-weight: 800;
  color: #0f172a;
  margin: 6px 0 .5rem 0;
  line-height: 1.3;
}
.course-title.truncate {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-description {
  color: #475569;
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0 0 1rem 0;
  max-height: 4.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.course-description--empty {
  color: #94a3b8;
  font-style: italic;
}

/* Meta : durée */
.course-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
}
.meta-item {
  display: inline-flex;
  align-items: center;
  font-size: .87rem;
  color: #334155;
  background: #f8fafc;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid #eef2f7;
}

/* CTA */
.course-btn {
  background: #2563eb;
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  transition: background .2s ease, transform .15s ease;
  border: none;
  cursor: pointer;
  line-height: 1;
  margin-top: auto;
}
.course-btn:hover {
  background: #1d4ed8;
  transform: translateY(-2px);
}
.course-btn:focus {
  outline: 3px solid rgba(37, 99, 235, 0.25);
  outline-offset: 2px;
}

/* ----------------------------
   Badges couleurs par niveau
   ---------------------------- */
.level-6e, .level-6eme {
  background: #d1fae5;
  color: #10b981;
  box-shadow: inset 0 -2px 0 rgba(16, 185, 129, 0.06);
}
.level-5e, .level-5eme {
  background: #cffafe;
  color: #06b6d4;
  box-shadow: inset 0 -2px 0 rgba(6, 182, 212, 0.06);
}
.level-4e, .level-4eme {
  background: #dbeafe;
  color: #3b82f6;
  box-shadow: inset 0 -2px 0 rgba(59, 130, 246, 0.06);
}
.level-3e, .level-3eme {
  background: #e0e7ff;
  color: #6366f1;
  box-shadow: inset 0 -2px 0 rgba(99, 102, 241, 0.06);
}
.course-level-badge:not([class*="level-"]) {
  background: #dbeafe;
  color: #2563eb;
}

/* ----------------------------
   Code couleurs par matière
   ---------------------------- */
.subject-biologie {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}
.subject-geologie {
  background: #f5efe6;
  color: #7c5a3c;
  border-color: #ead7c2;
}
.subject-technologie {
  background: #e5f0ff;
  color: #1e40af;
  border-color: #c7ddff;
}
.subject-mathematique {
  background: #efe9ff;
  color: #6d28d9;
  border-color: #ddd2ff;
}
.subject-physique {
  background: #e0e7ff;
  color: #3730a3;
  border-color: #c7d2fe;
}
.subject-chimie {
  background: #cffafe;
  color: #155e75;
  border-color: #a5f3fc;
}
.subject-physique-chimie {
  background: linear-gradient(90deg, #e0e7ff 0%, #cffafe 100%);
  color: #0f172a;
  border-color: #c7d2fe;
}
.course-subject-badge:not([class*="subject-"]) {
  background: #f1f5f9;
  color: #334155;
  border-color: #e2e8f0;
}

/* =========================================================
   FILTRES DESKTOP / MOBILE
   ========================================================= */
.only-desktop { display: block; }
.only-mobile  { display: none; }

/* wrapper */
.search-filters{
  display:flex;
  justify-content:center;
}

/* =========================================================
   DESKTOP : recherche + filtres à côté (stable)
   ========================================================= */
.search-bar.only-desktop{
  width: 100%;
  max-width: 1100px;
}

.search-bar__row{
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ✅ BARRE IDENTIQUE (sans bouton bleu à droite) */
.search-box { position: relative; max-width: none; width: 100%; flex: 1 1 460px; }
.search-box input[type="search"],
.search-box input[type="text"] {
  width: 100%;
  height: 46px;
  padding: 12px 50px 12px 16px; /* place pour l’icône */
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  font-size: 1rem;
  background: #fff;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.search-box input[type="search"]:focus,
.search-box input[type="text"]:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}

.search-box button{
  position:absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: #6b7280;
  line-height: 0;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  transition: color .2s ease, background .2s ease;
}
.search-box button:hover { color: #2563eb; background: #f3f4f6; }
.search-box button svg { width: 20px; height: 20px; display: block; }

.search-bar__filter{
  flex: 0 0 auto;
}

.search-bar__select{
  height: 46px;
  min-width: 170px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 0 .9rem;
  background: #ffffff;
  font-size: .98rem;
  cursor: pointer;
}

/* label invisible */
.sr-only{
  position:absolute;
  width:1px;height:1px;
  padding:0;margin:-1px;
  overflow:hidden;clip:rect(0,0,0,0);
  white-space:nowrap;border:0;
}

/* =========================================================
   MOBILE : panneau <details> (inchangé)
   ========================================================= */
.filters-mobile { width: 100%; }

.filters-mobile__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .8rem 1rem;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  font-weight: 700;
  color: #2563eb;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.filters-mobile[open] .filters-mobile__toggle {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.filters-mobile__panel {
  border: 1px solid #e5e7eb;
  border-top: none;
  background: #ffffff;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  padding: 14px;
}

.filters-mobile__form {
  display: grid;
  gap: 12px;
}

.fm-label {
  font-size: .92rem;
  font-weight: 600;
  color: #334155;
}

.fm-input,
.fm-select {
  width: 100%;
  height: 44px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0 .9rem;
  background: #ffffff;
  font-size: .98rem;
}

.fm-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.fm-apply {
  height: 44px;
  border: none;
  border-radius: 10px;
  background: #2563eb;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  transition: filter .15s ease, transform .02s ease;
}
.fm-apply:hover { filter: brightness(1.04); }
.fm-apply:active { transform: translateY(1px); }

/* =========================================================
   Responsive grille + switch mobile
   ========================================================= */
@media (max-width: 1200px) {
  .courses-grid { grid-template-columns: repeat(3, minmax(240px, 1fr)); }
}
@media (max-width: 900px) {
  .courses-grid { grid-template-columns: repeat(2, minmax(240px, 1fr)); }
}
@media (max-width: 720px) {
  .only-desktop { display: none !important; }
  .only-mobile  { display: block !important; }
  .fm-row       { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .courses-grid { grid-template-columns: 1fr; }
  .courses-grid-section { padding: 40px 0; }
}
@media (max-width: 420px) {
  .course-card { padding: 1rem; min-height: 210px; }
  .course-title { font-size: 1.05rem; }
  .course-description { font-size: 0.92rem; }
}