/* <x-sidebar>: the list on the left of a page, same look as Bouwplan. */
x-sidebar {
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;

  .tabs {
    display: flex;
    gap: 4px;
    padding: 0 16px;
    box-shadow: inset 0 -3px 0 var(--tab-base);
    flex: none;
    overflow-x: auto;
    scrollbar-width: none;

    &::-webkit-scrollbar { display: none; }

    &.title { height: 49px; align-items: center; font-weight: 600; }

    & button {
      height: 46px;
      padding: 0 12px;
      border: 0;
      background: none;
      color: var(--fg-2);
      font-weight: 500;
      white-space: nowrap;
      position: relative;
      flex: none;
      transition: color 0.25s var(--ease);

      &::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: transparent; transition: background 0.3s var(--ease); }
      &:hover { color: var(--fg); }
      &:hover::after { background: var(--tab-hover); }
      &.active { color: var(--fg); font-weight: 600; }
      &.active::after { background: var(--accent); }
    }
  }

  .filter { display: flex; gap: 8px; padding: 16px; flex: none; }

  .search {
    flex: 1;
    position: relative;
    min-width: 0;

    & .ic { position: absolute; left: 11px; 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); }
  }

  .add {
    width: 40px;
    height: 40px;
    flex: none;
    border: 0;
    border-radius: 6px;
    background: var(--btn-dark);
    color: #FFFFFF;
    display: grid;
    place-items: center;
    transition: background 0.25s var(--ease);

    &:hover { background: var(--btn-dark-hover); }
  }

  .picker { display: none; }

  .body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
  .body .tabs { display: none; }

  .list {
    flex: 1;
    overflow-y: auto;
    margin: 0 16px 16px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--input-bg);
  }

  .row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 11px 14px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: var(--input-bg);
    text-align: left;
    color: var(--fg);
    transition: background 0.25s var(--ease), box-shadow 0.25s var(--ease);

    &:last-child { border-bottom: 0; }
    &:nth-child(even) { background: var(--zebra); }
    &:hover { background: var(--line); }
    &.active { background: var(--accent-soft); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
  }

  .text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .name, .sub { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sub { color: var(--fg-3); font-size: 12.5px; font-weight: 400; margin-top: 1px; }
  .row.two-lines { padding-top: 8px; padding-bottom: 8px; }
  .meta { flex: none; color: var(--fg-3); font-size: 13px; font-weight: 400; display: inline-flex; align-items: center; gap: 6px; }

  .badge {
    padding: 1px 7px;
    border-radius: 9px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 17px;
    white-space: nowrap;
    background: var(--muted-soft);
    color: var(--fg-2);
  }
  .badge.ok { background: var(--ok-soft); color: var(--ok); }
  .badge.warn { background: var(--warn-soft); color: var(--warn); }

  .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-3); flex: none; }
  .dot.ok { background: var(--ok); }
  .dot.warn { background: var(--warn); }
  .dot.muted { background: var(--line-strong); }

  .empty { padding: 24px 16px; text-align: center; color: var(--fg-3); font-size: 13px; }
  .more { padding: 12px 14px; text-align: center; color: var(--fg-3); font-size: 12.5px; }
}

/* Mobile: the sidebar becomes a sticky bar with a dropdown picker above the content */
@media (max-width: 767px) {
  x-sidebar {
    display: block;
    position: sticky;
    top: 0;
    z-index: 20;
    border-radius: 0;
    border-width: 0 0 1px;

    & > .tabs { display: none; }
    .filter { padding: 10px 16px 8px; }

    .picker {
      display: flex;
      align-items: center;
      gap: 10px;
      width: calc(100% - 32px);
      margin: 0 16px 10px;
      padding: 10px 12px;
      border: 1px solid var(--line-strong);
      border-radius: 6px;
      background: var(--input-bg);
      text-align: left;
      font-weight: 600;

      & span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
      & .chev { width: 18px; height: 18px; color: var(--fg-2); transition: transform var(--dur) var(--ease); }
    }

    &.open .picker .chev { transform: rotate(180deg); }

    .body {
      display: none;
      position: absolute;
      top: 100%;
      left: 0;
      right: 0;
      max-height: 65vh;
      background: var(--panel);
      border-bottom: 1px solid var(--line);
      box-shadow: 0 18px 36px rgba(0, 0, 0, 0.2);
    }

    &.open .body { display: flex; }
    .body .tabs { display: flex; }
    .list { margin: 14px 16px 16px; }
  }
}
