/* Evolia — Définition d'outils. Thème bleu profond, cohérent avec l'app. */
:root {
  --bg: #f2f5f9;
  --card: #ffffff;
  --ink: #1c2733;
  --muted: #6b7a89;
  --brand: #1f4e79;
  --brand-dark: #163a5c;
  --accent: #2e7dc2;
  --ok: #1e7e46;
  --ok-bg: #e2f4e9;
  --err: #b3362b;
  --err-bg: #fbe6e3;
  --warn: #9a6b00;
  --warn-bg: #fdf3d7;
  --line: #dde5ee;
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; font-family: "Segoe UI", system-ui, Arial, sans-serif;
  background: var(--bg); color: var(--ink); min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ── Barre du haut ── */
/* Bandeau FIXE en haut de l'écran (demande de Theo, 07/10/2026) : il reste
   visible quand on descend. z-index sous les popups (.modal-overlay = 50). */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; gap: 24px; padding: 10px 22px;
  box-shadow: 0 2px 8px rgba(16, 42, 67, .25);
}
/* Un lien vers une ancre (#finish…) ne doit pas finir caché sous le bandeau. */
html { scroll-padding-top: 90px; }

/* ── Mode démonstration (2026-10-08) ── */
.demo-band {
  background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid #e8cf8a;
  padding: 9px 22px; text-align: center; font-size: .92em;
}
.demo-invite {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.demo-invite strong { color: var(--brand-dark); }
.brand img { display: block; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
  color: #cfe0f0; text-decoration: none; padding: 8px 14px; border-radius: 8px;
  font-weight: 600;
}
.topbar nav a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.topbar nav a.active { background: rgba(255, 255, 255, .16); color: #fff; }
.userbox { display: flex; align-items: center; gap: 12px; }
.userbox .who { font-size: .92em; color: #cfe0f0; }
/* Le nom est un lien vers « Mon compte » : pas de soulignement permanent,
   mais il doit se voir au survol pour qu'on devine qu'il est cliquable. */
a.who { text-decoration: none; }
a.who:hover { color: #fff; text-decoration: underline; }

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px; }
footer { text-align: center; color: var(--muted); font-size: .85em; padding: 14px; }

/* ── Cartes / titres ── */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 18px; box-shadow: 0 1px 3px rgba(20, 40, 60, .05);
}
h1 { font-size: 1.45em; margin: 0; color: var(--brand-dark); }
h2 { font-size: 1.05em; margin: 0 0 12px; color: var(--brand-dark); }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.right { text-align: right; }
.req { color: var(--err); }

/* ── Formulaires ── */
label { display: flex; flex-direction: column; gap: 4px; font-size: .9em; font-weight: 600; color: #33475c; }
input[type=text], input[type=password], select {
  font: inherit; font-weight: 400; padding: 8px 10px; border: 1px solid #c3cfdc;
  border-radius: 8px; background: #fff; min-width: 160px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.form-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.form-row .grow { flex: 1; min-width: 220px; }
.form-row .grow input { width: 100%; }
fieldset {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px 16px; margin: 0 0 14px;
}
legend { font-weight: 700; color: var(--brand); padding: 0 6px; }
.actions { display: flex; gap: 10px; margin-top: 4px; }

/* ── Boutons ── */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-block; padding: 9px 16px; border-radius: 8px;
  border: 1px solid #c3cfdc; background: #fff; color: var(--ink);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-danger { border-color: #dfb8b3; color: var(--err); }
.btn-danger:hover { background: var(--err-bg); border-color: var(--err); }
.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, .4); color: #fff; }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, .12); color: #fff; border-color: #fff; }
main .btn-ghost { border-color: #c3cfdc; color: var(--ink); background: #fff; }
.btn-small { padding: 5px 10px; font-size: .85em; }
.inline { display: inline; }

/* ── Tableaux ── */
table { width: 100%; border-collapse: collapse; font-size: .93em; }
th { text-align: left; color: var(--muted); font-size: .85em; text-transform: uppercase; letter-spacing: .03em; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: #f7fafd; }
a.ref { color: var(--brand); font-weight: 700; text-decoration: none; }
a.ref:hover { text-decoration: underline; }

/* ── Badges / verdicts / flash ── */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .8em; font-weight: 700; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-err { background: var(--err-bg); color: var(--err); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
/* Information neutre (ni bon ni mauvais) : ex. bague de sertissage déduite. */
.badge-info { background: #e3edf8; color: #1d5a91; }

.verdict { margin-top: 14px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid; }
.verdict-ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.verdict-err { background: var(--err-bg); border-color: var(--err); color: var(--err); }
.verdict-warn { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.verdict strong { font-size: 1.05em; }
.verdict div { color: var(--ink); margin-top: 4px; }

.flash { padding: 11px 16px; border-radius: 8px; margin-bottom: 14px; font-weight: 600; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-err { background: var(--err-bg); color: var(--err); }

/* ── Wizard (définition en étapes) ── */
.steps-nav { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 16px; }
.steps-nav .step {
  font-size: .82em; font-weight: 700; color: var(--muted);
  padding: 5px 11px; border-radius: 99px; background: var(--bg);
  border: 1px solid var(--line);
}
.steps-nav .step.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.steps-nav .step.done { color: var(--ok); border-color: var(--ok); background: var(--ok-bg); }
.steps-nav .step.clickable { cursor: pointer; font-family: inherit; font-size: .82em; }
.steps-nav .step.clickable:hover { border-color: var(--brand); color: var(--brand); }
.steps-nav .step-sep { color: var(--muted); }
.radio-group { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin: 12px 0 4px; }
.radio-group .lbl { font-size: .9em; font-weight: 600; color: #33475c; margin-right: 4px; }
.chk { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; cursor: pointer; }
.chk input { cursor: pointer; width: 16px; height: 16px; }
.compose {
  margin-top: 14px; padding: 12px 16px; border-radius: var(--radius);
  background: #eef4fb; border: 1px solid var(--accent); color: var(--ink);
}
.compose .bague-line { margin-top: 6px; }
.recap-row { display: flex; gap: 14px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.recap-row .muted { width: 130px; flex-shrink: 0; }
.finish-bar { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.finish-bar form { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }

/* ── Nez et accessoires (pièces détachées) ── */
.parts-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.parts-head h2 { margin: 0; }
.parts-layout { display: flex; gap: 20px; align-items: flex-start; }
.datasheet { width: 40%; flex-shrink: 0; }
.datasheet-frame {
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
  min-height: 320px; display: flex; align-items: center; justify-content: center;
  padding: 12px; overflow: hidden;
}
.datasheet-frame { overflow: hidden; }
.datasheet-frame img { max-width: 100%; max-height: 460px; object-fit: contain; }
/* Zoom au survol (datasheets des nez) : l'image s'agrandit à l'endroit du
   curseur. Curseur = la loupe standard du navigateur (zoom-in). */
.datasheet-frame img.zoomable {
  transition: transform .12s ease-out;
  cursor: zoom-in;
}
.ds-placeholder { text-align: center; }
.ds-ref { font-size: 1.4em; font-weight: 700; color: var(--brand-dark); margin-bottom: 8px; }
.datasheet .muted.small { margin-top: 8px; }
.parts-list { flex: 1; min-width: 0; }
.part-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 7px; background: #fff;
}
.part-row.picked { border-color: var(--brand); background: #eef4fb; }
.part-cat { font-size: .8em; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 700; }
.part-ref { font-weight: 700; color: var(--ink); }
.qty-ctrl { display: flex; align-items: center; gap: 10px; }
.qbtn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid #c3cfdc;
  background: #fff; font-size: 1.15em; font-weight: 700; cursor: pointer; color: var(--brand);
}
.qbtn:hover { border-color: var(--brand); background: #eef4fb; }
.qval { min-width: 24px; text-align: center; font-weight: 700; }

@media (max-width: 860px) {
  .parts-layout { flex-direction: column; }
  .datasheet { width: 100%; }
}

/* ── Saisie filtrante (référence rivet) ── */
.has-panel { position: relative; }
.filter-panel {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30; margin-top: 4px;
  background: #fff; border: 1px solid var(--accent); border-radius: 8px;
  max-height: 250px; overflow-y: auto;
  box-shadow: 0 10px 28px rgba(20, 40, 60, .18);
}
.filter-item { padding: 8px 12px; cursor: pointer; font-weight: 600; font-size: .92em; }
.filter-item:hover { background: #eef4fb; color: var(--brand); }
.filter-empty { padding: 10px 12px; color: var(--muted); font-style: italic; }

/* ── Éclaté machine interactif ── */
.mfig-layout { display: flex; gap: 18px; align-items: flex-start; }
.mfig-fig { flex: 1.4; min-width: 0; }
.mfig-wrap { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.mfig-wrap img { display: block; width: 100%; height: auto; }
.hotspot {
  position: absolute; background: rgba(46, 125, 194, .12);
  border: 1.5px solid rgba(46, 125, 194, .55); border-radius: 4px;
  cursor: pointer; padding: 0;
}
.hotspot:hover { background: rgba(46, 125, 194, .3); border-color: var(--brand); }
.hotspot.sel { background: rgba(22, 163, 74, .25); border-color: var(--ok); }
.hotspot.hit { background: rgba(22, 163, 74, .55); }
.mfig-list { width: 380px; flex-shrink: 0; }
.mfig-rows { max-height: 560px; overflow-y: auto; padding-right: 4px; }

@media (max-width: 980px) {
  .mfig-layout { flex-direction: column; }
  .mfig-list { width: 100%; }
}

/* ── Animation de chargement des aperçus (datasheets / éclatés) ── */
.ds-spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--brand);
  animation: dsspin .8s linear infinite;
}
.mfig-wrap .ds-spinner {
  position: absolute; left: 50%; top: 120px; margin-left: -23px;
}
@keyframes dsspin { to { transform: rotate(360deg); } }

/* ── Popup de confirmation ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(16, 32, 48, .55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: var(--card); border-radius: 14px; padding: 26px 30px;
  max-width: 440px; width: 100%; text-align: center;
  box-shadow: 0 18px 50px rgba(10, 25, 40, .35);
}
.modal-icon {
  width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 50%;
  background: var(--ok-bg); color: var(--ok); font-size: 26px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.modal-box h3 { margin: 0 0 8px; color: var(--brand-dark); font-size: 1.15em; }
.modal-box p { margin: 0 0 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }

/* ── Login ── */
.login-wrap { display: flex; justify-content: center; padding-top: 6vh; }
.login-card { width: 380px; text-align: center; }
.login-logo { height: 52px; margin: 10px 0 4px; }
.login-card h1 { font-size: 1.25em; }
.login-card form { display: flex; flex-direction: column; gap: 12px; text-align: left; margin-top: 14px; }
.login-card .btn { margin-top: 6px; }

/* Inscription (register.php) : 8 champs -> carte plus large que le login et
   champs groupes deux par deux. Repasse sur une colonne en etroit. */
.register-card { width: 560px; max-width: 100%; }
.register-card .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 620px) { .register-card .grid2 { grid-template-columns: 1fr; } }

.devis-info { display: flex; flex-wrap: wrap; gap: 8px 32px; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  main { padding: 12px; }
  .form-row { flex-direction: column; align-items: stretch; }
  input[type=text], input[type=password], select { min-width: 0; width: 100%; }
}

/* ── Machine multi-vues : grille de cartes + apercu au survol ── */
.views-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.view-card {
  display: flex; align-items: center; justify-content: center; text-align: center;
  width: 150px; height: 86px; padding: 10px;
  background: #fff; border: 2px solid var(--line); border-radius: 10px;
  font-weight: 700; color: var(--brand); text-decoration: none;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.view-card:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 22px rgba(20, 40, 60, .16);
  transform: translateY(-2px);
}
#viewPreview {
  position: absolute; z-index: 60; pointer-events: none;
  background: #fff; border: 1px solid var(--accent); border-radius: 10px;
  box-shadow: 0 14px 36px rgba(20, 40, 60, .25); padding: 6px;
}
#viewPreview img { display: block; max-width: 340px; max-height: 260px; }
