.local-mathewplugin-nav {
    margin-left: 0.5rem;
    display: inline-flex;
    align-items: center;
}

/*
 * Mirrors the Mathew ui package button (UiButton, color primary, filling
 * outline, size sm). Token values are inlined because Moodle does not ship
 * the ui package stylesheet; the comments map each one to its design token.
 */
.local-mathewplugin-nav__button {
    --mathewplugin-primary: #5e60ea;            /* color-primary-400 */
    --mathewplugin-primary-pressed: #2a1dc0;    /* color-primary-800 */
    --mathewplugin-primary-border: #c8c7f8;     /* color-primary-100 */
    --mathewplugin-on-primary: #f4f4fe;         /* color-primary-25 */
    --mathewplugin-surface: #ffffff;            /* color-white */
    --mathewplugin-ink: #111823;                /* color-neutral-1000 */
    --mathewplugin-icon-size: 16px;             /* size-sm icon container */

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;                                /* spacing-2 */
    padding: 0.5rem 0.75rem;                    /* spacing-2 / spacing-3 */
    border: 1px solid var(--mathewplugin-primary-border);
    border-radius: 0.75rem;                     /* border-radius-3 */
    background-color: var(--mathewplugin-surface);
    color: var(--mathewplugin-ink);
    font-size: 0.875rem;                        /* font-size-body-3 */
    line-height: 1rem;                          /* line-height-body-3 */
    font-weight: 600;                           /* font-weight-semibold */
    text-decoration: none;
    cursor: pointer;
    transition: background-color 200ms ease-out, border-color 200ms ease-out, color 200ms ease-out;
}

.local-mathewplugin-nav__button:hover,
.local-mathewplugin-nav__button:focus,
.local-mathewplugin-nav__button:focus-visible {
    background-color: var(--mathewplugin-primary);
    border-color: var(--mathewplugin-primary);
    color: var(--mathewplugin-on-primary);
    text-decoration: none;
}

.local-mathewplugin-nav__button:active {
    background-color: var(--mathewplugin-primary-pressed);
    border-color: var(--mathewplugin-primary-pressed);
    color: var(--mathewplugin-on-primary);
}

.local-mathewplugin-nav__button:focus-visible {
    outline: 2px solid var(--mathewplugin-ink);
    outline-offset: 2px;
}

.local-mathewplugin-nav__icon {
    display: block;
    flex: 0 0 var(--mathewplugin-icon-size);
    width: var(--mathewplugin-icon-size);
    height: var(--mathewplugin-icon-size);
    fill: currentColor;
}

.local-mathewplugin-nav__label {
    white-space: nowrap;
}

.local-mathewplugin-sso__wrapper {
    margin-bottom: 1rem;
}

