/* <x-project-switch>: the project picker in the topbar, same look as the Bouwplan prototype. */
x-project-switch {
  display: flex;
  align-items: center;
  min-width: 0;

  .back {
    width: 0;
    height: 40px;
    margin-right: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    flex: none;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--nav-fg);
    display: grid;
    place-items: center;
    transition: width var(--dur) var(--ease), margin var(--dur) var(--ease), opacity var(--dur) var(--ease), background 0.25s var(--ease);

    &:hover { background: var(--nav-hover); color: var(--nav-strong); }
  }

  &.in-project .back { width: 38px; margin-right: 8px; opacity: 1; pointer-events: auto; }

  .picker { position: relative; min-width: 0; }

  > .picker > .current {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 38px;
    max-width: 100%;
    padding: 0 12px;
    border: 1px solid var(--nav-line);
    border-radius: 6px;
    background: none;
    color: var(--nav-strong);
    font-weight: 600;
    transition: background 0.25s var(--ease), border-color 0.25s var(--ease);

    &:hover { background: var(--nav-hover); border-color: var(--nav-hover); }
    & .current-icon { display: grid; }
    & .current-icon .ic { width: 18px; height: 18px; color: var(--nav-dim); }
    & .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
    & .chev { width: 16px; height: 16px; transition: transform var(--dur) var(--ease); }
  }

  &.open > .picker > .current { background: var(--nav-hover); border-color: var(--nav-hover); }
  &.open > .picker > .current .chev { transform: rotate(180deg); }

  .menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 340px;
    max-width: calc(100vw - 24px);
    background: var(--panel);
    color: var(--fg);
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  }

  &.open .menu { opacity: 1; transform: none; pointer-events: auto; }

  .search {
    position: relative;
    padding: 12px;
    border-bottom: 1px solid var(--line);

    & .ic { position: absolute; left: 23px; top: 50%; transform: translateY(-50%); color: var(--fg-3); width: 18px; height: 18px; pointer-events: none; }
    & input { width: 100%; height: 40px; padding: 0 12px 0 36px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--input-bg); transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease); }
    & input::placeholder { color: var(--fg-3); }
    & input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  }

  .list { max-height: 320px; overflow-y: auto; padding: 6px; }

  .option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 6px;
    background: none;
    text-align: left;
    transition: background 0.2s var(--ease);

    &:hover { background: var(--zebra); color: var(--fg); }
    &.selected { background: var(--accent-soft); color: var(--fg); font-weight: 600; }
    & .meta { color: var(--fg-3); font-size: 13px; font-weight: 400; white-space: nowrap; }
  }

  .option.all { border-bottom: 1px solid var(--line); margin-bottom: 4px; border-radius: 6px 6px 0 0; }
  .empty { padding: 24px 16px; text-align: center; color: var(--fg-3); font-size: 13px; }
}

@media (max-width: 767px) {
  x-project-switch > .picker > .current { padding: 0 10px; }
}
