/*!
 * Leern back-office panel (/admin) - design system.
 *
 * Hand-written, no build step, no framework. Tokens and measurements are v1's
 * (.agents/reference/v1-admin-inventory.md section 3). Dark theme only.
 * Nothing here may be loaded by /admin2, and this file never loads anything from /cms.
 *
 * 1  Tokens
 * 2  Reset and base
 * 3  Layout shell (header, nav, main)
 * 4  Page header and tabs
 * 5  Tables, toolbar, pagination, empty state
 * 6  Forms (item/meta/box grid, inputs, switch, checkbox, radio, file field)
 * 7  Buttons and badges
 * 8  Modal, confirm dialog, toast
 * 9  Sortable lists, skeletons, KPI cards, charts, auth page
 * 10 Utilities
 */

/* ------------------------------------------------------------------ 1 Tokens */

:root {
    --black: #1c1c23;
    --black-2: #242429;
    --black-3: #1e1e24;
    --grey-2: #888896;
    --light-3: #f4f4f8;
    --light-4: #ceced9;

    --red: #ff3266;
    --red-darker: #ce264f;
    --danger: #ff3333;
    --danger-hover: #ce2626;
    --success: #1efdaf;
    --success-overlay: rgba(30, 253, 175, 0.2);
    --negative: #ff3266;
    --negative-overlay: rgba(240, 69, 111, 0.2);
    --warning: #fed301;
    --warning-overlay: rgba(254, 211, 1, 0.2);

    --accent-color: var(--red);
    --accent-color-hover: var(--red-darker);
    --primary-bg-color: var(--black);
    --secondary-bg-color: var(--black-2);
    --secondary-bg-color-hover: var(--black-3);
    --primary-text-color: #fff;
    --secondary-text-color: var(--grey-2);

    --border-color: rgba(255, 255, 255, 0.1);
    --border-color-active: rgba(255, 255, 255, 0.4);
    --overlay-bg-primary: rgba(28, 28, 35, 0.6);
    --hover-overlay: rgba(255, 255, 255, 0.05);

    --border-radius-primary: 16px;
    --border-radius-secondary: 8px;
    --transition-config: 0.25s ease-in-out;
    --blur-ratio: 16px;
    --box-shadow:
        rgba(0, 0, 0, 0.3) 0 13px 27px -5px,
        rgba(0, 0, 0, 0.3) 0 8px 16px -8px;

    --primary-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --header-height: 64px;
    --nav-width: 300px;
    --page-padding: 25px;
}

/* ------------------------------------------------------- 2 Reset and base */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body.admin {
    margin: 0;
    background: var(--primary-bg-color);
    color: var(--primary-text-color);
    font-family: var(--primary-font-family);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/*
 * Headings carry no size of their own here: every heading in the panel sits in a
 * wrapper that styles it (.page-header, .admin-settings-page .meta, .section-title,
 * .box__title, .modal__header). Resetting size and weight as well as the margin is
 * what lets a screen use the correct <h2>/<h3> tag instead of a styled <span>.
 */
h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
}

p,
figure,
fieldset {
    margin: 0;
}

fieldset {
    padding: 0;
    border: 0;
    min-width: 0;
}

ul,
ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition-config);
}

a.link {
    color: var(--secondary-text-color);
    text-decoration: underline;
    text-underline-offset: 2px;
}

a.link:hover {
    color: var(--primary-text-color);
}

img,
svg {
    vertical-align: middle;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

table {
    border-collapse: collapse;
    border-spacing: 0;
}

hr {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 20px 0;
}

code,
.mono {
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 13px;
}

:focus-visible {
    outline: 2px solid var(--border-color-active);
    outline-offset: 2px;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

.icon {
    flex: none;
}

/* -------------------------------------------------------- 3 Layout shell */

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 10100;
    padding: 10px 15px;
    background: var(--secondary-bg-color);
    border-radius: var(--border-radius-secondary);
}

.skip-link:focus {
    left: 15px;
    top: 15px;
}

.admin-header {
    position: sticky;
    top: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: var(--header-height);
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    background: var(--overlay-bg-primary);
    backdrop-filter: blur(var(--blur-ratio));
    -webkit-backdrop-filter: blur(var(--blur-ratio));
}

.admin-header__brand {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.admin-header__spacer {
    flex: 1;
}

.admin-header__user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--secondary-text-color);
}

