/* AL Dev Toolbox — admin surface styles.
   Per-org Administration page, audit log browser, bulk action toolbar,
   and the templates list / edit pages. Loaded last so admin-specific
   rules win when they share a class with a tool page. */

/* ---------- Administration & template-shaping pages ---------- */
/* The .admin-configuration marker class is shared by /admin/administration/*
   and /admin/templates/* (Defaults, Files, Workspace settings) — the visual
   primitives are the same, only the form fields differ. */

.logo-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: var(--color-bg);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    min-height: 120px;
}

.logo-preview__img {
    max-width: 220px;
    max-height: 120px;
    display: block;
}

.org-file-list {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.org-file-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.org-file-row__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
}

.org-file-row__head code {
    font-family: var(--font-mono);
    font-size: 12.5px;
}

.org-file-row__body { margin: 0; }

.org-file-row__content {
    margin: 0;
    padding: 8px 10px;
    background: var(--color-bg);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 180px;
    overflow: auto;
}

.org-file-row__actions {
    display: flex;
    gap: 8px;
}

.admin-configuration__danger {
    border-top-color: rgba(207, 34, 46, 0.4);
}

/* ---------- Audit log ---------- */

.audit-page { max-width: 1100px; }

.audit-page__limit-note { margin-top: 12px; font-size: 12.5px; }

/* Search and filter toolbars used by the SiteAdmin pages. The wider filter
   form wraps onto multiple rows on narrower screens; the search form is an
   input-group: input and button share an edge with no gap so they read as
   a single control. */
.admin-search-form {
    display: flex;
    align-items: stretch;
    margin: 16px 0 20px;
    max-width: 560px;
}

.admin-search-form .admin-search-input {
    flex: 1;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right-width: 0;
}

.admin-search-form .admin-search-input:focus { border-right-width: 1px; }

.admin-search-form > .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* When an icon-only button lives in the search input-group it should match
   the input's height (stretched by the form's align-items: stretch) rather
   than its own 28px square. Aspect-ratio keeps it square against whatever
   height the surrounding input ends up at. */
.admin-search-form > .btn--icon {
    width: auto;
    height: auto;
    padding: 0 10px;
    aspect-ratio: 1 / 1;
}

.admin-filter-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
    gap: 12px 16px;
    margin: 16px 0 20px;
    padding: 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.admin-filter-form > label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--color-text-secondary);
    text-transform: uppercase;
}


.audit-panel { margin-top: 28px; }

.audit-panel__header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.audit-panel__icon { color: var(--color-text-secondary); }

.audit-panel__title {
    font-size: 16px;
    font-weight: 500;
    margin: 0;
}

.audit-table summary {
    cursor: pointer;
    color: var(--color-text-secondary);
    font-size: 12.5px;
}

.audit-table summary:hover { color: var(--color-text); }

.audit-snapshot {
    margin: 6px 0 0;
    padding: 10px 12px;
    background: var(--color-surface-alt, var(--color-surface));
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 720px;
    max-height: 400px;
    overflow: auto;
}

.audit-action {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 500;
    text-transform: lowercase;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-secondary);
}

