/*
 * Settings cluster of the super admin panel: page heading, status card, callouts, step lists,
 * the overview grid and the sticky save bar.
 *
 * Tokens (.wm-tile, .wm-dot, .wm-pill and the [data-tone] variables) come from panel-ui.css.
 * Filament colours are "R, G, B" triples: use rgb(var(--x)) and rgba(var(--x), .1), never rgb(var(--x) / .1).
 */

/* ---------------------------------------------------------------------------------------------- */
/* Page heading with the icon tile                                                                */
/* ---------------------------------------------------------------------------------------------- */

.wm-page-heading {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

.wm-page-heading .wm-tile {
    width: 2.5rem;
    height: 2.5rem;
}

/* ---------------------------------------------------------------------------------------------- */
/* Status card                                                                                    */
/* ---------------------------------------------------------------------------------------------- */

.wm-status-card {
    display: grid;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(var(--gray-950), 0.06);
    border-inline-start: 4px solid rgb(var(--gray-300));
}

.dark .wm-status-card {
    background: rgb(var(--gray-900));
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
    border-inline-start-color: rgb(var(--gray-600));
}

.wm-status-card[data-state="ok"] { border-inline-start-color: rgb(var(--success-500)); }
.wm-status-card[data-state="warn"] { border-inline-start-color: rgb(var(--warning-500)); }
.wm-status-card[data-state="error"] { border-inline-start-color: rgb(var(--danger-500)); }

.wm-status-card__head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.wm-status-card__titles {
    flex: 1 1 12rem;
    min-width: 0;
}

.wm-status-card__title {
    margin: 0;
    font-size: 1rem;
    line-height: 1.5rem;
    font-weight: 600;
    color: rgb(var(--gray-950));
}

.dark .wm-status-card__title { color: #fff; }

.wm-status-card__caption {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1rem;
    color: rgb(var(--gray-500));
}

.wm-status-card__summary {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.375rem;
    color: rgb(var(--gray-700));
}

.dark .wm-status-card__summary { color: rgb(var(--gray-300)); }

.wm-status-card__list {
    display: grid;
    gap: 0.25rem 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
    grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
}

.wm-status-card__row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.375rem;
    color: rgb(var(--gray-800));
}

.wm-status-card__label { white-space: nowrap; }

/* A long hint (a sentence) goes to its own line under the label, so the labels keep one clean column. */
.wm-status-card__row--long .wm-status-card__hint {
    flex-basis: 100%;
    padding-inline-start: 1rem;
    line-height: 1.125rem;
}

.wm-status-card__toggle { display: none; }

.wm-status-card__toggle svg { transition: transform 0.15s ease; transform: rotate(-90deg); }

.wm-status-card__toggle svg.wm-rotated { transform: none; }

.dark .wm-status-card__row { color: rgb(var(--gray-200)); }

.wm-status-card__row .wm-dot { transform: translateY(-0.0625rem); }

.wm-status-card__label a,
.wm-status-card__link {
    color: rgb(var(--primary-600));
    text-decoration: none;
}

.dark .wm-status-card__label a,
.dark .wm-status-card__link { color: rgb(var(--primary-400)); }

.wm-status-card__label a:hover,
.wm-status-card__link:hover { text-decoration: underline; }

.wm-status-card__hint {
    color: rgb(var(--gray-500));
    font-size: 0.8125rem;
}

.wm-status-card__bar-head {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    color: rgb(var(--gray-700));
}

.dark .wm-status-card__bar-head { color: rgb(var(--gray-300)); }

.wm-status-card__bar-value { font-variant-numeric: tabular-nums; font-weight: 500; }

.wm-status-card__foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 1.25rem;
    font-size: 0.8125rem;
    line-height: 1.25rem;
}

.wm-status-card__note {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin: 0;
    color: rgb(var(--gray-600));
}

.dark .wm-status-card__note { color: rgb(var(--gray-400)); }

.wm-status-card__note svg { flex: none; color: rgb(var(--gray-400)); }

.wm-status-card__link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.wm-bar {
    height: 0.5rem;
    border-radius: 9999px;
    overflow: hidden;
    background: rgba(var(--gray-500), 0.18);
}

.wm-bar__fill {
    height: 100%;
    border-radius: 9999px;
    background: rgb(var(--success-500));
    transition: width 0.15s ease;
}

.wm-bar__fill--warn { background: rgb(var(--warning-500)); }
.wm-bar__fill--error { background: rgb(var(--danger-500)); }

/* ---------------------------------------------------------------------------------------------- */
/* Callout                                                                                        */
/* ---------------------------------------------------------------------------------------------- */

.wm-callout {
    --wm-callout-rgb: var(--info-500, var(--primary-500));
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.625rem;
    font-size: 0.875rem;
    line-height: 1.375rem;
    background: rgba(var(--wm-callout-rgb), 0.08);
    box-shadow: inset 0 0 0 1px rgba(var(--wm-callout-rgb), 0.22);
    color: rgb(var(--gray-800));
}

