/*
 * AdminCP additions.
 *
 * Only what the theme does not already provide. Anything that can be expressed with a Bootstrap
 * utility or a Zircos component is not repeated here.
 *
 * Colours are taken from the theme's CSS variables rather than written as literals, so dark mode
 * works by inheritance instead of by a parallel set of rules that has to be kept in step.
 *
 * Those variables are prefixed --ct-, not --bs-: Zircos compiles Bootstrap with its own prefix.
 * A --bs- name here resolves to nothing and CSS drops the declaration without a word, which is
 * how the drawer panel once shipped transparent.
 */

/* ---------------------------------------------------------------------------
 * Navigation: an item for a screen that does not exist yet.
 * ------------------------------------------------------------------------ */

/*
 * Rendered as a <span>, so it is unreachable by keyboard and by click already. This only makes
 * it look unreachable too — without it the row is indistinguishable from a working link.
 */
.side-nav-link--soon {
    cursor: default;
    opacity: 0.55;
}

.side-nav-link--soon:hover {
    background-color: transparent;
}

/*
 * The "Sắp có" badge sits after the label in a flex row. The label is a flex item with the
 * default `min-width: auto`, so a long name ("Nhật ký thao tác") refuses to shrink and pushes
 * the badge past the sidebar's right edge, where it is clipped mid-word. Letting the label
 * shrink and ellipsise keeps the badge inside the rail at every label length.
 */
.side-nav-link--soon .menu-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.side-nav-link--soon .badge {
    flex-shrink: 0;
}

/* ---------------------------------------------------------------------------
 * Permission drawer.
 * ------------------------------------------------------------------------ */

.perm-drawer {
    position: fixed;
    inset: 0;
    z-index: 1045; /* Above the sidebar, below Bootstrap's modals. */
}

.perm-drawer__backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
}

.perm-drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(42rem, 100%);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    /* The surface colour cards use, not the page behind them: the panel sits above the page. */
    background-color: var(--ct-secondary-bg);
    border-left: 1px solid var(--ct-border-color);
    box-shadow: var(--ct-box-shadow-lg);
}

.perm-drawer__header,
.perm-drawer__footer {
    padding: 1rem 1.25rem;
    background-color: var(--ct-secondary-bg);
}

.perm-drawer__header {
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 1px solid var(--ct-border-color);
}

.perm-drawer__footer {
    position: sticky;
    bottom: 0;
    margin-top: auto;
    border-top: 1px solid var(--ct-border-color);
}

.perm-drawer__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.perm-drawer__subject {
    margin: 0;
    color: var(--ct-secondary-color);
    font-size: 0.8125rem;
}

.perm-drawer__close {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
}

.perm-drawer__body {
    flex: 1 1 auto;
    padding: 1.25rem;
}

.perm-drawer__search {
    margin-bottom: 1rem;
}

.perm-drawer__legend,
.perm-drawer__stale,
.perm-drawer__empty,
.perm-drawer__error {
    margin-bottom: 1rem;
    font-size: 0.8125rem;
}

.perm-drawer__legend {
    color: var(--ct-secondary-color);
}

.perm-drawer__actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Groups ------------------------------------------------------------------ */

.perm-group + .perm-group {
    margin-top: 1.5rem;
}

.perm-group__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.perm-group__title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
}

.perm-group__description {
    margin: 0;
    color: var(--ct-secondary-color);
    font-size: 0.8125rem;
}

.perm-group__bulk {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

/* Items ------------------------------------------------------------------- */

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

.perm-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--ct-border-color-translucent);
}

.perm-item__text {
    flex: 1 1 auto;
    min-width: 0;
}

.perm-item__name {
    display: block;
    font-size: 0.875rem;
}

.perm-item__key {
    display: block;
    color: var(--ct-secondary-color);
    font-size: 0.75rem;
}

/*
 * Where the permission comes from. Muted by default and coloured once a role supplies it, so the
 * difference between "granted by a role" and "granted only here" is visible at a glance.
 */
.perm-item__source {
    flex-shrink: 0;
    color: var(--ct-secondary-color);
    font-size: 0.75rem;
}

.perm-item__source.is-inherited {
    color: var(--ct-primary);
}

/*
 * Marks a permission that applies in the end. Not the same as "a role grants it": a deny override
 * beats the role, and showing both states is the reason the drawer exists.
 */
.perm-item.is-effective .perm-item__name {
    font-weight: 600;
}

/* Tristate ---------------------------------------------------------------- */

.perm-tristate {
    display: inline-flex;
    flex-shrink: 0;
    border: 1px solid var(--ct-border-color);
    border-radius: var(--ct-border-radius);
    overflow: hidden;
}

.perm-tristate button {
    padding: 0.125rem 0.5rem;
    border: 0;
    background-color: transparent;
    color: var(--ct-body-color);
    font-size: 0.75rem;
}

.perm-tristate button:disabled {
    opacity: 0.5;
}

.perm-tristate button.is-active {
    background-color: var(--ct-primary);
    color: #fff;
}

/*
 * Deny is not just another choice: it overrides what a role grants, so it is the one state that
 * reads as a warning rather than a selection.
 */
.perm-tristate button[data-effect="deny"].is-active {
    background-color: var(--ct-danger);
}

/* Locks the page behind the drawer so the list does not scroll under it. */
body.is-drawer-open {
    overflow: hidden;
}
