/* ---------- Access: the permission screens (user permissions, role templates) and the "no access" page ---------- */

/* People or roles on the left, the chosen one's permissions on the right; one column on a narrow window. */
.access {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.access__side {
    position: sticky;
    top: 76px;
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--ft-line);
    border-radius: var(--ft-radius);
    background: #FFFFFF;
}

.access__side-count {
    font: 600 0.72rem var(--ft-font-display);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ft-stencil-soft);
}

.access__list {
    display: grid;
    gap: 2px;
    max-height: calc(100vh - 260px);
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.access__item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 8px;
    border: 0;
    border-radius: var(--ft-radius-sm);
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.access__item:hover {
    background: rgba(47, 127, 184, 0.06);
}

/* The chosen one: the lists' selected row (blue tint, amber inset). */
.access__item--on,
.access__item--on:hover {
    background: rgba(47, 127, 184, 0.12);
    box-shadow: inset 3px 0 0 var(--ft-caution);
}

.access__item-icon {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: var(--ft-radius-sm);
    background: var(--ft-chalk-deep);
    color: var(--ft-sky);
}

.access__item-text {
    display: grid;
    min-width: 0;
}

.access__item-name {
    overflow: hidden;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.access__item-meta {
    overflow: hidden;
    font-size: 0.78rem;
    color: var(--ft-stencil-soft);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.access__main {
    display: grid;
    gap: 14px;
    min-width: 0;
}

/* Nothing chosen yet: a quiet prompt where the editor will be. */
.access__pick {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 56px 16px;
    border: 1px dashed var(--ft-line);
    border-radius: var(--ft-radius);
    color: var(--ft-stencil-soft);
    text-align: center;
}

.access__pick .mud-icon-root {
    font-size: 2.4rem;
    color: var(--ft-altimeter);
}

.access__pick p {
    margin: 0;
}

/* Who is being edited: the page header's card (navy left edge) with the template picker on its right. */
.access__who {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
    padding: 14px 16px;
    border: 1px solid var(--ft-line);
    border-left: 4px solid var(--ft-apron);
    border-radius: var(--ft-radius);
    background: #FFFFFF;
}

.access__who-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: var(--ft-radius-sm);
    background: linear-gradient(160deg, var(--ft-sky), var(--ft-apron));
    color: #FFFFFF;
}

.access__who-text {
    display: grid;
    flex: 1 1 14rem;
    min-width: 0;
}

.access__who-name {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font: 600 1.15rem var(--ft-font-display);
    letter-spacing: 0.02em;
    color: var(--ft-apron);
}

.access__who-meta {
    font-size: 0.85rem;
    color: var(--ft-stencil-soft);
    overflow-wrap: anywhere;
}

.access__rename {
    flex: 0 1 300px;
}

.access__changes {
    margin-right: 4px;
    font: 600 0.85rem var(--ft-font-display);
    letter-spacing: 0.03em;
    color: var(--ft-stencil-soft);
}

.access__changes--on {
    color: #8A6410;
}

/* ---------- Permission editor (PermissionEditor / PermissionAreaCard) ---------- */

.pe {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.pe__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
}

.pe__search {
    flex: 1 1 260px;
    max-width: 420px;
}

.pe__switch {
    margin: 0;
}

/* Given / all, with a thin gauge: amber on the apron, like the login screen's horizon line. */
.pe__meter {
    display: grid;
    gap: 4px;
    min-width: 132px;
    margin-left: auto;
}

.pe__count {
    font: 400 0.95rem var(--ft-font-display);
    letter-spacing: 0.04em;
    color: var(--ft-stencil-soft);
    text-align: right;
}

.pe__count b {
    font-size: 1.25rem;
    color: var(--ft-apron);
}

.pe__track {
    display: block;
    height: 4px;
    border-radius: var(--ft-radius-pill);
    background: var(--ft-chalk-deep);
    overflow: hidden;
}

.pe__track > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--ft-altimeter), var(--ft-caution));
    transition: width 0.2s ease;
}

/* The areas as chips: one tap narrows the grid to that area; the chip's edge tells how much of it is given. */
.pe__areas {
    display: flex;
    gap: 6px;
    padding-bottom: 4px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.pe-chip {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--ft-line);
    border-radius: var(--ft-radius-pill);
    background: #FFFFFF;
    color: var(--ft-stencil);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
}

.pe-chip:hover {
    border-color: var(--ft-altimeter);
}

.pe-chip--some {
    border-color: rgba(47, 127, 184, 0.45);
}

