/* Automatismes (planned-script.js) : la fenêtre d'un automatisme : mise en route en trois étapes, résumé, ce qu'il a fait, bandeaux (en
   panne, amélioration), détails techniques repliés. Couleurs par les variables de l'app (clair et
   sombre). */

/* --- Son icône, en tête de la fenêtre --- */
.auto-card-icon { display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px;
  background: var(--wait-soft); color: var(--wait-text); }
.auto-card-icon svg { width: 21px; height: 21px; }

/* --- La fenêtre --- */
/* En-tête : l'éclair, le nom en titre, où il en est ; l'interrupteur à droite, avant ✕. */
.auto-head { align-items: center; padding-bottom: 14px; }
.auto-who { flex: 1; display: grid; gap: 3px; min-width: 0; }
.auto-title { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.auto-state { display: inline-flex; align-items: center; gap: 7px; min-width: 0; font-size: 13px; color: var(--t2); }
.auto-state i { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--idle); }
.auto-state.on i { background: var(--done); box-shadow: 0 0 0 3px color-mix(in srgb, var(--done) 22%, transparent); }
.auto-state.err { color: var(--alert); }
.auto-state.err i { background: var(--alert); }
.auto-state.new i { background: var(--wait); }
.auto-switch { flex: none; }
.auto-body { gap: 18px; }
.auto-desc { margin: 0; font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.auto-block { display: grid; gap: 8px; min-width: 0; }
.auto-block h3 { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--t2); }
.link.auto-link { flex: none; padding: 0; font-size: 13.5px; font-weight: 600; }
.auto-foot { align-items: center; }
.auto-spacer { flex: 1; }
.link.auto-delete { padding: 0; font-size: 13.5px; }
.auto-notice { margin: 0; }

