/* ============================================================
   Urbanito - Comparateur interactif + filtres (comparateur.css)
   ============================================================ */

.btn--sm { padding: 8px 14px; font-size: .85rem; }

/* ---- Barre de filtres (comparateur + tests) ---- */
.filter-wrap { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-bottom: 24px; }
.filter-search {
  flex: 1; min-width: 200px;
  font-family: inherit; font-size: .95rem;
  padding: 11px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink);
}
.filter-search:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.filt-btn {
  font-family: inherit; font-weight: 600; font-size: .85rem;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; transition: all .15s ease;
}
.filt-btn:hover { border-color: var(--brand); color: var(--brand-dark); }
.filt-btn--active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---- Liste comparateur ---- */
.cmp-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.cmp-row {
  display: grid; grid-template-columns: 44px 72px 1fr auto auto; align-items: center; gap: 14px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.cmp-row:last-child { border-bottom: none; }
.cmp-row.is-hidden { display: none; }
.cmp-row--disabled { opacity: .4; }
.cmp-row--disabled .cmp-check { cursor: not-allowed; }
.cmp-check__input:disabled + .cmp-check__box { opacity: .5; cursor: not-allowed; }
.cmp-row__media { width: 64px; height: 64px; background: #fff; border-radius: var(--radius-sm); padding: 6px; }
.cmp-row__media img { width: 100%; height: 100%; object-fit: contain; }
.cmp-row__name { display: flex; flex-direction: column; }
.cmp-row__name a { color: var(--ink); font-weight: 700; }
.cmp-row__name a:hover { color: var(--brand); }
.cmp-row__name span { font-size: .8rem; color: var(--muted); }
.cmp-row__badge { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--brand-dark); }

/* ---- Cases à cocher ---- */
.cmp-check { position: relative; display: inline-flex; cursor: pointer; }
.cmp-check__input { position: absolute; opacity: 0; width: 22px; height: 22px; cursor: pointer; }
.cmp-check__box { width: 22px; height: 22px; border: 2px solid var(--line); border-radius: 6px; display: inline-block; transition: all .15s ease; }
.cmp-check__input:checked + .cmp-check__box { background: var(--brand); border-color: var(--brand); }
.cmp-check__input:checked + .cmp-check__box::after { content: "\2713"; color: #fff; font-size: .85rem; font-weight: 800; display: flex; align-items: center; justify-content: center; height: 100%; }
.cmp-check__input:focus-visible + .cmp-check__box { box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---- Barre de sélection (tray) ---- */
.cmp-tray {
  position: sticky; top: 74px; z-index: 30;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--radius); margin-bottom: 16px;
}
.cmp-tray__label { font-weight: 700; font-size: .9rem; }
.cmp-tray__chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.cmp-chip { background: rgba(255,255,255,.14); color: #fff; font-size: .8rem; padding: 4px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; }
.cmp-chip button { background: none; border: none; color: #fff; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0; }
.cmp-tray__clear { background: none; border: none; color: #cfd8d2; cursor: pointer; font-size: .85rem; text-decoration: underline; }

/* ---- Overlay de comparaison ---- */
.cmp-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(17, 32, 27, .55); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh 18px; overflow-y: auto;
  animation: cmpFade .2s ease;
}
.cmp-overlay[hidden] { display: none; }
@keyframes cmpFade { from { opacity: 0; } to { opacity: 1; } }
.cmp-modal {
  position: relative; background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); max-width: 940px; width: 100%; padding: 30px;
  animation: cmpModalIn .26s cubic-bezier(.16,.8,.3,1);
}
@keyframes cmpModalIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.cmp-modal__close {
  position: absolute; top: 14px; right: 16px; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); font-size: 1.6rem; line-height: 1;
  cursor: pointer; color: var(--ink); z-index: 2; transition: background .15s ease;
}
.cmp-modal__close:hover { background: var(--bg-alt); }
.cmp-modal__body h2 { margin-bottom: 8px; padding-right: 44px; }

/* ---- Panneau de comparaison côte à côte ---- */
.cmp-panel { margin-top: 24px; }
.cmp-table-wrap { overflow-x: auto; }
.cmp-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.cmp-table th, .cmp-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .92rem; }
.cmp-table thead th { background: var(--bg-alt); }
.cmp-table .cmp-th-spec { font-weight: 700; color: var(--ink); background: var(--bg-alt); width: 180px; }
.cmp-table__prod img { width: 90px; height: 90px; object-fit: contain; background: linear-gradient(180deg,#fff,#fbfdfb); border-radius: 8px; padding: 6px; }
.cmp-table__prod-name { font-weight: 700; color: var(--ink); display: block; margin: 6px 0; }
.cmp-table td.is-best { background: rgba(31, 163, 104, .1); color: var(--ink); font-weight: 700; }
.cmp-table td.is-best::after { content: " \2605"; color: var(--amazon-dark); font-size: .75em; vertical-align: top; }

@media (max-width: 600px) {
  .cmp-overlay { padding: 0; align-items: stretch; }
  .cmp-modal { border-radius: 0; min-height: 100%; padding: 20px 16px 28px; max-width: none; }
  .cmp-modal__close { top: 10px; right: 10px; }
  .cmp-table__prod img { width: 64px; height: 64px; }
  .cmp-table th, .cmp-table td { padding: 10px 10px; font-size: .85rem; }
}

@media (max-width: 720px) {
  .cmp-row { grid-template-columns: 36px 56px 1fr; grid-template-areas: "check media name" "check media badge" "btn btn btn"; gap: 10px; }
  .cmp-row__media { grid-area: media; width: 52px; height: 52px; }
  .cmp-row__name { grid-area: name; }
  .cmp-row__badge { grid-area: badge; }
  .cmp-row .btn--amazon { grid-area: btn; }
  .cmp-check { grid-area: check; }
}