.pe-chip--all {
    border-color: var(--ft-altimeter);
    background: rgba(47, 127, 184, 0.08);
}

.pe-chip--on,
.pe-chip--on:hover {
    border-color: var(--ft-apron);
    background: var(--ft-apron);
    color: #FFFFFF;
}

.pe-chip__count {
    font-family: var(--ft-font-display);
    letter-spacing: 0.03em;
    opacity: 0.75;
}

.pe__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
    gap: 12px;
    align-items: start;
}

.pe__empty {
    margin: 0;
    padding: 24px;
    color: var(--ft-stencil-soft);
    text-align: center;
}

.pe-card {
    min-width: 0;
    border: 1px solid var(--ft-line);
    border-radius: var(--ft-radius);
    background: #FFFFFF;
    overflow: hidden;
}

/* The header gives or takes the whole area: grey when nothing is given, a blue tint for part, the apron navy for all. */
.pe-card__head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid var(--ft-line);
    background: #F7F9FB;
    color: var(--ft-stencil);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.pe-card__head:disabled {
    cursor: default;
}

.pe-card--some .pe-card__head {
    background: rgba(47, 127, 184, 0.08);
}

.pe-card--all .pe-card__head {
    background: linear-gradient(160deg, var(--ft-sky), var(--ft-apron));
    color: #FFFFFF;
}

.pe-card__icon {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: var(--ft-radius-sm);
    background: var(--ft-chalk-deep);
    color: var(--ft-sky);
}

.pe-card--all .pe-card__icon {
    background: rgba(255, 255, 255, 0.14);
    color: var(--ft-caution);
}

.pe-card__title {
    overflow: hidden;
    font: 600 0.98rem var(--ft-font-display);
    letter-spacing: 0.03em;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.pe-card__count {
    font: 600 0.95rem var(--ft-font-display);
}

.pe-card__count span {
    font-weight: 400;
    opacity: 0.7;
}

.pe-card__state {
    display: grid;
    color: var(--ft-altimeter);
}

.pe-card--all .pe-card__state {
    color: var(--ft-caution);
}

.pe-card__rows {
    margin: 0;
    padding: 4px 0;
    list-style: none;
}

.pe-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 2px 6px;
    padding: 0 12px 0 4px;
    border-left: 3px solid transparent;
}

.pe-row:hover {
    background: rgba(47, 127, 184, 0.04);
}

/* The view row opens the area's screens: set apart on a soft band, every action below needs it. */
.pe-row--view {
    margin-bottom: 2px;
    background: var(--ft-chalk);
    border-bottom: 1px dashed var(--ft-line);
}

.pe-row--on .pe-row__name {
    font-weight: 600;
    color: var(--ft-apron);
}

/* Changed since the last save: an amber mark on the row's edge. */
.pe-row--changed {
    border-left-color: var(--ft-caution);
}

.pe-row__text {
    display: grid;
    min-width: 0;
    padding: 6px 0;
    cursor: pointer;
}

.pe-row__name {
    overflow-wrap: anywhere;
    font-size: 0.9rem;
}

.pe-row__needs {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 0.75rem;
    color: var(--ft-stencil-soft);
}

.pe-row__needs .mud-icon-root {
    font-size: 0.95rem;
}

