/* ============================================================================
   LivePLC — pages "groupe de widgets" + mini-démos animées
   Dépend de liveplc.css (variables, nav, footer…). Réutilisé par les 8 pages.
   ============================================================================ */

/* ---------- Fil d'ariane + hero de groupe ---------- */
.breadcrumb { font-size: .85rem; color: var(--text3); padding: 22px 0 0; }
.breadcrumb a { color: var(--text2); }
.breadcrumb a:hover { color: var(--accent); }

.group-hero { padding: 30px 0 14px; }
.group-hero .ico { font-size: 2.4rem; }
.group-hero h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); margin: 10px 0 12px; }
.group-hero p { color: var(--text2); max-width: 720px; font-size: 1.06rem; }
.group-count { display: inline-block; margin-top: 14px; font-size: .82rem; font-weight: 700;
  color: var(--accent); background: var(--accent-soft); padding: 5px 12px; border-radius: 999px; }

/* ---------- Bloc widget (démo + descriptif, alterné) ---------- */
.wd-block { display: grid; grid-template-columns: 380px 1fr; gap: 38px; align-items: center;
  padding: 46px 0; border-top: 1px solid var(--border); }
.wd-block:nth-child(even) .wd-demo { order: 2; }
.wd-block h2 { font-size: 1.5rem; margin-bottom: 6px; }
.wd-block .wd-id { font-family: var(--mono); font-size: .76rem; color: var(--text3); margin-bottom: 12px; }
.wd-block .wd-desc { color: var(--text2); margin-bottom: 16px; }
.wd-feat { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 8px; }
.wd-feat li { display: flex; gap: 9px; font-size: .92rem; color: var(--text2); }
.wd-feat .ck { color: var(--accent); font-weight: 800; }
.wd-use { font-size: .85rem; color: var(--text3); font-style: italic; }
.wd-media-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: .82rem; color: var(--text3); }

/* cadre de démo */
.wd-demo { background: var(--bg2); border: 1px solid var(--border); border-radius: 16px;
  min-height: 220px; display: grid; place-items: center; padding: 26px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.wd-demo::after { content: "DÉMO LIVE"; position: absolute; top: 10px; right: 12px; font-size: .6rem; font-weight: 800;
  letter-spacing: .12em; color: var(--text3); }

/* ---------- Mini-démos (pilotées par --val 0..100 via JS) ---------- */
.demo-val { font-family: var(--mono); font-weight: 700; }

/* Jauge circulaire */
.d-gauge { --val: 50; width: 150px; height: 150px; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--val) * 3.6deg), var(--bg3) 0);
  display: grid; place-items: center; transition: background .8s ease; }
.d-gauge .hole { width: 110px; height: 110px; border-radius: 50%; background: var(--bg2);
  display: grid; place-items: center; flex-direction: column; text-align: center; }
.d-gauge .num { font-size: 1.7rem; font-weight: 900; color: var(--text); }
.d-gauge .unit { font-size: .7rem; color: var(--text3); }

/* Donut (plusieurs segments simulés) */
.d-donut { --val: 64; width: 150px; height: 150px; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--val)*3.6deg), var(--green) calc(var(--val)*3.6deg) calc(var(--val)*3.6deg + 70deg), var(--bg3) 0);
  display: grid; place-items: center; transition: background .8s ease; }
.d-donut .hole { width: 96px; height: 96px; border-radius: 50%; background: var(--bg2); display: grid; place-items: center; }
.d-donut .num { font-size: 1.5rem; font-weight: 900; }

/* Cuve / Tank */
.d-tank { --val: 60; width: 120px; height: 170px; border: 3px solid var(--text3); border-radius: 10px;
  position: relative; overflow: hidden; background: var(--bg3); }
.d-tank .liquid { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--val) * 1%);
  background: linear-gradient(var(--accent-2), var(--accent)); transition: height .8s ease; }
.d-tank .liquid::before { content: ""; position: absolute; top: -6px; left: 0; right: 0; height: 10px;
  background: var(--accent); border-radius: 50%; opacity: .6; animation: wave 2.5s ease-in-out infinite; }
