/* Cột phải (On this page) và hộp tìm kiếm, theo Figma "Map UI". */

/* --- Cột phải --------------------------------------------------------------- */
.md-nav--secondary .md-nav__title {
  padding: 0 0 8px;
  background: none;
  box-shadow: none;
  color: var(--vm-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 16px;
  text-transform: uppercase;
}

[dir] .md-nav--secondary .md-nav__list {
  padding: 0;
}

.md-nav--secondary .md-nav__item {
  padding: 0;
}

[dir] .md-nav--secondary .md-nav .md-nav__list {
  padding-left: 12px;
}

/* Theme kéo lề âm ở nhóm con làm dòng kế tiếp dính sát lên */
.md-nav--secondary .md-nav {
  margin-bottom: 0;
}

.md-nav--secondary .md-nav__link {
  margin: 0;
  padding: 4px 0;
  color: var(--vm-text);
  font-size: 13px;
  line-height: 18px;
}

/* Tên phương thức dài của trang tham chiếu không có chỗ ngắt tự nhiên */
.md-nav--secondary .md-ellipsis {
  overflow-wrap: anywhere;
  white-space: normal;
}

.md-nav--secondary .md-nav__link:hover {
  color: var(--vm-primary);
}

.md-nav--secondary .md-nav__link--active,
.md-nav--secondary .md-nav__link--passed.md-nav__link--active {
  color: var(--vm-primary);
  font-weight: 700;
}

/* Theme include toc.html cả trong menu điện thoại; nhóm này chỉ thuộc cột phải */
.vm-rail {
  display: none;
}

@media screen and (min-width: 60em) {
  /* Thẻ hỗ trợ dính đáy màn hình, sticky cần cuộn theo cửa sổ nên khung ngoài không
     được cuộn riêng; vùng cuộn là danh sách mục lục. height là giá trị tạm trước khi
     theme đặt chiều cao, container-type cần một chiều cao xác định. */
  .md-sidebar--secondary .md-sidebar__scrollwrap {
    height: calc(100vh - var(--vm-header-h) - var(--vm-tabs-h) - 2px);
    margin: 0;
    overflow: visible;
    container-type: size;
  }

  .md-sidebar--secondary .md-sidebar__inner {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    height: 100%;
  }

  .md-sidebar--secondary .md-nav--secondary {
    display: flex;
    flex: 0 1 auto;
    flex-direction: column;
    min-height: 0;
  }

  .md-sidebar--secondary .md-nav--secondary > .md-nav__title {
    position: static;
    flex: none;
  }

  /* Không đặt position ở đây: toc.follow của theme tính vị trí cuộn bằng offsetTop
     của mục và của khung cuộn, hai giá trị phải cùng một gốc. */
  .md-sidebar--secondary .md-nav--secondary > .md-nav__list {
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: var(--vm-border) transparent;
    scrollbar-width: thin;
  }

  .md-sidebar--secondary .vm-rail {
    display: flex;
    flex: 1 0 auto;
    flex-direction: column;
  }

  /* Bóng cùng màu nền che nội dung đi qua sau thẻ trong lúc cột trôi lên */
  .md-sidebar--secondary .vm-rail__card {
    position: sticky;
    bottom: var(--vm-rail-card-bottom);
    z-index: 1;
    margin-top: auto;
    box-shadow: 0 0 0 8px var(--vm-bg);
  }

  /* Cột dài quá đáy màn hình đúng bằng hàng tab khi hàng này còn hiện: đẩy thẻ xuống
     theo quãng đó để thẻ dính đáy không đè lên link của nhóm Resources */
  .md-sidebar--secondary .vm-rail__links {
    margin-bottom: calc(var(--vm-tabs-h) + 21px);
  }

  .vm-tabs-pinned .md-sidebar--secondary .vm-rail__links {
    margin-bottom: 12px;
  }

  /* Footer ép cột thấp lại: nhường chỗ cho mục lục */
  @container (max-height: 420px) {
    .md-sidebar--secondary .vm-rail__links {
      margin-bottom: 12px;
    }

    .md-sidebar--secondary .vm-rail__card {
      display: none;
    }
  }

  @container (max-height: 300px) {
    .md-sidebar--secondary .vm-rail {
      display: none;
    }
  }

  .md-sidebar--secondary .md-nav--secondary:has(.md-nav__title) + .vm-rail {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--vm-border);
  }
}

