/* --------------------------------------------------------------------------
   Admin
   -------------------------------------------------------------------------- */

.table-wrap {
    background: var(--surface);
    border: 3px solid var(--lav-200);
    border-radius: var(--r-lg);
    box-shadow: var(--ledge);
    overflow: hidden;
}

.table-scroll { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: 0.95rem; }

table.data caption {
    text-align: left;
    font-family: var(--display);
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--heading);
    padding: 1.1rem 1.25rem 0.85rem;
}

/* Total sits beside the caption instead of in a row of stat boxes. */
.caption__count {
    display: inline-block;
    font-size: 0.85rem;
    background: var(--surface-2);
    color: var(--violet-ink);
    border-radius: var(--r-pill);
    padding: 0.1rem 0.6rem;
    margin-left: 0.35rem;
    vertical-align: 0.1em;
}

/* A heading with a small action button beside it, e.g. Subjects + search. */
.section-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.6rem;
}

/* Topics drill-down header: back button + subject badge. */
.admin-topics-head { display: inline-flex; align-items: center; gap: 0.6rem; }
.admin-topics-head .admin-row__logo { width: 32px; height: 32px; border-radius: 9px; }
.admin-topics-head .admin-row__logo svg { width: 17px; height: 17px; }

/* Editor modal: English / Bahasa Melayu panes. */
.lang-switch {
    display: inline-flex;
    gap: 0.3rem;
    background: var(--surface-2);
    border-radius: var(--r-pill);
    padding: 0.3rem;
    margin-bottom: 1.25rem;
}

.lang-switch .btn--sm { box-shadow: none; border: 0; }

.lang-switch .btn.is-active {
    background: var(--violet);
    color: #fff;
    box-shadow: 0 3px 0 var(--violet-d);
}

.lang-pane__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.lang-pane__bar .field__hint { margin: 0; }

/* Free-form subject colour: swatch + hex box side by side. */
.color-picker {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.color-picker input[type="color"] {
    flex: none;
    width: 52px;
    height: 48px;
    padding: 4px;
    border: 3px solid var(--lav-200);
    border-radius: var(--r);
    background: var(--bg);
    cursor: pointer;
}

.color-picker input[type="color"]:focus { outline: none; border-color: var(--violet); }

.color-picker input[type="text"] { flex: 1; }

.color-picker input[type="text"],
.color-picker input[type="color"] {
    font-family: var(--body);
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
}

.color-picker input[type="text"] {
    flex: 1;
    min-width: 0;
    background: var(--bg);
    border: 3px solid var(--lav-200);
    border-radius: var(--r);
    padding: 0.75rem 0.9rem;
    transition: border-color 120ms ease, background 120ms ease;
}

.color-picker input[type="text"]:focus {
    outline: none;
    background: var(--surface);
    border-color: var(--violet);
}

/* Heading takes only its own width, so the search button sits right beside the
   word rather than being pushed to the far edge. */
.section-head h2 { flex: 0 0 auto; }

/* The collapsible search box those buttons reveal. */
.finder {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: -0.8rem 0 1.5rem;
    background: var(--surface);
    border: 3px solid var(--violet);
    border-radius: var(--r-pill);
    padding: 0.15rem 0.9rem;
    color: var(--ink-mute);
    max-width: 420px;
}

.finder svg { width: 18px; height: 18px; flex: none; }

.finder input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: none;
    font-family: var(--body);
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--ink);
    padding: 0.6rem 0;
}

.finder input:focus { outline: none; }
.finder input::placeholder { color: var(--ink-mute); font-weight: 500; }

/* The magnifier stays highlighted while its box is open. */
.icon-btn.is-on { border-color: var(--violet); background: var(--violet); color: #fff; }
.icon-btn.is-on:hover { color: #fff; }

/* Search + role filters above the users table. */
.userbar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

.userbar__search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1 1 240px;
    background: var(--surface);
    border: 3px solid var(--lav-200);
    border-radius: var(--r-pill);
    padding: 0.15rem 0.9rem;
    color: var(--ink-mute);
}

.userbar__search:focus-within { border-color: var(--violet); }
.userbar__search svg { width: 18px; height: 18px; flex: none; }

.userbar__search input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: none;
    font-family: var(--body);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
    padding: 0.55rem 0;
}

.userbar__search input:focus { outline: none; }
.userbar__search input::placeholder { color: var(--ink-mute); font-weight: 500; }

/* A tab row that hugs its buttons rather than filling the width. */
.tabs--inline { flex: 0 0 auto; margin-bottom: 0; }
.tabs--inline .board-tab { flex: 0 0 auto; }

table.data th {
    text-align: left;
    font-family: var(--display);
    font-weight: 800;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--violet-ink);
    background: var(--surface-2);
    padding: 0.7rem 1.25rem;
    white-space: nowrap;
}

table.data td { padding: 0.85rem 1.25rem; border-bottom: 2px dotted var(--lav-200); font-weight: 600; }
table.data tr:last-child td { border-bottom: 0; }

.role {
    display: inline-block;
    font-family: var(--display);
    font-weight: 800;
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-radius: var(--r-pill);
    padding: 0.2rem 0.65rem;
    background: var(--surface-2);
    color: var(--violet-ink);
}

