/* FisioUP — palette et typo de la planche d'identité (docs/) */
:root {
  --navy: #0B2E4F;
  --teal: #00BFA6;
  --teal-dark: #009A86;
  --mint: #A7F3D0;
  --sky: #E6F4FF;
  --grey: #F5F7FA;
  --line: #E3E8EF;
  --text: #0B2E4F;
  --muted: #5B6B7F;
  --ok: #10B981;
  --warn: #F59E0B;
  --bad: #EF4444;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(11, 46, 79, .08);
  font-family: Montserrat, Poppins, system-ui, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--grey); min-height: 100vh; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { line-height: 1.5; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* Barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px; background: #fff; border-bottom: 1px solid var(--line);
}
.brand img { height: 34px; display: block; }
.role-switch { display: flex; background: var(--grey); border-radius: 999px; padding: 4px; margin-left: auto; }
.role-switch a {
  text-decoration: none; padding: 8px 22px; border-radius: 999px; font-weight: 600; color: var(--muted);
}
.role-switch a.active { background: var(--navy); color: #fff; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; font-size: .85rem; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 700;
  background: var(--teal); color: #fff; text-decoration: none; transition: background .15s;
}
.btn:hover { background: var(--teal-dark); }
.btn.secondary { background: #fff; color: var(--navy); border: 1.5px solid var(--line); }
.btn.secondary:hover { background: var(--grey); }
.btn.navy { background: var(--navy); }
.btn.danger { background: #fff; color: var(--bad); border: 1.5px solid #FBD5D5; }
.btn.small { padding: 7px 12px; font-size: .85rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Cartes et éléments communs */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 700; background: var(--sky); color: var(--navy); white-space: nowrap;
}
.badge.ok { background: #D1FAE5; color: #065F46; }
.badge.warn { background: #FEF3C7; color: #92400E; }
.badge.bad { background: #FEE2E2; color: #991B1B; }
.badge.teal { background: var(--teal); color: #fff; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--sky); color: var(--navy); font-weight: 800;
}
.stat .value { font-size: 1.6rem; font-weight: 800; }
.stat .label { color: var(--muted); font-size: .8rem; font-weight: 600; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; }
td { padding: 12px; border-top: 1px solid var(--line); vertical-align: middle; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--grey); }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.chip {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px;
  font-weight: 600; font-size: .85rem; color: var(--navy);
}
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1; border: 1.5px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 6px; font-weight: 600; font-size: .85rem;
}
.seg button.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.field label { display: block; font-size: .78rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff;
}
.field textarea { min-height: 80px; resize: vertical; }
input[type=number] { width: 72px; border: 1.5px solid var(--line); border-radius: 8px; padding: 6px 8px; }
input[type=range] { width: 100%; accent-color: var(--teal); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.check input { width: 18px; height: 18px; accent-color: var(--teal); }

/* Face Physio */
.physio { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 57px); }
.sidebar { background: var(--navy); color: #fff; padding: 24px 16px; }
.sidebar .who { display: flex; gap: 10px; align-items: center; padding: 0 8px 20px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 16px; }
.sidebar .who .avatar { background: var(--teal); color: #fff; }
.sidebar a {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px;
  text-decoration: none; color: rgba(255,255,255,.75); font-weight: 600;
}
.sidebar a.active, .sidebar a:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar svg { width: 18px; height: 18px; }
.content { padding: 28px 32px 48px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; }
.back { text-decoration: none; color: var(--muted); font-weight: 600; font-size: .85rem; display: inline-block; margin-bottom: 8px; }

.suggestion { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 12px; background: var(--grey); }
.suggestion + .suggestion { margin-top: 10px; }
.suggestion.bad { background: #FEF2F2; }
.suggestion.warn { background: #FFFBEB; }
.suggestion.ok { background: #ECFDF5; }
.suggestion .grow { flex: 1; }
.suggestion strong { display: block; margin-bottom: 2px; }

.ex-card { overflow: hidden; padding: 0; cursor: pointer; transition: transform .15s; }
.ex-card:hover { transform: translateY(-2px); }
.ex-card .thumb { aspect-ratio: 16/10; background: var(--navy); position: relative; overflow: hidden; }
.ex-card .thumb video { width: 100%; height: 100%; object-fit: cover; }
.ex-card .body { padding: 14px 16px 16px; }

.prog-row { display: grid; grid-template-columns: 56px minmax(0,1fr) repeat(4, 86px) 40px; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.prog-row:first-child { border-top: 0; }
.prog-row .mini { width: 56px; height: 56px; border-radius: 10px; overflow: hidden; background: var(--navy); }
.prog-row .mini video { width: 100%; height: 100%; object-fit: cover; }
.prog-row .lbl { font-size: .7rem; color: var(--muted); font-weight: 700; display: block; }
.icon-btn { border: 0; background: none; color: var(--muted); padding: 6px; border-radius: 8px; }
.icon-btn:hover { background: var(--grey); color: var(--bad); }

.rule-row { display: grid; grid-template-columns: 1.1fr 110px 1.6fr 64px; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.rule-row input[type=text] { width: 100%; border: 1.5px solid var(--line); border-radius: 8px; padding: 6px 8px; }

.validation { display: grid; gap: 10px; }
.validation .item { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-radius: 12px; background: var(--grey); }

/* Lecteur vidéo + squelette */
.player { position: relative; background: #000; border-radius: 14px; overflow: hidden; }
.player video { display: block; width: 100%; max-height: 520px; object-fit: contain; background: #000; }
.player canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.player .hud {
  position: absolute; left: 12px; top: 12px; display: flex; gap: 8px; flex-wrap: wrap;
}
.player .hud .badge { background: rgba(11,46,79,.82); color: #fff; }
.player-controls { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }

/* Graphiques SVG */
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .8rem; font-weight: 600; color: var(--muted); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Face Patient : cadre téléphone */
.patient-stage {
  min-height: calc(100vh - 57px); display: flex; justify-content: center; align-items: flex-start; gap: 40px;
  padding: 28px 16px; background: linear-gradient(160deg, #fff 0%, var(--sky) 60%, #D9FBF1 100%);
}
.phone {
  width: 400px; height: 820px; max-height: calc(100vh - 90px); background: #fff; border-radius: 44px;
  border: 10px solid #0E1A2B; box-shadow: 0 30px 60px rgba(11,46,79,.25);
  display: flex; flex-direction: column; overflow: hidden; position: relative;
}
.phone.wide { width: 860px; border-radius: 28px; }
.phone-screen { flex: 1; overflow-y: auto; padding: 18px 18px 24px; }
.phone-head { display: flex; justify-content: center; padding: 14px 0 4px; }
.phone-head img { height: 28px; }
.tabbar { display: flex; border-top: 1px solid var(--line); background: #fff; }
.tabbar a {
  flex: 1; text-align: center; padding: 10px 0 12px; text-decoration: none; color: var(--muted);
  font-size: .72rem; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.tabbar a.active { color: var(--teal); }
.tabbar svg { width: 22px; height: 22px; }
.stage-note { max-width: 300px; margin-top: 60px; }
.stage-note h2 { font-size: 1.6rem; font-weight: 800; }
.stage-note .bar { width: 64px; height: 4px; background: var(--teal); border-radius: 2px; margin: 14px 0; }

.p-card { background: #fff; border-radius: 16px; box-shadow: 0 4px 18px rgba(11,46,79,.08); padding: 16px; }
.p-card + .p-card { margin-top: 14px; }
.hello { font-size: 1.3rem; font-weight: 800; margin: 6px 0 14px; }
.today { display: flex; align-items: center; gap: 14px; }
.today .ring { width: 46px; height: 46px; border-radius: 50%; border: 4px solid var(--teal); display: grid; place-items: center; color: var(--teal); font-weight: 800; }
.week { display: flex; justify-content: space-between; }
.week div { text-align: center; font-size: .72rem; font-weight: 700; color: var(--muted); }
.week i { display: block; width: 30px; height: 30px; border-radius: 50%; margin: 6px auto 0; background: var(--grey); }
.week i.done { background: var(--teal); }
.week i.miss { background: #FEE2E2; }
.week i.today { outline: 2px solid var(--navy); outline-offset: 2px; }
.msg { background: var(--sky); border-radius: 14px; padding: 12px 14px; font-size: .88rem; }
.msg b { display: block; font-size: .75rem; margin-bottom: 4px; }
.ex-line { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); text-decoration: none; }
.ex-line:first-child { border-top: 0; }
.ex-line .mini { width: 60px; height: 60px; border-radius: 12px; overflow: hidden; background: var(--navy); flex: none; }
.ex-line .mini video { width: 100%; height: 100%; object-fit: cover; }
.ex-line .grow { flex: 1; }
.ex-line .chev { color: var(--muted); }

/* Séance guidée */
.session { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; padding: 16px; height: 100%; }
.session .main-view { position: relative; background: #000; border-radius: 18px; overflow: hidden; min-height: 420px; }
.session .main-view video { width: 100%; height: 100%; object-fit: contain; display: block; }
.session .main-view canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.session .main-view .live-msg {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); max-width: 90%;
  background: rgba(255,255,255,.95); color: var(--navy); border-radius: 14px; padding: 12px 18px;
  font-weight: 700; box-shadow: var(--shadow); text-align: center; transition: opacity .2s;
}
.session .main-view .live-msg.bad { border-left: 6px solid var(--warn); }
.session .main-view .live-msg.ok { border-left: 6px solid var(--ok); }
.session .main-view .status {
  position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; gap: 8px;
}
.session .main-view .status .badge { background: rgba(11,46,79,.82); color: #fff; }
.session .side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.counter { text-align: center; }
.counter .big { font-size: 3.2rem; font-weight: 800; line-height: 1; }
.counter .big small { font-size: 1.2rem; color: var(--muted); }
.gauge { height: 14px; border-radius: 7px; background: var(--grey); position: relative; overflow: hidden; margin-top: 8px; }
.gauge .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--teal); transition: width .1s; }
.gauge .mark { position: absolute; top: -2px; bottom: -2px; width: 3px; background: var(--navy); }
.demo-thumb { border-radius: 12px; overflow: hidden; background: #000; position: relative; }
.demo-thumb video { width: 100%; display: block; max-height: 150px; object-fit: contain; }
.rest-overlay {
  position: absolute; inset: 0; background: rgba(11,46,79,.88); color: #fff; display: grid; place-items: center; text-align: center; z-index: 5;
}
.rest-overlay .big { font-size: 4rem; font-weight: 800; }
.feed { font-size: .8rem; max-height: 140px; overflow-y: auto; }
.feed div { padding: 4px 0; border-top: 1px solid var(--line); }

.pain-scale { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; }
.pain-scale button { border: 0; border-radius: 8px; padding: 9px 0; font-weight: 800; color: #fff; opacity: .35; }
.pain-scale button.on { opacity: 1; transform: scale(1.08); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow);
}

@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage-note { display: none; }
}
@media (max-width: 860px) {
  .physio { grid-template-columns: 1fr; }
  .sidebar { display: flex; gap: 6px; padding: 10px; overflow-x: auto; }
  .sidebar .who { display: none; }
  .content { padding: 20px 16px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .phone, .phone.wide { width: 100%; border: 0; border-radius: 0; height: auto; max-height: none; box-shadow: none; }
  .patient-stage { padding: 0; }
  .session { grid-template-columns: 1fr; }
  .prog-row { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 10px 16px; gap: 12px; }
  .brand img { height: 26px; }
  #reset-demo { display: none; }
}

/* Cartes alignées dans les grilles */
.grid > .card + .card, .grid > .p-card + .p-card { margin-top: 0; }
#hero .player { border-radius: 0; }
#hero .player { background: var(--navy); }
#hero .player video { max-height: 360px; background: var(--navy); }

/* Lecteur : vidéo assombrie quand les segments sont affichés */
.player video { transition: filter .35s ease; }
.player.skel-on video { filter: brightness(.5) saturate(.75); }
.player canvas { transition: opacity .35s ease; }
.player .skel-toggle {
  position: absolute; right: 10px; bottom: 10px; z-index: 2;
  border: 0; border-radius: 999px; padding: 7px 14px; font-weight: 700; font-size: .78rem;
  background: rgba(255,255,255,.92); color: var(--navy); box-shadow: 0 2px 10px rgba(0,0,0,.2);
}
.player.skel-on .skel-toggle { background: var(--teal); color: #fff; }
.hero-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; flex: none; }
.hero-actions .btn { white-space: nowrap; }
.hero-actions [aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.player-controls [aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Bouton « repères » actif : reste lisible au survol */
.player-controls [aria-pressed="true"]:hover, .hero-actions [aria-pressed="true"]:hover { background: #164A7A; border-color: #164A7A; color: #fff; }
.player-controls { flex-wrap: nowrap; }
.player-controls .btn { white-space: nowrap; }

/* Choix des jours (éditeur de programme) */
.prog-row { grid-template-columns: 56px minmax(0,1fr) repeat(3, 86px) 210px 40px; }
.days { display: flex; gap: 3px; }
.days button { width: 27px; height: 27px; border-radius: 50%; border: 1.5px solid var(--line); background: #fff; font-size: .68rem; font-weight: 700; color: var(--muted); padding: 0; }
.days button.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.week i.plan { background: #fff; border: 2px dashed var(--teal); box-sizing: border-box; }
.prog-layout { grid-template-columns: minmax(0, 1fr); max-width: 1000px; }
.prog-layout .ex-line .mini { width: 48px; height: 48px; }

/* Nouvel exercice */
.clip-pick { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.clip { border: 2px solid var(--line); border-radius: 12px; background: #fff; padding: 0 0 8px; overflow: hidden; cursor: pointer; text-align: center; color: var(--navy); font: inherit; }
.clip .thumb { aspect-ratio: 16/10; background: var(--navy); margin-bottom: 6px; }
.clip .thumb video { width: 100%; height: 100%; object-fit: cover; }
.clip.on { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,191,166,.2); }
.progress { height: 8px; border-radius: 4px; background: #E6EBF1; overflow: hidden; margin-bottom: 8px; }
.progress i { display: block; height: 100%; width: 0; background: var(--teal); transition: width .08s linear; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