.vm-rail__title {
  margin: 0 0 6px;
  color: var(--vm-ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
}

.vm-rail__links {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.vm-rail__links a {
  display: block;
  padding: 3px 0;
  color: var(--vm-text);
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
}

.vm-rail__links a:hover {
  color: var(--vm-primary);
}

.vm-rail__card {
  padding: 8px 12px;
  border-radius: var(--vm-radius);
  background-color: var(--vm-bg-subtle);
}

.vm-rail__card p {
  margin: 0;
}

.vm-rail__card-title {
  color: var(--vm-ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
}

.vm-rail__card-link {
  display: inline-block;
  color: var(--vm-primary);
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
}

.vm-rail__card-link:hover {
  text-decoration: underline;
}

/* --- Hộp tìm kiếm ------------------------------------------------------------
   Theme đặt ô tìm trong header rồi mở rộng tại chỗ. Ở đây hộp nổi giữa màn hình
   nên các quy tắc theo độ rộng của theme đều bị ghi đè.

   Khi đóng, hộp chỉ trong suốt chứ không dùng visibility: theme mở hộp bằng cách
   focus ô nhập, và iOS chỉ hiện bàn phím nếu focus xảy ra ngay trong lúc chạm. */
/* z-index tạo lớp riêng để hộp phủ lên các nút trong header */
.md-search {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  width: 0;
  height: 0;
  padding: 0;
}

/* Khung chat có z-index rất cao, che nền phủ và nút Đóng ở đáy màn hình điện thoại */
#__search:checked ~ iframe[title="AI Agent Chat Widget"] {
  visibility: hidden;
}

[dir] .md-search__overlay {
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  overflow: hidden;
  border-radius: 0;
  background-color: #111b2c99;
  cursor: pointer;
  opacity: 0;
  pointer-events: auto;
  position: fixed;
  transform: none;
  transition: opacity .15s;
}

[dir] [data-md-toggle="search"]:checked ~ .md-header .md-search__overlay {
  width: 100%;
  height: 100%;
  opacity: 1;
  transform: none;
  transition: opacity .15s;
}

[data-md-color-scheme="slate"] .md-search__overlay {
  background-color: #00000099;
}

.md-search__overlay {
  touch-action: none;
}

[dir] .md-search__inner {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 2;
  display: flex;
  float: none;
  flex-direction: column;
  box-sizing: border-box;
  width: min(680px, calc(100vw - 32px));
  height: min(500px, calc(100vh - 32px));
  height: min(500px, calc(100dvh - 32px));
  padding: 16px 16px 12px;
  overflow: hidden;
  border-radius: 12px;
  background-color: var(--vm-bg);
  box-shadow: 0 24px 48px -12px #10182840;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(.98);
  transition: opacity .12s, transform .12s;
}

[dir] [data-md-toggle="search"]:checked ~ .md-header .md-search__inner {
  width: min(680px, calc(100vw - 32px));
  height: min(500px, calc(100vh - 32px));
  height: min(500px, calc(100dvh - 32px));
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  transition: opacity .12s, transform .12s;
}

[data-md-color-scheme="slate"] .md-search__inner {
  outline: 1px solid var(--vm-border);
}

/* Khi đóng, các phần có chữ không được lọt vào Ctrl F hay thứ tự Tab */
[data-md-toggle="search"]:not(:checked) ~ .md-header .md-search__inner > :not(.md-search__form),
[data-md-toggle="search"]:not(:checked) ~ .md-header .vm-search-esc {
  visibility: hidden;
}

.md-search__form,
.md-search__form:hover,
[data-md-toggle="search"]:checked ~ .md-header .md-search__form {
  flex: none;
  height: 52px;
  border-radius: var(--vm-radius);
  background-color: var(--vm-bg-subtle);
  box-shadow: none;
  color: var(--vm-ink);
}

[dir] .md-search__input,
[dir] .md-search__suggest {
  height: 100%;
  padding: 0 124px 0 46px;
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
}

.md-search__input,
[data-md-toggle="search"]:checked ~ .md-header .md-search__input {
  color: var(--vm-ink);
  text-overflow: ellipsis;
}

.md-search__input::placeholder,
[data-md-toggle="search"]:checked ~ .md-header .md-search__input::placeholder {
  color: var(--vm-muted);
  font-weight: 500;
}

.md-search__suggest {
  color: var(--vm-border);
}

[dir] .md-search__icon[for="__search"] {
  top: 16px;
  left: 16px;
  width: 20px;
  height: 20px;
  color: var(--vm-ink);
  pointer-events: none;
}

.md-search__icon[for="__search"] .vm-icon {
  display: block;
  width: 20px;
  height: 20px;
}

.md-search__icon[for="__search"] svg {
  display: none;
}

[dir] .md-search__options {
  top: 12px;
  right: 60px;
  display: flex;
  align-items: center;
}

[dir] .md-search__options > .md-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 0;
  color: var(--vm-muted);
}

[dir] .md-search__options > .md-icon svg {
  width: 18px;
  height: 18px;
}

.vm-search-esc {
  position: absolute;
  top: 13px;
  right: 12px;
  z-index: 2;
  padding: 4px 10px;
  border: 1px solid var(--vm-border);
  border-radius: 6px;
  background-color: var(--vm-bg);
  color: var(--vm-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
}

.vm-search-scope {
  display: flex;
  flex: none;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  margin-top: 12px;
  padding: 0 8px;
}

.vm-search-scope[hidden] {
  display: none;
}

.vm-search-scope__label {
  margin-right: 8px;
  color: var(--vm-muted);
  font-size: 12px;
  font-weight: 500;
}

.vm-search-scope__chip {
  height: 28px;
  padding: 0 14px;
  border-radius: 6px;
  color: var(--vm-text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.vm-search-scope__chip:hover {
  color: var(--vm-primary);
}

.vm-search-scope__chip[aria-pressed="true"] {
  background-color: var(--vm-selected);
  color: var(--vm-primary);
  font-weight: 700;
}

.vm-search-scope__chip[data-scope="section"]:empty {
  display: none;
}

.vm-search-scope__chip:focus-visible,
.vm-search-status__all:focus-visible,
.vm-search-trigger:focus-visible {
  outline: 2px solid var(--vm-primary);
  outline-offset: 1px;
}

[dir] .md-search__output {
  position: relative;
  top: auto;
  z-index: auto;
  flex: 1 1 auto;
  width: auto;
  min-height: 0;
  margin-top: 12px;
  border-radius: 0;
  box-shadow: none;
  opacity: 1;
}

[dir] .md-search__output,
[data-md-toggle="search"]:checked ~ .md-header .md-search__output {
  box-shadow: none;
}

.md-search__scrollwrap,
[data-md-toggle="search"]:checked ~ .md-header .md-search__scrollwrap {
  width: auto;
  height: 100%;
  max-height: none;
  background: none;
  overscroll-behavior: contain;
  scrollbar-color: var(--vm-border) transparent;
  scrollbar-width: thin;
}

/* Số kết quả hiện ở chân hộp; docs-ui.js chép từ đây sang vì theme ghi đè nội dung */
.md-search-result__meta {
  display: none;
}

.md-search-result__list {
  user-select: text;
}

.md-search-result__item {
  box-shadow: none;
}

.md-search-result__link {
  border-radius: var(--vm-radius);
  transition: none;
}

.md-search-result__link:focus,
.md-search-result__link:hover {
  background-color: transparent;
}

[dir] .md-search-result__article {
  padding: 10px 12px 11px;
}

.md-search-result__icon {
  display: none;
}

.md-search-result .md-typeset h1 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  align-items: baseline;
  margin: 0;
  color: var(--vm-text);
  font-size: 13px;
  font-weight: 400;
  line-height: 18px;
}

.vm-sr__title {
  color: var(--vm-ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 20px;
}

.vm-sr__title mark {
  color: inherit;
  text-decoration: none;
}

.vm-sr__type {
  color: var(--vm-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 14px;
  text-transform: uppercase;
  white-space: nowrap;
}

.vm-sr__path {
  grid-column: 1 / -1;
  overflow: hidden;
  color: var(--vm-muted);
  font-size: 12px;
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vm-sr__text {
  grid-column: 1 / -1;
  display: -webkit-box;
  overflow: hidden;
  margin-top: 2px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.vm-sr__text:empty {
  display: none;
}

.vm-sr__text mark {
  background: none;
  color: var(--vm-ink);
  font-weight: 700;
  text-decoration: none;
}

.md-search-result__link.is-selected {
  background-color: var(--vm-selected);
}

.md-search-result__link.is-selected .vm-sr__title {
  color: var(--vm-primary);
}

.vm-search-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 24px 16px;
  text-align: center;
}

.vm-search-status[hidden] {
  display: none;
}

.vm-search-status p {
  margin: 0;
}

.vm-search-status__title {
  max-width: 100%;
  color: var(--vm-ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 22px;
  overflow-wrap: anywhere;
}

.vm-search-status__hint {
  margin-top: 4px !important;
  color: var(--vm-muted);
  font-size: 13px;
  line-height: 18px;
}

.vm-search-status__all {
  margin-top: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  background-color: var(--vm-selected);
  color: var(--vm-primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  line-height: 18px;
}

.vm-search-status__all[hidden] {
  display: none;
}

.vm-search-foot {
  display: flex;
  flex: none;
  align-items: center;
  gap: 20px;
  min-height: 28px;
  margin-top: 8px;
  padding: 0 8px;
  color: var(--vm-muted);
  font-size: 12px;
  line-height: 16px;
}

.vm-search-foot kbd {
  font-family: inherit;
  font-size: 12px;
}

.vm-search-foot__count {
  margin-left: auto;
}

.vm-search-foot__close {
  display: none;
}

/* Điện thoại: chiếm cả màn hình. Ô nhập ở trên, nút đóng ở đáy cho vừa tầm ngón cái. */
@media screen and (max-width: 44.9375em) {
  [dir] .md-search__inner,
  [dir] [data-md-toggle="search"]:checked ~ .md-header .md-search__inner {
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    transform: none;
  }

  [data-md-color-scheme="slate"] .md-search__inner {
    outline: none;
  }

  .md-search__form,
  .md-search__form:hover,
  [data-md-toggle="search"]:checked ~ .md-header .md-search__form {
    height: 56px;
    border-bottom: 1px solid var(--vm-border);
    border-radius: 0;
    background-color: var(--vm-bg);
  }

  [dir] .md-search__input,
  [dir] .md-search__suggest {
    padding: 0 84px 0 52px;
  }

  [dir] .md-search__icon[for="__search"] {
    top: 6px;
    left: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
  }

  /* Chỉ nhận chạm khi hộp mở: lúc đóng nút này nằm đúng chỗ icon menu của header */
  [dir] [data-md-toggle="search"]:checked ~ .md-header .md-search__icon[for="__search"] {
    pointer-events: auto;
  }

  .md-search__icon[for="__search"] .vm-icon {
    display: none;
  }

  .md-search__icon[for="__search"] svg {
    display: block;
    width: 24px;
    height: 24px;
  }

  [dir] .md-search__options {
    top: 6px;
    right: 4px;
  }

  [dir] .md-search__options > .md-icon {
    width: 40px;
    height: 44px;
  }

  .vm-search-esc,
  .vm-search-foot__hint {
    display: none;
  }

  .vm-search-scope {
    min-height: 40px;
    margin-top: 8px;
    padding: 0 12px;
  }

  .vm-search-scope__chip {
    height: 36px;
    font-size: 13px;
  }

  [dir] .md-search__output {
    margin-top: 8px;
    padding: 0 4px;
  }

  [dir] .md-search-result__article {
    padding: 12px;
  }

  .vm-search-foot {
    gap: 12px;
    min-height: 52px;
    margin: 0;
    padding: 0 8px 0 16px;
    border-top: 1px solid var(--vm-border);
  }

  .vm-search-foot__count {
    margin-left: 0;
  }

  .vm-search-foot__close {
    display: flex;
    align-items: center;
    height: 44px;
    margin-left: auto;
    padding: 0 16px;
    color: var(--vm-primary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
  }
}

@media screen and (max-width: 22.4375em) {
  .vm-search-scope__label {
    display: none;
  }
}