.dark .wm-callout { color: rgb(var(--gray-200)); }

.wm-callout--info { --wm-callout-rgb: var(--info-500, 59, 130, 246); }
.wm-callout--success { --wm-callout-rgb: var(--success-500); }
.wm-callout--warning { --wm-callout-rgb: var(--warning-500); }
.wm-callout--danger { --wm-callout-rgb: var(--danger-500); }

.wm-callout--compact {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    line-height: 1.25rem;
}

.wm-callout__icon {
    flex: none;
    margin-top: 0.0625rem;
    color: rgb(var(--wm-callout-rgb));
}

.wm-callout__body { min-width: 0; }

.wm-callout__title { margin: 0 0 0.125rem; font-weight: 600; }
.wm-callout__line { margin: 0; }
.wm-callout__line + .wm-callout__line { margin-top: 0.25rem; }

.wm-callout__links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    margin: 0.375rem 0 0;
}

.wm-callout__links a {
    color: rgb(var(--primary-600));
    text-decoration: underline;
}

.dark .wm-callout__links a { color: rgb(var(--primary-400)); }

/* ---------------------------------------------------------------------------------------------- */
/* Steps                                                                                          */
/* ---------------------------------------------------------------------------------------------- */

.wm-steps {
    display: grid;
    gap: 0.625rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.wm-steps__item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5rem;
    color: rgb(var(--gray-800));
}

.dark .wm-steps__item { color: rgb(var(--gray-200)); }

.wm-steps__number {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(var(--gray-500), 0.14);
    color: rgb(var(--gray-700));
}

.dark .wm-steps__number { color: rgb(var(--gray-200)); }

/* ---------------------------------------------------------------------------------------------- */
/* Overview                                                                                       */
/* ---------------------------------------------------------------------------------------------- */

.wm-overview-page > section { gap: 1.5rem; }

.wm-overview__group {
    display: grid;
    gap: 0.875rem;
}

.wm-overview__group-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.wm-overview__group-title {
    margin: 0;
    font-size: 1.0625rem;
    line-height: 1.5rem;
    font-weight: 600;
    color: rgb(var(--gray-950));
}

.dark .wm-overview__group-title { color: #fff; }

.wm-overview__group-desc {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.25rem;
    color: rgb(var(--gray-500));
}

.wm-overview__grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
}

