/* ═════════════════════════════════════════════════════════════════
   SIMULATEUR DE PRESTATIONS DE RÉNOVATION — page autonome
   ═════════════════════════════════════════════════════════════════ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Space Grotesk',
               Roboto, Helvetica, Arial, sans-serif;
  color: #0f172a;
  background: #f1f5f9;
  line-height: 1.45;
  min-height: 100vh;
}

/* ─── Header ─── */
.p-header {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #fff;
  padding: 1.3rem 2rem;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: 1rem;
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
}
.p-header-main { display: flex; align-items: center; gap: 1.4rem; min-width: 0; }
.p-back {
  color: #94a3b8; text-decoration: none; font-size: .85rem; font-weight: 600;
  padding: .45rem .85rem; border-radius: 8px; background: rgba(255,255,255,.06);
  transition: background .18s;
  white-space: nowrap;
}
.p-back:hover { background: rgba(255,255,255,.14); color: #fff; }
.p-brand { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.p-brand-icon {
  font-size: 2rem;
  width: 54px; height: 54px;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 8px 22px rgba(14,165,233,.35);
}
.p-title { margin: 0; font-size: 1.25rem; font-weight: 700; line-height: 1.15; font-family: 'Space Grotesk', sans-serif; }
.p-subtitle { font-size: .8rem; color: #cbd5e1; margin-top: .2rem; }
.p-subtitle strong { color: #fff; }

.p-header-meta { display: flex; gap: .8rem; flex-wrap: wrap; }
.p-meta-link {
  display: flex; flex-direction: column; gap: .1rem;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  padding: .55rem .85rem;
  text-decoration: none; color: #fff;
  transition: background .18s, border-color .18s;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.p-meta-link:hover { background: rgba(255,255,255,.14); border-color: rgba(14,165,233,.6); }
.p-meta-lbl { font-size: .68rem; color: #94a3b8; text-transform: uppercase; letter-spacing: .04em; }
.p-meta-val { font-size: 1.25rem; font-weight: 700; color: #38bdf8; line-height: 1; }
.p-meta-sub { font-size: .64rem; color: #94a3b8; }

/* ─── Toolbar ─── */
.p-toolbar {
  background: #fff;
  padding: 1rem 2rem;
  display: grid;
  grid-template-columns: minmax(200px, 2fr) repeat(4, minmax(150px, 1fr)) auto;
  gap: .8rem;
  align-items: end;
  box-shadow: 0 1px 0 #e2e8f0;
  position: sticky; top: 0; z-index: 50;
}
.p-field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.p-field label {
  font-size: .7rem; font-weight: 700; color: #475569;
  text-transform: uppercase; letter-spacing: .04em;
}
.p-field input, .p-field select {
  padding: .55rem .75rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: .88rem;
  background: #fff;
  font-family: inherit;
  color: #0f172a;
  transition: border-color .18s, box-shadow .18s;
  min-width: 0;
  width: 100%;
}
.p-field input:focus, .p-field select:focus {
  outline: none;
  border-color: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14,165,233,.18);
}
.p-field-search input { font-size: .95rem; }
.p-field-filters { display: flex; align-items: flex-end; padding-bottom: .3rem; }
.p-chip-toggle {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: .82rem; color: #334155; cursor: pointer;
  padding: .55rem .8rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  transition: background .18s, border-color .18s;
  white-space: nowrap;
}
.p-chip-toggle:hover { background: #e0f2fe; border-color: #0ea5e9; }
.p-chip-toggle input { accent-color: #0ea5e9; }

/* ─── Légende badges ─── */
.p-legend {
  display: flex; flex-wrap: wrap; gap: .5rem;
  padding: .85rem 2rem; background: #fff; border-bottom: 1px solid #e2e8f0;
  font-size: .7rem;
}
.p-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .55rem; border-radius: 6px;
  font-size: .68rem; font-weight: 700; letter-spacing: .02em;
  white-space: nowrap;
}
.p-badge-green   { background: #d1fae5; color: #047857; }
.p-badge-cyan    { background: #cffafe; color: #0e7490; }
.p-badge-purple  { background: #ede9fe; color: #6d28d9; }
.p-badge-orange  { background: #fed7aa; color: #c2410c; }

/* ─── Grille principale ─── */
.p-grid {
  padding: 1.5rem 2rem 6rem;
  display: flex; flex-direction: column; gap: 1.8rem;
}
.p-loading, .p-empty {
  background: #fff; border-radius: 12px;
  padding: 2.5rem 1.5rem; text-align: center;
  color: #64748b; font-size: .95rem;
  box-shadow: 0 2px 8px rgba(15,23,42,.05);
}
.p-empty.p-error { color: #dc2626; }

/* Sections de catégories */
.p-cat-section { }
.p-cat-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem; font-weight: 700; color: #0f172a;
  margin: 0 0 .8rem;
  display: flex; align-items: center; gap: .6rem;
}
.p-cat-title span:first-child { font-size: 1.4rem; }
.p-cat-count {
  font-size: .72rem; color: #64748b;
  background: #fff; border: 1px solid #e2e8f0;
  padding: .2rem .55rem; border-radius: 999px;
  font-weight: 600;
}
.p-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: .9rem;
}

/* Carte prestation */
.p-card {
  background: #fff; border-radius: 12px;
  padding: 1rem 1.1rem;
  box-shadow: 0 2px 8px rgba(15,23,42,.05);
  border-left: 3px solid #cbd5e1;
  display: flex; flex-direction: column; gap: .5rem;
  transition: transform .15s, box-shadow .2s;
}
.p-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(15,23,42,.1); }
.p-card-blue    { border-left-color: #0ea5e9; }
.p-card-orange  { border-left-color: #f59e0b; }
.p-card-purple  { border-left-color: #8b5cf6; }
.p-card-amber   { border-left-color: #d97706; }
.p-card-cyan    { border-left-color: #06b6d4; }
.p-card-yellow  { border-left-color: #eab308; }
.p-card-green   { border-left-color: #10b981; }
.p-card-indigo  { border-left-color: #6366f1; }
.p-card-slate   { border-left-color: #64748b; }
.p-card-sky     { border-left-color: #0284c7; }
.p-card-stone   { border-left-color: #78716c; }
.p-card-emerald { border-left-color: #059669; }

.p-card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: .5rem; flex-wrap: wrap;
}
.p-card-cat {
  font-size: .68rem; font-weight: 700; color: #64748b;
  text-transform: uppercase; letter-spacing: .04em;
  display: flex; align-items: center; gap: .3rem;
}
.p-card-badges { display: flex; flex-wrap: wrap; gap: .25rem; }
.p-card-nom {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem; font-weight: 700; color: #0f172a;
  margin: 0;
  line-height: 1.25;
}
.p-card-desc {
  font-size: .8rem; color: #475569; margin: 0;
  line-height: 1.45;
}
.p-card-price {
  display: flex; align-items: baseline; gap: .4rem;
  padding-top: .4rem; border-top: 1px dashed #e2e8f0;
  margin-top: auto;
}
.p-price-range {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem; font-weight: 700; color: #0369a1; /* U9 — contraste AA (2.77:1 → ~6:1) */
}
.p-price-unit { font-size: .72rem; color: #64748b; }
.p-card-total {
  font-size: .82rem; color: #0f172a;
  background: #f0f9ff; padding: .5rem .7rem;
  border-radius: 8px; border-left: 3px solid #0ea5e9;
}
.p-card-total strong { color: #0ea5e9; font-family: 'Space Grotesk', sans-serif; }
/* Source : discrète, compacte, accessible. Survol = révèle l'origine. */
.p-card-src {
  font-size: .7rem; color: #64748b; /* U9 — contraste AA (2.56:1 → ~4.6:1) */
  text-decoration: none;
  display: inline-flex; align-items: baseline; gap: .35rem;
  margin-top: .15rem;
  padding: .25rem 0;
  border-top: 1px dotted #e2e8f0;
  transition: color .18s;
}
.p-card-src-lbl {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.p-card-src-dom {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  font-size: .62rem;
  color: #cbd5e1;
  padding: .08rem .35rem;
  border-radius: 4px;
  background: #f8fafc;
  flex-shrink: 0;
}
.p-card-src-icon {
  font-size: .75rem;
  color: #cbd5e1;
  transition: transform .18s, color .18s;
  flex-shrink: 0;
}
.p-card-src:hover {
  color: #0ea5e9;
}
.p-card-src:hover .p-card-src-dom {
  color: #0ea5e9; background: #e0f2fe;
}
.p-card-src:hover .p-card-src-icon {
  color: #0ea5e9; transform: translate(1px, -1px);
}

/* ─── Footer ─── */
.p-footer {
  background: #fff;
  border-top: 1px solid #e2e8f0;
  padding: 1rem 2rem;
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; flex-wrap: wrap;
  position: sticky; bottom: 0; z-index: 50;
  box-shadow: 0 -2px 8px rgba(15,23,42,.04);
}
.p-footer-left { font-size: .75rem; color: #64748b; flex: 1; min-width: 250px; }
.p-footer-left strong { color: #0f172a; }
.p-src-link { color: #0ea5e9; text-decoration: none; margin-right: .2rem; }
.p-src-link:hover { text-decoration: underline; }
.p-footer-right { display: flex; gap: .6rem; }
.p-btn {
  padding: .6rem 1.1rem; border-radius: 10px; border: none;
  font-size: .82rem; font-weight: 700; cursor: pointer;
  transition: opacity .18s, transform .12s;
}
.p-btn-ghost {
  background: #fff; color: #334155; border: 1px solid #cbd5e1;
}
.p-btn-ghost:hover { background: #f1f5f9; }
.p-btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  color: #fff;
  box-shadow: 0 4px 12px rgba(14,165,233,.3);
}
.p-btn-primary:hover { opacity: .92; transform: translateY(-1px); }

/* ─── Impression ─── */
@media print {
  .p-toolbar, .p-footer, .p-back, .p-legend { display: none !important; }
  .p-header { background: #0f172a !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; }
  .p-card { break-inside: avoid; page-break-inside: avoid; box-shadow: none; border: 1px solid #cbd5e1; }
  .p-grid { padding: 1rem; }
}

/* ─── Responsive ─── */
@media (max-width: 960px) {
  .p-toolbar { grid-template-columns: 1fr 1fr; padding: 1rem; }
  .p-field-filters { grid-column: 1 / -1; }
  .p-header, .p-grid, .p-footer, .p-legend { padding-left: 1rem; padding-right: 1rem; }
  .p-header-meta { width: 100%; }
}
@media (max-width: 560px) {
  .p-toolbar { grid-template-columns: 1fr; }
  .p-brand-icon { width: 42px; height: 42px; font-size: 1.5rem; }
  .p-title { font-size: 1rem; }
  .p-cards { grid-template-columns: 1fr; }
  /* U3 — empêche la carte de dépasser son conteneur (contenu min-content) */
  .p-card { min-width: 0; }
  .p-card-head { min-width: 0; }
  .p-card-nom, .p-card-desc { overflow-wrap: anywhere; }
  /* U11 — footer non-sticky sur mobile (occupait ~40% du viewport) */
  .p-footer { position: static; }
  .p-footer-left { min-width: 0; }
}
