/* ============================================================
   MOTOPARTS — Catalogue de pièces moto
   Direction : « atelier nocturne ». Carbone profond, braises
   orange, titres condensés mécaniques, données en chasse fixe.
   Le décor 3D (js/scene3d.js) vit derrière un voile qui
   garantit la lisibilité du contenu.
   ============================================================ */

:root {
  --fond:      #0c1116;
  --fond-2:    #10171e;
  --surface:   rgba(24, 34, 43, 0.72);
  --surface-pleine: #18222b;
  --surface-2: #1e2a34;
  --ligne:     #28353f;
  --ligne-claire: #36454f;
  --texte:     #eef4f2;
  --texte-2:   #a3b6c6;
  --texte-3:   #62707b;
  --accent:    #f4581c;
  --accent-2:  #ff7a3d;
  --accent-3:  #ffb066;
  --ok:        #35c97e;
  --erreur:    #ff5e5e;
  --radius:    14px;
  --titres:    "Barlow Condensed", system-ui, sans-serif;
  --corps:     system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono:      ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ombre:     0 22px 50px rgba(0, 0, 0, 0.5);
  --lueur:     0 0 0 1px rgba(244, 88, 28, 0.5), 0 12px 40px rgba(244, 88, 28, 0.22);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font: 16px/1.55 var(--corps);
  color: var(--texte);
  background: var(--fond);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Décor 3D animé + voile de lisibilité (sous tout le contenu) */
#scene3d {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  display: block;
  pointer-events: none;
}
.voile {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(12, 17, 22, 0.92) 0%, rgba(12, 17, 22, 0.35) 45%, transparent 70%),
    radial-gradient(100% 100% at 50% 120%, rgba(244, 88, 28, 0.10), transparent 55%),
    linear-gradient(180deg, rgba(12, 17, 22, 0.55), rgba(12, 17, 22, 0.25) 40%, rgba(12, 17, 22, 0.75));
}

::selection { background: var(--accent); color: #fff; }
img { display: block; max-width: 100%; }

/* ---------- Animations d'apparition ---------- */
@keyframes monter {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}
@keyframes surgir {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--ligne-claire);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--texte);
  font: 600 0.92rem/1 var(--corps);
  padding: 0.72rem 1.1rem;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.12s, box-shadow 0.2s, color 0.18s;
}
.btn:hover { border-color: var(--texte-3); background: #243140; }
.btn:active { transform: translateY(1px); }

.btn-principal {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 24px rgba(244, 88, 28, 0.28);
}
.btn-principal:hover {
  box-shadow: 0 10px 30px rgba(244, 88, 28, 0.45);
  transform: translateY(-1px);
}

.btn-danger { color: var(--erreur); border-color: rgba(255, 94, 94, 0.4); background: transparent; }
.btn-danger:hover { background: rgba(255, 94, 94, 0.12); border-color: var(--erreur); }

.btn-discret { background: transparent; color: var(--texte-2); }
.btn-discret:hover { color: var(--texte); }

.btn-petit { padding: 0.45rem 0.75rem; font-size: 0.82rem; border-radius: 8px; }

:where(button, a, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- En-tête ---------- */
.entete {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(12, 17, 22, 0.66);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--ligne);
}
.marque { display: flex; align-items: baseline; gap: 0.55rem; text-decoration: none; color: inherit; }
.marque-nom {
  font: 700 1.5rem/1 var(--titres);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.marque-nom em { color: var(--accent); font-style: normal; }
.marque-sous { font: 0.7rem/1 var(--mono); color: var(--texte-3); letter-spacing: 0.14em; text-transform: uppercase; }
.entete-actions { margin-left: auto; display: flex; gap: 0.6rem; align-items: center; }
.lien-admin {
  color: var(--texte-2);
  text-decoration: none;
  font: 600 0.85rem/1 var(--corps);
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--ligne-claire);
  border-radius: 10px;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}
.lien-admin:hover { color: var(--texte); border-color: var(--accent); background: rgba(244, 88, 28, 0.08); }

/* ---------- Héros ---------- */
.heros {
  position: relative;
  padding: clamp(3rem, 9vw, 6rem) clamp(1rem, 4vw, 2.5rem) clamp(1.8rem, 4vw, 2.8rem);
  max-width: 1180px;
  margin: 0 auto;
}
.heros-kicker {
  font: 600 0.78rem/1.4 var(--mono);
  color: var(--accent-2);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin: 0 0 1rem;
  animation: monter 0.6s 0.05s both;
}
.heros h1 {
  margin: 0 0 0.9rem;
  font: 600 clamp(2.8rem, 8.5vw, 5.2rem)/0.96 var(--titres);
  text-transform: uppercase;
  letter-spacing: 0.012em;
  text-shadow: 0 4px 40px rgba(0, 0, 0, 0.6);
  animation: monter 0.7s 0.13s both;
}
.heros h1 em {
  font-style: normal;
  background: linear-gradient(135deg, var(--accent-3), var(--accent) 55%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 26px rgba(244, 88, 28, 0.35));
}
.heros p {
  margin: 0;
  max-width: 54ch;
  color: var(--texte-2);
  font-size: 1.05rem;
  animation: monter 0.7s 0.22s both;
}

/* ---------- Barre d'outils ---------- */
.outils {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2.5rem) 1.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
  animation: monter 0.7s 0.3s both;
}
.champ-recherche {
  flex: 1 1 260px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--ligne-claire);
  border-radius: 12px;
  padding: 0 0.95rem;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.champ-recherche:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(244, 88, 28, 0.15); }