.wm-overview__card {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.75rem;
    align-items: start;
    padding: 1rem;
    border-radius: 0.75rem;
    text-decoration: none;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(var(--gray-950), 0.06);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.dark .wm-overview__card {
    background: rgb(var(--gray-900));
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.wm-overview__card:hover,
.wm-overview__card:focus-visible {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(var(--primary-500), 0.45);
}

.wm-overview__card:focus-visible { outline: 2px solid rgb(var(--primary-500)); outline-offset: 2px; }

.wm-overview__card-body {
    display: grid;
    gap: 0.125rem;
    min-width: 0;
}

.wm-overview__card-title {
    font-size: 0.9375rem;
    line-height: 1.375rem;
    font-weight: 600;
    color: rgb(var(--gray-950));
}

.dark .wm-overview__card-title { color: #fff; }

.wm-overview__card-desc,
.wm-overview__card-summary {
    font-size: 0.8125rem;
    line-height: 1.25rem;
    color: rgb(var(--gray-500));
}

.wm-overview__card-summary { color: rgb(var(--gray-700)); }
.dark .wm-overview__card-summary { color: rgb(var(--gray-300)); }

.wm-overview__card-pill {
    grid-column: 2;
    justify-self: start;
    margin-top: 0.5rem;
}

@media (prefers-reduced-motion: reduce) {
    .wm-overview__card,
    .wm-bar__fill { transition: none; }
}

/* ---------------------------------------------------------------------------------------------- */
/* Sticky save bar                                                                                */
/* ---------------------------------------------------------------------------------------------- */

.wm-sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin-inline: -0.5rem;
    padding: 0.75rem 0.75rem;
    /* Solid: the text of the form must never show through under the buttons. */
    background: #fff;
    border-top: 1px solid rgba(var(--gray-950), 0.08);
    box-shadow: 0 -6px 12px -8px rgba(0, 0, 0, 0.18);
}

.dark .wm-sticky-actions {
    background: rgb(var(--gray-900));
    border-top-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 -6px 12px -8px rgba(0, 0, 0, 0.6);
}

.wm-sticky-actions > .fi-ac { flex: none; }

.wm-sticky-actions__hint {
    font-size: 0.8125rem;
    color: rgb(var(--warning-700));
}

.dark .wm-sticky-actions__hint { color: rgb(var(--warning-300)); }

/* Nothing changed yet: save is quiet and the discard button is not offered. */
.wm-sticky-actions[data-dirty="false"] button[type="submit"] { opacity: 0.6; }
.wm-sticky-actions[data-dirty="false"] button:not([type="submit"]) { display: none; }

/* ---------------------------------------------------------------------------------------------- */
/* Secret fields: the saved marker sits in the hint line                                          */
/* ---------------------------------------------------------------------------------------------- */

.wm-settings-page .fi-fo-field-wrp-hint { align-items: center; }

/* ---------------------------------------------------------------------------------------------- */
/* Small screens                                                                                  */
/* ---------------------------------------------------------------------------------------------- */

@media (max-width: 639px) {
    .wm-status-card { padding: 0.875rem 1rem; }
    .wm-status-card__list { grid-template-columns: 1fr; }
    .wm-status-card__toggle {
        display: inline-flex;
        align-items: center;
        gap: 0.375rem;
        padding: 0;
        border: 0;
        background: none;
        font-size: 0.8125rem;
        font-weight: 500;
        color: rgb(var(--gray-700));
        cursor: pointer;
    }
    .dark .wm-status-card__toggle { color: rgb(var(--gray-300)); }
    .wm-status-card__toggle + .wm-status-card__list { margin-top: 0.5rem; }
    .wm-overview__grid { grid-template-columns: 1fr; }
    .wm-page-heading .wm-tile { width: 2.25rem; height: 2.25rem; }
}

/* ---------------------------------------------------------------------------------------------- */
/* Narrow content column                                                                          */
/* ---------------------------------------------------------------------------------------------- */

/*
 * Beside the main sidebar the sub navigation takes a column of its own, so at 1024 px the form is only about
 * 20 rem wide although the viewport says "large". Filament lays grids out by viewport width, so below a
 * container width of 44 rem every field grid of the form falls back to one column.
 */
.wm-settings-page .fi-form { container-type: inline-size; container-name: wmform; }

@container wmform (max-width: 44rem) {
    .wm-settings-page .fi-fo-component-ctn[style*="--cols-"] {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .wm-settings-page .fi-fo-component-ctn[style*="--cols-"] > * {
        grid-column: 1 / -1 !important;
    }

    /* A section action (for example "Test connection") drops under the heading instead of squeezing it. */
    .wm-settings-page .fi-section-header > .flex { flex-wrap: wrap; }

    .wm-settings-page .fi-section-header > .flex > .hidden.sm\:block { flex-basis: 100%; }
}


/* ---------------------------------------------------------------------------------------------- */
/* Sub navigation of the cluster                                                                  */
/* ---------------------------------------------------------------------------------------------- */

/*
 * The 19 pages are one long list: it stays in view while the page scrolls (own scroll when it is taller than
 * the window), takes less width and has tighter rows. Below 1280 px the same list becomes the select box that
 * Filament already renders for phones, which gives the form about 290 px back.
 */
.wm-settings-page .fi-page-sub-navigation-sidebar-ctn {
    position: sticky;
    top: 5rem;
    align-self: flex-start;
    width: 15rem;
    flex: none;
    max-height: calc(100vh - 6.5rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding-inline-end: 0.25rem;
}

.wm-settings-page .fi-page-sub-navigation-sidebar { gap: 0.25rem; }

.wm-settings-page .fi-page-sub-navigation-sidebar .fi-sidebar-group { gap: 0.125rem; }

.wm-settings-page .fi-page-sub-navigation-sidebar .fi-sidebar-group-button { padding-block: 0.375rem; }

.wm-settings-page .fi-page-sub-navigation-sidebar .fi-sidebar-item-button {
    padding-block: 0.25rem;
    gap: 0.625rem;
}

.wm-settings-page .fi-page-sub-navigation-sidebar .fi-sidebar-item-label { font-size: 0.8125rem; }

@media (max-width: 1279px) {
    .wm-settings-page .fi-page-sub-navigation-sidebar-ctn { display: none !important; }

    .wm-settings-page .fi-page-sub-navigation-select { display: flex !important; width: 100%; }

    /* Filament lays the select and the content side by side from 768 px: with the sidebar gone they stack. */
    .wm-settings-page section > .md\:flex-row { flex-direction: column; }
}

/* ---------------------------------------------------------------------------------------------- */
/* Overview: attention strip and quieter cards                                                    */
/* ---------------------------------------------------------------------------------------------- */

.wm-overview__attention {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    background: rgba(var(--warning-500), 0.1);
    box-shadow: inset 0 0 0 1px rgba(var(--warning-500), 0.28);
    color: rgb(var(--gray-800));
}

.dark .wm-overview__attention { color: rgb(var(--gray-200)); }

.wm-overview__attention-title { display: inline-flex; align-items: center; gap: 0.375rem; font-weight: 600; }

.wm-overview__attention-title svg { color: rgb(var(--warning-600)); }

.wm-overview__attention a { color: rgb(var(--primary-600)); text-decoration: none; }

.dark .wm-overview__attention a { color: rgb(var(--primary-400)); }

.wm-overview__attention a:hover { text-decoration: underline; }
