/* Composants réutilisables. Préfixes BEM courts. */

/* --- Boutons --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 12px; border: 0; border-radius: var(--r-pill); padding: 17px 30px; font-size: 15px; font-weight: 700; white-space: nowrap; background: var(--btn); color: var(--btn-ink); transition: background .2s, color .2s, opacity .2s; }
.btn:hover { background: var(--btn-hover); color: var(--btn-ink); }
.btn:disabled { opacity: .6; }
.btn--block { width: 100%; }
.btn--ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line-strong); font-weight: 600; }
.btn--ghost:hover { background: var(--pill); color: var(--ink); }
.btn--sm { padding: 11px 16px; font-size: 13px; font-weight: 800; }
.btn--link { background: transparent; border: 0; padding: 0; border-radius: 0; font-size: 14px; font-weight: 700; color: var(--ink); border-bottom: 1px solid currentColor; }
.btn--link:hover { background: transparent; color: var(--mute); }
.btn--link.is-muted { color: var(--mute); }
.btn--link.is-muted:hover { color: var(--ink); }
.btn__spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(128, 128, 128, .3); border-top-color: currentColor; animation: spin .8s linear infinite; }

/* --- Champs --- */
.field { display: flex; flex-direction: column; gap: 8px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.field__opt { font-weight: 500; color: var(--mute-2); }
.field__hint { font-size: 13px; font-weight: 500; color: var(--mute-2); }
.input { height: 56px; width: 100%; border: 1px solid var(--line-strong); border-radius: var(--r-input); padding: 0 18px; font-size: 16px; font-weight: 500; background: var(--card); color: var(--ink); outline: none; transition: border-color .2s, box-shadow .2s; }
.input::placeholder { color: var(--mute-2); font-weight: 400; }
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 4px var(--focus-ring); }
.input--mono { font-family: var(--font-mono); text-align: center; }
.input--sm { height: 44px; border-radius: 12px; padding: 0 12px; font-size: 15px; background: var(--pill); border-color: var(--line); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 100px; }
.input-wrap__btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); height: 38px; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--line-strong); background: var(--bg); font-size: 13px; font-weight: 700; }
.input-wrap__icon { position: absolute; left: 17px; top: 50%; transform: translateY(-50%); color: var(--mute); pointer-events: none; }
.input-wrap--icon .input { padding-left: 46px; padding-right: 18px; }

.error { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--red-ink); animation: fade-up .25s ease both; }
.error::before { content: ""; width: 6px; height: 6px; background: var(--red); flex: none; }

/* --- Force du mot de passe --- */
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pw-meter span { height: 4px; border-radius: 2px; background: var(--pill); transition: background .3s; }
.pw-meter[data-score="1"] span:nth-child(-n+1) { background: var(--red); }
.pw-meter[data-score="2"] span:nth-child(-n+2) { background: var(--amber); }
.pw-meter[data-score="3"] span:nth-child(-n+3) { background: var(--yellow); }
.pw-meter[data-score="4"] span { background: var(--green); }
.pw-rules { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.pw-rules li { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--mute-2); transition: color .2s; }
.pw-rules li::before { content: ""; width: 7px; height: 7px; background: var(--line-strong); transition: background .2s; }
.pw-rules li.is-ok { color: var(--ink); }
.pw-rules li.is-ok::before { background: var(--green); }

/* --- Saisie de code à 6 chiffres --- */
.code-input { position: relative; display: flex; align-items: center; gap: 10px; cursor: text; }
.code-input__box { display: inline-flex; align-items: center; justify-content: center; width: clamp(40px, 10vw, 58px); height: 66px; border-radius: var(--r-input); border: 1px solid var(--line-strong); background: var(--card); font-family: var(--font-mono); font-size: 26px; font-weight: 500; color: var(--ink); transition: border-color .2s, box-shadow .2s; }
.code-input__box.is-filled { border-color: var(--ink); }
.code-input__box.is-current { border-color: var(--ink); box-shadow: 0 0 0 4px var(--focus-ring); }
.code-input__box.is-current:empty::after { content: ""; width: 2px; height: 28px; background: var(--ink); animation: pulse 1s steps(1) infinite; }
.code-input.is-error .code-input__box { border-color: var(--red); }
.code-input.is-disabled .code-input__box { opacity: .5; background: var(--bg); }
/* le vrai champ, invisible, couvre les cases : un tap n'importe où ouvre le clavier */
.code-input__field { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; color: transparent; background: transparent; caret-color: transparent; font-size: 16px; outline: none; }
.code-input--split .code-input__box:nth-child(4) { margin-left: 14px; }