.champ-recherche svg { flex: none; color: var(--texte-3); }
.champ-recherche input {
  flex: 1; background: none; border: none; color: var(--texte);
  font: 0.95rem var(--corps); padding: 0.82rem 0; outline: none;
}
.champ-recherche input::placeholder { color: var(--texte-3); }

select {
  appearance: none;
  background: var(--surface) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a3b6c6' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 0.9rem center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--ligne-claire);
  border-radius: 12px;
  color: var(--texte);
  font: 0.95rem var(--corps);
  padding: 0.82rem 2.4rem 0.82rem 0.95rem;
  cursor: pointer;
  transition: border-color 0.18s;
}
select:hover, select:focus { border-color: var(--accent); }

.compteur {
  width: 100%;
  font: 600 0.72rem/1 var(--mono);
  color: var(--texte-3);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* ---------- Grille & cartes produit ---------- */
.zone-catalogue { max-width: 1180px; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2.5rem) 3.5rem; }
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.1rem; }

.carte {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  border: 1px solid var(--ligne);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.22s, border-color 0.22s, box-shadow 0.22s;
  animation: surgir 0.5s both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
.carte:hover {
  transform: translateY(-5px);
  border-color: rgba(244, 88, 28, 0.6);
  box-shadow: var(--lueur);
}
.carte-visuel { position: relative; aspect-ratio: 4 / 3; background: var(--fond-2); overflow: hidden; }
.carte-visuel img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.carte:hover .carte-visuel img { transform: scale(1.06); }
.carte-visuel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 52%, rgba(12, 17, 22, 0.6));
  pointer-events: none;
}
.badge {
  position: absolute; z-index: 1; top: 0.7rem; left: 0.7rem;
  font: 700 0.62rem/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent-2);
  background: rgba(12, 17, 22, 0.82);
  border: 1px solid rgba(244, 88, 28, 0.5);
  border-radius: 999px; padding: 0.32rem 0.6rem;
}
.carte-corps { padding: 0.95rem 1rem 1.05rem; display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
.carte-nom { margin: 0; font: 600 1.22rem/1.15 var(--titres); letter-spacing: 0.01em; }
.carte-marque { margin: 0; font: 0.8rem var(--corps); color: var(--texte-2); }
.carte-pied { margin-top: auto; padding-top: 0.7rem; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.carte-prix { font: 700 1.05rem var(--mono); color: var(--accent-2); }
.carte-lien { font: 600 0.78rem/1 var(--corps); color: var(--texte-2); display: inline-flex; align-items: center; gap: 0.3rem; }
.carte:hover .carte-lien { color: var(--texte); }

/* ---------- Squelettes de chargement ---------- */
.squelette { border-radius: var(--radius); border: 1px solid var(--ligne); overflow: hidden; background: var(--surface); }
.squelette > div {
  height: 100%; min-height: 270px;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.05) 50%, transparent 70%) var(--surface-pleine);
  background-size: 220% 100%;
  animation: miroiter 1.3s infinite linear;
}
@keyframes miroiter { to { background-position: -120% 0; } }