.admin-header__user strong {
    font-weight: 500;
    color: var(--primary-text-color);
}

.nav-toggle {
    display: none;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-secondary);
    background: transparent;
    color: var(--primary-text-color);
    cursor: pointer;
}

.admin-body {
    display: flex;
    align-items: flex-start;
    min-height: calc(100vh - var(--header-height));
}

.admin-nav {
    position: sticky;
    top: var(--header-height);
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: var(--nav-width);
    min-width: var(--nav-width);
    height: calc(100vh - var(--header-height));
    padding: 15px;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
}

.admin-nav__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px;
    border-radius: var(--border-radius-secondary);
    color: var(--secondary-text-color);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.1px;
    transition:
        color var(--transition-config),
        background var(--transition-config);
}

.admin-nav__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: var(--border-radius-secondary);
    background: var(--secondary-bg-color);
}

.admin-nav__item:hover,
.admin-nav__item.is-active {
    color: var(--primary-text-color);
}

.admin-nav__item.is-active {
    background: var(--hover-overlay);
}

.admin-nav__footer {
    margin-top: auto;
    padding-top: 15px;
    font-size: 13px;
    color: var(--secondary-text-color);
}

.admin-nav-backdrop {
    display: none;
}

.admin-main {
    flex: 1;
    min-width: 0;
}

.page-content {
    padding: var(--page-padding);
}

@media (max-width: 991px) {
    .nav-toggle {
        display: inline-flex;
    }

    .admin-nav {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        z-index: 9998;
        width: 100%;
        min-width: 0;
        height: auto;
        background: var(--primary-bg-color);
        border-right: 0;
        transform: translateX(-100%);
        transition: transform var(--transition-config);
    }

    .admin-nav.is-open {
        transform: translateX(0);
    }

    .admin-nav-backdrop.is-open {
        display: block;
        position: fixed;
        inset: var(--header-height) 0 0 0;
        z-index: 9997;
        background: var(--overlay-bg-primary);
    }

    :root {
        --page-padding: 15px;
    }
}

/* ------------------------------------------------- 4 Page header and tabs */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    min-height: 75px;
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
}

.page-header__title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

/*
 * The title column shrinks (min-width: 0) so the h1's own .truncate can ellipsise,
 * while the description below it wraps normally. .truncate must never sit on this
 * wrapper: white-space: nowrap inherits into the <p>, and the ellipsis stays on the
 * wrapper - which clipped the description mid-sentence at 390px.
 */
.page-header__heading {
    min-width: 0;
}

.page-header h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.page-header__description {
    margin-top: 2px;
    font-size: 13px;
    font-weight: 400;
    color: var(--secondary-text-color);
}

.page-header__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: none;
}

.page-header__back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 35px;
    background: var(--secondary-bg-color);
    color: var(--primary-text-color);
    opacity: 0.7;
    transition: opacity var(--transition-config);
}

.page-header__back:hover {
    opacity: 1;
}

.tab-bar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 5px;
    height: 50px;
    padding: 0 25px;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    overflow-y: hidden;
    /* No scrollbar at all (owner, WP-UI2): a classic scrollbar drew a grey 10px bar under
       the tabs. The bar still scrolls by trackpad, touch, shift+wheel and - through
       admin.js (initTabBars) - a plain vertical wheel; the edge fade is the overflow hint. */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/*
 * admin.js (initTabBars) marks the side that still hides tabs and the bar fades out there.
 * The second mask layer keeps the 1px bottom border unfaded.
 */
.tab-bar.is-fade-start {
    --tab-fade-start: 48px;
}

.tab-bar.is-fade-end {
    --tab-fade-end: 48px;
}