@keyframes wave { 50% { transform: translateX(6px) scaleY(1.3); } }
.d-tank .num { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; color: var(--text); mix-blend-mode: difference; }

/* Thermomètre */
.d-thermo { --val: 55; width: 40px; height: 180px; position: relative; display: flex; flex-direction: column; align-items: center; }
.d-thermo .tube { width: 16px; flex: 1; background: var(--bg3); border-radius: 10px 10px 0 0; position: relative; overflow: hidden; border: 2px solid var(--text3); border-bottom: 0; }
.d-thermo .merc { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--val) * 1%);
  background: linear-gradient(var(--red), var(--orange)); transition: height .8s ease; }
.d-thermo .bulb { width: 30px; height: 30px; border-radius: 50%; background: var(--red); margin-top: -4px; border: 2px solid var(--text3); }
.d-thermo .num { position: absolute; right: -42px; top: 50%; transform: translateY(-50%); font-weight: 800; }

/* Indicateur de niveau (barre verticale segmentée) */
.d-level { --val: 70; display: flex; flex-direction: column-reverse; gap: 4px; height: 170px; }
.d-level i { width: 60px; height: 14px; border-radius: 3px; background: var(--bg3); transition: background .4s; }
.d-level i.on { background: linear-gradient(90deg, var(--green), var(--accent)); }

/* Afficheur numérique (style panneau) */
.d-digital { background: #06121a; border: 1px solid var(--border); border-radius: 10px; padding: 18px 26px; text-align: center; }
.d-digital .num { font-family: var(--mono); font-size: 2.4rem; font-weight: 700; color: #2bf0c0; text-shadow: 0 0 12px rgba(43,240,192,.5); }
.d-digital .lbl { font-size: .7rem; color: #4a6b7a; letter-spacing: .1em; text-transform: uppercase; margin-top: 4px; }

/* Afficheur analogique (aiguille) */
.d-analog { --val: 50; width: 180px; height: 100px; position: relative; overflow: hidden; }
.d-analog .dial { width: 180px; height: 180px; border-radius: 50%; border: 10px solid var(--bg3); border-top-color: var(--accent); border-right-color: var(--accent);
  position: absolute; top: 0; left: 0; transform: rotate(-135deg); }
.d-analog .needle { position: absolute; bottom: 6px; left: 50%; width: 3px; height: 78px; background: var(--red); transform-origin: bottom center;
  transform: translateX(-50%) rotate(calc(-90deg + var(--val) * 1.8deg)); transition: transform .8s cubic-bezier(.34,1.56,.64,1); border-radius: 3px; }
.d-analog .pin { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 14px; height: 14px; border-radius: 50%; background: var(--text); }
.d-analog .num { position: absolute; bottom: -4px; width: 100%; text-align: center; font-weight: 800; }

/* KPI card */
.d-kpi { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px 26px; min-width: 190px; box-shadow: var(--shadow); }
.d-kpi .k-lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text3); }
.d-kpi .k-num { font-size: 2.1rem; font-weight: 900; color: var(--text); margin: 4px 0; }
.d-kpi .k-trend { font-size: .82rem; font-weight: 700; color: var(--green); }
.d-kpi .k-spark { display: flex; gap: 3px; align-items: flex-end; height: 30px; margin-top: 10px; }
.d-kpi .k-spark i { width: 7px; background: var(--accent-soft); border-radius: 2px; }
.d-kpi .k-spark i.hi { background: var(--accent); }

/* ---------- Navigation entre groupes ---------- */
.group-nav { padding: 40px 0 0; }
.group-nav h3 { font-size: 1.1rem; margin-bottom: 16px; }
.group-nav .chips { display: flex; flex-wrap: wrap; gap: 10px; }
.group-nav .chips a { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card); font-size: .88rem; font-weight: 600; color: var(--text2); transition: .15s; }
.group-nav .chips a:hover { border-color: var(--accent); color: var(--accent); }
.group-nav .chips a.cur { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb,var(--accent) 40%, transparent); }

@media (max-width: 820px) {
  .wd-block { grid-template-columns: 1fr; gap: 22px; }
  .wd-block:nth-child(even) .wd-demo { order: 0; }
}

/* ============================================================================
   Démos supplémentaires (commande, données, états, conteneurs, multimédia…)
   ============================================================================ */

