/*
 * alignvu UI v2.1: Connect > Schedules: the schedules grid, the schedule wizard (create_schedule, schedule_vendors,
 * schedule_delivery_options) and View Schedule (application/views/align_from/configure/schedule, js/align_from/configure/
 * schedule, js/align_from/configure/schedule_delivery.js).
 * Shared Connect parts are in css/v21_connect.css.
 */

/* ---------- Schedules grid (schedule/grid.php, schedule/grid.js) ---------- */

/* the schedule's name leads the row */
.app-connect-schedules tbody th.app-connect-schedules__name {
    font-weight: 600;
    color: var(--heading-ink);
    text-align: left;
    background: var(--surface);
}

/* the action buttons take only the room they need */
.app-connect-schedules td:last-child {
    width: 1%;
}

/* the name opens the schedule: a button that reads as a link */
.app-connect-schedules .app-connect-schedules__link {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: var(--heading-ink);
    text-align: left;
    cursor: pointer;
}

.app-connect-schedules .app-connect-schedules__link:hover,
.app-connect-schedules .app-connect-schedules__link:focus-visible {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.app-connect-schedules .app-connect-schedules__link:focus-visible {
    outline: 2px solid var(--heading-ink);
    outline-offset: 2px;
}

/* Edit and Delete: icon buttons side by side, no gap beyond their own padding */
.app-connect-schedules .app-connect__actions {
    gap: 0;
}

/* ---------- Schedule wizard (create_schedule.php, schedule_vendors.php, schedule_delivery_options.php;
   extract_schedule.js). Each step is a page of Panels holding FormFields and Radio groups. ---------- */

/* The steps keep the legacy .create-extract-body hook (the script selects inside it); here it is the page, not a
   card body, so drop the card padding (css/v21_connect.css) */
.align-from .app-connect-schedule-form.create-extract-body {
    padding: 0 0 32px;
}

/* the legacy step text rule (css/v21_connect.css) would restyle the v2.1 text inside */
.align-from .app-connect-schedule-form p {
    margin: 0;
}

.align-from .app-connect-schedule-form p.av-text {
    font: 400 14px/21px var(--font-display);
    color: var(--body-ink);
}

.align-from .app-connect-schedule-form p.av-small {
    font: 400 12px/18px var(--font-display);
    color: var(--muted);
}

/* A step's Panel: title, then its fields and groups 18px apart */
.app-connect-schedule-form .av-panel {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* FormFields side by side, as many as fit */
.app-connect-schedule-form__fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
    gap: 16px 24px;
}

/* Radio groups side by side */
.app-connect-schedule-form__groups {
    display: flex;
    flex-wrap: wrap;
    gap: 18px 48px;
}

/* A group's Radios on one line, wrapping */
.app-connect-schedule-form__choices {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
}

/* Frequency start fields (shown by the script for scheduled frequencies) */
.app-connect-schedule-form__start {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.app-connect-schedule-form__start h3 {
    margin: 0;
}

/* Subset Checkboxes: columns, scrolling inside when the list is long */
.app-connect-schedule-form__checklist {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
    gap: 8px 20px;
    max-height: min(320px, 50vh);
    overflow-y: auto;
}

/* Custom subset fields (legacy margin from css/align_from.css) */
.app-connect-schedule-form .set-data-enrichment-model-selectors {
    margin: 0;
}

.app-connect-schedule-form__buttons {
    justify-content: flex-end;
}

/* The added providers: section heading over the table */
.app-connect-schedule-form__added {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* SFTP private key: the label is a secondary button; the file input stays focusable but out of sight (css/align_from.css
   hides it, which would take it out of the keyboard order) */
.app-connect-schedule-form .delivery-sftp-key-file {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin: 0;
}

.app-connect-schedule-form .delivery-sftp-key-file label.av-btn {
    position: relative;
}

.app-connect-schedule-form .delivery-sftp-key-file input[type="file"] {
    display: block;
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.app-connect-schedule-form .delivery-sftp-key-file label.av-btn:focus-within {
    outline: 2px solid var(--heading-ink);
    outline-offset: 2px;
}

/* ---------- Providers and products tables (wizard step 2 and View Schedule's Data selection) ---------- */

.app-connect-schedule-vendors tbody th,
.app-connect-schedule-history tbody th {
    font-weight: 600;
    color: var(--heading-ink);
    text-align: left;
    background: var(--surface);
}

/* wizard: a product's rows are a tbody; a rule between products */
.app-connect-schedule-vendors .schedule-vendor-group + .schedule-vendor-group tr:first-child > * {
    border-top: 1px solid var(--border);
}

/* the action buttons take only the room they need */
.app-connect-schedule-vendors.extract-schedule-vendor-grid td:last-child {
    width: 1%;
}

/* View Schedule: a product's subsets, one per line */
.app-connect-schedule-vendors__subset {
    display: block;
}

/* ---------- View Schedule (view_schedule.php, view_schedule.js) ---------- */

/* legacy section margin (css/align_from.css); the page spaces its sections */
.app-connect-schedule-view .extract-view-container {
    margin: 0;
}

.app-connect-schedule-view__section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* a run's file name: plain text that wraps a long name */
.app-connect-schedule-history .app-connect-schedule-history__file {
    overflow-wrap: anywhere;
}

/* a run's row opens its audit */
.app-connect-schedule-history .app-connect-schedule-history__run {
    cursor: pointer;
}

/* the queue ID: a button that reads as the row's link */
.app-connect-schedule-history .app-connect-schedule-history__open {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: var(--heading-ink);
    cursor: pointer;
}

.app-connect-schedule-history .app-connect-schedule-history__run:hover .app-connect-schedule-history__open,
.app-connect-schedule-history .app-connect-schedule-history__open:focus-visible {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.app-connect-schedule-history .app-connect-schedule-history__open:focus-visible {
    outline: 2px solid var(--heading-ink);
    outline-offset: 2px;
}

/* ---------- Audit pop-ups (wide v2.1 Dialogs) ---------- */

.modal-content.app-dialog.app-connect-schedule-audit {
    width: min(1040px, calc(100vw - 32px));
}

#view-audit-field-detail-modal .modal-content.app-dialog {
    width: min(760px, calc(100vw - 32px));
}

/* the body scrolls inside the Dialog (css/align_from.css forces a scrollbar) */
#view-audit-modal .modal-content.app-dialog .modal-body,
#view-audit-field-detail-modal .modal-content.app-dialog .modal-body {
    flex: 1 1 auto;
    max-height: none;
    overflow: auto;
}

/* many files: the tabs scroll sideways */
.app-connect-schedule-audit .av-tabs {
    flex: none;
    overflow-x: auto;
}

.app-connect-schedule-audit .av-tab,
.app-connect-schedule-field .av-tab {
    flex: none;
    white-space: nowrap;
}

/* a file's audit, and a field's detail tab, shown by the script with the hidden attribute */
.app-connect-schedule-audit__file {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.app-connect-schedule-audit__file[hidden],
.app-connect-schedule-field__panel[hidden] {
    display: none;
}

/* a field with a detail: its name opens the field detail */
/* a field with details: the whole row opens them; its name is a plain-looking button for the keyboard */
.app-connect-schedule-audit__fields .app-connect-schedule-audit__field--detail {
    cursor: pointer;
}

.app-connect-schedule-audit__fields .app-connect-schedule-audit__fieldlink {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-weight: 600;
    color: var(--heading-ink);
    text-align: left;
    white-space: normal;
    cursor: pointer;
}

.app-connect-schedule-audit__fields .app-connect-schedule-audit__fieldlink:focus-visible {
    outline: 2px solid var(--heading-ink);
    outline-offset: 2px;
}

/* the sequence column takes only the room it needs */
.app-connect-schedule-audit__fields th[data-sort-key="sequence"] {
    width: 1%;
}

.app-connect-schedule-field .modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.app-connect-schedule-field__stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.app-connect-schedule-field__tabs {
    overflow-x: auto;
}

.app-connect-schedule-field__panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* the field's counts: three small summary tiles side by side */
.app-connect-schedule-field__tiles {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.app-connect-schedule-field__tile {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
}

.app-connect-schedule-field__tile-label {
    font: 400 13px/18px var(--font-display);
    color: var(--body-ink);
}

.app-connect-schedule-field__tile-value {
    font: 700 20px/28px var(--font-display);
    color: var(--heading-ink);
    font-variant-numeric: tabular-nums;
}

/* a breakdown's table: the value on the left, its count and share bar taking the rest */
.app-connect-schedule-field__counts tbody th {
    width: 1%;
    min-width: 120px;
    font-weight: 400;
    color: var(--table-ink);
    text-align: left;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: var(--surface);
}

/* the Active / Inactive tabs sit close above their table */
.align-from-schedule-grid-container .app-connect {
    gap: 12px;
}

.app-connect-schedules__count {
    font-weight: 400;
    color: var(--muted);
}

.app-connect-schedules__tab-empty {
    margin: 0;
    padding: 12px 0;
    color: var(--muted);
}

/* View Schedule's Data selection: a row per subset field and comparator; values one per line, cells aligned to
   the top so a field lines up with the first of its values; a rule between products */
.extract-schedule-vendors-frame .app-connect-schedule-vendors td,
.extract-schedule-vendors-frame .app-connect-schedule-vendors th {
    vertical-align: top;
}

.extract-schedule-vendors-frame .app-connect-schedule-vendors__product:not(:first-child) > * {
    border-top: 1px solid var(--border);
}

.extract-schedule-vendors-frame .app-connect-schedule-vendors tbody tr:not(.app-connect-schedule-vendors__product) > * {
    border-top: 0;
}

/* ---------- View Schedule's page header (title set in js/application/views.js): "Schedule", then the schedule's
   name and its template as grey filled pills, as the Field Assess workflow pop-up's pills (css/v21_drilldowns.css) */
:is(.app-pagehead .view-header, .app-connect-schedule-audit__title) .app-connect-title-pills {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-left: 12px;
    vertical-align: middle;
}

:is(.app-pagehead .view-header, .app-connect-schedule-audit__title) .app-connect-title-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--day-band);
    font: 500 12.5px/18px var(--font-display);
    letter-spacing: 0;
    color: var(--heading-ink);
}

/* until the schedule has loaded, its pills are not shown */
:is(.app-pagehead .view-header, .app-connect-schedule-audit__title) .app-connect-title-pill:empty,
.app-pagehead .view-header .app-connect-title-pill--template:has(.extract-schedule-view-template:empty),
.app-connect-schedule-audit__title .app-connect-title-pill--template:has(.schedule-audit-template:empty) {
    display: none;
}

:is(.app-pagehead .view-header, .app-connect-schedule-audit__title) .app-connect-title-pill :is(.extract-schedule-view-template, .schedule-audit-template) {
    margin-left: 4px;
}

/* the audit pop-up's title: "Extract: <ID> <time>", then the pills (styled with the page header's above) */
.app-connect-schedule-audit__title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 4px;
    row-gap: 6px;
}

.app-connect-schedule-audit__title .schedule-audit-time {
    margin-left: 6px;
    font-weight: 400;
    color: var(--muted);
}

/* Field Population: the count, then its share of the file's records in grey */
.app-connect-schedule-audit__fields .app-connect-schedule-audit__share {
    display: inline-block;
    min-width: 48px;
    margin-left: 8px;
    font-size: 12px;
    color: var(--muted);
    text-align: right;
}

/* the field detail pop-up's tables: headings on the left, over their values and share bars */
.app-connect-schedule-field__counts thead th.av-num {
    text-align: left;
}

/* Setup Schedule's first block: each question on its own line */
.app-connect-schedule-form__groups--stacked {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 18px;
}

/* the frequency choices: more room between them */
.app-connect-schedule-form .extract-schedule-frequency .app-connect-schedule-form__choices {
    gap: 12px 32px;
}

/* Feeds step: the added feeds table, cells aligned to the top (a field lines up with its first value); the Delete
   icon buttons need no gap between them */
.extract-schedule-vendor-grid td,
.extract-schedule-vendor-grid th {
    vertical-align: top;
}

.extract-schedule-vendor-grid .app-connect__actions {
    gap: 0;
}

/* Feeds step, Ref Code: Filter values and its additional codes; the codes linked to the Ref Code list above are
   ticked and locked, shown in grey */
.app-connect-schedule-form__filter {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.app-connect-schedule-form__checklist .av-check.app-connect-schedule-form__linked {
    color: var(--muted);
    cursor: default;
}

.app-connect-schedule-form__checklist .av-check.app-connect-schedule-form__linked input {
    cursor: default;
}

/* Feeds step, Ref Code: the jurisdiction filter above each code list (schedule_jurisdiction_filter.js), with the
   matching jurisdictions listed under it as on Monitor > Datafeeds */
.app-connect-schedule-form__jurisdiction {
    flex: none;
    width: min(320px, 100%);
    margin-bottom: 12px;
}

.app-connect-schedule-form__jurisdiction .av-input {
    height: var(--control-height);
}

.app-connect-schedule-form__suggest {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 20;
    max-height: 320px;
    overflow-y: auto;
}

.app-connect-schedule-form__suggest[hidden],
.app-connect-schedule-form__checklist .av-check.is-filtered {
    display: none;
}

.app-connect-schedule-form__suggest button.is-active {
    background: var(--fill);
}