.tab-bar.is-fade-start,
.tab-bar.is-fade-end {
    -webkit-mask-image:
        linear-gradient(
            to right,
            transparent,
            #000 var(--tab-fade-start, 0px),
            #000 calc(100% - var(--tab-fade-end, 0px)),
            transparent
        ),
        linear-gradient(#000, #000);
    mask-image:
        linear-gradient(
            to right,
            transparent,
            #000 var(--tab-fade-start, 0px),
            #000 calc(100% - var(--tab-fade-end, 0px)),
            transparent
        ),
        linear-gradient(#000, #000);
    -webkit-mask-size:
        100% calc(100% - 1px),
        100% 1px;
    mask-size:
        100% calc(100% - 1px),
        100% 1px;
    -webkit-mask-position: top, bottom;
    mask-position: top, bottom;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
}

.tab-bar::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.tab-bar__item {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 12px;
    border-radius: var(--border-radius-secondary);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.15px;
    white-space: nowrap;
    color: var(--secondary-text-color);
    transition:
        color var(--transition-config),
        background var(--transition-config);
}

.tab-bar__item:hover {
    background: var(--hover-overlay);
    color: var(--primary-text-color);
}

.tab-bar__item.is-active {
    color: var(--primary-text-color);
}

.tab-bar__item.is-active::after {
    content: '';
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: -6px;
    height: 2px;
    background: var(--primary-text-color);
}

.tab-bar__spacer {
    flex: 1;
    min-width: 10px;
}

/* ------------------------------------------------------------- 5 Tables */

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.table-toolbar__actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-field {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.search-field .icon {
    position: absolute;
    left: 15px;
    color: var(--secondary-text-color);
    pointer-events: none;
}

.search-field input {
    height: 40px;
    width: 260px;
    max-width: 100%;
    padding: 0 15px 0 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-secondary);
    background: var(--primary-bg-color);
    color: var(--primary-text-color);
    font-size: 14px;
}

.search-field input::placeholder {
    color: var(--secondary-text-color);
}

.search-field input:focus {
    outline: none;
    border-color: var(--border-color-active);
}

.table-frame {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-secondary);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    table-layout: fixed;
    min-width: 640px;
}

.data-table th {
    height: 50px;
    padding: 15px 25px;
    background: var(--secondary-bg-color);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
}

.data-table th.is-right,
.data-table td.is-right {
    text-align: right;
}

.data-table th.is-center,
.data-table td.is-center {
    text-align: center;
}

.data-table td {
    height: 60px;
    padding: 15px 25px;
    background: var(--primary-bg-color);
    border-top: 1px solid var(--border-color);
    font-size: 14px;
    font-weight: 300;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/*
 * The up/down column of the three ordered lists (courses, carousels, categories):
 * <x-admin.table>'s `'move' => true` writes a fixed 105px <col>. A % column (v1's 6%)
 * was 65px at 1440 against the 76px the two 36px buttons need beside 50px of padding,
 * and `overflow: hidden` on the cell cut "Move down" off - visible but unclickable.
 */
.data-table th.col-move,
.data-table td.col-move {
    padding-left: 15px;
    padding-right: 10px;
}

/* A cell of buttons never ellipsises: clipping a control is worse than a wide cell. */
.data-table td:has(.row-actions, .move-actions) {
    overflow: visible;
    text-overflow: clip;
}

.data-table tbody tr.is-clickable:hover td {
    background: var(--secondary-bg-color);
    cursor: pointer;
}

.data-table td.is-wrap {
    white-space: normal;
}

.table-no-results,
.data-table td.table-no-results {
    height: auto;
    padding: 32px;
    white-space: normal;
    text-align: center;
    font-size: 14px;
    color: var(--secondary-text-color);
    background: var(--primary-bg-color);
    border-top: 1px solid var(--border-color);
}

.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.btn-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 35px;
    background: var(--secondary-bg-color);
    color: var(--primary-text-color);
    opacity: 0.7;
    cursor: pointer;
    transition:
        opacity var(--transition-config),
        color var(--transition-config);
}

.btn-circle:hover {
    opacity: 1;
}

.btn-circle:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.btn-circle.is-danger {
    color: var(--danger);
}

.move-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 15px;
    font-size: 13px;
    color: var(--secondary-text-color);
}

.pagination__pages {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pagination__pages a,
.pagination__pages span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-secondary);
    color: var(--secondary-text-color);
    transition:
        color var(--transition-config),
        border-color var(--transition-config);
}

.pagination__pages a:hover {
    color: var(--primary-text-color);
    border-color: var(--border-color-active);
}

