/* Ограничиваем действие базовых правил только областью сортировки */
.xsort-area *,
.xsort-area *::before,
.xsort-area *::after {
  box-sizing: border-box;
}

/* Поля ввода и textarea внутри сортировочной области */
.xsort-area input,
.xsort-area textarea {
  border: 1px solid #404040;
  background-color: #2b2b2b;
  color: #eaeaea;
  padding: 5px;
  border-radius: 3px;
}

/* Стили для области сортировки */
.xsort-area {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 15px 10px;
  border-left: 1px solid #404040;
  font-size: 12px;
  line-height: 32px;
  user-select: none;
  gap: 8px;
}

.xsort-area > div {
  flex: 0 0 auto;
  padding: 0 8px;
  color: #eaeaea;
}

/* Стили для кнопок/элементов сортировки */
.xsort-div {
  height: 30px;
  line-height: 30px;
  padding: 0 10px;
  border-radius: 3px;
  background: linear-gradient(145deg, #3f3f3f, #2a2a2a);
  color: #fff;
  position: relative;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.xsort-div:hover {
  background: linear-gradient(145deg, #4a4a4a, #333333);
}

/* Состояния выделения */
.xsort-active {
  box-shadow: 0 0 0 2px #e77764;
}

.xsort-selected {
  padding-right: 15px;
  position: relative;
  color: #cfcfcf;
}

.xsort-selected span {
  color: #cfcfcf;
}

.xsort-selected:after {
  content: "";
  position: absolute;
  top: 50%;
  right: 5px;
  transform: translateY(-50%);
  border: 4px solid transparent;
  border-top-color: #7a7a75;
}

/* Выпадающее меню */
.xsort-ul {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 1px;
  background: #404040;
  border-radius: 3px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 999;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.3);
}

.xsort-ul li {
  padding: 0 18px;
  line-height: 30px;
  white-space: nowrap;
  cursor: pointer;
  color: #a8a8a8;
  border-bottom: 1px solid #383838;
  transition: background 0.2s ease;
}

.xsort-ul li:last-child {
  border-bottom: none;
}

.xsort-ul li:hover {
  background: #a8a8a8;
  color: #111;
}

/* Выбранный элемент в выпадающем меню */
.xsort-ul li.current {
  background: #e77764;
  color: #fff;
  position: relative;
}

.xsort-ul li.current:after {
  content: "";
  position: absolute;
  top: 0;
  right: 5px;
  bottom: 0;
  width: 5px;
  background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAQAAAAnZu5uAAAAJUlEQVQY01XIMQEAIAwDsDivroGe6Sg3OQNxBGLVCldVzbfECA+g/g9v8ooTNAAAAABJRU5ErkJggg==)
    center center no-repeat;
}

/* Стрелки сортировки (по возрастанию/убыванию) */
.xasc,
.xsort-ul li.xasc {
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAICAQAAACfDS2NAAAAHklEQVQYV2NgAIO0/xAaygFBFA5UAMGBq0BRTDwXAPWMJw0b8PLnAAAAAElFTkSuQmCC);
  background-position: 6px center;
  background-repeat: no-repeat;
  padding-left: 20px;
}

.xdesc,
.xsort-ul li.xdesc {
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAICAQAAACfDS2NAAAAIElEQVQY02NgYGBgSPsPggwwQDQXwoRBFAHsekECEBoASUcnDSh9+RUAAAAASUVORK5CYII=);
  background-position: 6px center;
  background-repeat: no-repeat;
  padding-left: 20px;
}

