/**
 * Power Suite UI kit.
 *
 * The Suite's shared controls. Every value here comes from a token; there are
 * no literals in this file by design, and the DesignSystem test fails if one
 * appears.
 *
 * The look is the one PowerLeads already established. This file does not
 * introduce a style, it records one.
 */

/* ------------------------------------------------------------------ select */

ps-select {
    display: block;
    position: relative;
}

/* The native select stays in the DOM as the source of truth for value, form
   participation, and change events. It is visually replaced, not removed. */
ps-select select {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

.ps-select-trigger {
    align-items: center;
    background: var(--pl-control-surface);
    border: 1px solid var(--pl-border-color);
    border-radius: var(--pl-control-radius);
    color: var(--pl-control-text);
    cursor: pointer;
    display: flex;
    font: inherit;
    font-size: var(--pl-control-font-size);
    font-weight: var(--pl-font-weight-regular);
    gap: var(--pl-control-gap);
    height: var(--pl-control-height);
    justify-content: space-between;
    padding: var(--pl-control-padding-y) var(--pl-control-padding-x);
    text-align: left;
    width: 100%;
}

.ps-select-trigger[data-size="sm"] {
    height: var(--pl-control-height-sm);
}

.ps-select-trigger:focus-visible {
    border-color: var(--pl-panel-border-color);
    outline: none;
}

.ps-select-trigger[disabled] {
    background: var(--pl-surface-muted);
    cursor: default;
    opacity: var(--pl-control-icon-opacity);
}

.ps-select-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ps-select-trigger svg {
    fill: none;
    flex: none;
    height: var(--pl-control-icon-size);
    opacity: var(--pl-control-icon-opacity);
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: var(--pl-icon-stroke-width);
    width: var(--pl-control-icon-size);
}

/* ------------------------------------------------------------------- panel */

.ps-select-panel {
    background: var(--pl-panel-surface);
    border: 1px solid var(--pl-panel-border-color);
    border-radius: var(--pl-panel-radius);
    box-shadow: var(--pl-panel-shadow);
    box-sizing: border-box;
    margin: 0;
    max-height: 16rem;
    min-width: var(--pl-panel-min-width);
    overflow-y: auto;
    padding: var(--pl-panel-padding);
    position: fixed;
    z-index: var(--pl-layer-select);
}

.ps-select-option {
    align-items: center;
    border-radius: var(--pl-panel-item-radius);
    color: var(--pl-panel-item-text);
    cursor: default;
    display: flex;
    font-size: var(--pl-control-font-size);
    font-weight: var(--pl-font-weight-regular);
    gap: var(--pl-control-gap);
    padding: var(--pl-panel-item-padding);
    position: relative;
    user-select: none;
}

.ps-select-option[data-active="true"] {
    background: var(--pl-surface-muted-hover);
}

.ps-select-option[data-disabled="true"] {
    opacity: var(--pl-control-icon-opacity);
}

.ps-select-option-check {
    align-items: center;
    display: flex;
    height: var(--pl-panel-item-indicator-size);
    justify-content: center;
    position: absolute;
    right: var(--pl-control-padding-y);
    width: var(--pl-panel-item-indicator-size);
}

.ps-select-option-check svg {
    fill: none;
    height: var(--pl-panel-item-indicator-size);
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: var(--pl-icon-stroke-width);
    width: var(--pl-panel-item-indicator-size);
}

.ps-select-option[aria-selected="false"] .ps-select-option-check {
    display: none;
}

/* ---------------------------------------------------------------- checkbox */

ps-checkbox {
    align-items: center;
    cursor: pointer;
    display: inline-flex;
    gap: calc(var(--pl-control-gap) / 2);
}

/* The native input stays as the source of truth and is visually replaced. */
ps-checkbox input[type="checkbox"] {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

.ps-checkbox-box {
    align-items: center;
    background: transparent;
    border: 1px solid var(--pl-border-color);
    border-radius: var(--pl-checkbox-radius);
    box-shadow: var(--pl-checkbox-shadow);
    box-sizing: border-box;
    color: var(--pl-control-text);
    display: inline-flex;
    flex: none;
    height: var(--pl-checkbox-size);
    justify-content: center;
    width: var(--pl-checkbox-size);
}

.ps-checkbox-box svg {
    fill: none;
    height: 100%;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: var(--pl-icon-stroke-width);
    width: 100%;
}

ps-checkbox input:focus-visible ~ .ps-checkbox-box {
    border-color: var(--pl-panel-border-color);
}

ps-checkbox[data-disabled="true"] {
    cursor: default;
    opacity: var(--pl-control-icon-opacity);
}

/* ------------------------------------------------------------------ fields */

.ps-field {
    display: flex;
    flex-direction: column;
    gap: calc(var(--pl-control-padding-y) / 2);
}

.ps-field-label {
    color: var(--pl-text-muted);
    font-size: var(--pl-control-font-size);
    font-weight: var(--pl-font-weight-regular);
}

/* --------------------------------------------------------- shared surfaces */

.ps-panel {
    background: var(--pl-control-surface);
    border: 1px solid var(--pl-border-color);
    border-radius: var(--pl-surface-radius);
    overflow: hidden;
}

.ps-panel-head {
    background: var(--pl-surface-muted);
    border-bottom: 1px solid var(--pl-border-color);
    padding: var(--pl-control-padding-y) var(--pl-table-cell-padding-x);
}

.ps-panel-head h2 {
    color: var(--pl-text-color);
    font-size: var(--pl-control-font-size);
    font-weight: var(--pl-font-weight-strong);
    margin: 0;
}

.ps-panel-head p {
    color: var(--pl-text-muted);
    font-size: var(--pl-control-font-size);
    margin: calc(var(--pl-control-padding-y) / 4) 0 0;
}

.ps-button {
    align-items: center;
    background: var(--pl-control-active-bg);
    border: 0;
    border-radius: var(--pl-control-radius);
    color: var(--pl-control-active-text);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: var(--pl-control-font-size);
    font-weight: var(--pl-font-weight-medium);
    gap: var(--pl-control-gap);
    justify-content: center;
    min-height: var(--pl-control-height);
    padding: var(--pl-control-padding-y) calc(var(--pl-control-padding-x) * 2);
    text-decoration: none;
}

.ps-button:hover {
    opacity: var(--pl-control-icon-opacity);
}

.ps-button:focus-visible {
    outline: var(--pl-focus-ring-width) solid var(--pl-field-focus-ring);
    outline-offset: var(--pl-control-border);
}

.ps-button[disabled] {
    cursor: default;
    opacity: var(--pl-control-icon-opacity);
}

.ps-button--primary {
    background: var(--pl-action-primary-surface);
    color: var(--pl-action-primary-text);
}

.ps-button-secondary,
.ps-button--secondary {
    background: var(--pl-control-surface);
    border: 1px solid var(--pl-border-color);
    color: var(--pl-text-color);
}

/* --------------------------------------------------------- settings pages */

.ps-settings-page {
    box-sizing: border-box;
    margin: 0 auto;
    max-width: var(--pl-settings-page-max-width);
    width: 100%;
}

.ps-settings-page__header {
    margin-bottom: var(--pl-settings-section-gap);
    max-width: var(--pl-settings-copy-max-width);
}

.ps-settings-page__header h1 {
    color: var(--pl-text-color);
    font-size: var(--pl-settings-heading-size);
    font-weight: var(--pl-font-weight-strong);
    letter-spacing: var(--pl-heading-letter-spacing);
    line-height: var(--pl-heading-line-height);
    margin: 0;
}

.ps-settings-page__header p {
    color: var(--pl-text-muted);
    font-size: var(--pl-settings-body-font-size);
    line-height: var(--pl-settings-description-leading);
    margin: calc(var(--pl-control-padding-y) / 2) 0 0;
}

.ps-settings-page__layout {
    align-items: start;
    display: grid;
    gap: var(--pl-settings-layout-gap);
    grid-template-columns: minmax(0, 1fr);
}

.ps-settings-sections {
    display: flex;
    flex-direction: column;
    gap: var(--pl-settings-section-gap);
    min-width: 0;
}

.ps-settings-section {
    background: var(--pl-control-surface);
    border: 1px solid var(--pl-form-card-border);
    border-radius: var(--pl-settings-section-radius);
    box-shadow: var(--pl-settings-section-shadow);
    box-sizing: border-box;
    margin: 0;
    min-width: 0;
    overflow: hidden;
    padding: 0;
}

.ps-settings-section__legend {
    background: var(--pl-settings-header-surface);
    border-bottom: 1px solid var(--pl-form-card-divider);
    border-radius: var(--pl-settings-section-radius) var(--pl-settings-section-radius) 0 0;
    box-sizing: border-box;
    display: block;
    float: left;
    padding: var(--pl-settings-section-padding);
    width: 100%;
}

.ps-settings-section__title {
    color: var(--pl-text-color);
    display: block;
    font-size: var(--pl-settings-section-heading-size);
    font-weight: var(--pl-font-weight-strong);
    line-height: var(--pl-heading-line-height);
}

.ps-settings-section__description {
    color: var(--pl-text-muted);
    display: block;
    font-size: var(--pl-settings-body-font-size);
    font-weight: var(--pl-font-weight-regular);
    line-height: var(--pl-settings-description-leading);
    margin-top: calc(var(--pl-control-padding-y) / 2);
    max-width: var(--pl-settings-copy-max-width);
}

.ps-settings-section__body {
    clear: both;
    display: grid;
    gap: var(--pl-settings-field-gap);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: var(--pl-settings-section-padding);
}

.ps-settings-section__body--single {
    grid-template-columns: minmax(0, 1fr);
}

.ps-settings-disclosure {
    border-top: 1px solid var(--pl-form-card-divider);
    grid-column: 1 / -1;
    padding-top: var(--pl-settings-field-gap);
}

.ps-settings-disclosure summary {
    color: var(--pl-text-color);
    cursor: pointer;
    font-size: var(--pl-control-font-size);
    font-weight: var(--pl-font-weight-medium);
}

.ps-settings-disclosure__body {
    display: grid;
    gap: var(--pl-settings-field-gap);
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding-top: var(--pl-settings-field-gap);
}

.ps-settings-actions {
    align-items: center;
    background: var(--pl-control-surface);
    border: 1px solid var(--pl-form-card-border);
    border-radius: var(--pl-settings-section-radius);
    bottom: 0;
    box-shadow: var(--pl-settings-action-shadow);
    display: flex;
    gap: var(--pl-control-gap);
    justify-content: flex-end;
    padding: var(--pl-control-padding-x) var(--pl-settings-section-padding);
    position: sticky;
    z-index: var(--pl-layer-dropdown);
}

.ps-settings-actions__status {
    color: var(--pl-text-muted);
    font-size: var(--pl-control-font-size);
    margin-right: auto;
}

@media (max-width: 45rem) {
    .ps-settings-section__body,
    .ps-settings-disclosure__body {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ── The entity table ──────────────────────────────────────────────────
   THE reusable "list of things" table: connections, applications,
   mappings — anything that is rows of identities with a status. Use it
   instead of inventing a new list; the whole recipe is here.

   <table class="ps-table">
     <thead><tr><th>Name</th><th>Status</th><th></th></tr></thead>
     <tbody><tr>
       <td><span class="ps-entity">
         <span class="ps-tile" data-tint="blue" aria-hidden="true">G</span>
         <span class="ps-entity-text"><strong>Google</strong><small>detail</small></span>
       </span></td>
       <td><span class="ps-chip" data-tone="positive">Connected</span></td>
       <td class="ps-table-actions"><button class="ps-link-button">…</button></td>
     </tr></tbody>
   </table>

   Cells: .ps-table-muted (secondary values), .ps-table-actions
   (right-aligned row actions), .ps-table-control (holds a ps-select),
   .ps-table-empty (one-cell empty state). Tiles: data-tint blue | purple
   | emerald | amber | slate — identity accents, never data colour.
   Chips: data-tone positive | neutral | caution | info; a script that
   maintains data-status (verified, unverified, error) gets the same
   tones without knowing about them. */
.ps-table {
    border-collapse: collapse;
    width: 100%;
}

.ps-table th {
    border-bottom: 1px solid var(--pl-border-color);
    color: var(--pl-text-muted);
    font-size: var(--pl-table-detail-font-size);
    font-weight: var(--pl-font-weight-medium);
    padding: var(--pl-table-head-padding-y) var(--pl-table-row-padding-x);
    text-align: left;
    white-space: nowrap;
}

.ps-table td {
    border-top: 1px solid var(--alpha-shade-40);
    color: var(--pl-text-color);
    font-size: var(--pl-table-font-size);
    padding: var(--pl-table-row-padding-y) var(--pl-table-row-padding-x);
    vertical-align: middle;
}

.ps-table tbody tr:first-child td {
    border-top: 0;
}

.ps-table tbody tr:hover {
    background: var(--pl-table-row-hover);
}

.ps-table-muted {
    color: var(--pl-text-muted);
}

.ps-table-actions {
    text-align: right;
    white-space: nowrap;
}

.ps-table-control ps-select {
    min-width: min(24rem, 46vw);
}

/* A control cell holds a live choice - it must read as one: control
   surface, visible border, ink text; never the row's muted grey. */
.ps-table-control select {
    background: var(--pl-control-surface);
    border: 1px solid var(--pl-border-color);
    border-radius: var(--pl-control-radius);
    color: var(--pl-text-color);
    font: inherit;
    font-size: var(--pl-control-font-size);
    padding: var(--pl-control-padding-y) var(--pl-control-padding-x);
    width: 100%;
}

.ps-table-control select:disabled {
    color: var(--pl-text-muted);
}

.ps-table-empty {
    color: var(--pl-text-muted);
}

.ps-entity {
    align-items: center;
    display: inline-flex;
    gap: calc(var(--pl-control-gap) * 1.5);
    min-width: 0;
}

.ps-entity-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ps-entity-text strong {
    color: var(--pl-text-color);
    font-size: var(--pl-table-font-size);
    font-weight: var(--pl-font-weight-medium);
}

.ps-entity-text small {
    color: var(--pl-text-muted);
    font-size: var(--pl-table-detail-font-size);
}

.ps-tile {
    align-items: center;
    border-radius: var(--pl-control-radius);
    display: inline-flex;
    flex: none;
    font-size: var(--pl-table-font-size);
    font-weight: var(--pl-font-weight-strong);
    height: 2.25rem;
    justify-content: center;
    width: 2.25rem;
}

.ps-tile[data-tint="blue"] { background: var(--alpha-blue-45); color: var(--pl-accent-blue); }
.ps-tile[data-tint="purple"] { background: var(--alpha-purple-45); color: var(--pl-accent-purple); }
.ps-tile[data-tint="emerald"] { background: var(--pl-status-positive-surface); color: var(--pl-accent-emerald); }
.ps-tile[data-tint="amber"] { background: var(--pl-status-caution-surface); color: var(--pl-accent-amber); }
.ps-tile[data-tint="slate"] { background: var(--alpha-shade-50); color: var(--pl-accent-slate); }

.ps-chip {
    align-items: center;
    background: var(--pl-status-neutral-surface);
    border-radius: 999px;
    color: var(--pl-status-neutral-text);
    display: inline-flex;
    font-size: var(--pl-control-font-size);
    gap: calc(var(--pl-control-gap) * 0.75);
    height: 1.4rem;
    line-height: 1;
    padding: 0 var(--pl-control-padding-x);
    white-space: nowrap;
    --ps-chip-dot: var(--pl-status-neutral-dot);
}

.ps-chip::before {
    background: var(--ps-chip-dot);
    border-radius: 50%;
    content: '';
    flex: none;
    height: 0.375rem;
    width: 0.375rem;
}

.ps-chip[data-tone="positive"],
.ps-chip[data-status="verified"] {
    background: var(--pl-status-positive-surface);
    color: var(--pl-status-positive-text);
    --ps-chip-dot: var(--pl-status-positive-dot);
}

.ps-chip[data-tone="caution"],
.ps-chip[data-status="error"] {
    background: var(--pl-status-caution-surface);
    color: var(--pl-status-caution-text);
    --ps-chip-dot: var(--pl-status-caution-dot);
}

.ps-chip[data-tone="info"],
.ps-chip[data-status="unverified"] {
    background: var(--pl-status-info-surface);
    color: var(--pl-status-info-text);
    --ps-chip-dot: var(--pl-status-info-dot);
}

/* A panel head that carries an action on its right edge; it breathes on
   the settings scale like the rows beneath it. */
.ps-panel-head--actions {
    align-items: center;
    display: flex;
    gap: var(--pl-control-gap);
    justify-content: space-between;
    padding: var(--pl-table-row-padding-y) var(--pl-table-row-padding-x);
}