/* Stesso aspetto della web-app di Jeko (packages/admin/src/styles.css): colori, font, bottoni. */
@font-face {
  font-family: 'Lato';
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/lato-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Lato';
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/lato-700.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/plex-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/plex-mono-600.woff2') format('woff2');
}

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --subtle: #f4f4f5;
  --line: #e4e4e7;
  --fg: #18181b;
  --muted: #71717a;
  --faint: #a1a1aa;
  --accent: #18181b;
  --accent-fg: #ffffff;
  /* Stati (come jk-status): pallino e testo. */
  --sky: #0ea5e9;
  --sky-text: #0369a1;
  --amber: #f59e0b;
  --amber-text: #b45309;
  --emerald: #10b981;
  --emerald-text: #047857;
  --red: #ef4444;
  --red-text: #b91c1c;
  --danger: #dc2626;
  --font-sans: 'Lato', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0d;
    --surface: #151518;
    --subtle: #222227;
    --line: #2c2c32;
    --fg: #f4f4f5;
    --muted: #a1a1aa;
    --faint: #6b6b74;
    --accent: #f4f4f5;
    --accent-fg: #18181b;
    --sky-text: #38bdf8;
    --amber-text: #fbbf24;
    --emerald-text: #34d399;
    --red-text: #f87171;
    --danger: #f87171;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}
/* Come la web-app: barra in alto, task scorrevoli al centro, chat in fondo. */
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
:focus-visible {
  outline: 2px solid #0ea5e9;
  outline-offset: 2px;
}
::placeholder {
  color: var(--faint);
}

.bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.bar h1 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
}
.status.on::before {
  background: var(--emerald);
}
.status.off::before {
  background: var(--red);
}

main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px max(16px, calc((100% - 720px) / 2));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
main:has(+ #dock:not([hidden])) {
  padding-bottom: 16px;
}
/* Come jk-label. */
h2 {
  margin: 20px 0 8px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  color: var(--muted);
}
.card {
  margin-bottom: 8px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow-wrap: anywhere;
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
}
button.row {
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: background-color 0.15s;
}
button.row:hover {
  background: var(--subtle);
}
.row .grow {
  flex: 1;
  min-width: 0;
}
.clip {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.muted {
  font-size: 12px;
  color: var(--faint);
}

/* Stato di un task: pallino e testo colorato (come jk-status). */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  white-space: nowrap;
  color: var(--muted);
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
}
.badge.running {
  color: var(--sky-text);
}
.badge.running::before {
  background: var(--sky);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
.badge.waiting {
  color: var(--amber-text);
}
.badge.waiting::before {
  background: var(--amber);
}
.badge.done {
  color: var(--emerald-text);
}
.badge.done::before {
  background: var(--emerald);
}
.badge.failed,
.badge.rejected {
  color: var(--red-text);
}
.badge.failed::before,
.badge.rejected::before {
  background: var(--red);
}
@keyframes pulse {
  50% {
    opacity: 0.5;
  }
}

.path {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.path i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line);
}
.path i.done {
  background: var(--emerald);
}
.path i.failed {
  background: var(--red);
}
.path i.current {
  background: var(--sky);
}
.path i.skipped {
  background: var(--faint);
  opacity: 0.4;
}