.pagination__pages .is-active {
    color: var(--primary-text-color);
    border-color: var(--border-color-active);
}

.pagination__pages .is-disabled {
    opacity: 0.4;
}

.empty-state {
    padding: 48px 25px;
    text-align: center;
    color: var(--secondary-text-color);
}

.empty-state__title {
    margin-top: 12px;
    font-size: 16px;
    font-weight: 500;
    color: var(--primary-text-color);
}

.empty-state__text {
    margin-top: 4px;
    font-size: 13px;
}

@media (max-width: 500px) {
    .data-table th,
    .data-table td {
        height: 50px;
        padding: 0 15px;
    }
}

/* -------------------------------------------------------------- 6 Forms */

.admin-settings-page {
    padding: 0 var(--page-padding);
}

/*
 * A form section stacks its title and description (.meta) above the content
 * (.inner), which takes the full content width - v1's layout, owner 2026-10-02
 * (task admin-full-width-layout). Never reintroduce a side column: it squeezed
 * the wide editors (certificate builder, course editor, tables).
 */
.admin-settings-page .item {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 25px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.admin-settings-page .item:last-child {
    border-bottom: 0;
}

.admin-settings-page .meta h2 {
    font-size: 16px;
    font-weight: 500;
    letter-spacing: -0.1px;
}

.admin-settings-page .meta p {
    max-width: 720px;
    margin-top: 4px;
    font-size: 13px;
    font-weight: 400;
    color: var(--secondary-text-color);
}

.admin-settings-page .inner {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.box {
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.box + .box {
    margin-top: 15px;
}

.box__title {
    margin-bottom: 15px;
    font-size: 14px;
    font-weight: 500;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.grid-1 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.is-full {
    grid-column: 1 / -1;
}

.controls {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: var(--overlay-bg-primary);
    backdrop-filter: blur(var(--blur-ratio));
    -webkit-backdrop-filter: blur(var(--blur-ratio));
}

.controls__hint {
    margin-right: auto;
    font-size: 13px;
    color: var(--secondary-text-color);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field__label {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.1px;
}

.field__label .is-required {
    color: var(--accent-color);
}

.field__help {
    font-size: 13px;
    color: var(--secondary-text-color);
}

.field__error {
    font-size: 13px;
    color: var(--danger);
}

.input,
.select,
.textarea {
    width: 100%;
    height: 40px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--border-radius-secondary);
    background: var(--secondary-bg-color);
    color: var(--primary-text-color);
    font-size: 14px;
    transition:
        box-shadow var(--transition-config),
        border-color var(--transition-config);
}

.input::placeholder,
.textarea::placeholder {
    color: var(--secondary-text-color);
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    box-shadow: inset 0 0 0 1px #6b7280;
}

.input:disabled,
.select:disabled,
.textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input--xl {
    height: 50px;
}

.input--lg {
    height: 40px;
}

.input--base {
    height: 36px;
}

.input--sm {
    height: 30px;
    padding: 0 12px;
}

.input--xs {
    height: 26px;
    padding: 0 10px;
    font-size: 13px;
}

.input--secondary,
.select--secondary,
.textarea--secondary {
    background: var(--primary-bg-color);
    border-color: var(--border-color);
}

.textarea {
    height: auto;
    min-height: 110px;
    padding: 12px 16px;
    resize: vertical;
    line-height: 1.5;
}

.select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 38px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888896' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 9 7 7 7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 16px;
    cursor: pointer;
}

/*
 * A plain single-line control in a form section stops at 720px, so a lone
 * "Title" does not span the whole screen. Textareas, list boxes, input groups,
 * file fields, tables and the editors keep the full width.
 */
.admin-settings-page .field > .input,
.admin-settings-page .field > .select:not([multiple]) {
    max-width: 720px;
}

/* A list box (multiple, size="n") shows n rows: no fixed height, no dropdown chevron. */
.select[multiple] {
    height: auto;
    padding: 8px 12px;
    background-image: none;
    cursor: default;
}

.select option {
    background: var(--secondary-bg-color);
    color: var(--primary-text-color);
}

.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea {
    border-color: var(--danger);
    animation: field-shake 0.3s ease-in-out;
}

@keyframes field-shake {
    0%,
    100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-4px);
    }
    75% {
        transform: translateX(4px);
    }
}

.input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-group .input {
    flex: 1;
}

/* x-admin.color-field: a native swatch beside the hex text input, same height. */
.color-field {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 720px;
}

.color-field .input {
    flex: 1;
}

.color-field__swatch {
    flex: none;
    width: 40px;
    height: 40px;
    padding: 4px;
    border: 1px solid transparent;
    border-radius: var(--border-radius-secondary);
    background: var(--secondary-bg-color);
    cursor: pointer;
}

.color-field__swatch::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-field__swatch::-webkit-color-swatch {
    border: 0;
    border-radius: 4px;
}

.color-field__swatch::-moz-color-swatch {
    border: 0;
    border-radius: 4px;
}

.color-field__swatch:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 1px #6b7280;
}

