/* puush website: the admin and settings pages. Builds on account.css (header, menu bar, dialogs, fades). */

:root {
    --line: #e2e5e7;
    --muted: #6b7378;
    --danger: #c0392b;
    --green: #9ccc31; /* the puush arrow */
    --done: #4d7a12;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

main {
    padding-bottom: 10px;
}

#admin-error:not(:empty),
.page-error:not(:empty) {
    padding: 10px 10px 0;
    color: var(--error);
}

/* White panels on the slate background, like the upload tiles, with a strip like the page bar. */

.panel {
    margin: 10px;
    border: 1px solid #333a3f;
    background: #fff;
    color: #222;
    box-shadow: 0 0 3px #1a1c1d;
}

.panel h2,
.panel-head {
    margin: 0;
    padding: 5px 10px;
    background: var(--slate-mid);
    color: #fff;
    font-size: 13px;
    text-shadow: var(--slate) 1px 1px 1px;
}

/* A panel strip with a button on the right, e.g. "Accounts ... New user". */
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 3px;
    padding-bottom: 3px;
}

.panel-head h2 {
    padding: 2px 0;
}

.panel-action {
    padding: 0 9px;
    border: 1px solid rgba(255, 255, 255, .45);
    border-radius: 3px;
    color: #fff;
    line-height: 20px;
    white-space: nowrap;
}

.panel-action:hover {
    background: var(--slate);
    text-decoration: none;
}

.panel .note {
    margin: 0;
    padding: 8px 10px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

.panel .table-scroll:has(table[hidden]) + .note {
    border-top: 0;
}

/* Account and invite lists */

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

.list {
    width: 100%;
    border-collapse: collapse;
}

.list th,
.list td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

.list th {
    color: var(--muted);
    font-size: 12px;
    font-weight: normal;
}

.list tbody tr:last-child td {
    border-bottom: 0;
}

.list tbody tr:hover {
    background: #f4f6f7;
}

.list .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.list .email,
.list .status {
    width: 40%;
    white-space: normal;
    overflow-wrap: break-word;
}

.list .actions {
    text-align: right;
}

.list .date {
    white-space: nowrap;
}

.list .actions a + a {
    margin-left: 12px;
}

.list .muted,
.list .estimated,
.list tr.inactive .email,
.list tr.past td:not(.actions) {
    color: var(--muted);
}

.list-avatar {
    width: 22px;
    height: 22px;
    margin: -3px 7px -2px 0;
    font-size: 11px;
}

.list tr.inactive .list-avatar {
    opacity: .5;
}

.badge {
    display: inline-block;
    padding: 0 5px;
    border-radius: 3px;
    background: var(--line);
    color: var(--slate);
    font-size: 11px;
    line-height: 16px;
    vertical-align: 1px;
    white-space: nowrap;
}

.badge.admin {
    background: var(--selected);
    color: #000;
}

.badge.inactive {
    background: var(--slate-mid);
    color: #fff;
}

.badge.pending {
    background: var(--green);
    color: #000;
}

.badge.twofactor {
    background: #d6e9f5;
    color: #1f4e6b;
}

.badge.needs2fa {
    background: #fde7c4;
    color: #7a4a00;
}

.badge.you {
    padding: 0 4px;
    border: 1px solid var(--slate-light);
    background: none;
    color: var(--muted);
    line-height: 14px;
}

/* Rows in a panel: client downloads, and settings with a button on the right. */

.download,
.setting {
    border-top: 1px solid var(--line);
}

.panel > h2 + .download,
.panel > h2 + .setting {
    border-top: 0;
}

.download {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    padding: 12px 10px;
}

.download-link {
    min-width: 15em;
    padding: 6px 14px;
    text-align: center;
    border: 1px solid var(--slate);
    border-radius: 3px;
    background: var(--slate-mid);
    color: #fff;
    font-weight: bold;
    text-shadow: var(--slate) 1px 1px 1px;
}

.download-link:hover {
    background: var(--slate);
    text-decoration: none;
}

.download-file {
    color: var(--muted);
}

.download.missing .download-link {
    opacity: .45;
    cursor: default;
}

.download.missing .download-link:hover {
    background: var(--slate-mid);
}

.download.missing .copy-download {
    display: none;
}

.setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px 20px;
    padding: 11px 10px;
}

.setting-text {
    min-width: 0;
}

.setting-text strong {
    display: block;
    margin-bottom: 1px;
}

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

.setting-text span.done {
    color: var(--done);
}

.setting button {
    flex: none;
}

.api-key {
    display: block;
    width: fit-content;
    max-width: 100%;
    margin-top: 6px;
    user-select: all;
}

@media (max-width: 520px) {
    .setting {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Settings page: the profile card on the left (on top on narrow screens), the rest on the right. */

.settings {
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    max-width: 1080px;
    margin: 10px;
}

.settings .panel {
    margin: 0;
}

.settings-main {
    display: grid;
    gap: 10px;
    min-width: 0;
}

@media (max-width: 760px) {
    .settings {
        grid-template-columns: minmax(0, 1fr);
    }
}

.profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 18px 12px 6px;
    text-align: center;
}

.avatar-button {
    position: relative;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    cursor: pointer;
}

.avatar-button:hover {
    background: none;
}

.profile-avatar {
    width: 116px;
    height: 116px;
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px var(--line), 0 1px 4px rgba(0, 0, 0, .3);
    font-size: 50px;
}

.avatar-overlay {
    position: absolute;
    inset: 3px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 14px;
    border-radius: 50%;
    background: linear-gradient(transparent 55%, rgba(0, 0, 0, .55));
    color: #fff;
    font-size: 12px;
    opacity: 0;
    transition: opacity .2s;
}

.avatar-button:hover .avatar-overlay,
.avatar-button:focus-visible .avatar-overlay {
    opacity: 1;
}

.avatar-button.busy {
    cursor: progress;
}

.avatar-button.busy .profile-avatar {
    opacity: .4;
}

.avatar-button.busy .avatar-overlay {
    display: none;
}

.avatar-button.busy::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    background: url(../img/bigspinner.gif) no-repeat center / contain;
}