/* Дополнительные блоки и утилиты */
.xsort_empty {
  margin-top: 15px;
  background: #fff;
  border: 1px solid #ccc;
  padding: 15px;
  color: #2b2b2b;
  border-radius: 3px;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.last_comments,
.searchheading,
.speedbarpd {
  background-color: #2b2b2b;
  padding: 10px;
  border-radius: 3px;
}

.contentfulldp,
.last_comments,
.msupdate_block_list_item {
  box-shadow: 0 0 0 1px #111;
}

.mimiserblock_bn {
  overflow: auto;
  padding: 6px 0;
  margin: 0 auto -5px;
  max-width: 100%;
}

.li_block_bn {
  position: relative;
  display: block;
  padding: 0 8px 6px 6px;
}

.li_block_rmb {
  position: relative;
  display: block;
  padding: 6px 16px 7px;
}

/* Контейнер для bbcode */
.bbcodes {
  border-radius: 4px;
  padding: 10px;
  font-size: 16px;
  background-color: #242424;
  margin: 10px;
}

/* Блок с категориями */
.block_category {
  width: 100%;
  display: block;
  margin-bottom: 15px;
}

/* Административная панель сортировки */
.xsort-admin-area {
  padding-left: 210px;
}

.xsort-admin-area:after {
  content: "";
  display: block;
  clear: both;
}

.xsort-admin-area ul {
  list-style: none;
  margin: 0;
  padding: 0;
  float: left;
  width: 200px;
  border-right: 1px solid #ddd;
}

.xsort-admin-area ul li {
  padding: 1px 0;
  cursor: pointer;
  color: silver;
}

.xsort-admin-area ul li.current,
.xsort-admin-area ul li:hover {
  color: #000;
}

.xsort-admin-area p {
  padding-top: 7px;
  margin: 0;
}

.xsort-admin-area code {
  max-height: 400px;
  overflow: auto;
}

/* Кнопка "Очистить все" */
.xsort-div-clearall {
  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAQAAACR313BAAAAKklEQVQoz2NgGATA4L/Bf3QWmrTBfwSNQwEOSWQT8EjiNRqnCQRcPgAAAG+mJxC7ICdhAAAAAElFTkSuQmCC);
  background-position: center;
  width: 25px;
  height: 25px;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* Разметка разделителя */
.x-sort {
  border-bottom: 1px solid #111;
  border-left: 1px solid #404040;
}

/* Стили для нижнего блока (расширенного, на всю ширину) */
.xsort-advanced {
  width: 100%;
  margin: 0;
  padding: 15px 20px;
  background: #2b2b2b;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
}

.xsort-advanced .xsort-div {
  flex: 1;
  max-width: 200px;
  text-align: center;
  padding: 0 10px;
  border-radius: 3px;
  background: linear-gradient(145deg, #3f3f3f, #2a2a2a);
  transition: background 0.2s ease;
  cursor: pointer;
}

.xsort-advanced .xsort-div:hover {
  background: linear-gradient(145deg, #4a4a4a, #333333);
}

/* Стили для блоков [available=cat] и [available=main] */
.available-cat div,
.available-main div {
  font-family: "Comic Sans MS", sans-serif;
  font-size: 13px;
  font-weight: bold;
  padding: 2px 5px;
  line-height: 1;
  border: 1px solid #404040;
  border-radius: 3px;
  display: inline-block;
  margin-right: 10px;
}

.available-cat div {
  color: #eaeaea;
  background: #2b2b2b;
}

.available-main div {
  color: #ffffff;
  background: #3f3f3f;
}

/* Адаптивность */
@media (max-width: 768px) {
  .xsort-advanced {
    flex-wrap: wrap;
    gap: 10px;
  }
  
  .xsort-advanced .xsort-div {
    flex: 0 0 calc(50% - 10px);
    max-width: calc(50% - 10px);
    margin: 5px 0;
  }
}

@media (max-width: 480px) {
  .xsort-advanced .xsort-div {
    flex: 0 0 calc(50% - 5px);
    max-width: calc(50% - 5px);
    font-size: 12px;
  }
}

/* Стили скроллбара для WebKit внутри области сортировки */
.xsort-area ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.xsort-area ::-webkit-scrollbar-thumb {
  background-color: #3f3f3f;
  border-radius: 5px;
  border: 2px solid #242424;
}

.xsort-area ::-webkit-scrollbar-track {
  background-color: #242424;
  border-radius: 5px;
}

/* Стили скроллбара для Firefox в области сортировки */
.xsort-area * {
  scrollbar-width: thin;
  scrollbar-color: #3f3f3f #242424;
}