.field.has-error .color-field__swatch {
    border-color: var(--danger);
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.switch__track {
    position: relative;
    display: block;
    width: 50px;
    min-width: 50px;
    height: 24px;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.1);
    transition: background var(--transition-config);
}

.switch__track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--secondary-text-color);
    transition:
        transform var(--transition-config),
        background var(--transition-config);
}

.switch input:checked + .switch__track {
    background: var(--secondary-text-color);
}

.switch input:checked + .switch__track::after {
    transform: translateX(26px);
    background: #fff;
}

.switch input:focus-visible + .switch__track {
    outline: 2px solid var(--border-color-active);
    outline-offset: 2px;
}

.switch input:disabled + .switch__track {
    opacity: 0.5;
}

.switch__label {
    font-size: 14px;
    font-weight: 500;
}

.choice {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
}

.choice input {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    width: 20px;
    height: 20px;
    min-width: 20px;
    margin: 0;
    border: 1px solid var(--border-color-active);
    border-radius: 6px;
    background: var(--secondary-bg-color);
    cursor: pointer;
    transition:
        background var(--transition-config),
        border-color var(--transition-config);
}

.choice input[type='radio'] {
    border-radius: 50%;
}

.choice input:checked {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.choice input[type='checkbox']:checked::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.choice input[type='radio']:checked::after {
    content: '';
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    background: #fff;
}

.choice input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.choice-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/*
 * flex-wrap + a real flex-basis on the body is what gives the file name and the
 * hint their space: in a .grid-2 column the field is ~330px wide, and preview (64)
 * + Choose/Remove (114) left the text 89px - "No file cho..." and a four-line hint.
 * With a 160px basis the buttons drop to their own line instead of squeezing the
 * text, and on a wide field everything still sits on one row.
 */
.file-field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    transition: border-color var(--transition-config);
}

.file-field > .row {
    flex: none;
    margin-left: auto;
}

.file-field.is-dragover {
    border-color: var(--border-color-active);
}

.file-field__preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    min-width: 64px;
    border-radius: var(--border-radius-secondary);
    background: var(--secondary-bg-color);
    color: var(--secondary-text-color);
    overflow: hidden;
}

.file-field__preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-field__body {
    flex: 1 1 160px;
    min-width: 0;
}

.file-field__name {
    display: block;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-field__hint {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    color: var(--secondary-text-color);
}

.file-field input[type='file'] {
    display: none;
}

/* Direct video upload (admin.js uploadVideo): the bar under the file name while the parts go to S3. */
.file-field__progress {
    display: block;
    width: 100%;
    height: 6px;
    margin-top: 8px;
    border: 0;
    border-radius: 3px;
    background: var(--secondary-bg-color);
    overflow: hidden;
    appearance: none;
}

.file-field__progress::-webkit-progress-bar {
    background: var(--secondary-bg-color);
}

.file-field__progress::-webkit-progress-value {
    background: var(--accent-color);
}

.file-field__progress::-moz-progress-bar {
    background: var(--accent-color);
}

.file-field.is-uploading {
    border-color: var(--border-color-active);
}

/*
 * The one-line variant for a list row (course materials): file name + one button in the
 * dashed box, no preview. `.material-row` wraps, and the title and the file control both
 * keep a real flex-basis, so at 1280 and 390 the file control drops to its own line
 * instead of squeezing the title to nothing.
 */
.file-field--compact {
    flex-wrap: nowrap;
    gap: 10px;
    min-height: 40px;
    padding: 6px 6px 6px 14px;
    border-radius: var(--border-radius-secondary);
}

.file-field--compact .file-field__name {
    flex: 1;
    min-width: 0;
    color: var(--secondary-text-color);
}

.file-field--compact .btn {
    flex: none;
}

/*
 * One framed row per material (WP-UI2): title, then one controls group (download link, file
 * control, trash button) that wraps as a whole, so a stored and a new row break the same way
 * and the trash button always stays beside the file control. The frame shows which lines
 * belong to one material once the row has wrapped (1280, 390).
 */
.material-row {
    flex-wrap: wrap;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-secondary);
}

