/* =============================================
   A company's pages: Company Management
   (manager/company_management.html: the invite
   form, API keys, the webhook, the user modal),
   Registrations'
   company view (user/user_registrations.html:
   the Registered By filter) and staff's
   Installer Details (admin/admin_installer_
   detail.html: the invite form, PPA, the
   registrations' bulk actions, paging and
   quick edit, the PPA modals). Their panels
   and tables are components.css's.
   ============================================= */

/* Company Management's forms in a panel's header, Team Members' invite and
   API Keys' new key, and a key just created, shown once. Installer Details'
   invite is one too, with a Manager tick. */
.api-key-form {
    flex: 0 1 380px;
    flex-wrap: nowrap;
}

.api-key-form--invite {
    flex-basis: 460px;
}

.api-key-form__check {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 6px;
    margin: 0;
    color: var(--in-text-2);
    font-size: 0.82rem;
    white-space: nowrap;
    cursor: pointer;
}

.api-key-form__check input {
    margin: 0;
    accent-color: var(--in-accent);
    cursor: pointer;
}

.api-key-form__input {
    flex: 1 1 auto;
    min-width: 0;
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--in-border-input);
    border-radius: 6px;
    background-color: var(--in-surface);
    color: var(--in-text);
    font-size: 0.85rem;
}

.api-key-form__input::placeholder {
    color: var(--in-text-placeholder);
}

.api-key-form__input:focus {
    border-color: var(--in-accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--in-focus);
}

.api-key-form__error {
    margin: 0;
    padding: 8px 16px;
    border-bottom: 1px solid var(--in-border-soft);
    color: var(--in-danger);
    font-size: 0.82rem;
}

.api-key-new {
    padding: 12px 16px;
    border-bottom: 1px solid var(--in-border-soft);
    background-color: var(--in-accent-wash);
}

.api-key-new__label {
    margin: 0 0 8px;
    color: var(--in-text);
    font-size: 0.85rem;
    font-weight: 600;
}

.api-key-new__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.api-key-new__value {
    flex: 1 1 auto;
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid var(--in-border-input);
    border-radius: 6px;
    background-color: var(--in-surface);
    color: var(--in-text);
    font-size: 0.82rem;
    overflow-wrap: anywhere;
}

.api-key-prefix {
    color: var(--in-text-muted);
    font-size: 0.8rem;
}

/* Company Management's API Guide link, at the right just above API Keys,
   closer to it than the stack's gap */
.api-guide-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: -8px;
}

/* Company Management's webhook: its address, its signing secret, and the
   events sent lately */
.webhook-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--in-border-soft);
}

.webhook-form .api-key-form__input {
    flex: 1 1 260px;
}

.webhook-form__label {
    min-width: 110px;
    color: var(--in-text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.webhook-state {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 4px;
    background-color: var(--in-amber-wash);
    color: var(--in-amber-text);
    font-size: 0.72rem;
    font-weight: 600;
}

.webhook-state--delivered {
    background-color: var(--in-complete-wash);
    color: var(--in-complete-text);
}

.webhook-state--failed {
    background-color: var(--in-danger-wash);
    color: var(--in-danger);
}

/* A webhook turned off because its events stopped getting through */
.webhook-off {
    background-color: var(--in-danger-wash);
}

.webhook-off__reason {
    flex: 1 1 260px;
    min-width: 0;
    color: var(--in-text);
    font-size: 0.82rem;
}

/* Installer Details' record: PPA on or off, and a field's aside */
.ppa-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ppa-state::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--in-idle);
}

.ppa-state--on::before {
    background-color: var(--in-complete);
}

.record-fields__note {
    margin-left: 4px;
    color: var(--in-text-faint);
    font-size: 0.75rem;
}

/* Installer Details' bulk actions: a status to set, and Apply */
.bulk-actions {
    display: flex;
    flex: 0 1 360px;
    align-items: center;
    gap: 8px;
    margin: 0;
}

/* Registrations' switch hiding Complete and Unresponsive registrations, at
   the toolbar's end */
.registrations-finished {
    margin-left: auto;
}

/* Registrations' Registered By filter, in its company view: a team member,
   or all */
.registered-by {
    display: flex;
    flex: 0 1 400px;
    align-items: center;
    gap: 10px;
}

.registered-by__label {
    margin: 0;
    color: var(--in-text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.bulk-actions__select,
.registered-by__select {
    flex: 1 1 auto;
    min-width: 0;
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--in-border-input);
    border-radius: 6px;
    background-color: var(--in-surface);
    color: var(--in-text);
    font-size: 0.82rem;
    cursor: pointer;
}

.bulk-actions__select:focus,
.registered-by__select:focus {
    border-color: var(--in-accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--in-focus);
}

/* Installer Details' registrations: a checkbox per row for the bulk
   actions, and the rows the status filters hide */
#facilities-table input[type="checkbox"] {
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
    padding: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    left: auto !important;
    display: inline-block !important;
    -webkit-appearance: checkbox !important;
    -moz-appearance: checkbox !important;
    appearance: checkbox !important;
    border: 2px solid var(--fe-primary-green) !important;
}

#facilities-table tr.selected {
    background-color: rgba(30, 169, 155, 0.15) !important;
}

#facilities-table tbody {
    user-select: none;
}