/* Come jk-input; 16px perché sotto iOS ingrandisce la pagina al tocco. */
textarea,
input[type='text'],
select {
  width: 100%;
  padding: 8px 12px;
  font: 16px/1.4 var(--font-sans);
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s;
}
textarea:focus,
input[type='text']:focus,
select:focus {
  border-color: var(--faint);
}
textarea {
  min-height: 90px;
  resize: vertical;
}
input[type='checkbox'] {
  accent-color: var(--accent);
}
label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
/* Come jk-btn-outline / jk-btn-primary / jk-btn-danger. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font: 14px/1.25 var(--font-sans);
  white-space: nowrap;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition:
    background-color 0.15s,
    opacity 0.15s;
}
.btn:hover {
  background: var(--subtle);
}
.btn.primary {
  color: var(--accent-fg);
  background: var(--accent);
  border-color: var(--accent);
}
.btn.primary:hover {
  opacity: 0.9;
}
.btn.danger {
  color: var(--danger);
  border-color: transparent;
}
.btn.danger:hover {
  background: rgb(239 68 68 / 0.1);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
/* Indietro: come jk-btn-ghost con l'icona. */
.icon {
  display: inline-flex;
  margin-left: -6px;
  padding: 4px;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.icon[hidden] {
  display: none;
}
.icon:hover {
  color: var(--fg);
  background: var(--subtle);
}
.icon svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

pre {
  max-height: 320px;
  margin: 8px 0 0;
  padding: 8px 12px;
  overflow: auto;
  font: 13px/1.45 var(--font-mono);
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--subtle);
  border-radius: 8px;
}
.feed p {
  margin: 0 0 6px;
  font-size: 14px;
  /* Percorsi e comandi lunghi vanno a capo invece di uscire dal riquadro. */
  overflow-wrap: anywhere;
}
.feed .text {
  white-space: pre-wrap;
}
.feed .more {
  margin-bottom: 6px;
}
.feed .more p {
  margin: 0;
}
.feed .more:not(.open) p {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
  overflow: hidden;
}
.feed .more.lines-2:not(.open) p {
  -webkit-line-clamp: 2;
}
.feed .more button.link {
  width: fit-content;
  margin: 4px auto 0;
  padding: 3px 12px;
  font-size: 11px;
  text-align: center;
  text-decoration: none;
  color: var(--faint);
  background: var(--subtle);
  border-radius: 6px;
}
.feed .tool {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.empty {
  padding: 40px 16px;
  text-align: center;
  font-size: 14px;
  color: var(--faint);
}
.error {
  margin-top: 8px;
  font-size: 12px;
  color: var(--red-text);
}
.mt {
  margin-top: 10px;
}

/* ---------- chat in fondo al progetto (come jk-task-composer) ---------- */
#dock {
  flex-shrink: 0;
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.composer {
  --tone-border: #7dd3fc;
  --tone-focus: #0ea5e9;
  --tone-badge-bg: #e0f2fe;
  --tone-badge-fg: #075985;
  --tone-active: #0284c7;
  max-width: 720px;
  margin: 0 auto;
  background: var(--bg);
  border: 2px solid var(--tone-border);
  border-radius: 16px;
  transition: border-color 0.15s;
}
.composer.direct {
  --tone-border: #fcd34d;
  --tone-focus: #f59e0b;
  --tone-badge-bg: #fef3c7;
  --tone-badge-fg: #92400e;
  --tone-active: #f59e0b;
}
@media (prefers-color-scheme: dark) {
  .composer {
    --tone-border: #075985;
    --tone-badge-bg: rgb(12 74 110 / 0.5);
    --tone-badge-fg: #7dd3fc;
    --tone-active: #0ea5e9;
  }
  .composer.direct {
    --tone-border: #92400e;
    --tone-badge-bg: rgb(120 53 15 / 0.5);
    --tone-badge-fg: #fcd34d;
    --tone-active: #f59e0b;
  }
}
.composer:focus-within {
  border-color: var(--tone-focus);
}
.composer svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: currentColor;
}
.composer-head {
  display: flex;
  justify-content: flex-end;
  padding: 8px 10px 0;
}
.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--tone-badge-fg);
  background: var(--tone-badge-bg);
  border-radius: 999px;
}
.mode-badge svg {
  width: 14px;
  height: 14px;
}
.composer textarea {
  display: block;
  min-height: 0;
  max-height: 30vh;
  padding: 4px 14px;
  background: transparent;
  border: 0;
  resize: none;
}
.composer .error {
  margin: 0;
  padding: 0 14px;
}
.composer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 10px;
}
/* Come jk-segmented. */
.seg,
.switch {
  display: inline-flex;
  padding: 2px;
  background: var(--subtle);
  border: 0;
  border-radius: 8px;
}
.seg button {
  padding: 6px 10px;
  font: 14px/1.25 var(--font-sans);
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s;
}
.seg button[aria-checked='true'] {
  color: var(--fg);
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}
.switch {
  cursor: pointer;
}
.switch span {
  display: flex;
  padding: 6px;
  color: var(--muted);
  border-radius: 6px;
  transition:
    background-color 0.15s,
    color 0.15s;
}
.switch span.on {
  color: #fff;
  background: var(--tone-active);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}
/* Modello e impegno (come jk-agent-choice): il pulsante nella barra, il pannello sopra al testo. */
button.agent {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  padding: 4px 8px;
  font: 12px/1.25 var(--font-sans);
  color: var(--fg);
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
button.agent:hover:not(:disabled) {
  background: var(--subtle);
}
button.agent span {
  color: var(--faint);
}
button.agent:not(:disabled)::after {
  content: '▾';
  color: var(--faint);
}
button.agent:disabled {
  cursor: default;
  opacity: 0.6;
}
.agent-panel {
  display: grid;
  gap: 6px;
  margin: 8px 10px 4px;
  padding: 10px;
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.chips button {
  padding: 6px 10px;
  font: 13px/1.25 var(--font-sans);
  color: var(--fg);
  background: var(--subtle);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
}
.chips button small {
  color: var(--faint);
}
.chips button[aria-checked='true'] {
  background: var(--surface);
  border-color: var(--tone-active);
}
.btn.send {
  margin-left: auto;
  color: #fff;
  background: var(--tone-active);
  border-color: transparent;
}
.btn.send:hover {
  opacity: 0.9;
}

/* Fra i messaggi: l'utente, e la riga per continuare o chiudere un task diretto. */
.feed .you {
  margin: 10px 0;
  padding: 8px 12px;
  background: var(--subtle);
  border-radius: 8px;
}
.feed .you b {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.follow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}
.follow::before,
.follow::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
.btn.ghost {
  padding: 4px 8px;
  font-size: 12px;
  color: var(--muted);
  border-color: transparent;
}
.switch.invisible {
  visibility: hidden;
}
.seg button:disabled {
  cursor: default;
}
.seg[aria-disabled='true'] {
  opacity: 0.6;
}

button.link {
  display: block;
  max-width: 100%;
  padding: 0;
  font: inherit;
  font-size: 12px;
  text-align: left;
  text-decoration: underline;
  background: none;
  border: 0;
  cursor: pointer;
}