.material-row > .spacer {
    flex: 1 1 240px;
    min-width: 0;
}

.material-row__controls {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1 1 280px;
    min-width: 0;
}

.material-row__controls > .btn,
.material-row__controls > .btn-circle {
    flex: none;
    margin-top: 2px;
}

.material-row__file {
    flex: 1;
    min-width: 0;
}

.field.has-error .file-field--compact {
    border-color: var(--danger);
}

@media (max-width: 991px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* -------------------------------------------- 7 Buttons and badges */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 30px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: var(--border-radius-secondary);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: -0.1px;
    white-space: nowrap;
    cursor: pointer;
    transition:
        background var(--transition-config),
        border-color var(--transition-config),
        color var(--transition-config);
}

.btn--lg {
    height: 40px;
    padding: 0 24px;
    font-size: 14px;
}

.btn--xl {
    height: 50px;
    padding: 0 28px;
    font-size: 14px;
}

.btn--sm {
    height: 26px;
    padding: 0 10px;
}

.btn--block {
    width: 100%;
}

.btn--primary {
    background: var(--accent-color);
    color: #fff;
}

.btn--primary:hover {
    background: var(--accent-color-hover);
}

.btn--danger {
    background: var(--danger);
    color: #fff;
}

.btn--danger:hover {
    background: var(--danger-hover);
}

.btn--secondary {
    background: var(--secondary-bg-color);
    color: var(--primary-text-color);
}

.btn--secondary:hover {
    background: var(--secondary-bg-color-hover);
}

.btn--tertiary {
    background: transparent;
    color: var(--secondary-text-color);
}

.btn--tertiary:hover {
    background: var(--hover-overlay);
    color: var(--primary-text-color);
}

.btn--outline {
    background: transparent;
    border-color: var(--border-color);
    color: var(--primary-text-color);
}

.btn--outline:hover {
    border-color: var(--border-color-active);
}

.btn--outline.btn--danger {
    background: transparent;
    border-color: rgba(255, 51, 51, 0.4);
    color: var(--danger);
}

.btn--outline.btn--danger:hover {
    border-color: var(--danger);
}

.btn--outline.btn--primary {
    background: transparent;
    border-color: rgba(255, 50, 102, 0.5);
    color: var(--accent-color);
}

.btn--outline.btn--primary:hover {
    border-color: var(--accent-color);
}

.btn--icon {
    width: 30px;
    padding: 0;
}

.btn--icon.btn--lg {
    width: 40px;
}

.btn:disabled,
.btn.is-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.btn.is-loading {
    pointer-events: none;
}

.btn.is-loading .icon {
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.badge {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.1px;
    background: var(--hover-overlay);
    color: var(--secondary-text-color);
}

.badge--success {
    background: var(--success-overlay);
    color: var(--success);
}

.badge--danger {
    background: var(--negative-overlay);
    color: var(--danger);
}

.badge--warning {
    background: var(--warning-overlay);
    color: var(--warning);
}

.badge--accent {
    background: var(--negative-overlay);
    color: var(--accent-color);
}

.badge--neutral {
    background: var(--hover-overlay);
    color: var(--light-4);
}

/* --------------------------------------- 8 Modal, confirm dialog, toast */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--overlay-bg-primary);
    backdrop-filter: blur(var(--blur-ratio));
    -webkit-backdrop-filter: blur(var(--blur-ratio));
    overflow-y: auto;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 40px);
    background: var(--primary-bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-primary);
    box-shadow: var(--box-shadow);
    animation: modal-pop 0.2s ease-out;
}

