/* Market Panel — embedded below the host page's header */

/* ─── Panel Layout ────────────────────────────────────────────────────────── */
.marketPage {
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ─── Provider chips (first layer, multi-select) ─────────────────────────── */
.providerChips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 12px;
  font-size: 13px;
  border-radius: 999px;
  border: 1px solid var(--ant-color-border, #d9d9d9);
  color: var(--ant-color-text-secondary, rgba(0, 0, 0, 0.65));
  cursor: pointer;
  user-select: none;
  transition: all 0.2s;

  &:hover {
    color: var(--ant-color-primary, #1677ff);
    border-color: var(--ant-color-primary, #1677ff);
  }
}

.chipActive {
  color: var(--ant-color-primary, #1677ff);
  border-color: var(--ant-color-primary, #1677ff);
  background: var(--ant-color-primary-bg, rgba(22, 119, 255, 0.08));
  font-weight: 500;
}

.chipDisabled {
  opacity: 0.45;
  cursor: not-allowed;

  &:hover {
    color: var(--ant-color-text-secondary, rgba(0, 0, 0, 0.65));
    border-color: var(--ant-color-border, #d9d9d9);
  }
}

/* ─── Toolbar (second layer: category tabs + search) ─────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.searchInput {
  width: 260px;
  flex-shrink: 0;
}

.filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.categorySelect {
  width: 200px;
  flex-shrink: 0;
}

.searchHint {
  font-size: 13px;
  color: var(--ant-color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Browse hint (search-only sources) ──────────────────────────────────── */
.browseHint {
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(22, 119, 255, 0.06);
  border: 1px solid rgba(22, 119, 255, 0.16);
  color: #1668dc;
  font-size: 13px;
}

/* ─── Error row ──────────────────────────────────────────────────────────── */
.errorRow {
  background: rgba(245, 34, 45, 0.06);
  border: 1px solid rgba(245, 34, 45, 0.18);
  color: #cf1322;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
}

/* ─── Results grid ───────────────────────────────────────────────────────── */
.resultsGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

/* ─── Load more ──────────────────────────────────────────────────────────── */
.loadMoreRow {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
  padding: 8px;
}

.noMoreText {
  color: rgba(20, 20, 19, 0.45);
  font-size: 13px;
}

.sentinel {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 32px;
  color: rgba(20, 20, 19, 0.45);
  font-size: 13px;
}

/* ─── Install queue tray (bottom-right) ──────────────────────────────────── */
.queueDrawer {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 320px;
  max-height: 400px;
  border: 1px solid var(--color-border-secondary, #eae8e7);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.queueHeader {
  padding: 12px;
  border-bottom: 1px solid var(--color-border-secondary, #eae8e7);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 13px;
  color: rgba(20, 20, 19, 0.88);
}

.queueList {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

/* ─── Dark mode ──────────────────────────────────────────────────────────── */
:global(.dark-mode) {
  .chip {
    border-color: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.65);

    &:hover {
      color: #4da3ff;
      border-color: #4da3ff;
    }
  }

  .chipActive {
    color: #4da3ff;
    border-color: #4da3ff;
    background: rgba(22, 119, 255, 0.16);
  }

  .chipDisabled {
    &:hover {
      color: rgba(255, 255, 255, 0.65);
      border-color: rgba(255, 255, 255, 0.18);
    }
  }

  .searchHint {
    color: rgba(255, 255, 255, 0.65);
  }

  .browseHint {
    background: rgba(22, 119, 255, 0.12);
    border-color: rgba(22, 119, 255, 0.28);
    color: #6cb2ff;
  }

  .errorRow {
    background: rgba(245, 34, 45, 0.12);
    border-color: rgba(245, 34, 45, 0.25);
    color: #ff7875;
  }

  .noMoreText {
    color: rgba(255, 255, 255, 0.45);
  }

  .sentinel {
    color: rgba(255, 255, 255, 0.45);
  }

  .queueDrawer {
    background: #2a2a2a;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  }

  .queueHeader {
    color: rgba(255, 255, 255, 0.88);
  }
}

/* ─── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .filters {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .categorySelect {
    width: 100%;
  }

  .searchInput {
    width: 100%;

    :global(input) {
      text-align: center;
    }
  }

  .resultsGrid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .queueDrawer {
    left: 16px;
    width: auto;
  }
}