/* --- Pilules / chips / segmented --- */
.chip { border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); border-radius: var(--r-pill); padding: 12px 20px; font-size: 14px; font-weight: 700; transition: background .2s, color .2s; }
.chip.is-on { border-color: var(--ink); background: var(--btn); color: var(--btn-ink); }
.chip--sm { padding: 9px 14px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--pill); border-radius: var(--r-pill); padding: 4px; max-width: 100%; }
.seg button { border: 0; border-radius: var(--r-pill); padding: 8px 14px; font-size: 13px; font-weight: 700; white-space: nowrap; background: transparent; color: var(--mute); transition: background .2s, color .2s; }
.seg button.is-on { background: var(--btn); color: var(--btn-ink); }
.seg--grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg--grid button { padding: 9px 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tag { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); background: var(--card); border-radius: var(--r-pill); padding: 9px 14px; font-size: 13px; font-weight: 700; }
.tag i { width: 7px; height: 7px; background: var(--c, var(--red)); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; border: 1px solid var(--line-strong); border-radius: var(--r-pill); padding: 5px 9px; white-space: nowrap; color: var(--mute); }
.badge--ok { color: var(--green-ink); border-color: rgba(31, 157, 90, .4); }
[data-theme="dark"] .badge--ok { color: var(--green); border-color: rgba(61, 220, 132, .45); }
.badge--ok::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--on { background: var(--btn); color: var(--btn-ink); border-color: var(--btn); }

/* --- Interrupteur --- */
.toggle { flex: none; width: 46px; height: 28px; border-radius: var(--r-pill); border: 0; padding: 0; background: var(--pill); position: relative; transition: background .2s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.toggle[aria-checked="true"] { background: var(--red); }
.toggle[aria-checked="true"]::after { transform: translateX(18px); }

/* --- Range --- */
input[type="range"] { -webkit-appearance: none; appearance: none; background: transparent; margin: 0; height: 4px; flex: 1; min-width: 0; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: rgba(128, 128, 128, .32); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--red); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); margin-top: -7px; }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(128, 128, 128, .32); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--red); border: 2px solid #fff; }
.range-row { display: flex; align-items: center; gap: 14px; width: 100%; }
.range-row__val { font-family: var(--font-mono); font-size: 12px; min-width: 64px; text-align: right; }

/* --- Nuancier --- */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; padding: 3px; border: 2px solid transparent; background: transparent; }
.swatches button.is-on { border-color: var(--ink); }
.swatches button i { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(128, 128, 128, .3); }

/* --- Cartes --- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card-lg); }
.card--pad { padding: 24px; }
.card--dark { background: #0b0c0e; color: #fff; border-color: transparent; }

/* --- Écran LED (conteneur de <liveled-screen>) --- */
.led { position: relative; aspect-ratio: 2 / 1; background: var(--led-bg); border-radius: 14px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); }
.led > liveled-screen { width: 100%; height: 100%; }
.led__live { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: var(--led-bg); }
.led__dim { position: absolute; inset: 0; background: #000; pointer-events: none; transition: opacity .2s; }
.led__pill { position: absolute; top: 10px; display: inline-flex; align-items: center; gap: 6px; background: rgba(0, 0, 0, .55); backdrop-filter: blur(8px); border-radius: var(--r-pill); padding: 5px 9px; font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; }
.led__pill--live { right: 10px; color: var(--green); }
.led__pill--live i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 2.8s ease-in-out infinite; }
.led__pill--night { left: 10px; color: var(--violet); }
.led--bezel { border: 9px solid var(--led-bezel); border-radius: 10px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 40px 90px rgba(0, 0, 0, .7); }