.modal--sm {
    max-width: 420px;
}

.modal--lg {
    max-width: 760px;
}

.modal--xl {
    max-width: 1040px;
}

@keyframes modal-pop {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
}

.modal__header h2 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.1px;
}

.modal__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 35px;
    background: transparent;
    color: var(--secondary-text-color);
    cursor: pointer;
    transition: color var(--transition-config);
}

.modal__close:hover {
    color: var(--primary-text-color);
}

.modal__body {
    padding: 25px;
    overflow-y: auto;
}

.modal__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 25px;
    border-top: 1px solid var(--border-color);
}

.confirm-dialog {
    max-width: 420px;
}

.confirm-dialog .modal__body {
    text-align: center;
    padding: 30px 25px 20px;
}

.confirm-dialog__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin-bottom: 15px;
    border-radius: 50%;
    background: var(--negative-overlay);
    color: var(--accent-color);
}

.confirm-dialog__title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.confirm-dialog__text {
    margin-top: 8px;
    font-size: 14px;
    color: var(--secondary-text-color);
}

.confirm-dialog .modal__footer {
    justify-content: center;
    border-top: 0;
    padding-top: 0;
}

.toast-stack {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 10010;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100vw - 30px));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--success);
    border-radius: 12px;
    background: var(--secondary-bg-color);
    box-shadow: var(--box-shadow);
    font-size: 14px;
    pointer-events: auto;
    animation: toast-in 0.25s ease-out;
}

.toast--success {
    border-left-color: var(--success);
    color: var(--primary-text-color);
}

.toast--success .toast__icon {
    color: var(--success);
}

.toast--error {
    border-left-color: var(--danger);
}

.toast--error .toast__icon {
    color: var(--danger);
}

.toast--warning {
    border-left-color: var(--warning);
}

.toast--warning .toast__icon {
    color: var(--warning);
}

.toast__body {
    flex: 1;
    min-width: 0;
}

.toast__close {
    border: 0;
    background: transparent;
    color: var(--secondary-text-color);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.toast.is-leaving {
    animation: toast-out 0.25s ease-in forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(16px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateX(16px);
    }
}

/* ------------------- 9 Sortable lists, skeletons, KPI cards, charts, auth */

.sortable-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sortable-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--primary-bg-color);
}

/*
 * The text side of a row shrinks (a flex item's min-width is its content by default,
 * so a long nowrap .truncate description made carousel 119 3534px wide and pushed
 * its buttons off-screen); the controls keep their size.
 */
.sortable-item > .stack {
    min-width: 0;
}

.sortable-item > .btn-circle,
.sortable-item > .move-actions,
.sortable-item > .drag-handle {
    flex: none;
}

/* A picker list that scrolls instead of pushing the page's Save bar away (v1: 400px). */
.sortable-list--scroll {
    max-height: 320px;
    overflow-y: auto;
}

.sortable-item.is-dragging {
    opacity: 0.4;
}

.sortable-item.is-over {
    border-color: var(--border-color-active);
}

.drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: var(--secondary-text-color);
    cursor: grab;
    background: transparent;
    border: 0;
    padding: 0;
}

.drag-handle:active {
    cursor: grabbing;
}

.skeleton {
    height: 14px;
    border-radius: var(--border-radius-secondary);
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.04),
        rgba(255, 255, 255, 0.09),
        rgba(255, 255, 255, 0.04)
    );
    background-size: 200% 100%;
    animation: skeleton 1.2s ease-in-out infinite;
}

.skeleton + .skeleton {
    margin-top: 10px;
}

@keyframes skeleton {
    from {
        background-position: 200% 0;
    }
    to {
        background-position: -200% 0;
    }
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
}

.kpi-card {
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.kpi-card__label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--secondary-text-color);
}

.kpi-card__value {
    margin-top: 8px;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.4px;
}

.kpi-card__meta {
    margin-top: 4px;
    font-size: 13px;
    color: var(--secondary-text-color);
}

.chart {
    width: 100%;
    overflow: hidden;
}