tr.filtered-out {
    display: none;
}

/* A page picked under the table scrolls to its top, clear of the phone's
   top bar */
#facilities-table {
    scroll-margin-top: 16px;
}

/* The column the table is sorted by */
.data-table .sort-icon.is-on {
    opacity: 1;
}

/* Installer Details' switches, in its record */
.record-switch {
    margin: 0;
}

/* ----- Installer Details' quick edit (installer/js/installer-
   registrations.js): a cell that can be edited is outlined under the
   pointer; double-clicked, it holds fields for what it shows, then glows
   a moment once saved ----- */
#facilities-table td[data-edit] {
    cursor: default;
}

#facilities-table td[data-edit]:not(.is-editing):hover {
    box-shadow: inset 0 0 0 1px var(--in-border-hover);
}

#facilities-table td.is-editing {
    background-color: var(--in-surface);
    box-shadow: inset 0 0 0 2px var(--in-accent);
    vertical-align: top;
}

/* As wide as its cell was: sized to it, it doesn't widen its column and
   shift the others */
.quick-edit {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 0;
    min-width: 100%;
    margin: 0;
    user-select: text;
}

.quick-edit__line {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

/* The state beside the city, or under it in a narrow cell */
.quick-edit__line--city {
    flex-wrap: wrap;
}

.quick-edit__line--city > :first-child {
    flex: 1 1 110px;
}

.quick-edit__line--city > :last-child {
    flex: 0 0 64px;
}

.quick-edit__input {
    width: 100%;
    min-width: 0;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--in-border-input);
    border-radius: 5px;
    background-color: var(--in-surface);
    color: var(--in-text);
    font-size: 0.82rem;
    font-weight: 400;
}

select.quick-edit__input {
    padding-right: 4px;
    cursor: pointer;
}

.quick-edit__input:focus {
    border-color: var(--in-accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--in-focus);
}

.quick-edit__input:disabled {
    background-color: var(--in-wash);
    color: var(--in-text-faint);
}

.quick-edit__input.is-invalid {
    border-color: var(--in-danger-border);
}

.quick-edit__unit {
    flex: none;
    color: var(--in-text-muted);
    font-size: 0.8rem;
}

.quick-edit__check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    color: var(--in-text-2);
    font-size: 0.8rem;
    cursor: pointer;
}

.quick-edit__check-input {
    accent-color: var(--in-accent);
}

.quick-edit__error {
    margin: 0;
    color: var(--in-danger);
    font-size: 0.75rem;
    line-height: 1.35;
    white-space: normal;
}

.quick-edit__line--actions {
    gap: 4px;
}

.quick-edit.is-saving {
    opacity: 0.6;
    cursor: progress;
}

@keyframes quick-edit-updated {
    from {
        background-color: var(--in-glow);
    }
    to {
        background-color: transparent;
    }
}

#facilities-table td.is-updated {
    animation: quick-edit-updated 2s ease-out;
}

.checkbox-column {
    width: 40px;
    text-align: center;
}

/* PPA accounts: the available list, the arrows, the authorized list */
.ppa-lists {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 12px;
    align-items: center;
}

.ppa-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.ppa-transfer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ppa-note {
    margin: 14px 0 0;
    color: var(--in-text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
}

.ppa-note .fa {
    margin-right: 4px;
    color: var(--in-text-faint);
}

/* Adding a PPA account opens a second modal over the first, which darkens */
.modal.show + .modal {
    background-color: rgba(0, 0, 0, 0.3);
}

#ppaManagementModal.modal-darkened::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    background-color: rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

#addPPAAccountModal {
    z-index: 1060;
}

#addPPAAccountModal .modal-dialog {
    z-index: 1061;
}

/* Company Management's Edit User: Change Password opens the two fields */
.toggle-password {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--in-accent);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.toggle-password:hover,
.toggle-password:focus {
    color: var(--in-accent-hover);
    text-decoration: none;
}

.toggle-password i {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.toggle-password i.rotated {
    transform: rotate(180deg);
}

/* Room round the fields for their focus ring, which overflow would cut */
.password-fields {
    overflow: hidden;
    max-height: 280px;
    margin: 0 -4px;
    padding: 10px 4px 4px;
    opacity: 1;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
}

.password-fields.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

#password-input {
    margin-bottom: 12px;
}

@media (max-width: 900px) {
    #facilities-table .checkbox-column {
        width: 30px;
    }

    #facilities-table input[type="checkbox"] {
        width: 16px !important;
        height: 16px !important;
    }
}

@media (max-width: 767.98px) {
    .bulk-actions,
    .registered-by {
        flex-basis: 100%;
    }

    /* Below the phone's top bar (shell.css, 56px) */
    #facilities-table {
        scroll-margin-top: 72px;
    }

    /* A cell being edited, its label and fields inside its outline */
    #facilities-table td.is-editing {
        padding-top: 8px;
        padding-right: 8px;
        padding-bottom: 8px;
    }

    #facilities-table td.is-editing::before {
        top: 9px;
        left: 8px;
    }

    #facilities-table td.data-table__lead.is-editing {
        padding-left: 8px;
    }

    /* The PPA lists stack, the arrows between them */
    .ppa-lists {
        grid-template-columns: minmax(0, 1fr);
    }
}
