/* EventIT — Charte graphique Treezor */

:root {
  --primary: #2376E5;
  --primary-dark: #304053;
  --primary-vdark: #0B253B;
  --accent-yellow: #FFDE37;
  --accent-green: #51EDD5;
  --accent-orange: #FFAD01;
  --accent-red: #E53E3E;
  --bg-light: #F6F9FD;
  --bg-card: #FFFFFF;
  --border: #CEDFF6;
  --text: #304053;
  --text-muted: #6E7987;
  --radius-btn: 8px;
  --radius-pill: 16px;
  --radius-card: 12px;
  --shadow: 0 2px 12px rgba(48, 64, 83, 0.08);
  --shadow-lg: 0 8px 28px rgba(48, 64, 83, 0.14);
  --sidebar-w: 300px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Roboto', sans-serif;
  color: var(--text);
  background: var(--bg-light);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: 'Lexend', sans-serif; font-weight: 600; color: var(--primary-dark); }
h1 { font-size: 28px; } h2 { font-size: 22px; } h3 { font-size: 18px; }
code, .mono { font-family: 'Roboto Mono', monospace; }
a { color: var(--primary); text-decoration: none; }

/* --- Layout --- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: 64px 1fr 48px; grid-template-areas: "header header" "sidebar main" "sidebar footer"; height: 100vh; }
.header { grid-area: header; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; background: var(--bg-card); border-bottom: 1px solid var(--border); }
.sidebar { grid-area: sidebar; background: var(--bg-card); border-right: 1px solid var(--border); padding: 20px 16px; overflow-y: auto; }
.main { grid-area: main; padding: 32px 40px; overflow-y: auto; }
.footer { grid-area: footer; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; background: var(--bg-card); border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }

/* --- Header --- */
.brand { display: flex; align-items: center; gap: 10px; font-family: 'Lexend', sans-serif; font-weight: 700; font-size: 20px; }
.brand .logo { width: 30px; height: 30px; }
.brand .logo path, .brand .logo circle { }
.header .team { display: flex; align-items: center; gap: 12px; }
.header .team-name { font-weight: 500; }
.step-indicator { background: var(--primary); color: #fff; padding: 4px 14px; border-radius: var(--radius-pill); font-size: 13px; font-weight: 500; }

/* --- Statut / contrôle ESP32 (barre du haut) --- */
.esp-status { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--bg-light); }
.esp-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-muted); flex: none; }
.esp-dot.on { background: #1FB53A; box-shadow: 0 0 0 3px rgba(31,181,58,.18); }
.esp-dot.off { background: #B0B8C1; }
.esp-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.esp-action { border: 1px solid var(--border); background: #fff; color: var(--primary); font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: var(--radius-pill); cursor: pointer; }
.esp-action:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.esp-action.danger { color: #C62828; }
.esp-action.danger:hover { background: #C62828; color: #fff; border-color: #C62828; }
.esp-action:disabled { opacity: .55; cursor: default; }

/* --- Sidebar steps --- */
.steps-list { list-style: none; }
.steps-list li { display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: var(--radius-btn); margin-bottom: 4px; color: var(--text-muted); font-weight: 500; transition: background .15s; }
.steps-list li.active { background: var(--bg-light); color: var(--primary-dark); }
.steps-list li.done { color: var(--accent-green); }
.steps-list li.clickable { cursor: pointer; }
.steps-list li.clickable:hover:not(.active) { background: var(--bg-light); }
.step-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid currentColor; display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
.steps-list li.done .step-dot { background: var(--accent-green); border-color: var(--accent-green); color: var(--primary-dark); }
.steps-list li.active .step-dot { border-color: var(--primary); color: var(--primary); }
.substeps { list-style: none; margin: 6px 0 10px 34px; }
.substeps li { font-size: 13px; padding: 5px 0; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.substeps li.done::before { content: "✓"; color: var(--accent-green); font-weight: 700; }
.substeps li.active { color: var(--primary); font-weight: 500; }
.substeps li.active::before { content: "▸"; color: var(--primary); }
.substeps li.clickable { cursor: pointer; }
.substeps li.clickable:hover { color: var(--primary-dark); }
.substeps li.todo::before { content: "○"; color: var(--border); }

/* --- Wallet widget --- */
.wallet-widget { margin-top: 24px; padding: 16px; background: var(--bg-light); border-radius: var(--radius-card); border: 1px solid var(--border); }
.wallet-widget .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.wallet-widget .balance { font-family: 'Lexend', sans-serif; font-size: 26px; font-weight: 700; color: var(--primary); }
.mini-gauge { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.mini-gauge > div { height: 100%; background: linear-gradient(90deg, var(--accent-orange), var(--accent-green)); transition: width .5s; }

/* --- Schedulers de jauge (barre de droite, sous le wallet) --- */
.schedulers-widget { margin-top: 16px; padding: 14px; background: var(--bg-light); border-radius: var(--radius-card); border: 1px solid var(--border); }
.schedulers-widget .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.sched-item { display: flex; align-items: center; gap: 6px; padding: 6px 0; font-size: 13px; border-top: 1px solid var(--border); }
.sched-item:first-of-type { border-top: none; }
.sched-dot { color: var(--accent-green); animation: sched-spin 2s linear infinite; }
@keyframes sched-spin { to { transform: rotate(360deg); } }
.sched-name { flex: 1; font-weight: 600; color: var(--text); }
.sched-freq { font-size: 11px; color: var(--text-muted); font-family: 'Roboto Mono', monospace; }
.sched-pct { font-family: 'Roboto Mono', monospace; font-weight: 700; color: var(--primary); min-width: 34px; text-align: right; }
.sched-err { color: var(--accent-red, #E53E3E); }
.sched-stop { border: none; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 13px; padding: 2px 4px; border-radius: 4px; }
.sched-stop:hover { background: var(--border); color: var(--accent-red, #E53E3E); }

/* --- Cards & content --- */
.card { background: var(--bg-card); border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 28px; margin-bottom: 24px; }
.objective { background: var(--primary); color: #fff; border-radius: var(--radius-card); padding: 16px 20px; margin-bottom: 24px; font-size: 15px; }
.objective strong { font-family: 'Lexend', sans-serif; }
.hint { background: #FFF9E0; border-left: 4px solid var(--accent-yellow); padding: 12px 16px; border-radius: var(--radius-btn); font-size: 14px; margin: 16px 0; }

/* --- Buttons --- */
.btn { font-family: 'Roboto', sans-serif; font-size: 14px; font-weight: 700; border: none; border-radius: var(--radius-btn); padding: 12px 28px; min-height: 45px; cursor: pointer; transition: all .15s ease-out; box-shadow: var(--shadow); }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--accent-yellow); color: var(--primary-dark); }
.btn-success { background: var(--accent-green); color: var(--primary-dark); }
.btn-danger { background: var(--accent-red); color: #fff; }
.btn-ghost { background: transparent; color: var(--primary); border: 2px solid var(--primary); box-shadow: none; }

/* --- Forms --- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-btn); font-size: 15px; font-family: inherit; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(35,118,229,.15); }
.input.code { font-family: 'Roboto Mono', monospace; letter-spacing: 3px; text-align: center; font-size: 20px; text-transform: uppercase; }
.input.error { border-color: var(--accent-red); animation: shake .3s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }

/* --- Feedback --- */
.feedback { padding: 14px 18px; border-radius: var(--radius-btn); margin: 16px 0; font-weight: 500; display: none; }
.feedback.show { display: block; }
.feedback.ok { background: #E6FBF6; color: #01806A; border-left: 4px solid var(--accent-green); }
.feedback.err { background: #FDECEC; color: #B02222; border-left: 4px solid var(--accent-red); }

/* --- Color picker (step 1b) --- */
.color-grid { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
.color-swatch { width: 56px; height: 56px; border-radius: var(--radius-btn); cursor: pointer; border: 3px solid transparent; transition: transform .1s; }
.color-swatch:hover { transform: scale(1.08); }
.color-swatch.selected { border-color: var(--primary-dark); }

/* --- NeoPixel ring representation (anneau 24 LEDs) --- */
.neo-ring { position: relative; }
.neo-ring .ring-led { border-radius: 50%; background: #2a2a2a; border: 2px solid #444; cursor: pointer; transition: transform .1s, box-shadow .15s; display: flex; align-items: center; justify-content: center; }
.neo-ring .ring-led:hover { transform: scale(1.25); box-shadow: 0 0 8px rgba(35,118,229,.5); z-index: 2; }
.neo-ring .led-idx { font-size: 9px; color: #888; font-family: 'Roboto Mono', monospace; pointer-events: none; }
.neo-hub { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 150px; height: 150px; border-radius: 50%; background: var(--bg-light); border: 2px dashed var(--border); display: flex; align-items: center; justify-content: center; text-align: center; font-family: 'Lexend', sans-serif; font-size: 13px; color: var(--text-muted); }

/* --- Gauge display --- */
.gauge-display { display: flex; align-items: center; gap: 20px; margin: 20px 0; }
.gauge-bar { flex: 1; height: 32px; background: var(--border); border-radius: var(--radius-pill); overflow: hidden; }
.gauge-bar > div { height: 100%; border-radius: var(--radius-pill); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.gauge-value { font-family: 'Lexend', sans-serif; font-size: 32px; font-weight: 700; color: var(--primary); min-width: 120px; }

/* --- Bank card visual --- */
.bank-card { width: 340px; height: 214px; border-radius: 16px; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-vdark) 100%); color: #fff; padding: 22px; box-shadow: var(--shadow-lg); position: relative; font-family: 'Roboto Mono', monospace; }
.bank-card .chip { width: 42px; height: 32px; background: linear-gradient(135deg,#FFD700,#B8860B); border-radius: 6px; margin: 20px 0; }
.bank-card .pan { font-size: 20px; letter-spacing: 2px; margin: 8px 0; }
.bank-card .row { display: flex; justify-content: space-between; font-size: 13px; margin-top: 14px; }
.bank-card .brand-mark { position: absolute; top: 22px; right: 22px; font-family: 'Lexend'; font-weight: 700; }

/* --- Crypto explainer --- */
.crypto-flow { display: flex; flex-direction: column; gap: 12px; margin: 20px 0; }
.crypto-step { display: flex; align-items: center; gap: 14px; padding: 14px; background: var(--bg-light); border-radius: var(--radius-card); border: 1px solid var(--border); }
.crypto-step .icon { font-size: 28px; }

/* --- Wiring diagram container --- */
.wiring { background: var(--bg-light); border-radius: var(--radius-card); padding: 20px; margin: 16px 0; border: 1px solid var(--border); cursor: zoom-in; position: relative; }
.wiring svg { width: 100%; height: auto; }
.wiring::after { content: '🔍 Zoom'; position: absolute; top: 10px; right: 12px; font-size: 11px; color: var(--text-muted); background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 2px 10px; pointer-events: none; opacity: .85; }

/* --- Overlay de zoom des schémas --- */
.wiring-zoom { position: fixed; inset: 0; z-index: 1000; display: none; background: rgba(15, 23, 34, .92); }
.wiring-zoom.show { display: block; }
.wz-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: grab; touch-action: none; }
.wz-stage.dragging { cursor: grabbing; }
.wz-stage svg { width: min(92vw, 1400px); height: auto; transition: transform .05s linear; user-select: none; }
.wz-toolbar { position: absolute; top: 16px; right: 16px; z-index: 1001; display: flex; gap: 8px; }
.wz-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.1); color: #fff; font-size: 20px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.wz-btn:hover { background: rgba(255,255,255,.22); }
.wz-btn.wz-close { background: rgba(229,62,62,.85); border-color: rgba(229,62,62,.9); }
.wz-hint { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,.7); font-size: 12px; background: rgba(0,0,0,.35); padding: 6px 14px; border-radius: var(--radius-pill); }

/* --- Toast --- */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--primary-dark); color: #fff; padding: 14px 20px; border-radius: var(--radius-card); box-shadow: var(--shadow-lg); transform: translateY(120px); transition: transform .3s; z-index: 100; }
.toast.show { transform: translateY(0); }
.toast.success { background: #01806A; }

/* --- Modal --- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(11,37,59,.55); display: none; align-items: center; justify-content: center; z-index: 200; }
.modal-backdrop.show { display: flex; }
.modal { background: #fff; border-radius: var(--radius-card); padding: 28px; max-width: 480px; width: 90%; box-shadow: var(--shadow-lg); }

/* --- Login screen --- */
.login { display: flex; align-items: center; justify-content: center; height: 100vh; background: linear-gradient(135deg, var(--bg-light), #E7F1FE); }
.login .card { max-width: 420px; width: 90%; }
.login .brand { justify-content: center; margin-bottom: 8px; font-size: 26px; }
.login .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 24px; }

.hidden { display: none !important; }
.row-btns { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.center { text-align: center; }

/* --- Étape 2 : interface API pédagogique (type Postman) --- */
.mode-toggle { display: flex; align-items: center; gap: 8px; margin: 8px 0 14px; font-size: 13px; color: var(--text-muted); }
.mode-toggle .chip { border: 1px solid var(--border); background: #fff; color: var(--text-muted); padding: 5px 12px; border-radius: var(--radius-pill); font-size: 12px; cursor: pointer; transition: all .15s; }
.mode-toggle .chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.req-bar { display: flex; align-items: stretch; gap: 8px; margin: 12px 0 4px; }
.verb-select { flex: 0 0 130px; font-family: 'Roboto Mono', monospace; font-size: 13px; }
.url-select { flex: 1; font-family: 'Roboto Mono', monospace; font-size: 13px; }
.verb-badge { display: inline-flex; align-items: center; padding: 0 12px; border-radius: var(--radius-btn); font-family: 'Roboto Mono', monospace; font-weight: 700; font-size: 13px; color: #fff; }
.verb-post { background: var(--accent-orange); }
.verb-get { background: var(--accent-green); color: var(--primary-dark); }
.verb-put { background: var(--primary); }
.url-input { flex: 1; font-family: 'Roboto Mono', monospace; font-size: 13px; background: var(--bg-light); }
.btn-sm { font-size: 13px; padding: 6px 12px; }

.req-label { display: block; font-size: 12px; color: var(--text-muted); font-weight: 600; margin: 12px 0 4px; }
.code-area { font-family: 'Roboto Mono', monospace; font-size: 13px; line-height: 1.5; width: 100%; resize: vertical; }

.resp-head { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.status-pill { font-family: 'Roboto Mono', monospace; font-weight: 700; font-size: 13px; padding: 3px 10px; border-radius: var(--radius-pill); }
.status-pill.ok { background: #E4F9EF; color: #01806A; }
.status-pill.ko { background: #FDE8E8; color: var(--accent-red); }
.verdict { font-weight: 600; font-size: 14px; }
.verdict.ok { color: #01806A; }
.verdict.ko { color: var(--accent-red); }
.json-view { background: var(--primary-vdark); color: #C7E0FF; font-family: 'Roboto Mono', monospace; font-size: 12.5px; line-height: 1.55; padding: 14px 16px; border-radius: var(--radius-btn); overflow-x: auto; white-space: pre; margin-top: 4px; }

/* --- Étape 2 : flow guidé "Jauge" --- */
.flow-steps { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.flow-step { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 5px 10px; border-radius: var(--radius-pill); border: 1px solid var(--border); color: var(--text-muted); }
.flow-step b { display: inline-flex; width: 16px; height: 16px; align-items: center; justify-content: center; border-radius: 50%; background: var(--border); color: #fff; font-size: 10px; }
.flow-step.active { border-color: var(--primary); color: var(--primary); }
.flow-step.active b { background: var(--primary); }
.flow-step.done { border-color: var(--accent-green); color: #01806A; }
.flow-step.done b { background: var(--accent-green); color: var(--primary-dark); }

.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 12px; }
.action-card { text-align: left; padding: 14px; border: 1.5px solid var(--border); border-radius: var(--radius-card); background: #fff; cursor: pointer; display: flex; flex-direction: column; gap: 6px; transition: all .15s; }
.action-card:hover { border-color: var(--primary); }
.action-card.on { border-color: var(--primary); background: var(--bg-light); }
.action-card strong { color: var(--primary-dark); }
.action-card span { font-size: 13px; color: var(--text-muted); }
.action-preview { display: flex; justify-content: center; align-items: center; padding: 6px 0; min-height: 76px; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chip-row .chip { border: 1px solid var(--border); background: #fff; color: var(--text-muted); padding: 6px 16px; border-radius: var(--radius-pill); cursor: pointer; font-size: 13px; }
.chip-row .chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