.pe-kind {
    padding: 1px 8px;
    border-radius: var(--ft-radius-pill);
    font: 600 0.68rem var(--ft-font-display);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.pe-kind--view {
    background: rgba(47, 127, 184, 0.12);
    color: var(--ft-altimeter-deep);
}

.pe-kind--create {
    background: rgba(46, 139, 87, 0.12);
    color: #23704A;
}

.pe-kind--update {
    background: rgba(227, 179, 65, 0.18);
    color: #8A6410;
}

.pe-kind--delete {
    background: rgba(200, 16, 46, 0.1);
    color: var(--ft-streamer);
}

/* ---------- Live roles (DB stage 20): a person's roles, a role's members, where a permission comes from ---------- */

.access__roles {
    display: flex;
    flex: 1 1 100%;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.access__roles-label {
    margin-right: 4px;
    font: 600 0.72rem var(--ft-font-display);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ft-stencil-soft);
}

.access__roles-none {
    font-size: 0.85rem;
    color: var(--ft-stencil-soft);
}

/* A role on a person: the apron navy tag of the area cards' "all" state, with its own remove button. */
.access__role {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 4px 3px 10px;
    border-radius: var(--ft-radius-pill);
    background: var(--ft-apron);
    color: #FFFFFF;
    font-size: 0.85rem;
    font-weight: 600;
}

.access__role .mud-icon-root {
    color: var(--ft-caution);
}

.access__role-x {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #FFFFFF;
    cursor: pointer;
}

.access__role-x .mud-icon-root {
    font-size: 0.95rem;
    color: #FFFFFF;
}

.access__role-x:hover:not(:disabled) {
    background: rgba(200, 16, 46, 0.85);
}

.access__role-x:disabled {
    cursor: default;
    opacity: 0.5;
}

/* Adding a role: the menu's own button, drawn as a dashed pill beside the role tags. */
.access__add-role .mud-button-root {
    border-style: dashed !important;
    border-color: var(--ft-altimeter) !important;
    border-radius: var(--ft-radius-pill) !important;
    color: var(--ft-altimeter-deep);
    text-transform: none;
    font-weight: 600;
}

.access__hint {
    margin: 0;
    font-size: 0.85rem;
    color: var(--ft-stencil-soft);
}

.access__members {
    display: grid;
    gap: 8px;
    padding: 12px 16px;
    border: 1px solid var(--ft-line);
    border-radius: var(--ft-radius);
    background: #FFFFFF;
}

.access__members-head {
    display: flex;
    align-items: center;
    gap: 6px;
    font: 600 0.9rem var(--ft-font-display);
    letter-spacing: 0.03em;
    color: var(--ft-apron);
}

.access__member-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.access__member {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 3px;
    border: 1px solid var(--ft-line);
    border-radius: var(--ft-radius-pill);
    background: var(--ft-chalk);
    color: var(--ft-stencil);
    font-size: 0.85rem;
    text-decoration: none;
}

.access__member .people-avatar {
    width: 26px;
    height: 26px;
    font-size: 0.68rem;
}

a.access__member:hover {
    border-color: var(--ft-altimeter);
}

.access__member--other {
    padding-left: 10px;
    border-style: dashed;
    color: var(--ft-stencil-soft);
}

/* Where a user's permission comes from: a role (altimeter blue), the person alone (green), a role's switched off (red). */
.pe-src {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.74rem;
    font-weight: 600;
}

.pe-src .mud-icon-root {
    font-size: 0.9rem;
}

.pe-src--role {
    color: var(--ft-altimeter-deep);
}

.pe-src--own {
    color: #23704A;
}

.pe-src--revoked {
    color: var(--ft-streamer);
}

.pe-row--revoked .pe-row__name {
    color: var(--ft-stencil-soft);
    text-decoration: line-through;
    text-decoration-color: rgba(200, 16, 46, 0.5);
}

/* ---------- No access (PageGuard) ---------- */

.noaccess {
    display: grid;
    justify-items: center;
    gap: 12px;
    max-width: 560px;
    margin: 48px auto;
    padding: 36px 28px;
    border: 1px solid var(--ft-line);
    border-radius: var(--ft-radius-lg);
    background: #FFFFFF;
    box-shadow: var(--ft-shadow-raised);
    text-align: center;
}

.noaccess__seal {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(160deg, var(--ft-sky), var(--ft-apron));
    box-shadow: inset 0 0 0 3px rgba(227, 179, 65, 0.55);
    color: var(--ft-caution);
}

.noaccess__seal .mud-icon-root {
    font-size: 2rem;
}

.noaccess__title {
    margin: 0;
    font: 600 1.5rem var(--ft-font-display);
    letter-spacing: 0.03em;
    color: var(--ft-apron);
}

.noaccess__lead,
.noaccess__hint {
    margin: 0;
    color: var(--ft-stencil-soft);
}

.noaccess__needs {
    display: grid;
    gap: 6px;
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--ft-radius);
    background: var(--ft-chalk);
    text-align: left;
}

.noaccess__label {
    font: 600 0.72rem var(--ft-font-display);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ft-stencil-soft);
}

.noaccess__list {
    display: grid;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.noaccess__list li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--ft-apron);
}

.noaccess__list .mud-icon-root {
    color: var(--ft-caution);
}

@media (max-width: 900px) {
    .access {
        grid-template-columns: 1fr;
    }

    .access__side {
        position: static;
    }

    .access__list {
        max-height: 38vh;
    }
}

@media (max-width: 600px) {
    .pe__meter {
        width: 100%;
        margin-left: 0;
    }

    .pe__count {
        text-align: left;
    }

    .noaccess {
        margin: 16px auto;
        padding: 24px 16px;
    }
}