/* ---------- États vides / erreurs ---------- */
.etat {
  text-align: center; padding: 3.5rem 1rem; color: var(--texte-2);
  border: 1px dashed var(--ligne); border-radius: var(--radius);
  background: rgba(16, 23, 30, 0.5);
}
.etat strong { color: var(--texte); font-family: var(--titres); font-size: 1.4rem; letter-spacing: 0.02em; }
.etat p { margin: 0.4rem 0 0; }
.masque { display: none !important; }

/* ---------- Dialogues ---------- */
dialog {
  width: min(640px, calc(100vw - 2rem));
  border: 1px solid var(--ligne-claire);
  border-radius: 18px;
  background: rgba(14, 20, 26, 0.92);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  color: var(--texte);
  padding: 0;
  box-shadow: var(--ombre);
}
dialog::backdrop { background: rgba(5, 8, 11, 0.72); backdrop-filter: blur(5px); }
dialog[open] { animation: surgir 0.24s ease-out; }

.dialogue-entete { display: flex; align-items: flex-start; gap: 1rem; padding: 1.2rem 1.4rem 0.9rem; }
.dialogue-entete h2 { margin: 0; font: 600 1.7rem/1.05 var(--titres); letter-spacing: 0.01em; }
.dialogue-sous { margin: 0.2rem 0 0; color: var(--texte-2); font-size: 0.88rem; }
.btn-fermer {
  margin-left: auto; flex: none; width: 2.2rem; height: 2.2rem;
  display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--ligne-claire); background: transparent; color: var(--texte-2);
  font-size: 1rem; cursor: pointer; transition: color 0.18s, border-color 0.18s;
}
.btn-fermer:hover { color: var(--texte); border-color: var(--texte-3); }
.dialogue-corps { padding: 0 1.4rem 1.4rem; }

