@import "../../node_modules/@patternfly/react-styles/css/components/Alert/alert.css";
@import "../lib/page.scss";
@import "../../node_modules/@patternfly/patternfly/components/Button/button.scss";
@import "../../node_modules/@patternfly/patternfly/components/Page/page.css";
@import "../../node_modules/@patternfly/patternfly/components/DataList/data-list.scss";
@import "../lib/table.css";
@import "../lib/ct-card.scss";

#account .pf-c-card {
    @extend .ct-card;

    // Make the header properly wrap
    &__header {
        flex-wrap: wrap;
        // WebKit and older versions of Chrome have issues with "gap" on flex
        // (but they'll just be a few pixels too close together)
        gap: var(--pf-global--spacer--sm) 0;
    }

    // Remove the gap from the actions...
    &__actions {
        margin-left: 0;
        padding-left: 0;
    }

    // And add the gap to the title
    &__title {
        flex: auto;
        margin-right: var(--pf-global--spacer--md);
    }
}

.account-details .pf-c-card__header {
    margin-bottom: var(--pf-global--spacer--lg);
}

#account {
    --pf-c-page__main-breadcrumb--PaddingBottom: var(--pf-c-page__main-breadcrumb--PaddingTop);
}

#account .pf-l-gallery {
    --pf-l-gallery--GridTemplateColumns: 1fr;
}

#account .pf-c-page__main-section,
#account .pf-c-page__main-nav {
    padding: var(--pf-global--gutter);
}

#accounts-list {
    --ct-account-pic-size: 3rem;
    display: grid;
    align-items: stretch;
    grid-gap: 0.5rem;
    margin: 2rem 0 0;
    grid-template-columns: repeat(auto-fit, minmax(calc(8rem + var(--ct-account-pic-size)), 1fr));
}

@media (max-width: 640px) {
    #accounts-list {
        --ct-account-pic-size: 0rem;
    }
}

.cockpit-account {
    align-content: center;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.05);
    display: grid;
    grid-template-areas: "pic name"
                         "pic account";
    grid-template-columns: var(--ct-account-pic-size) 1fr;
    grid-gap: 0 0.25rem;
    min-height: 4rem;
    padding: 0.5rem;
}

.cockpit-account:hover,
.cockpit-account:focus-within {
    background-color: var(--color-link-hover-bg);
    cursor: pointer;
}

.cockpit-account > .cockpit-account-pic {
    font-size: var(--ct-account-pic-size);
    color: #bebebe;
    grid-area: pic;
}

.cockpit-account > .cockpit-account-real-name {
    font-weight: bold;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    grid-area: name;
}

.cockpit-account > .cockpit-account-user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    grid-area: account;
    /* We're using an underline on focus and focus-within above for focus indication */
    outline: none;

    > a {
        margin-right: 0.5rem;
    }
}

#account-details div.checkbox:first-child {
	margin-top: 0px;
}

#account-details div.checkbox:last-child {
	margin-bottom: 0px;
}

#dashboard_setup_address_discovered li:hover {
    background-color: var(--color-link-hover-bg);
}

#account-pic {
    background: #d3d7cf;
    border-radius: 5px;
    cursor: pointer;
}

#account-authorized-keys {
    .pf-c-data-list__item {
        // Align text with heading
        --pf-c-data-list__item-row--PaddingLeft: var(--pf-global--spacer--lg);

        // Align - buttons with + button
        --pf-c-data-list__item-row--PaddingRight: var(--pf-global--spacer--md);

        // Add a border to the top item
        &:first-child {
            border-top: var(--pf-c-data-list__item--BorderBottomWidth) solid var(--pf-c-data-list__item--BorderBottomColor);
        }

        // Remove a border from the bottom item
        &:last-child {
            border-bottom: none;
        }
    }

    .pf-c-data-list__cell {
        // Align to center (when stretched wide)
        align-self: center;
        // Allow cells to be wrappable
        overflow-wrap: anywhere;

        // Comment is user@hostname
        &.comment {
            // Grow, shrink, and try to be around 12rem (or more or less)
            flex: 1 1 10rem;
        }

        &.fingerprint {
            // Grow more, shrink, and try to be around 20rem (or more or less)
            flex: 100 1 50%;
        }
    }

    // Handle empty state
    .no-keys {
        display: block;
        text-align: center;
        padding: var(--pf-global--spacer--lg);
    }
}

/* Use subgrid to properly align items, making the list act like a table  */
@supports (grid-template-columns: subgrid) {
    @media screen and (min-width: 512px) {
        #account-authorized-keys-list {
            display: grid;
            // This template will apply to the subgrids too
            grid-template-columns: minmax(8rem, auto) minmax(33%, 1fr) auto;

            /* Bring the grid through all the children */
            .pf-c-data-list__item,
            .pf-c-data-list__item-row:not(.no-keys),
            .pf-c-data-list__item-content {
                display: grid;
                grid-template-columns: subgrid;
            }

            /* Align children across all the grid */
            .pf-c-data-list__item,
            .pf-c-data-list__item-row {
                grid-column: 1 / -1;
            }

            /* Put the wrapper for the items on the first two grid cells (leaving the actions on the third) */
            .pf-c-data-list__item-content {
                grid-column: 1 / -2;
            }

            /* Place comment and fingerprint on their cells */
            .pf-c-data-list__cell {
                &.comment {
                    grid-column: 1;
                }

                &.fingerprint {
                    grid-column: 2;
                }
            }
        }
    }
}

#account-authorized-keys-list {
    border: none;
    margin-bottom: 0;
}

#account-authorized-keys-list > .list-group-item {
    display: flex;
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    align-items: center;
}

#authorized-key-add {
    min-width: 28px;
    min-height: 28px;
}

#authorized-keys-text {
    height: 200px;
    resize: none;
    margin-bottom: 10px;
}

.align-top {
    vertical-align: top;
}

.password-strength-meter {
    height: 5px;
    margin-top: 5px;
    margin-bottom: 0;
}

.password-strength-meter div {
    width: 25%;
    border-right: 3px solid var(--color-bg);
    background-color: transparent;
}

.password-strength-meter div:last-child {
    border-right: none;
}

.password-strength-meter.weak div:first-child {
    background-color: #C00;
}

.password-strength-meter.okay div:nth-child(-n+2) {
    background-color: #EC7A08;
}

.password-strength-meter.good div:nth-child(-n+3) {
    background-color: var(--color-alert-success-text);
}

.password-strength-meter.excellent div:nth-child(-n+4) {
    background-color: var(--color-alert-success-text);
}

.size-text-ct {
    display: inline;
    width: 8em;
    text-align: left;
    margin: 2px;
}

@media (min-width: 500px) {
    .modal-sm-ct {
        width: 32rem;
    }
}

.account-column-one {
    min-width: 270px;
    display: inline-block;
}

.expiration-modal .form-table-ct td:first-child {
    text-align: left;
}

.expiration-modal label input[type=text] {
    position: relative;
    top: -5px;
}

.help-block {
    white-space: pre-wrap;
}