/* --- Barre de phases (onboarding) --- */
.phases { display: grid; grid-template-columns: 3fr 2fr 4fr; gap: 14px; }
.phase { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.phase__label { font-family: var(--font-mono); font-size: 11px; letter-spacing: .18em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #b7bac1; transition: color .3s; }
.phase.is-done .phase__label { color: var(--mute); }
.phase.is-current .phase__label { color: var(--ink); }
.phase__segs { display: flex; gap: 4px; }
.phase__segs span { flex: 1; height: 3px; border-radius: 2px; background: var(--line); transition: background .4s; }
.phase__segs span.is-done { background: var(--ink); }
.phase__segs span.is-current { background: var(--red); }
@media (max-width: 640px) { .phase__label--long { display: none; } }
@media (min-width: 641px) { .phase__label--short { display: none; } }

/* --- Progress --- */
.progress { width: 200px; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ink); transform-origin: left; }
.progress--auto i { animation: grow-x 2.4s linear both; }

/* --- Étapes d'installation --- */
.steps-list { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 4px 18px; }
.steps-list li { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 14px; font-weight: 600; color: var(--mute-2); }
.steps-list li:last-child { border-bottom: 0; }
.steps-list li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--line-strong); }
.steps-list li.is-active { color: var(--ink); }
.steps-list li.is-active::before { background: var(--red); animation: pulse 1s ease-in-out infinite; }
.steps-list li.is-done { color: var(--ink); }
.steps-list li.is-done::before { background: var(--green); }

