/**
 * vt-cd-theme.css — єдиний шар стилів шторки каталогу.
 * Замінює vt-cd-mobile-fix.css (той видалити).
 *
 * Порядок блоків: 1) каркас  2) шапка  3) сітка  4) кольори плиток
 * 5) пошук  6) темна тема.  Усередині блоку — від загального до
 * мобільного, щоб не було випадкових перекриттів.
 */

/* ── 1. Каркас ─────────────────────────────────────────── */
@media (max-width: 767px) {
  #vt-catalog-drawer.open {
    top: 0 !important;
    bottom: 0 !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    background: #f6f7f9 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px);
  }
  body.admin-bar #vt-catalog-drawer.open {
    padding-top: calc(env(safe-area-inset-top, 0px) + 46px) !important;
  }
  body:has(#vt-catalog-drawer.open) .vt-mnav,
  body:has(#vt-catalog-drawer.open) #vt-mnav {
    display: none !important;
  }

  #vt-catalog-drawer .vt-cd-handle,
  #vt-catalog-drawer .vt-cd-header {
    flex: 0 0 auto !important;
  }

  #vt-catalog-drawer .vt-cd-body {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    background: transparent !important;
    padding: 0 !important;
    align-items: stretch !important;
  }
}

/* ── 2. Шапка ──────────────────────────────────────────── */
@media (max-width: 767px) {
  #vt-catalog-drawer .vt-cd-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 5 !important;
    background: #fff !important;
    padding: 10px 14px 10px !important;
    border-bottom: 1px solid #eceef1 !important;
  }
  #vt-catalog-drawer .vt-cd-header-top h3 {
    font-size: 17px !important;
    line-height: 1.25 !important;
    margin: 0 !important;
  }
  /* кошик/вибране та швидкі посилання займають пів-екрана на мобільному */
  #vt-catalog-drawer .vt-cd-header-meta,
  #vt-catalog-drawer .vt-cd-quicklinks {
    display: none !important;
  }

  #vt-catalog-drawer .vt-cd-search {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    gap: 0 !important;
    background: #f1f3f5 !important;
    border: 1.5px solid transparent !important;
    border-radius: 999px !important;
    padding: 0 6px 0 14px !important;
    margin: 8px 0 2px !important;
    min-height: 46px !important;
    transition: border-color .18s, background .18s, box-shadow .18s;
  }
  #vt-catalog-drawer .vt-cd-search:focus-within {
    background: #fff !important;
    border-color: var(--vt-c, #f26f21) !important;
    box-shadow: 0 0 0 4px rgba(242, 111, 33, .12) !important;
  }
  #vt-catalog-drawer .vt-cd-search-icon {
    flex: 0 0 auto !important;
    padding: 0 10px 0 0 !important;
    font-size: 15px !important;
    opacity: .45 !important;
  }
  #vt-catalog-drawer #vt-cd-search-input {
    flex: 1 1 auto !important;
    width: 100% !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    border-radius: 0 !important;
    font-size: 16px !important;   /* <16px = автозум на iOS */
    line-height: 1.2 !important;
    padding: 12px 0 !important;
    margin: 0 !important;
    min-height: 0 !important;
    height: auto !important;
    color: #111827 !important;
  }
  #vt-catalog-drawer #vt-cd-search-input::placeholder {
    color: #9aa1a9 !important;
    font-weight: 400 !important;
  }
  #vt-catalog-drawer #vt-cd-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #cfd4da;
    cursor: pointer;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M6 6l12 12M18 6L6 18' stroke='black' stroke-width='3' stroke-linecap='round'/></svg>") center/12px no-repeat;
  }
}

/* ── 3. Сітка категорій ────────────────────────────────── */
@media (max-width: 767px) {
  #vt-catalog-drawer .vt-cd-sidebar {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    grid-auto-rows: max-content !important;
    align-content: start !important;
    gap: 8px !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    background: transparent !important;
    border-right: none !important;
    padding: 10px 10px calc(28px + env(safe-area-inset-bottom, 0px)) !important;
  }

  #vt-catalog-drawer .vt-cd-sidebar-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 6px !important;
    min-height: 0 !important;
    padding: 12px 6px 10px !important;
    background: #fff !important;
    border: none !important;
    border-left: none !important;
    border-radius: 14px !important;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .06) !important;
    overflow: visible !important;
    transition: transform .12s ease, box-shadow .12s ease;
  }
  #vt-catalog-drawer .vt-cd-sidebar-item:active {
    transform: scale(.97) !important;
  }
  #vt-catalog-drawer .vt-cd-sidebar-item.active {
    background: #fff !important;
    box-shadow: 0 0 0 1.5px var(--vt-c, #f26f21) !important;
  }

  #vt-catalog-drawer .vt-cd-sidebar-icon {
    width: 46px !important;
    height: 46px !important;
    min-height: 46px !important;
    margin: 0 auto !important;
    border-radius: 13px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  #vt-catalog-drawer .vt-cd-sidebar-icon-emoji {
    font-size: 24px !important;
    line-height: 1 !important;
  }
  #vt-catalog-drawer .vt-cd-sidebar-name {
    font-size: 11.5px !important;
    line-height: 1.25 !important;
    font-weight: 600 !important;
    -webkit-line-clamp: 2 !important;
  }
  #vt-catalog-drawer .vt-cd-sidebar-count {
    font-size: 10px !important;
    padding: 1px 6px !important;
  }
}

