/* Control center: automations. One table that pages to the height it has, never scrolls. */
.automations { padding: 0; min-height: 0; }
.automations[hidden] { display: none; }
.automations-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; padding: 12px 14px 4px; }
.automations-head > div:first-child { flex: 1 1 320px; min-width: 0; }
.automations-head h2 { margin: 0 0 2px; font-size: 16px; }
.automations-hint { margin: 0; color: var(--muted); font-size: 12px; }
.automations-head-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.automations-problems { margin: 8px 14px 0; padding: 8px 12px; border-radius: 12px; background: color-mix(in srgb, var(--amber, #f2b44b) 12%, transparent); font-size: 13px; }
.automations-problems-line { cursor: pointer; list-style: none; }
.automations-problems-line::-webkit-details-marker { display: none; }
.automations-problems-line b { color: var(--amber, #f2b44b); }
.automations-problems-more { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.automations-problems[open] .automations-problems-more { display: none; }
.automations-problems-list { margin: 6px 0 0; padding-left: 18px; color: var(--muted); }
.automations-problems[hidden] { display: none; }
.automations-notices { margin: 8px 14px 0; padding: 8px 12px 8px 30px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 10%, transparent); font-size: 13px; color: var(--muted); }
.automations-notices[hidden] { display: none; }
.automations-conflict { color: var(--text); }
.automations-conflict button { margin: 4px 6px 0 0; }

.automations-table { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 8px 14px 10px; container: automations / inline-size; }
.automations-table[hidden], .automations-form[hidden] { display: none; }
.automation-columns, .automation-row {
  display: grid; align-items: center; column-gap: 10px;
  grid-template-columns: 44px minmax(150px, 2.2fr) 80px minmax(100px, 1.2fr) minmax(130px, 1.6fr) minmax(100px, 1.1fr) minmax(150px, auto);
}
.automation-columns { color: var(--muted); font-size: 11px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.automations-list { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.automations-list .relay-empty { margin: 14px 8px; color: var(--muted); }
.automation-row { flex: none; padding: 7px 8px; border-bottom: 1px solid var(--line); font-size: 12.5px; min-width: 0; }
.automation-row > * { min-width: 0; }
.automation-meta { display: contents; }
.automation-name, .automation-project { display: flex; flex-direction: column; overflow: hidden; }
.automation-name strong, .automation-name small, .automation-project span, .automation-project small, .automation-when { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.automation-name small, .automation-project small { color: var(--muted); font-size: 11px; }
.automation-when { color: var(--muted); }
.automation-kind { justify-self: start; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--field); }
.automation-kind.schedule { color: #c08bff; }
.automation-kind.webhook { color: #7fc4ff; }
.automation-kind.bob { color: var(--accent); }
.automation-last { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.automation-last.ok { color: var(--accent); }
.automation-last.bad { color: #ef6b6b; }
.automation-last.warn { color: #f2b44b; }
.automation-actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: nowrap; }

.automation-toggle { position: relative; width: 30px; height: 17px; padding: 0; border: 0; border-radius: 999px; background: var(--accent); cursor: pointer; }
.automation-toggle::after { content: ""; position: absolute; top: 2px; right: 2px; width: 13px; height: 13px; border-radius: 50%; background: #06201a; transition: transform .12s; }
.automation-toggle[aria-checked="false"] { background: #3a3f46; }
.automation-toggle[aria-checked="false"]::after { background: #9aa0a8; transform: translateX(-13px); }
.automation-toggle:disabled { opacity: .5; cursor: default; }
@media (prefers-reduced-motion: reduce) { .automation-toggle::after { transition: none; } }

.automations-pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding-top: 6px; color: var(--muted); font-size: 11px; min-height: 28px; }
.automations-pager[hidden] { display: none; }

.automations-form { flex: 1; min-height: 0; overflow: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; max-width: 760px; }
.automations-form h3 { margin: 0; font-size: 14px; }
.automation-form-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 10px; align-items: start; }
.automation-form-fields > .full { grid-column: 1 / -1; }
.automation-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.automation-field[hidden] { display: none; }
.automation-field input[type="text"], .automation-field input[type="time"], .automation-field select, .automation-field textarea { width: 100%; font-size: 13px; }
.automation-field textarea { resize: vertical; }
.automation-check { display: inline-flex; flex-direction: row; justify-content: flex-start; align-items: center; align-self: start; gap: 6px; width: auto; font-size: 12.5px; color: var(--text); }
.automation-check input { width: auto; flex: none; margin: 0; }
.automation-projects { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.automation-form-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.automations-error { margin: 0; min-height: 1em; color: #ef6b6b; font-size: 12px; }
.automation-address { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.automation-address code { flex: 1 1 320px; min-width: 0; overflow-wrap: anywhere; font-size: 12px; background: var(--field); padding: 4px 8px; border-radius: 6px; }

/* The table lives in a column that may be narrow whatever the screen is: below this width a row is two lines. */
@container automations (max-width: 860px) {
  .automation-columns { display: none; }
  .automation-row { grid-template-columns: 40px minmax(0, 1fr) auto; grid-template-areas: "toggle name actions" "toggle meta actions"; row-gap: 2px; }
  .automation-toggle { grid-area: toggle; align-self: start; margin-top: 2px; }
  .automation-name { grid-area: name; }
  .automation-meta { grid-area: meta; display: flex; flex-wrap: wrap; align-items: center; gap: 1px 8px; font-size: 11.5px; min-width: 0; }
  .automation-meta .automation-project { flex-direction: row; gap: 4px; }
  .automation-actions { grid-area: actions; align-self: start; flex-wrap: wrap; max-width: 150px; }
}