.local-mathewplugin-sso--dashboard {
    max-width: 900px;
    margin: 0 auto;
    border-radius: 14px;
    border: 1px solid #cdddf0;
    background: linear-gradient(145deg, #fbfdff 0%, #f1f7ff 100%);
    box-shadow: 0 12px 24px rgba(8, 59, 108, 0.08);
    padding: 1.05rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.local-mathewplugin-sso__copy {
    min-width: 0;
}

.local-mathewplugin-sso__eyebrow {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    border: 1px solid #bfd8f2;
    background: #ffffff;
    color: #0f6cbf;
    font-size: 0.69rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.18rem 0.5rem;
    margin-bottom: 0.38rem;
}

.local-mathewplugin-sso__title {
    margin: 0 0 0.22rem;
    color: #103456;
    font-size: 1.05rem;
    line-height: 1.2;
    font-weight: 700;
}

.local-mathewplugin-sso__description {
    margin: 0;
    color: #47617b;
    font-size: 0.9rem;
    line-height: 1.4;
}

.local-mathewplugin-sso__actions {
    flex-shrink: 0;
}

.local-mathewplugin-sso__button {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border-radius: 999px;
    border: 1px solid #0f6cbf;
    background: #0f6cbf;
    color: #ffffff;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.58rem 0.9rem;
    transition: background-color 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.local-mathewplugin-sso__button:hover,
.local-mathewplugin-sso__button:focus {
    color: #ffffff;
    text-decoration: none;
    background: #0d5da6;
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(15, 108, 191, 0.22);
}

.local-mathewplugin-sso__button:focus-visible {
    outline: 2px solid #0f6cbf;
    outline-offset: 2px;
}

.local-mathewplugin-sso__button-icon {
    font-size: 0.9rem;
    line-height: 1;
}

.local-mathewplugin-setup-status,
.local-mathewplugin-setup-panel {
    margin: 1rem 0;
}

.local-mathewplugin-setup-status__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.local-mathewplugin-setup-status__item {
    border: 1px solid #d7dee6;
    border-radius: 8px;
    padding: 0.85rem;
    background: #ffffff;
}

.local-mathewplugin-setup-status__item p {
    margin: 0.35rem 0 0;
}

.local-mathewplugin-setup-status__badge {
    margin-bottom: 0.45rem;
}

.local-mathewplugin-setup-panel {
    border-top: 1px solid #d7dee6;
    padding-top: 1rem;
}

.local-mathewplugin-environment-field {
    margin-bottom: 1rem;
    width: min(100%, 32rem);
}

.local-mathewplugin-environment-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.local-mathewplugin-environment-select {
    width: 100%;
}

.local-mathewplugin-scope-field {
    margin-bottom: 1rem;
}

.local-mathewplugin-scope-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.local-mathewplugin-scope-select {
    width: min(100%, 640px);
}

.dropdown-menu .local-mathewplugin-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 1.5rem;
    white-space: nowrap;
}

.dropdown-menu .local-mathewplugin-action--activity {
    border-top: 1px solid #dee2e6;
}

.dropdown-menu .local-mathewplugin-action .icon {
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    flex: 0 0 1.125rem;
    object-fit: contain;
}

/*
 * Mathew's expanded view remains a standard mod_lti embed. The body class is
 * added only for an exact Mathew module with an explicit expanded preference,
 * keeping every selector below isolated from unrelated Moodle pages and LTIs.
 */
body.local-mathewplugin-expanded-lti {
    --local-mathewplugin-lti-top: 0px;
}

body.local-mathewplugin-expanded-lti #page.drawers .main-inner,
body.local-mathewplugin-expanded-lti #page .main-inner {
    width: 100%;
    max-width: none;
    padding-top: 0;
    padding-right: 0;
    padding-left: 0;
}

/* The course index and navbar replace the redundant activity breadcrumb/title. */
body.local-mathewplugin-expanded-lti #page-header {
    display: none;
}

body.local-mathewplugin-expanded-lti #page-content,
body.local-mathewplugin-expanded-lti #region-main-box,
body.local-mathewplugin-expanded-lti #region-main {
    width: 100%;
    max-width: none;
    margin: 0;
    padding-right: 0;
    padding-left: 0;
}

body.local-mathewplugin-expanded-lti #page-content {
    padding-bottom: 0 !important;
}

body.local-mathewplugin-expanded-lti #region-main {
    border: 0;
    border-radius: 0;
}

body.local-mathewplugin-expanded-lti iframe.lti-iframe,
body.local-mathewplugin-expanded-lti iframe#contentframe,
body.local-mathewplugin-expanded-lti iframe[name="contentframe"] {
    display: block;
    width: 100% !important;
    height: calc(100vh - var(--local-mathewplugin-lti-top)) !important;
    border: 0;
}

@supports (height: 100dvh) {
    body.local-mathewplugin-expanded-lti iframe.lti-iframe,
    body.local-mathewplugin-expanded-lti iframe#contentframe,
    body.local-mathewplugin-expanded-lti iframe[name="contentframe"] {
        height: calc(100dvh - var(--local-mathewplugin-lti-top)) !important;
    }
}

@media (max-width: 767.98px) {
    .local-mathewplugin-sso--dashboard {
        flex-direction: column;
        align-items: flex-start;
    }

    .local-mathewplugin-sso__actions {
        width: 100%;
    }

    .local-mathewplugin-sso__button {
        width: 100%;
        justify-content: center;
    }

    .local-mathewplugin-nav {
        margin-left: 0.3rem;
    }

}
