/*
 * Device picker — decision 139.
 *
 * One component in two shapes: "inline" sits in a page header where the
 * Factory ID used to be plain text, "utilbar" is the compact top-bar jump.
 * Everything here uses the shared --nt-* tokens from builtair.css.
 */

.devpick {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* ── Trigger ─────────────────────────────────────────────────────────── */

.devpick__btn {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    max-width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    border-radius: var(--nt-radius-sm);
}

.devpick__btn:disabled {
    cursor: default;
    opacity: .7;
}

.devpick__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.devpick__chevron {
    font-size: .7em;
    color: var(--nt-text-muted);
    transition: transform .15s, color .15s;
}

.devpick__btn:hover:not(:disabled) .devpick__chevron { color: var(--nt-primary); }
.devpick__btn[aria-expanded="true"] .devpick__chevron { transform: rotate(180deg); }
.devpick__btn:disabled .devpick__chevron { display: none; }

/* Inline: inherits the heading treatment the Factory ID already had, so the
   page looks unchanged until you notice it is now clickable. */
.devpick--inline .devpick__btn {
    font-family: var(--nt-font-heading);
    font-size: 18px;
    font-weight: 600;
    color: var(--nt-text-dark);
    line-height: 1.2;
}
.devpick--inline .devpick__btn:hover:not(:disabled) .devpick__label {
    color: var(--nt-primary);
}

/* Utility bar: a small bordered control, sized like its neighbours. */
.devpick--utilbar .devpick__btn {
    height: 28px;
    width: 150px;
    justify-content: space-between;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    color: var(--nt-text);
    background: var(--nt-white);
    border: 1px solid var(--nt-gray-200);
    border-radius: var(--nt-radius-sm);
}
.devpick--utilbar .devpick__btn:hover:not(:disabled) { border-color: var(--nt-primary); }
.devpick--utilbar .devpick__btn[aria-expanded="true"] {
    border-color: var(--nt-primary);
    box-shadow: 0 0 0 2px var(--nt-highlight-50);
}

/* ── Menu ────────────────────────────────────────────────────────────── */

.devpick__menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1060;
    margin-top: 4px;
    min-width: 260px;
    max-width: 340px;
    padding: 6px;
    background: var(--nt-white);
    border: 1px solid var(--nt-gray-150);
    border-radius: 8px;
    box-shadow: var(--nt-shadow-sm);
}

.devpick__menu[hidden] { display: none; }

/* In the top bar the control sits at the right-hand end, so the menu hangs
   off the right edge rather than running off-screen. */
.devpick--utilbar .devpick__menu { left: auto; right: 0; }

.devpick__search {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    margin-bottom: 4px;
    border: 1px solid var(--nt-gray-150);
    border-radius: var(--nt-radius-sm);
    color: var(--nt-text-muted);
}

.devpick__search:focus-within {
    border-color: var(--nt-primary);
    box-shadow: 0 0 0 2px var(--nt-highlight-50);
}

.devpick__input,
.devpick__admin-input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    outline: none;
    background: none;
    font-size: 13px;
    color: var(--nt-text);
}

.devpick__list,
.devpick__admin-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 300px;
    overflow-y: auto;
}

.devpick__admin-list { max-height: 200px; }

.devpick__item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 7px 10px;
    border-radius: var(--nt-radius-sm);
    font-size: 13px;
    cursor: pointer;
}

.devpick__item:hover,
.devpick__item:focus {
    background: var(--nt-highlight);
    outline: none;
}

.devpick__item[aria-selected="true"] { background: var(--nt-gray-50); }
.devpick__item-id { font-weight: 600; color: var(--nt-secondary); }

.devpick__item-meta {
    margin-left: auto;
    color: var(--nt-text-muted);
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.devpick__empty {
    padding: 8px 10px;
    font-size: 12.5px;
    color: var(--nt-text-muted);
}

/* ── Admin cross-organisation search ─────────────────────────────────── */

.devpick__admin {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--nt-gray-150);
}

.devpick__admin-head {
    padding: 0 2px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--nt-text-muted);
}

/* ── In the mobile top-bar panel ─────────────────────────────────────── */
/*
 * The panel is a narrow vertical stack, so the picker fills its width rather
 * than sitting at the fixed size it uses on the desktop top bar, and its menu
 * stays inside the panel instead of hanging off the edge of a phone screen.
 */
.mobile-topbar__panel .devpick { display: flex; margin: 4px 0; }
.mobile-topbar__panel .devpick--utilbar .devpick__btn { width: 100%; }
.mobile-topbar__panel .devpick__menu {
    left: 0;
    right: 0;
    min-width: 0;
    max-width: none;
}

/* ── Inside a card ───────────────────────────────────────────────────── */
/*
 * device_picker.js adds this while a menu is open. Cards that lift on hover
 * create a stacking context, and without an explicit z-index everything after
 * the card in the page paints over the open menu.
 */
.card.devpick-open { position: relative; z-index: 1070; }