/* ── 4. Кольорові плитки ───────────────────────────────── */
/* Колір ставить JS через --vt-tile на .vt-cd-sidebar-icon.
   Фолбек — нейтральний сірий, якщо JS не відпрацював. */
#vt-catalog-drawer .vt-cd-sidebar-icon {
  background: var(--vt-tile, #eef0f3) !important;
}

/* ── 5. Результати пошуку ──────────────────────────────── */
#vt-catalog-drawer.vt-cd-searching .vt-cd-sidebar,
#vt-catalog-drawer.vt-cd-searching .vt-cd-panel,
#vt-catalog-drawer.vt-cd-searching .vt-cd-mobile-bar {
  display: none !important;
}
#vt-catalog-drawer.vt-cd-searching .vt-cd-content {
  display: block !important;
  width: 100% !important;
  max-height: none !important;
  padding: 8px 10px calc(28px + env(safe-area-inset-bottom, 0px)) !important;
  background: transparent !important;
}

#vt-cd-search-panel .vt-cd-sr-count {
  font-size: 12px;
  font-weight: 600;
  color: #8b929a;
  padding: 6px 6px 10px;
}
#vt-cd-search-panel .vt-cd-sr-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  margin-bottom: 6px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
  text-decoration: none;
  color: inherit;
  min-height: 52px;
}
#vt-cd-search-panel .vt-cd-sr-item:active {
  background: #fafbfc;
}
#vt-cd-search-panel .vt-cd-sr-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: #f1f3f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  line-height: 1;
}
#vt-cd-search-panel .vt-cd-sr-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#vt-cd-search-panel .vt-cd-sr-name {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
  line-height: 1.3;
}
#vt-cd-search-panel .vt-cd-sr-path {
  font-size: 11.5px;
  color: #9aa1a9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#vt-cd-search-panel .vt-cd-hl {
  background: rgba(242, 111, 33, .18);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}
#vt-cd-search-panel .vt-cd-sr-count-badge {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--vt-c, #f26f21);
  border-radius: 20px;
  padding: 2px 8px;
}
#vt-cd-search-panel .vt-cd-sr-empty {
  text-align: center;
  padding: 44px 20px;
}
#vt-cd-search-panel .vt-cd-sr-empty-icon {
  font-size: 34px;
  opacity: .35;
  margin-bottom: 10px;
}
#vt-cd-search-panel .vt-cd-sr-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: #4b5563;
}
#vt-cd-search-panel .vt-cd-sr-empty-sub {
  font-size: 13px;
  color: #9aa1a9;
  margin-top: 4px;
}

/* ── 6. Темна тема ─────────────────────────────────────── */
html.dark #vt-catalog-drawer.open { background: #0b1220 !important; }
html.dark #vt-catalog-drawer .vt-cd-header { background: #0f172a !important; border-color: #1e293b !important; }
html.dark #vt-catalog-drawer .vt-cd-search { background: #1e293b !important; }
html.dark #vt-catalog-drawer #vt-cd-search-input { color: #e2e8f0 !important; }
html.dark #vt-catalog-drawer .vt-cd-sidebar-item { background: #0f172a !important; box-shadow: 0 1px 2px rgba(0,0,0,.4) !important; }
html.dark #vt-catalog-drawer .vt-cd-sidebar-name { color: #cbd5e1 !important; }
html.dark #vt-cd-search-panel .vt-cd-sr-item { background: #0f172a !important; }
html.dark #vt-cd-search-panel .vt-cd-sr-name { color: #e2e8f0; }
html.dark #vt-cd-search-panel .vt-cd-sr-icon { background: #1e293b; }
@media (max-width:767px){
  #vt-catalog-drawer .vt-cd-sidebar-item{
    justify-content:flex-start!important;
  }
  #vt-catalog-drawer .vt-cd-sidebar-name{
    min-height:2.5em!important;      /* завжди місце під 2 рядки */
    display:-webkit-box!important;
    -webkit-line-clamp:2!important;
    -webkit-box-orient:vertical!important;
    overflow:hidden!important;
    font-size:11px!important;
    letter-spacing:-.1px!important;
  }
  #vt-catalog-drawer .vt-cd-sidebar-count{
    margin-top:auto!important;       /* бейдж притиснуто до низу */
  }
}