.audit-action--created { color: #1a7f37; border-color: rgba(26, 127, 55, 0.4); }

.audit-action--updated { color: #9a6700; border-color: rgba(154, 103, 0, 0.4); }

.audit-action--deleted { color: #cf222e; border-color: rgba(207, 34, 46, 0.4); }

.audit-diff { margin-top: 16px; }

.audit-diff__header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.audit-diff__title { margin: 0; font-size: 16px; font-weight: 500; }

.audit-diff__icon { color: var(--color-text-secondary); }

.audit-diff__labels { margin: 0; display: inline-flex; gap: 8px; font-size: 12.5px; }

.audit-diff__meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 4px 24px;
    margin: 12px 0 18px;
}

.audit-diff__meta div { display: flex; gap: 8px; align-items: baseline; }

.audit-diff__meta dt { color: var(--color-text-secondary); font-size: 12.5px; margin: 0; }

.audit-diff__meta dd { margin: 0; font-size: 13px; }

.audit-diff__table { table-layout: fixed; width: 100%; }

.audit-diff__cell {
    font-family: var(--font-mono);
    font-size: 12px;
    word-break: break-word;
    vertical-align: top;
}

.audit-diff__kind {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 500;
    text-transform: lowercase;
    border: 1px solid var(--color-border);
}

.audit-diff__kind--added { color: #1a7f37; border-color: rgba(26, 127, 55, 0.4); }
.audit-diff__kind--removed { color: #cf222e; border-color: rgba(207, 34, 46, 0.4); }
.audit-diff__kind--changed { color: #9a6700; border-color: rgba(154, 103, 0, 0.4); }

.audit-diff__redacted {
    color: var(--color-text-secondary);
    font-style: italic;
}

.audit-diff__row--added .audit-diff__cell--after { background: rgba(26, 127, 55, 0.08); }
.audit-diff__row--removed .audit-diff__cell--before { background: rgba(207, 34, 46, 0.08); }
.audit-diff__row--changed .audit-diff__cell--before { background: rgba(207, 34, 46, 0.05); }
.audit-diff__row--changed .audit-diff__cell--after { background: rgba(26, 127, 55, 0.05); }

/* ---------- Bulk action toolbar ---------- */

.bulk-bar {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.bulk-bar__summary { font-size: 13px; }

.bulk-bar__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }

.bulk-bar__error {
    width: 100%;
    margin: 0;
    color: #cf222e;
    font-size: 12.5px;
}

.bulk-bar__success {
    width: 100%;
    margin: 0;
    color: #1a7f37;
    font-size: 12.5px;
}

.bulk-failures {
    margin-top: 10px;
    border: 1px solid rgba(207, 34, 46, 0.4);
    border-radius: var(--radius);
    padding: 10px 12px;
    background: rgba(207, 34, 46, 0.05);
}

.bulk-failures h3 { margin: 0 0 6px; font-size: 13px; }

.bulk-failures ul { margin: 0; padding-left: 18px; font-size: 12.5px; }

.bulk-checkbox { width: 32px; text-align: center; }

/* ---------- Admin pages (templates list + edit) ---------- */

.admin-page { max-width: 1100px; }

.admin-page__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.admin-page__header h1 { margin: 0 0 6px; }

/* Cap descriptive prose at the typographic readable measure (~72 chars).
   .admin-page itself stays 1100px so tables, the tile grid, and form-grid
   layouts get the full width — only the muted explanatory paragraphs are
   constrained. */
.admin-page__header p { margin: 0; max-width: 72ch; }
.admin-page > p,
.admin-section > p { max-width: 72ch; }

.admin-page__header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.admin-page__toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

/* Compact inline select used inside data-table rows (e.g. role picker on the
   Users page). Standard form-section padding makes the control overpower
   the rest of the row; this tightens it without losing the focus ring. */
.row-role-select {
    padding: 4px 8px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: 12.5px;
}

/* Trailing action row for "content creation" buttons that sit at the bottom
   of the list they relate to (e.g. New template, New module, New snippet).
   The top-right corner is reserved for navigation (Back to admin); creation
   actions live with the data they create. */
.admin-page__footer-actions {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

.data-table__row--muted td { opacity: 0.65; }

.btn--danger {
    background: #cf222e;
    border-color: #cf222e;
    color: white;
}

.btn--danger:hover { background: #a40e26; }

/* Inline confirm-and-delete form used on /admin/object-explorer. The input
   sits next to the danger button so an admin can type the release label
   and submit in one row. align-items: stretch makes the input and button
   the same height regardless of border treatment. */
.hard-delete-form {
    display: inline-flex;
    gap: 6px;
    align-items: stretch;
    vertical-align: middle;
}

.hard-delete-form__input {
    min-width: 14rem;
}

/* Cards on the per-release Manage page — details / content / danger sections,
   each a bordered block stacked down the admin-page column. */
.manage-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    padding: 20px;
    margin-bottom: 20px;
    max-width: 640px;
}

.manage-card--danger {
    border-color: color-mix(in srgb, var(--color-danger, #c0233f) 45%, var(--color-border));
}

.manage-card__title {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 600;
}

.manage-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Background-workers page: a readable block for a failed import's full error
   message (e.g. an Npgsql stack), so it's not crammed into a table cell. */
.worker-failure__meta {
    margin: 0 0 8px;
    font-size: 13px;
}

.worker-failure__error {
    margin: 0;
    padding: 12px;
    border-radius: var(--radius);
    background: var(--color-bg, #1116);
    color: var(--color-text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 280px;
    overflow: auto;
}

/* File pickers: style the native control's button portion to match our
   outline .btn instead of the browser default grey chrome. The input keeps
   a light frame; the ::file-selector-button carries the button look. */
.field__input--file {
    padding: 6px;
    cursor: pointer;
}

.field__input--file::file-selector-button {
    margin-right: 12px;
    padding: 7px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
}

.field__input--file::file-selector-button:hover {
    background: var(--color-bg);
}

/* Upload + ingest feedback on the Import Release form, shown as a top-of-form
   alert banner while a submit is in flight. The bar runs determinate while
   bytes upload (driven by object-explorer-import.js), then drops its value
   attribute to go indeterminate for the server-side parse. Layout is scoped to
   :not([hidden]) so the `hidden` attribute keeps it off until upload starts. */
.oe-import-progress:not([hidden]) {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    padding: 14px 16px;
    border: 1px solid var(--color-accent);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--color-accent) 10%, var(--color-surface));
}

.oe-import-progress__row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 13.5px;
    font-weight: 600;
}

.oe-import-progress__pct {
    font-variant-numeric: tabular-nums;
    color: var(--color-text-muted, var(--color-text));
}

.oe-import-progress__bar {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    height: 10px;
    border: none;
    border-radius: 999px;
    background: var(--color-bg);
    overflow: hidden;
}

.oe-import-progress__bar::-webkit-progress-bar {
    background: var(--color-bg);
    border-radius: 999px;
}

.oe-import-progress__bar::-webkit-progress-value {
    background: var(--color-accent);
    border-radius: 999px;
    transition: width 0.15s linear;
}

.oe-import-progress__bar::-moz-progress-bar {
    background: var(--color-accent);
    border-radius: 999px;
}

.oe-import-progress__hint {
    margin: 0;
    font-size: 12px;
}

/* Bottom-of-table pagination strip used by /admin/audit. Counter on the
   left, prev/next on the right; disabled state is presentational so the
   anchor still renders for the keyboard tab order. */
.audit-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    gap: 16px;
    flex-wrap: wrap;
}

.audit-pagination__buttons {
    display: inline-flex;
    gap: 8px;
}

.btn--disabled,
.btn--disabled:hover,
.btn[aria-disabled="true"],
.btn[aria-disabled="true"]:hover {
    opacity: 0.45;
    pointer-events: none;
    cursor: default;
}

.form-success {
    color: var(--color-valid);
    background: var(--color-surface);
    border: 1px solid var(--color-valid);
    border-radius: var(--radius);
    padding: 8px 12px;
    /* Separate the toast from the form below — without bottom margin the
       success message sat flush against the next section header. */
    margin: 0 0 16px;
    font-size: 13px;
}

.form-field-error {
    display: block;
    color: var(--color-error-text);
    font-size: 12px;
    margin-top: 4px;
}

/* Used by the "Import config" section on the builder pages — keeps the
   field-keyed validation errors visible without obscuring the rest of the
   form. */
ul.form-field-error {
    margin: 4px 0 0;
    padding-left: 20px;
    list-style: disc;
}

.form-section textarea.json-editor {
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.5;
}

/* Inline failure reason under a "Failed" release status in the admin list,
   so a background import error is visible without digging through logs. */
.oe-status-error {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--color-error-text);
    max-width: 32ch;
}