.chart svg,
.chart canvas {
    display: block;
    width: 100%;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 25px 0 15px;
    font-size: 16px;
    font-weight: 500;
}

.callout {
    display: flex;
    gap: 12px;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 14px;
    color: var(--secondary-text-color);
}

.callout--danger {
    border-color: rgba(255, 51, 51, 0.4);
    color: var(--danger);
}

.auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth__card {
    width: 100%;
    max-width: 400px;
    padding: 30px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-primary);
    background: var(--primary-bg-color);
    box-shadow: var(--box-shadow);
}

.auth__brand {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.2px;
    text-align: center;
}

.auth__title {
    margin-top: 20px;
    font-size: 16px;
    font-weight: 500;
}

.auth__text {
    margin-top: 4px;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--secondary-text-color);
}

.auth__form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.auth__footer {
    margin-top: 20px;
    text-align: center;
    font-size: 13px;
    color: var(--secondary-text-color);
}

/* ---------------------------------------------------------- 10 Utilities */

/*
 * `hidden` always hides. The UA rule is plain `display: none`, which any class that
 * sets display (.grid-2, .stack, .sortable-item, .row ...) beats - so every reveal
 * toggle and every hidden picker row showed anyway. Scripts and views toggle the
 * attribute, never a display class.
 */
[hidden] {
    display: none !important;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.stack--sm {
    gap: 10px;
}

.row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.row--end {
    justify-content: flex-end;
}

.row--between {
    justify-content: space-between;
}

.row--wrap {
    flex-wrap: wrap;
}

.spacer {
    flex: 1;
}

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

.text-danger {
    color: var(--danger);
}

.text-success {
    color: var(--success);
}

.text-sm {
    font-size: 13px;
}

.text-strong {
    font-weight: 500;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nowrap {
    white-space: nowrap;
}

.mt-0 {
    margin-top: 0;
}

.mt-10 {
    margin-top: 10px;
}

.mt-15 {
    margin-top: 15px;
}

.mt-25 {
    margin-top: 25px;
}

.mb-15 {
    margin-bottom: 15px;
}

/*
 * Visually hidden, still read out loud - and deliberately NOT position: absolute.
 * Nothing in this panel is positioned by default (a <td>, a .row-actions, a flex
 * row), so an absolutely positioned .sr-only resolves its containing block to the
 * document and escapes every overflow: auto wrapper around it: the two list screens
 * grew ~250px of horizontal page scroll at 390px because the "Delete <name>" labels
 * inside .table-frame could not be clipped. A 1px inline-block clipped with
 * clip-path stays in the flow, so the bug cannot reappear on a screen that happens
 * to have no positioned ancestor. inline-block (not the default inline) is what
 * makes the 1px box apply at all.
 */
.sr-only {
    display: inline-block;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    white-space: nowrap;
    border: 0;
    clip-path: inset(50%);
}

.is-hidden {
    display: none !important;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* File library - the media picker of <x-admin.file-field> (admin.js initFileLibrary) */

.file-library__search {
    position: relative;
    display: flex;
    align-items: center;
}

.file-library__search > svg {
    position: absolute;
    left: 14px;
    color: var(--secondary-text-color);
    pointer-events: none;
}

.file-library__search .input {
    width: 100%;
    padding-left: 38px;
}

.file-library__status {
    margin: 12px 0 0;
    font-size: 13px;
    color: var(--secondary-text-color);
}

.file-library__status:empty {
    display: none;
}

.file-library__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 15px;
}

.file-library__card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding: 8px;
    text-align: left;
    color: var(--primary-text-color);
    background: var(--secondary-bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-secondary);
    cursor: pointer;
    transition: border-color var(--transition-config);
}

.file-library__card:hover,
.file-library__card:focus-visible {
    border-color: var(--border-color-active);
}

.file-library__thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4 / 3;
    border-radius: 6px;
    background: var(--primary-bg-color);
    color: var(--secondary-text-color);
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
}

.file-library__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-library__name,
.file-library__meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-library__name {
    font-size: 13px;
}

.file-library__meta {
    font-size: 12px;
    color: var(--secondary-text-color);
}

.file-library__pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 15px;
    font-size: 13px;
}
