/* =========================================================
   AUTOPILOT — an agent page. The hero carries the agent's orb and
   its live status; the cards (from pillars.css .auto-*) are restyled
   here as the agent's jobs.
========================================================= */

#page-autopilot { display: none; flex-direction: column; gap: 16px; }
#page-autopilot.active { display: flex; }

.ap-hero {
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 22px;
    padding: 24px 26px; border-radius: 20px; position: relative; overflow: hidden;
    background:
        radial-gradient(60% 120% at 0% 0%, rgba(0, 113, 219, .10), transparent 60%),
        radial-gradient(50% 120% at 100% 100%, rgba(111, 92, 255, .10), transparent 60%),
        var(--surface);
    border: 1px solid var(--border);
}
.ap-hero::after { content: ""; position: absolute; inset: auto 0 0; height: 3px; background: var(--as-aurora); }
.ap-hero-mark { position: relative; width: 84px; height: 84px; display: grid; place-items: center; }
.ap-hero-mark i { position: absolute; inset: 6px; border-radius: 50%; border: 1.5px dashed rgba(111, 92, 255, .35); animation: ap-orbit 14s linear infinite; }
.ap-hero-mark i + i { inset: -4px; border-color: rgba(0, 113, 219, .2); animation-duration: 22s; animation-direction: reverse; }
.ap-hero-icon { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #0071db, #3d8ce0); box-shadow: 0 12px 28px rgba(0, 113, 219, .32); }
.ap-hero-icon svg { width: 30px; height: 30px; }
@keyframes ap-orbit { to { transform: rotate(360deg); } }
.ap-hero-copy h1 { margin: 4px 0 6px; font-size: 28px; font-weight: 800; letter-spacing: -.03em; color: var(--text); }
.ap-hero-copy p { margin: 0; max-width: 620px; font-size: 13.5px; line-height: 1.6; color: var(--text-2); }
.ap-hero-status { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: 99px; background: var(--surface-soft); font-size: 12px; font-weight: 700; color: var(--text-3); }
.ap-hero-status.is-on { background: var(--success-soft); color: var(--success); }
.ap-hero-status.is-on .as-dot { background: var(--success); box-shadow: 0 0 0 3px rgba(18, 133, 95, .18); animation: ap-pulse 2s ease-in-out infinite; }
@keyframes ap-pulse { 50% { box-shadow: 0 0 0 6px rgba(18, 133, 95, 0); } }
.ap-hero-actions { display: flex; gap: 8px; }
.ap-hero-actions svg { width: 15px; height: 15px; }

.ap-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.ap-stat { display: grid; gap: 2px; padding: 14px 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); text-align: left; font: inherit; }
button.ap-stat { cursor: pointer; }
button.ap-stat:hover { border-color: var(--primary); }
.ap-stat b { font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--text); line-height: 1.1; }
.ap-stat.is-wide b { font-size: 17px; padding: 4px 0 2px; }
.ap-stat span { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.ap-stat small { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ap-loop { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border-radius: 16px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.ap-loop li { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; padding: 14px 16px; position: relative; }
.ap-loop li:not(:last-child)::after { content: ""; position: absolute; right: -7px; top: 50%; width: 14px; height: 14px; transform: translateY(-50%) rotate(45deg); background: var(--surface); border-top: 1px solid var(--border); border-right: 1px solid var(--border); z-index: 1; }
.ap-loop span { grid-row: span 2; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft-2); color: var(--primary); font-weight: 800; font-size: 12px; }
.ap-loop li:last-child span { background: var(--as-aurora); color: #fff; }
.ap-loop b { font-size: 13px; color: var(--text); }
.ap-loop small { font-size: 11.5px; color: var(--text-3); line-height: 1.4; }

.ap-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.ap-section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.ap-section-head h2 { margin: 0; font-size: 17px; font-weight: 800; color: var(--text); }
.ap-count { font-size: 12.5px; color: var(--text-3); }
.ap-side { position: sticky; top: calc(var(--topbar) + 16px); padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); }
.ap-side h3 { margin: 0 0 12px; font-size: 14px; font-weight: 800; }
.ap-upcoming { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.ap-upcoming li { display: grid; gap: 1px; padding: 0 0 12px 18px; position: relative; }
.ap-upcoming li::before { content: ""; position: absolute; left: 3px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.ap-upcoming li:not(:last-child)::after { content: ""; position: absolute; left: 6px; top: 15px; bottom: 0; width: 2px; background: var(--primary-soft-2); }
.ap-upcoming time { font-size: 11.5px; font-weight: 700; color: var(--primary); }
.ap-upcoming span { font-size: 13px; font-weight: 600; color: var(--text); }
.ap-upcoming small { font-size: 11.5px; color: var(--text-3); }
.ap-upcoming .ap-upcoming-empty { padding-left: 0; font-size: 12.5px; color: var(--text-3); }
.ap-upcoming .ap-upcoming-empty::before { display: none; }

/* the agent's jobs: the cards were drawn for a dark band on the pillars tab;
   here they sit on the light page */
#page-autopilot .auto-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
#page-autopilot .auto-card {
    border-radius: 16px; border: 1px solid var(--border); background: var(--surface); backdrop-filter: none;
    box-shadow: var(--shadow-sm); transition: box-shadow var(--transition), transform var(--transition);
}
#page-autopilot .auto-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
#page-autopilot .auto-card.is-on { border-color: var(--primary-soft); background: linear-gradient(170deg, var(--primary-soft-2), var(--surface) 45%); }
#page-autopilot .auto-card:not(.is-on) { opacity: .8; }
#page-autopilot .auto-card-top h4 { color: var(--text); }
#page-autopilot .auto-light { background: var(--border-strong); }
#page-autopilot .auto-card.is-on .auto-light { background: var(--success); }
#page-autopilot .auto-switch span { background: var(--border-strong); }
#page-autopilot .auto-switch input:checked + span { background: var(--primary); }
#page-autopilot .auto-sentence { color: var(--text-2); }
#page-autopilot .auto-sentence b { color: var(--text); }
#page-autopilot .auto-card .auto-chips span { background: var(--surface-soft); color: var(--text-2); }
#page-autopilot .auto-next-label { color: var(--text-3); }
#page-autopilot .auto-slot { background: var(--surface-soft); color: var(--text-3); }
#page-autopilot .auto-slot b { color: var(--text); }
#page-autopilot .auto-slot:first-of-type { background: var(--primary); color: #fff; }
#page-autopilot .auto-slot:first-of-type b { color: #fff; }
#page-autopilot .auto-foot { border-top-color: var(--border); color: var(--text-3); }
#page-autopilot .auto-foot button { border-color: var(--border); color: var(--text); }
#page-autopilot .auto-foot button:hover { background: var(--surface-soft); }
#page-autopilot .auto-foot button[data-auto-act="run"] { background: var(--primary); border-color: var(--primary); color: #fff; }
#page-autopilot .auto-foot button[data-auto-act="delete"] { color: var(--danger); }
#page-autopilot .auto-empty { grid-column: 1 / -1; }
#page-autopilot .auto-empty > p { color: var(--text-3); }
#page-autopilot .auto-template { color: var(--text); border-color: var(--border-strong); background: var(--surface); }
#page-autopilot .auto-template:hover { background: var(--primary-soft-2); border-color: var(--primary); border-style: solid; }
#page-autopilot .auto-template span { color: var(--text-3); }
#page-autopilot .auto-dots i { background: var(--primary-soft); }
#page-autopilot .auto-dots i.on { background: var(--primary); }

/* the link left behind on the pillars tab */
.pl-autopilot-link { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-radius: 16px; border: 1px solid var(--border); background: linear-gradient(110deg, var(--surface-soft), #f6f3ff); }
.pl-autopilot-link p { margin: 0; flex: 1; font-size: 13px; color: var(--text-2); }
.pl-autopilot-link b { color: var(--text); }

/* the sidebar entry */

@media (max-width: 1100px) {
    .ap-layout { grid-template-columns: 1fr; }
    .ap-side { position: static; }
    .ap-stats { grid-template-columns: repeat(2, 1fr); }
    .ap-loop { grid-template-columns: repeat(2, 1fr); }
    .ap-loop li::after { display: none; }
}
@media (max-width: 720px) {
    .ap-hero { grid-template-columns: 1fr; padding: 20px; }
    .ap-hero-mark { display: none; }
    .ap-hero-actions { flex-wrap: wrap; }
    .ap-loop { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    .ap-hero-mark i, .ap-hero-status.is-on .as-dot { animation: none; }
}

/* an automation that can't plan: a channel with no approved pillar */
.auto-warn { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 11px; background: var(--warning-soft); color: #6c4b04; font-size: 12px; line-height: 1.45; }
.auto-warn span { flex: 1; }
.auto-section .auto-warn { background: rgba(253, 241, 215, .12); color: #f6d38a; }
#page-autopilot .auto-warn button, .auto-warn button { flex: none; border: 0; border-radius: 8px; padding: 6px 10px; background: var(--warning); color: #fff; font: 700 11.5px inherit; cursor: pointer; }
.ap-hero-status.is-warn { background: var(--warning-soft); color: var(--warning); }
.ap-hero-status.is-warn .as-dot { background: var(--warning); }