/* --- Check circle --- */
.check-circle { width: 68px; height: 68px; border-radius: 50%; background: var(--green); display: flex; align-items: center; justify-content: center; animation: pop .55s var(--ease-out) both; }
.check-circle--dark { background: #0b0c0e; }
.check-circle svg { stroke: #0b0c0e; }
.check-circle--dark svg { stroke: var(--green); }

/* --- Toast --- */
.toast { position: fixed; right: clamp(16px, 3vw, 32px); bottom: clamp(16px, 3vw, 32px); width: min(360px, calc(100vw - 32px)); background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 18px 20px; box-shadow: var(--shadow-pop); z-index: 50; animation: fade-up .45s var(--ease-out) both; }
.toast__close { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--card); font-size: 15px; line-height: 1; }

/* --- Theme switch --- */
.theme-switch { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 4px; }
.theme-switch button { border: 0; background: transparent; color: var(--mute); border-radius: var(--r-pill); padding: 8px 14px; font-size: 13px; font-weight: 700; white-space: nowrap; transition: background .2s, color .2s; }
.theme-switch button.is-on { background: var(--btn); color: var(--btn-ink); }

/* --- Skeleton --- */
.skeleton { background: linear-gradient(90deg, var(--pill) 25%, var(--line) 50%, var(--pill) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* --- Messages (snackbar.js) : en bas, visibles, typés --- */
.snacks { position: fixed; z-index: 150; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(460px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
@media (min-width: 761px) { .snacks { left: auto; right: 28px; bottom: 28px; transform: none; } }
.snack { position: relative; overflow: hidden; display: flex; align-items: center; gap: 13px; padding: 14px 14px 14px 16px; border-radius: 18px; background: #0b0c0e; color: #fff; box-shadow: 0 24px 60px rgba(11, 12, 14, .35), 0 0 0 1px rgba(255, 255, 255, .06); font-size: 14.5px; font-weight: 600; line-height: 1.4; pointer-events: auto; animation: snack-in .38s cubic-bezier(.2, .9, .25, 1.1) both; }
:root[data-theme="dark"] .snack { background: #f4f5f7; color: #0b0c0e; box-shadow: 0 24px 60px rgba(0, 0, 0, .5); }
.snack.is-leaving { animation: snack-out .22s ease both; }
.snack__icon { flex: none; width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; color: #0b0c0e; background: var(--green); }
.snack--err .snack__icon { background: var(--red); color: #fff; }
.snack--info .snack__icon { background: #c9ccd3; font-family: var(--font-mono); }
.snack__text { flex: 1; min-width: 0; }
.snack__action { flex: none; border: 0; background: none; color: inherit; font: inherit; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 6px; }
.snack__close { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(127, 127, 127, .18); color: inherit; font-size: 15px; line-height: 1; cursor: pointer; }
.snack__timer { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: currentColor; opacity: .25; transform-origin: left; animation: snack-timer linear both; }
.snack--err .snack__timer { background: var(--red); opacity: .8; }
.snack.is-paused .snack__timer { animation-play-state: paused; }
@keyframes snack-in { from { opacity: 0; transform: translateY(16px) scale(.97); } }
@keyframes snack-out { to { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes snack-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .snack, .snack.is-leaving { animation: none; } .snack__timer { display: none; } }

/* --- Liste déroulante (réglage enum, widget "select") --- */
.select-wrap { position: relative; display: block; width: 100%; max-width: 420px; }
.select { appearance: none; -webkit-appearance: none; width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--pill); color: var(--ink); padding: 0 42px 0 14px; font-size: 15px; font-weight: 600; cursor: pointer; outline: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: border-color .2s, box-shadow .2s; }
.select:hover { border-color: var(--line-strong); }
.select:focus-visible { border-color: var(--ink); box-shadow: 0 0 0 4px var(--focus-ring); }
.select option { background: var(--card); color: var(--ink); font-weight: 500; }
.select-wrap::after { content: ""; position: absolute; right: 17px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--mute); border-bottom: 2px solid var(--mute); transform: translateY(-70%) rotate(45deg); pointer-events: none; }

/* --- Curseur à crans (réglage enum, widget "slider") : une position par option, libellé affiché --- */
.steps { display: flex; align-items: flex-start; gap: 14px; width: 100%; }
.steps__track { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; padding-top: 7px; }
.steps__ticks { display: flex; justify-content: space-between; padding: 0 7px; }
.steps__ticks i { position: relative; width: 4px; height: 4px; border-radius: 50%; background: var(--line-strong); cursor: pointer; transition: background .2s, transform .2s; }
.steps__ticks i::before { content: ""; position: absolute; inset: -9px; }
.steps__ticks i:hover { transform: scale(1.5); }
.steps__ticks i.is-on { background: var(--ink); }
.steps__val { flex: none; max-width: 46%; padding-top: 2px; font-family: var(--font-mono); font-size: 12px; line-height: 1.4; text-align: right; color: var(--ink); }

/* --- Liste de suggestions sous un champ (sélecteur de ville, réglage à recherche) : parent en position: relative --- */
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 8px); background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-float); overflow: hidden; z-index: 5; animation: fade-up .2s ease both; }
.suggest button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 13px 16px; color: var(--ink); }
.suggest button:last-child { border-bottom: 0; }
.suggest button:hover, .suggest button.is-active { background: var(--bg); }
.suggest__name { font-size: 15px; font-weight: 700; }
.suggest__country { font-size: 13px; color: var(--mute); }
.suggest__tz { font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; color: var(--mute-2); white-space: nowrap; }
.suggest__item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.suggest__item .suggest__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest__detail { font-size: 12.5px; line-height: 1.4; color: var(--mute); }
.suggest__msg { padding: 13px 16px; font-size: 14px; color: var(--mute); }
.suggest__msg.is-err { color: var(--red-ink); }
.suggest__msg.is-wait::after { content: ""; display: inline-block; width: 10px; height: 10px; margin-left: 10px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--ink); vertical-align: -1px; animation: spin .8s linear infinite; }

/* --- Réglage à recherche (string, widget "search") : champ + liste fournie par l'API de l'app (settings-panel.js) --- */
.search-field { width: 100%; max-width: 420px; }
.search-field__box { position: relative; }
.search-field__icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); display: flex; color: var(--mute); pointer-events: none; }
.search-field__input { padding-left: 38px; }
.search-field.has-value .search-field__input { font-weight: 700; }
.search-field .suggest { max-height: 300px; overflow-y: auto; }
.search-field__detail { padding: 7px 2px 0; font-size: 12.5px; line-height: 1.4; color: var(--mute); }
.search-field__detail:empty { display: none; }