/* Interrupteur */
.d-switch { cursor: pointer; }
.d-switch .track { width: 92px; height: 42px; border-radius: 999px; background: var(--bg3); border: 2px solid var(--border); position: relative; transition: .3s; margin: 0 auto; }
.d-switch.on .track { background: var(--green); border-color: var(--green); }
.d-switch .knob { position: absolute; top: 3px; left: 3px; width: 32px; height: 32px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); transition: left .3s; }
.d-switch.on .knob { left: 53px; }
.d-switch .st { text-align: center; margin-top: 12px; font-weight: 800; font-family: var(--mono); }

/* Bouton (boucle d'appui) */
.d-button { padding: 14px 30px; border-radius: 12px; background: linear-gradient(var(--accent), var(--accent-2)); color: #04121a; font-weight: 800; cursor: pointer; user-select: none; animation: press 1.9s ease-in-out infinite; }
@keyframes press { 0%,100% { transform: translateY(0); box-shadow: 0 6px 0 color-mix(in srgb,var(--accent) 55%,#000); } 55% { transform: translateY(5px); box-shadow: 0 1px 0 color-mix(in srgb,var(--accent) 55%,#000); } }

/* Bouton graphique (glossy) */
.d-gbtn { width: 140px; height: 74px; border-radius: 14px; background: linear-gradient(160deg,#3b82f6,#1e3a8a); position: relative; overflow: hidden; display: grid; place-items: center; color: #fff; font-weight: 800; box-shadow: var(--shadow-lg); animation: press 2.3s ease-in-out infinite; }
.d-gbtn::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,255,255,.45), transparent 45%); }

/* Vanne */
.d-valve .body { width: 84px; height: 52px; margin: 0 auto; border-radius: 8px; border: 3px solid var(--text3); background: var(--bg3); transition: .4s; position: relative; }
.d-valve .body::before { content: ""; position: absolute; inset: 0; margin: auto; width: 0; height: 0; border-left: 16px solid currentColor; border-top: 12px solid transparent; border-bottom: 12px solid transparent; opacity: .55; }
.d-valve.open .body { border-color: var(--green); background: color-mix(in srgb,var(--green) 22%,transparent); color: var(--green); }
.d-valve.closed .body { border-color: var(--red); background: color-mix(in srgb,var(--red) 20%,transparent); color: var(--red); }
.d-valve .st { text-align: center; margin-top: 12px; font-weight: 800; font-family: var(--mono); }

/* Pompe (rotation) */
.d-pump { width: 120px; height: 120px; border-radius: 50%; border: 6px solid var(--border); background: var(--bg3); position: relative; display: grid; place-items: center; }
.d-pump .rotor { position: relative; width: 70px; height: 70px; animation: spin 1.1s linear infinite; }
.d-pump .rotor::before, .d-pump .rotor::after { content: ""; position: absolute; inset: 0; margin: auto; width: 70px; height: 12px; background: var(--accent); border-radius: 6px; }
.d-pump .rotor::after { transform: rotate(90deg); }

/* Slider */
.d-slider { width: 230px; }
.d-slider .rail { height: 8px; border-radius: 4px; background: var(--bg3); position: relative; }
.d-slider .fill { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--val,50) * 1%); background: linear-gradient(90deg,var(--accent-2),var(--accent)); border-radius: 4px; transition: width .8s; }
.d-slider .handle { position: absolute; top: 50%; left: calc(var(--val,50) * 1%); transform: translate(-50%,-50%); width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-shadow: var(--shadow); transition: left .8s; }
.d-slider .st { text-align: center; margin-top: 16px; font-weight: 800; font-family: var(--mono); }

/* Pavé numérique */
.d-numpad { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; width: 168px; }
.d-numpad span { aspect-ratio: 1; display: grid; place-items: center; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; font-weight: 700; font-family: var(--mono); transition: .15s; }
.d-numpad span.hot { background: var(--accent); color: #04121a; transform: scale(1.08); }

/* Joystick */
.d-joy { width: 130px; height: 130px; border-radius: 50%; background: var(--bg3); border: 2px solid var(--border); position: relative; }
.d-joy .knob { position: absolute; top: 50%; left: 50%; width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(var(--accent),var(--accent-2)); transform: translate(-50%,-50%); transition: transform .9s cubic-bezier(.34,1.56,.64,1); }

/* Courbes (trend / xy) */
.d-chart { width: 300px; height: 150px; background: var(--bg3); border-radius: 10px; padding: 8px; }
.d-chart svg { width: 100%; height: 100%; overflow: visible; }
.d-chart polyline { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.d-chart polyline.b { stroke: var(--orange); }

/* Histogramme */
.d-histo { display: flex; gap: 9px; align-items: flex-end; height: 140px; }
.d-histo i { width: 26px; background: linear-gradient(var(--accent),var(--accent-2)); border-radius: 4px 4px 0 0; transition: height .6s; }

/* Bargraphe LED */
.d-bargraph { display: flex; flex-direction: column-reverse; gap: 3px; }
.d-bargraph i { width: 48px; height: 11px; border-radius: 2px; background: var(--bg3); transition: background .3s; }
.d-bargraph i.on { background: linear-gradient(90deg,var(--green),var(--accent)); }
.d-bargraph i.hi { background: var(--red); }

/* Data logger */
.d-log { width: 300px; font-family: var(--mono); font-size: .74rem; background: #06121a; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.d-log div { display: flex; justify-content: space-between; padding: 6px 12px; color: #8fa6b5; border-bottom: 1px solid rgba(255,255,255,.05); }
.d-log div span:last-child { color: #2bf0c0; }

/* Voyant */
.d-led { width: 60px; height: 60px; border-radius: 50%; background: var(--green); box-shadow: 0 0 26px var(--green); animation: blink 1.3s steps(1) infinite; }

/* Indicateur de tendance */
.d-trendind { font-size: 3.2rem; font-weight: 900; color: var(--green); transition: .3s; }

/* Grafcet */
.d-grafcet { display: flex; flex-direction: column; align-items: flex-start; }
.d-grafcet .step { display: flex; align-items: center; gap: 12px; }
.d-grafcet .box { width: 36px; height: 36px; border: 2px solid var(--text3); border-radius: 4px; display: grid; place-items: center; font-weight: 800; font-family: var(--mono); background: var(--bg2); transition: .3s; }
.d-grafcet .step.active .box { background: var(--accent); border-color: var(--accent); color: #04121a; box-shadow: 0 0 16px var(--accent); }
.d-grafcet .link { width: 2px; height: 16px; background: var(--text3); margin-left: 18px; }
.d-grafcet .lbl { font-size: .82rem; color: var(--text2); }

/* Onglets */
.d-tabs { width: 270px; }
.d-tabs .bar { display: flex; gap: 4px; border-bottom: 2px solid var(--border); }
.d-tabs .bar span { padding: 8px 14px; font-size: .82rem; font-weight: 700; color: var(--text3); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: .2s; }
.d-tabs .bar span.active { color: var(--accent); border-color: var(--accent); }
.d-tabs .body { padding: 20px; color: var(--text2); font-size: .86rem; background: var(--bg2); border-radius: 0 0 8px 8px; }

/* Navbar */
.d-navbar { width: 290px; background: #0f1620; border-radius: 10px; padding: 8px; display: flex; gap: 6px; }
.d-navbar a { flex: 1; text-align: center; padding: 11px 0; border-radius: 7px; color: #9fb0c3; font-size: .78rem; font-weight: 700; }
.d-navbar a.active { background: var(--accent); color: #04121a; }

/* Fenêtre modale */
.d-modal { position: relative; width: 270px; height: 156px; background: var(--bg3); border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.d-modal .win { position: absolute; top: 26px; left: 36px; right: 36px; bottom: 26px; background: var(--card); border: 1px solid var(--accent); border-radius: 8px; box-shadow: var(--shadow-lg); display: grid; place-items: center; color: var(--text2); font-size: .82rem; animation: pop 3.4s ease-in-out infinite; }
@keyframes pop { 0%,100% { opacity: 0; transform: scale(.9); } 20%,70% { opacity: 1; transform: none; } }

/* Centre de notifications */
.d-notif { position: relative; width: 64px; height: 64px; display: grid; place-items: center; }
.d-notif .bell { font-size: 2.6rem; }
.d-notif .badge { position: absolute; top: -2px; right: -2px; background: var(--red); color: #fff; border-radius: 999px; min-width: 22px; height: 22px; display: grid; place-items: center; font-size: .72rem; font-weight: 800; padding: 0 5px; }
.d-toast { position: absolute; bottom: 10px; right: 10px; background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--red); border-radius: 8px; padding: 8px 12px; font-size: .76rem; box-shadow: var(--shadow-lg); animation: toast 4s ease-in-out infinite; }
@keyframes toast { 0%,100% { opacity: 0; transform: translateX(18px); } 12%,42% { opacity: 1; transform: none; } }

/* Bandeau d'alarme */
.d-alarm { width: 300px; border-radius: 10px; background: var(--red); color: #fff; padding: 13px 16px; display: flex; align-items: center; gap: 12px; font-weight: 800; animation: alarmpulse 1.2s ease-in-out infinite; }
@keyframes alarmpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.5); } 50% { box-shadow: 0 0 0 12px rgba(220,38,38,0); } }

/* Webcam */
.d-webcam { width: 270px; height: 152px; background: #0a0a0a; border-radius: 10px; position: relative; overflow: hidden; display: grid; place-items: center; color: #3a3a3a; font-size: 2.4rem; }
.d-webcam::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(255,255,255,.035) 0 2px, transparent 2px 4px); animation: scan 6s linear infinite; }
@keyframes scan { to { background-position: 0 200px; } }
.d-webcam .rec { position: absolute; top: 9px; left: 9px; display: flex; align-items: center; gap: 5px; color: #f55; font-size: .7rem; font-weight: 800; z-index: 2; }
.d-webcam .rec b { width: 9px; height: 9px; border-radius: 50%; background: #f55; animation: blink 1.2s steps(1) infinite; }

/* QR */
.d-qr { width: 124px; height: 124px; background: #fff; border-radius: 8px; padding: 10px; box-shadow: var(--shadow); }
.d-qr svg { width: 100%; height: 100%; }

/* Page web embarquée */
.d-web { width: 290px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--card); }
.d-web .bar { display: flex; gap: 5px; padding: 9px; background: var(--bg3); }
.d-web .bar i { width: 9px; height: 9px; border-radius: 50%; background: var(--text3); }
.d-web .page { height: 122px; background: linear-gradient(135deg, var(--accent-soft), transparent); display: grid; place-items: center; color: var(--text3); font-size: .82rem; }

/* Texte / valeur */
.d-text { font-size: 2.1rem; font-weight: 900; color: var(--accent); font-family: var(--mono); }

/* Forme (couleur cyclante) */
.d-shape { width: 92px; height: 92px; background: var(--green); animation: shapecycle 5s ease-in-out infinite; }
@keyframes shapecycle { 0% { background: var(--green); border-radius: 14px; } 33% { background: var(--orange); border-radius: 50%; } 66% { background: var(--blue); border-radius: 14px; transform: rotate(45deg); } 100% { background: var(--green); border-radius: 14px; } }

/* Générateur de page (illustration phrase → widgets) */
.d-gen { width: 300px; }
.d-gen .phrase { font-family: var(--mono); font-size: .76rem; background: var(--bg3); border: 1px dashed var(--border); border-radius: 8px; padding: 10px 12px; color: var(--text2); }
.d-gen .arrow { text-align: center; color: var(--accent); font-size: 1.2rem; margin: 6px 0; }
.d-gen .out { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
.d-gen .out span { aspect-ratio: 1.4; background: var(--accent-soft); border: 1px solid color-mix(in srgb,var(--accent) 30%,transparent); border-radius: 6px; display: grid; place-items: center; font-size: 1.1rem; animation: pop 3s ease-in-out infinite; }
.d-gen .out span:nth-child(2){animation-delay:.3s} .d-gen .out span:nth-child(3){animation-delay:.6s}
.d-gen .out span:nth-child(4){animation-delay:.9s} .d-gen .out span:nth-child(5){animation-delay:1.2s} .d-gen .out span:nth-child(6){animation-delay:1.5s}