.profile-who {
    min-width: 0;
    max-width: 100%;
}

.profile-email {
    font-size: 16px;
    font-weight: bold;
    overflow-wrap: anywhere;
}

.profile-badges {
    margin-top: 2px;
    color: var(--muted);
}

.profile-links {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-top: 8px;
    font-size: 12px;
}

.profile-error {
    margin: 0 12px 6px;
    text-align: center;
}

.stats {
    margin: 8px 0 0;
    border-top: 1px solid var(--line);
}

.stats div {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
}

.stats div + div {
    border-top: 1px solid var(--line);
}

.stats dt {
    color: var(--muted);
}

.stats dd {
    margin: 0;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.stats dd.estimated {
    color: var(--muted);
    font-weight: normal;
}

/* On narrow screens the profile card goes on top, with the picture beside the name to save room. */
@media (max-width: 760px) {
    .profile {
        flex-direction: row;
        padding: 12px;
        text-align: left;
    }

    .profile-avatar {
        width: 76px;
        height: 76px;
        font-size: 32px;
    }

    .avatar-overlay {
        padding-bottom: 8px;
        font-size: 11px;
    }

    .profile-links {
        justify-content: flex-start;
    }

    .profile-error {
        text-align: left;
    }

    .stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
        margin-top: 0;
    }

    .stats div {
        flex-direction: column;
        gap: 0;
    }

    .stats div + div {
        border-top: 0;
    }

    .stats div:nth-child(n + 3) {
        border-top: 1px solid var(--line);
    }

    .stats div:nth-child(even) {
        border-left: 1px solid var(--line);
    }

    .stats dd {
        text-align: left;
    }
}

.required-note {
    margin: 0;
    padding: 10px;
    border-bottom: 1px solid #f3d9a6;
    background: #fff6e5;
    color: #5c3d00;
}

/* Dialogs with forms */

.form-dialog,
#confirm-dialog {
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    overflow-y: auto;
}

.form-dialog {
    width: 320px;
    text-align: left;
}

#confirm-dialog {
    width: 280px;
}

#confirm-msg {
    overflow-wrap: anywhere;
}

.form-dialog h1 {
    text-align: center;
}

.form-dialog label {
    display: block;
    margin: 10px 0 3px;
    color: #333;
}

.form-dialog label.check {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.form-dialog label.check:has(input:disabled) {
    color: #999;
}

.form-dialog .optional {
    color: var(--muted);
}

.form-dialog input:not([type="checkbox"]),
.form-dialog select {
    width: 100%;
    padding: 5px 7px;
    border: 1px solid #9aa1a6;
    border-radius: 3px;
    background: #fff;
    color: #000;
    font: inherit;
}

.form-dialog input[readonly] {
    background: #f1f3f4;
}

.form-dialog p {
    margin: 8px 0;
}

.form-dialog .hint {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.form-dialog .check + .hint {
    margin-left: 19px;
}

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

.dialog-error:empty {
    display: none;
}

.buttons {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 14px;
    margin-top: 15px;
}

button {
    padding: 5px 16px;
    border: 1px solid var(--slate);
    border-radius: 3px;
    background: var(--slate-mid);
    color: #fff;
    font: inherit;
    cursor: pointer;
}

button:hover {
    background: var(--slate);
}

button:disabled {
    opacity: .6;
    cursor: default;
}

.more {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    font-size: 12px;
}

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

.more .danger {
    margin-left: auto;
}

/* Two-factor login on the settings page */

.panel-body {
    padding: 4px 10px 12px;
}

.panel-body p {
    margin: 8px 0;
}

.panel-body .hint {
    color: var(--muted);
    font-size: 12px;
}

.buttons.start {
    justify-content: flex-start;
}

.setup {
    margin: 8px 0 0;
    padding-left: 20px;
}

.setup li + li {
    margin-top: 14px;
}

.qr {
    display: block;
    width: 185px;
    height: 185px;
    margin: 6px 0;
    border: 1px solid var(--line);
}

code {
    padding: 1px 4px;
    border-radius: 3px;
    background: #f1f3f4;
    font: 13px Consolas, Menlo, monospace;
    overflow-wrap: anywhere;
}

.stacked-form {
    max-width: 280px;
}

.stacked-form label {
    display: block;
    margin: 8px 0 3px;
    color: #333;
}

.stacked-form input {
    width: 100%;
    padding: 5px 7px;
    border: 1px solid #9aa1a6;
    border-radius: 3px;
    background: #fff;
    color: #000;
    font: inherit;
}

.stacked-form .dialog-error {
    margin: 8px 0 0;
}

.recovery-codes {
    display: inline-grid;
    grid-template-columns: repeat(2, auto);
    gap: 6px 32px;
    margin: 10px 0;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: #f4f6f7;
    list-style: none;
    font: 14px/1.4 Consolas, Menlo, monospace;
}

button.danger {
    border-color: #8e2a20;
    background: var(--danger);
}

button.danger:hover {
    background: #a93226;
}

@media (max-width: 640px) {
    .list .wide {
        display: none;
    }

    .list .email,
    .list .status {
        width: auto;
    }

    .list th,
    .list td {
        padding: 7px 8px;
    }
}