/* Le résumé : trois lignes (quand, ce qu'il lit et fait, où il vous écrit), et ses réglages. */
.auto-facts { display: grid; margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.auto-facts li { display: flex; align-items: center; gap: 12px; padding: 11px 14px; font-size: 14px; }
.auto-facts li + li { border-top: 1px solid var(--line); }
.auto-fact-icon { display: inline-grid; flex: none; width: 18px; height: 18px; color: var(--t2); }
.auto-fact-icon svg { width: 100%; height: 100%; }
.auto-fact-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.auto-fact-text small { display: block; margin-top: 1px; font-size: 12.5px; color: var(--t2); }

/* Ce qu'il a fait : une frise lisible, l'heure à gauche. */
.auto-feed { display: grid; margin: 0; padding: 0; list-style: none; }
.auto-feed li { position: relative; display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 12px; padding: 6px 0; font-size: 14px; }
.auto-feed li::before { content: ""; position: absolute; left: 57.5px; top: 0; bottom: 0; width: 1px; background: var(--line); }
.auto-feed li:first-child::before { top: 14px; }
.auto-feed li:last-child::before { bottom: calc(100% - 14px); }
.auto-feed li:only-child::before { display: none; }
.auto-feed time { font-size: 13px; color: var(--t2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.auto-ev { position: relative; min-width: 0; padding-left: 12px; overflow-wrap: anywhere; }
.auto-ev::before { content: ""; position: absolute; left: -4.5px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--line); box-shadow: 0 0 0 3px var(--surface, var(--bg)); }
.auto-ev.quiet { color: var(--t2); }
.auto-ev.said::before { background: var(--wait); }
.auto-ev.act::before { background: var(--run); }
.auto-ev.bad::before { background: var(--alert); }
.auto-ev.bad strong { color: var(--alert); font-weight: 600; }
.auto-ev blockquote, .auto-result-box blockquote { margin: 5px 0 0; padding: 7px 11px; border-radius: 10px; background: var(--bg2); font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; }

/* Bandeaux : en panne (la cause, le geste qui répare) ; amélioration proposée. */
.auto-banner { display: block; padding: 12px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5; }
.auto-banner strong { font-weight: 600; }
.auto-banner.new { background: var(--wait-soft); }
.auto-banner.err { background: color-mix(in srgb, var(--alert) 12%, var(--bg)); }
.auto-banner-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.auto-banner-acts .pill-button { height: 32px; padding: 0 14px; font-size: 13px; }
.auto-banner-status { margin: 8px 0 0; font-size: 13px; }

/* --- Mise en route : trois étapes --- */
.auto-steps { display: grid; margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: 14px; }
.auto-steps > li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding: 14px; }
.auto-steps > li + li { border-top: 1px solid var(--line); }
.auto-num { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--bg2); color: var(--t2); font-size: 13px; font-weight: 700; }
.auto-num.done { background: var(--done); color: #fff; }
.auto-step { display: grid; gap: 8px; min-width: 0; }
.auto-step h4 { margin: 2px 0 0; font-size: 15px; font-weight: 600; }
.auto-step-note { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--t2); }
.auto-can { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 14px; }
.auto-can li { display: flex; align-items: flex-start; gap: 8px; overflow-wrap: anywhere; }
.auto-can li::before { content: "✓"; flex: none; color: var(--done); font-weight: 700; }
.auto-can li.off { color: var(--t2); }
.auto-can li.off::before { content: "–"; color: var(--t2); }
/* Ses écritures : une ligne chacune, « Me demander » ou « Le faire seul » à droite. */
.auto-can.writes li { align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; }
.auto-can.writes li::before { content: "?"; color: var(--run); }
.auto-can.writes li > span { flex: 1; min-width: 12em; }
.auto-can.writes .segmented { flex: none; font-size: 12.5px; }
.auto-trial-box { display: grid; gap: 8px; }
.auto-result-box { padding: 10px 12px; border-radius: 12px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.auto-result-box.ok { background: color-mix(in srgb, var(--done) 12%, var(--bg)); }
.auto-result-box.ok > strong { color: var(--done); }
.auto-result-box.err { background: color-mix(in srgb, var(--alert) 12%, var(--bg)); }
.auto-result-box.err > strong { color: var(--alert); }
.auto-result-box p { margin: 6px 0 0; }
.auto-trial-acts { display: flex; }
.auto-params-box { display: grid; gap: 8px; }
.auto-params-box h5 { margin: 4px 0 0; font-size: 13px; font-weight: 600; color: var(--t2); }
.auto-next { margin: 0; font-size: 13px; color: var(--t2); overflow-wrap: anywhere; }
.auto-next.error { color: var(--error); }

/* Quand il tourne : la fréquence, puis des pastilles à allumer (heures, jours ouvrés). */
.auto-when { display: grid; gap: 10px; }
.auto-when-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.auto-when-row .auto-freq { min-width: 13em; }
.auto-once { margin: 0; color: var(--t2); }
.auto-at { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--t2); }
.auto-at[hidden], .auto-pills[hidden], .auto-range[hidden] { display: none; }
.auto-at .routine-time { min-width: 9.5em; }
.auto-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.auto-pill { padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--t2); font: inherit; font-size: 13.5px; cursor: pointer; }
.auto-pill:hover { color: var(--t1); background: color-mix(in srgb, var(--t1) 4%, transparent); }
.auto-pill[aria-pressed="true"] { border-color: color-mix(in srgb, var(--wait) 40%, transparent); background: var(--wait-soft); color: var(--t1); font-weight: 600; }
.auto-range { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13.5px; color: var(--t2); }
.auto-range .routine-time { min-width: 9.5em; }
.auto-params { display: grid; gap: 10px; }
.auto-param.bool { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* --- Détails techniques, repliés --- */
.auto-tech { display: grid; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.auto-tech summary { justify-self: start; color: var(--t2); font-size: 13px; font-weight: 600; cursor: pointer; }
.auto-tech summary:hover { color: var(--t1); }
.auto-tech[open] { gap: 10px; }
.auto-tech-facts { margin: 0; font-size: 13px; color: var(--t2); overflow-wrap: anywhere; }
.auto-tech h5 { margin: 4px 0 0; font-size: 12.5px; font-weight: 600; color: var(--t2); }
.auto-result { display: grid; gap: 10px; min-width: 0; }
.auto-outcome { margin: 0; font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.auto-outcome.ok { color: var(--done); }
.auto-outcome.err { color: var(--alert); }
.auto-events { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.auto-event { display: grid; gap: 3px; padding-left: 12px; border-left: 2px solid var(--line); font-size: 13px; min-width: 0; }
.auto-event.message, .auto-event.tache { border-left-color: var(--wait); }
.auto-event.ecriture { border-left-color: var(--run); }
.auto-event.failed { border-left-color: var(--alert); }
.auto-event-title { font-weight: 600; overflow-wrap: anywhere; }
.auto-event-text { color: var(--t2); overflow-wrap: anywhere; }
.auto-event-quote { margin: 0; padding: 8px 10px; border-radius: 10px; background: var(--raised); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.auto-log, .auto-code {
  margin: 0; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--t1) 4%, transparent);
  font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow: auto;
}
.auto-code { max-height: 420px; tab-size: 2; }
.auto-return { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.auto-return code { font-size: 12.5px; }

@media (max-width: 720px), (pointer: coarse) and (max-height: 500px) and (max-width: 1000px) {
  .auto-feed li { grid-template-columns: 40px minmax(0, 1fr); gap: 10px; }
  .auto-feed li::before { left: 49.5px; }
  .auto-when-row .auto-freq { flex: 1; min-width: 0; }
  .auto-at .routine-time, .auto-range .routine-time { min-width: 0; flex: 1; }
  .auto-can.writes .segmented { width: 100%; }
}
