:root {
  --sa-accent: #ff9900;
  --sa-accent-hi: #ffae33;
  --sa-bg: #f6f7fb;
  --sa-card: #ffffff;
  --sa-border: #e5e7eb;
  --sa-text: #0b0c0f;
  --sa-muted: #667085;
  --sa-line: #eceff3;
  --sa-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --radius: 16px;
}

/* PAGE */
.brands-page {
  background: #fff;
  color: var(--sa-text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.brands-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 16px;
}

/* HEADER SIMPLE (sans alphabet) */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #fff;
  border-bottom: 1px solid var(--sa-border);
}

.topbar__wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.page-title {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 900;
  letter-spacing: 0.2px;
}

.page-sub {
  color: var(--sa-muted);
  font-size: 0.95rem;
}

/* SEARCH */
.search {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
  justify-content: flex-end;
}

.search input {
  width: 320px;
  max-width: 80vw;
  height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--sa-border);
  border-radius: 12px;
  background: var(--sa-card);
  font-size: 0.95rem;
}

.search button {
  min-width: 92px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--sa-border);
  background: var(--sa-card);
  font-weight: 700;
  cursor: pointer;
}

.search button:hover {
  filter: brightness(1.02);
}

/* GRID */
.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  align-items: stretch;
}

@media (min-width: 560px) {
  .grid {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }
}

@media (min-width: 880px) {
  .grid {
    grid-template-columns: repeat(4, minmax(180px, 1fr));
  }
}

@media (min-width: 1120px) {
  .grid {
    grid-template-columns: repeat(5, minmax(200px, 1fr));
  }
}

@media (min-width: 1360px) {
  .grid {
    grid-template-columns: repeat(6, minmax(200px, 1fr));
  }
}

/* CARD */
.brand-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border: 1px solid var(--sa-border);
  border-radius: 14px;
  background: var(--sa-card);
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease,
    border-color 0.18s ease;
  min-height: 250px;
}

.brand-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--sa-shadow);
  border-color: #eaecef;
}

.brand-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.brand-logo {
  width: 96px;
  height: 96px;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--sa-line);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-initial {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1.2rem;
  color: #fff;
  background: linear-gradient(135deg, #ffe0b2, #ffb74d);
}

.brand-name {
  font-weight: 800;
  text-align: center;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

/* CTA : deux boutons systématiques */
.brand-cta {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: space-between;
  margin-top: auto;
}

.btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--sa-border);
  background: #fff;
  color: var(--sa-text);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  filter: brightness(1.02);
}

.btn.primary {
  border-color: transparent;
  background: linear-gradient(180deg, var(--sa-accent-hi), var(--sa-accent));
  color: #fff;
}

.btn.secondary {
  background: #fff;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* MOBILE FINESSE */
@media (max-width: 560px) {
  .page-title {
    font-size: 1.35rem;
  }

  .brand-card {
    padding: 14px;
    min-height: 230px;
  }

  .brand-logo {
    width: 84px;
    height: 84px;
    border-radius: 12px;
  }
}

/* SKELETONS */
.skeleton {
  position: relative;
  overflow: hidden;
  background: #f3f4f6;
  border: 1px solid var(--sa-border);
  border-radius: 14px;
  min-height: 250px;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.5),
    transparent
  );
  transform: translateX(-100%);
  animation: sweep 1.2s infinite;
}

@keyframes sweep {
  to {
    transform: translateX(100%);
  }
}

.skeleton .sk-logo {
  width: 96px;
  height: 96px;
  border-radius: 14px;
  background: #e5e7eb;
  margin: 16px auto;
}

.skeleton .sk-line {
  height: 12px;
  background: #e5e7eb;
  border-radius: 6px;
  margin: 10px 20px;
}

.skeleton .sk-cta {
  height: 36px;
  background: #e5e7eb;
  border-radius: 10px;
  margin: 14px 16px;
}

/* LIST STATES */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin: 14px 0 10px;
}

.section-head .page-sub b {
  color: var(--sa-text);
}

.loadbar {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}

.loadbar button {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 800;
  border: 1px solid var(--sa-border);
  background: var(--sa-card);
  cursor: pointer;
}

.loadbar button:hover {
  filter: brightness(1.02);
}

.loadbar button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.empty,
.error {
  border: 1px solid var(--sa-border);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  color: var(--sa-muted);
  background: var(--sa-card);
}

.brands-page {
  padding-top: 50px;
}

/* --- Topbar améliorée --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--sa-border);
  backdrop-filter: saturate(120%) blur(8px);
}

.topbar__wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.tb-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.page-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 900;
}

.tb-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--sa-accent-hi), var(--sa-accent));
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
}

.page-sub {
  color: var(--sa-muted);
  font-size: 0.95rem;
  white-space: nowrap;
}

.tb-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Search avec loupe + Clear */
.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--sa-card);
  border: 1px solid var(--sa-border);
  border-radius: 12px;
  padding: 6px;
  height: 42px;
}

.search input {
  width: 280px;
  max-width: 60vw;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 0.95rem;
}

.search .btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--sa-border);
  background: #fff;
  font-weight: 700;
}

.btn.primary {
  border-color: transparent;
  background: linear-gradient(180deg, var(--sa-accent-hi), var(--sa-accent));
  color: #fff;
}

.search-icon {
  position: relative;
  left: 2px;
  font-size: 1rem;
  opacity: 0.7;
}

.search-clear {
  border: 0;
  background: transparent;
  font-size: 1rem;
  opacity: 0.6;
  cursor: pointer;
  padding: 0 6px;
}

.search-clear:hover {
  opacity: 0.9;
}

/* Sort */
.sort select {
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--sa-border);
  border-radius: 12px;
  background: var(--sa-card);
  font-weight: 600;
}

/* Accessibilité */
.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 */
@media (max-width: 640px) {
  .topbar__wrap {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .tb-left {
    justify-content: space-between;
  }

  .page-title {
    font-size: 1.35rem;
  }

  .search {
    width: 100%;
  }

  .search input {
    max-width: 100%;
  }

  .tb-right {
    flex-direction: column;
    align-items: stretch;
  }

  .sort select {
    width: 100%;
  }
}

/* ✅ Empêche le débordement dans le groupe de recherche */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  /* <— coupe ce qui dépasse */
}

.search input {
  flex: 1 1 auto;
  /* <— prend tout l’espace dispo */
  min-width: 0;
  /* <— autorise la contraction */
  width: auto;
  /* <— pas de largeur fixe */
  box-sizing: border-box;
  font-size: 16px;
  /* <— évite le zoom iOS */
  line-height: 1.2;
}

/* Boutons ne forcent pas l’input à rétrécir trop */
.search .btn,
.search .search-clear,
.search .search-icon {
  flex: 0 0 auto;
}

/* ✅ Placeholder tronqué proprement */
.search input::placeholder {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.7;
}

/* 🔧 Mobile: espace un peu plus serré */
@media (max-width: 640px) {
  .search {
    gap: 6px;
    padding: 6px;
  }
}

/* .brands-container {
        background-color: #f5f7fa !important;
    } */

.brands-page {
  background: linear-gradient(180deg, #f6f7fb 0%, #ffffff 100%);
}

.search-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  /* gris neutre */
  margin-left: 4px;
}

.search-icon svg {
  width: 18px;
  height: 18px;
}