.role--admin { background: var(--violet); color: #fff; }

.cell-empty { text-align: center; color: var(--ink-mute); padding: 2rem 1.25rem; }
.cell-error { text-align: center; color: var(--bad-d); padding: 2rem 1.25rem; font-weight: 700; }

/* --------------------------------------------------------------------------
   Admin content manager
   -------------------------------------------------------------------------- */

.panel__head--split { justify-content: space-between; }

.btn--sm { font-size: 0.85rem; padding: 0.5rem 0.85rem; box-shadow: 0 3px 0 var(--violet-d); }
.btn--sm svg { width: 16px; height: 16px; }
.btn--ghost.btn--sm { box-shadow: 0 3px 0 var(--lav-200); }

/* Square icon-only button for move/delete actions. */
.icon-btn {
    flex: none;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 2px solid var(--lav-200);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink-soft);
    cursor: pointer;
    transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}

.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover:not(:disabled) { border-color: var(--violet); color: var(--violet-ink); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn--danger:hover:not(:disabled) { border-color: var(--bad); color: var(--bad-d); background: var(--wash-coral); }

.admin-list { list-style: none; margin: 0; padding: 0; }

.admin-row {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-wrap: wrap;
    padding: 0.85rem 0;
    border-bottom: 2px dotted var(--lav-200);
}

.admin-row:last-child { border-bottom: 0; }

.admin-row__swatch {
    flex: none;
    width: 16px;
    height: 16px;
    border-radius: 5px;
    background: var(--violet);
    transform: rotate(12deg);
}

.admin-row__swatch--violet { background: var(--violet); }
.admin-row__swatch--mint   { background: var(--mint); }
.admin-row__swatch--sky    { background: var(--sky); }
.admin-row__swatch--coral  { background: var(--coral); }
.admin-row__swatch--sun    { background: var(--sun); }

/* Subject logo swatch in the admin list: the chosen icon on its colour. */
.admin-row__logo {
    flex: none;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: #fff;
    background: var(--violet);
}

.admin-row__logo svg { width: 20px; height: 20px; }
.admin-row__logo--violet { background: var(--violet); }
.admin-row__logo--mint   { background: var(--mint-d); }
.admin-row__logo--sky    { background: var(--sky-d); }
.admin-row__logo--coral  { background: var(--coral-d); }
.admin-row__logo--sun    { background: var(--sun-d); }

/* Icon chooser in the subject form. */
.icon-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.icon-pick {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 3px solid var(--lav-200);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--ink-soft);
    cursor: pointer;
    transition: border-color 120ms ease, color 120ms ease, transform 90ms ease;
}

.icon-pick svg { width: 22px; height: 22px; }
.icon-pick:hover { color: var(--violet-ink); border-color: var(--lav-300); }
.icon-pick.is-chosen {
    border-color: var(--violet);
    color: #fff;
    background: var(--violet);
    transform: translateY(-1px);
}

.admin-row__main { flex: 1; min-width: 220px; }

.admin-row__title {
    display: block;
    font-family: var(--display);
    font-weight: 800;
    font-size: 1.05rem;
    line-height: 1.25;
}

.admin-row__meta {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink-mute);
    margin-top: 0.15rem;
}

.admin-row__meta strong { color: var(--bad-d); }

.admin-row__actions { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }

.admin-group + .admin-group {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 3px dotted var(--lav-200);
}

.admin-group__head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 0.35rem;
}

.admin-group__head h3 { flex: 1; min-width: 140px; font-size: 1.2rem; }

/* Draft / Coming soon / Published pill. */
.status {
    display: inline-block;
    font-family: var(--display);
    font-weight: 800;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-radius: var(--r-pill);
    padding: 0.1rem 0.5rem;
    margin-right: 0.35rem;
    background: var(--surface-2);
    color: var(--ink-soft);
}

.status--published { background: var(--wash-mint); color: var(--good-d); }
.status--coming_soon { background: var(--wash-sun); color: var(--sun-d); }
.status--draft { background: var(--surface-2); color: var(--ink-mute); }

/* Question list inside the editor. */
.qlist { list-style: none; margin: 0 0 1.25rem; padding: 0; counter-reset: q; }

.qlist__item {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    flex-wrap: wrap;
    padding: 0.8rem 0;
    border-bottom: 2px dotted var(--lav-200);
    counter-increment: q;
}

.qlist__item:last-child { border-bottom: 0; }

.qlist__body { flex: 1; min-width: 200px; }

.qlist__prompt {
    margin: 0 0 0.2rem;
    font-weight: 700;
}

.qlist__prompt::before {
    content: counter(q) ". ";
    font-family: var(--display);
    font-weight: 800;
    color: var(--violet-ink);
}

.qlist__answer { margin: 0; font-size: 0.85rem; font-weight: 600; color: var(--ink-mute); }

/* Answer rows in the question form. */
.option-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.5rem 0;
    border-bottom: 2px dotted var(--lav-200);
}

.option-row:last-of-type { border-bottom: 0; }

.option-row__pick {
    flex: none;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    padding-top: 0.5rem;
}

.option-row__pick input { width: 18px; height: 18px; accent-color: var(--violet); cursor: pointer; }

.option-row__letter {
    font-family: var(--display);
    font-weight: 800;
    color: var(--ink-mute);
    width: 1ch;
}

.option-row__pick input:checked + .option-row__letter { color: var(--good-d); }

.option-row__inputs { flex: 1; min-width: 0; display: grid; gap: 0.35rem; }

.option-row__inputs input {
    width: 100%;
    font-family: var(--body);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink);
    background: var(--bg);
    border: 2px solid var(--lav-200);
    border-radius: var(--r-sm);
    padding: 0.5rem 0.7rem;
}

.option-row__inputs input:focus { outline: none; border-color: var(--violet); background: var(--surface); }

