/* Administration → System → Schedule (M-303/M-323). Page-scoped presentation only — the run-history grid is the
   shared Tabulator component, so this sheet carries the section headings, the merged registered-task table above
   it, and the per-row edit modal. Token-driven; mirrors the self-updater / jobs pages. Mobile-first: the task
   table scrolls horizontally on a narrow viewport rather than crushing its columns. */

/* Heading above each section (Registered tasks / Run history), stacked down the page. */
.platform-system-schedule__section-title {
    margin: var(--platform-space-lg, 1.5rem) 0 var(--platform-space-sm, 0.5rem);
    font-size: var(--platform-font-size-md, 1rem);
    font-weight: 600;
}

/* Let the task table scroll sideways on small screens instead of squeezing the cadence/next-due columns. */
.platform-system-schedule__table-wrap {
    overflow-x: auto;
}

.platform-system-schedule__tasks {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--platform-font-size-sm, 0.875rem);
}

.platform-system-schedule__tasks th,
.platform-system-schedule__tasks td {
    padding: var(--platform-space-sm, 0.5rem) var(--platform-space-md, 0.75rem);
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--platform-color-border, #e0e6ea);
}

.platform-system-schedule__tasks th {
    font-weight: 600;
    color: var(--platform-color-text-muted, #6b7a86);
    white-space: nowrap;
}

.platform-system-schedule__task-name {
    font-weight: 600;
}

/* The task key reads as an identifier — monospace — both in the table's Task cell and in the modal header. */
.platform-system-schedule__task-key {
    font-family: var(--platform-font-mono, ui-monospace, monospace);
    font-size: var(--platform-font-size-sm, 0.875rem);
    font-weight: 600;
    overflow-wrap: anywhere;
}

/* The last-run timestamp sits quietly beside its status badge. */
.platform-system-schedule__last-ran {
    display: inline-block;
    margin-left: var(--platform-space-sm, 0.5rem);
    color: var(--platform-color-text-muted, #6b7a86);
}

/* A task that has never run, and the empty-state line, both read as muted secondary text. */
.platform-system-schedule__never,
.platform-system-schedule__empty {
    color: var(--platform-color-text-muted, #6b7a86);
}

/* ── Row action: the icon-only edit button ───────────────────────────────────────────────────────────────
   Reuses the app's one icon-button primitive (.platform-btn--icon + the --edit glyph). The actions column
   hugs its content on the right; the button is a real tap target on a touch device (M-223 tap-target token),
   raised only on a coarse pointer so the desktop row height is untouched. */
.platform-system-schedule__actions-head,
.platform-system-schedule__actions {
    text-align: right;
    white-space: nowrap;
}

@media (hover: none) and (pointer: coarse) {
    .platform-system-schedule__edit {
        min-width: var(--platform-tap-target, 2.75rem);
        min-height: var(--platform-tap-target, 2.75rem);
    }
}

/* ── The per-row edit modal (M-323) ──────────────────────────────────────────────────────────────────────
   ONE shared native <dialog> the `schedule-task-edit` controller opens and populates per row. Token-styled so
   it re-skins with the theme (incl. dark mode); the native top-layer + ::backdrop give the overlay for free.
   Presentation only — behaviour is in the Stimulus controller (coding-standards §4). */
.platform-schedule-modal {
    width: min(28rem, calc(100vw - 2 * var(--platform-space-lg)));
    max-height: calc(100vh - 2 * var(--platform-space-lg));
    padding: 0;
    color: var(--platform-color-text);
    background: var(--platform-color-surface);
    border: 1px solid var(--platform-color-border);
    border-radius: var(--platform-radius-lg);
    box-shadow: var(--platform-shadow-lg, var(--platform-shadow-md));
    overflow: hidden;
}

.platform-schedule-modal::backdrop {
    background: rgba(0, 0, 0, 0.45);
}

.platform-schedule-modal__panel {
    display: flex;
    flex-direction: column;
    max-height: inherit;
}

.platform-schedule-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--platform-space-md);
    padding: var(--platform-space-md) var(--platform-space-lg);
    border-bottom: 1px solid var(--platform-color-border);
}

.platform-schedule-modal__title {
    margin: 0;
    font-size: var(--platform-font-size-lg);
    font-weight: 600;
}

.platform-schedule-modal__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    color: var(--platform-color-text-muted, var(--platform-color-text));
    background: none;
    border: 0;
    border-radius: var(--platform-radius-md);
    cursor: pointer;
}

.platform-schedule-modal__close:hover,
.platform-schedule-modal__close:focus-visible {
    background: var(--platform-color-surface-muted);
}

.platform-schedule-modal__close-icon {
    width: 1.25rem;
    height: 1.25rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* The field set stacks; it scrolls inside the fixed-height dialog so it never pushes the actions off-screen. */
.platform-schedule-modal__body {
    display: flex;
    flex-direction: column;
    gap: var(--platform-space-md);
    padding: var(--platform-space-lg);
    overflow-y: auto;
}

/* The key reads as an identifier, on its own line above the controls. */
.platform-schedule-modal__key {
    font-family: var(--platform-font-mono, ui-monospace, monospace);
    font-size: var(--platform-font-size-sm, 0.875rem);
    color: var(--platform-color-text-muted, #6b7a86);
    overflow-wrap: anywhere;
}

.platform-schedule-modal__time-input {
    width: auto;
}

/* Hidden for an hourly task — there is no meaningful time to move. Toggled via a class, never an inline style. */
.platform-schedule-modal__time-field--hidden {
    display: none;
}

.platform-schedule-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--platform-space-sm);
    padding: var(--platform-space-md) var(--platform-space-lg);
    border-top: 1px solid var(--platform-color-border);
}