.detail-visuel { aspect-ratio: 16 / 8; border-radius: 12px; overflow: hidden; border: 1px solid var(--ligne); background: var(--fond); }
.detail-visuel img { width: 100%; height: 100%; object-fit: cover; }
.detail-prix { font: 700 1.7rem var(--mono); color: var(--accent-2); margin: 0.9rem 0 0.2rem; }
.section-titre {
  font: 700 0.68rem/1 var(--mono); letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--texte-3); margin: 1.2rem 0 0.5rem;
}
.specs { font-family: var(--mono); font-size: 0.88rem; }
.specs div { display: flex; align-items: baseline; gap: 0.6rem; padding: 0.34rem 0; }
.specs .cle { color: var(--texte-2); }
.specs .points { flex: 1; border-bottom: 1px dotted var(--texte-3); transform: translateY(-3px); }
.specs .valeur { color: var(--texte); text-align: right; }
.puces { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.puces span {
  font: 0.8rem var(--corps); color: var(--texte-2);
  border: 1px solid var(--ligne-claire); background: var(--surface-2);
  border-radius: 999px; padding: 0.34rem 0.8rem;
}
.dialogue-actions { display: flex; justify-content: flex-end; gap: 0.6rem; padding: 1rem 1.4rem 1.3rem; border-top: 1px solid var(--ligne); }

/* ---------- Formulaire ---------- */
form .grille-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.champ { display: flex; flex-direction: column; gap: 0.32rem; }
.champ-large { grid-column: 1 / -1; }
.champ label { font: 600 0.74rem/1 var(--corps); letter-spacing: 0.04em; text-transform: uppercase; color: var(--texte-2); }
.champ input, .champ textarea, .champ select {
  background: var(--surface-2); border: 1px solid var(--ligne-claire); border-radius: 10px;
  color: var(--texte); font: 0.95rem var(--corps); padding: 0.72rem 0.85rem;
  transition: border-color 0.18s; width: 100%;
}
.champ textarea { resize: vertical; min-height: 4.6rem; font-family: var(--mono); font-size: 0.87rem; }
.champ input:focus, .champ textarea:focus, .champ select:focus { border-color: var(--accent); outline: none; }
.champ .aide { font-size: 0.76rem; color: var(--texte-3); }
.bloc-attributs {
  grid-column: 1 / -1; border: 1px solid var(--ligne); border-radius: 12px;
  background: rgba(255, 255, 255, 0.025); padding: 0.85rem;
}
.bloc-attributs > label { display: block; font: 600 0.74rem/1 var(--corps); letter-spacing: 0.04em; text-transform: uppercase; color: var(--texte-2); margin-bottom: 0.6rem; }
.ligne-attribut { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.5rem; margin-bottom: 0.5rem; }
.ligne-attribut input { background: var(--surface-2); border: 1px solid var(--ligne-claire); border-radius: 8px; color: var(--texte); font: 0.87rem var(--mono); padding: 0.55rem 0.7rem; }
.ligne-attribut input:focus { border-color: var(--accent); outline: none; }

/* ---------- Notifications ---------- */
#toasts { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 0.5rem; width: min(420px, calc(100vw - 2rem)); }
.toast {
  display: flex; align-items: center; gap: 0.6rem;
  background: rgba(30, 42, 52, 0.95); backdrop-filter: blur(10px);
  border: 1px solid var(--ligne-claire); border-left: 3px solid var(--accent);
  border-radius: 12px; padding: 0.8rem 1rem; font-size: 0.9rem; box-shadow: var(--ombre);
  animation: surgir 0.25s ease-out;
}
.toast.ok { border-left-color: var(--ok); }
.toast.erreur { border-left-color: var(--erreur); }

/* ---------- Pied de page ---------- */
.pied {
  border-top: 1px solid var(--ligne);
  padding: 1.6rem clamp(1rem, 4vw, 2.5rem) 2.2rem;
  display: flex; flex-wrap: wrap; gap: 0.8rem 1.6rem; align-items: center; justify-content: space-between;
  color: var(--texte-3); font-size: 0.85rem;
  background: rgba(12, 17, 22, 0.5);
}
.pied a { color: var(--texte-2); }
.pied .mono { font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.08em; }

/* ============================================================
   ADMINISTRATION
   ============================================================ */
.ecran-connexion { min-height: calc(100vh - 70px); display: grid; place-items: center; padding: 2rem 1rem; }
.carte-connexion {
  width: min(400px, 100%);
  background: rgba(20, 28, 36, 0.82);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border: 1px solid var(--ligne-claire);
  border-radius: 18px; padding: 2.2rem 1.9rem;
  box-shadow: var(--ombre);
  animation: surgir 0.4s both;
}
.carte-connexion h1 { margin: 0 0 0.3rem; font: 600 2.1rem/1 var(--titres); text-transform: uppercase; letter-spacing: 0.02em; }
.carte-connexion h1 em { color: var(--accent); font-style: normal; }
.carte-connexion p { margin: 0 0 1.4rem; color: var(--texte-2); font-size: 0.9rem; }
.message-erreur { margin: 0.8rem 0 0; color: var(--erreur); font-size: 0.86rem; min-height: 1.2em; }

.barre-admin { max-width: 1180px; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 2.5rem) 1rem; display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; }
.barre-admin h1 { margin: 0; font: 600 2.2rem/1 var(--titres); text-transform: uppercase; letter-spacing: 0.02em; }
.barre-admin h1 em { color: var(--accent); font-style: normal; }
.barre-admin .actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 0.55rem; }

.liste-admin { max-width: 1180px; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2.5rem) 3.5rem; display: flex; flex-direction: column; gap: 0.6rem; }
.ligne-produit {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 0.9rem; align-items: center;
  background: var(--surface); backdrop-filter: blur(8px);
  border: 1px solid var(--ligne); border-radius: 12px; padding: 0.6rem 0.8rem;
  transition: border-color 0.18s, transform 0.15s;
}
.ligne-produit:hover { border-color: var(--ligne-claire); transform: translateX(2px); }
.ligne-produit img { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; background: var(--fond); border: 1px solid var(--ligne); }
.ligne-infos { min-width: 0; }
.ligne-infos .nom { font: 600 1.05rem/1.2 var(--titres); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ligne-infos .meta { font: 0.74rem var(--mono); color: var(--texte-2); display: flex; flex-wrap: wrap; gap: 0.3rem 0.7rem; }
.ligne-infos .meta .prix { color: var(--accent-2); font-weight: 700; }
.ligne-actions { display: flex; gap: 0.4rem; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  form .grille-form { grid-template-columns: 1fr; }
  .ligne-produit { grid-template-columns: 52px 1fr; }
  .ligne-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .heros p { font-size: 0.98rem; }
}

/* ---------- Mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .heros-kicker, .heros h1, .heros p, .outils, .carte, .carte-connexion { animation: none !important; opacity: 1 !important; }
}
