/* ===== Main header row: logo | burger | search | cart ===================== */
.nk-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 0;
  min-height: 72px;
  font-family: 'Montserrat', 'Open Sans', sans-serif;
}

.nk-header__logo {
  flex: 0 0 auto;
  line-height: 0;
}

.nk-header__logo img {
  width: 230px;
  max-width: 100%;
  height: auto;
}

.nk-header__menu {
  flex: 0 0 auto;
}

.nk-header__search {
  flex: 1 1 auto;
  min-width: 0;
}

.nk-header__cart {
  flex: 0 0 auto;
}

/* burger trigger in the header — plain icon, no box */
.nk-header__menu .nk-menu__trigger {
  background: transparent;
  color: #111;
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: 44px;
  height: 44px;
  justify-content: center;
}

.nk-header__menu .nk-menu__trigger:hover {
  background: #f2f2f3;
}

.nk-header__menu .nk-menu__burger {
  width: 22px;
  height: 2px;
}

.nk-header__menu .nk-menu__burger,
.nk-header__menu .nk-menu__burger::before,
.nk-header__menu .nk-menu__burger::after {
  background: #111;
}

.nk-header__menu .nk-menu__burger::before {
  top: -7px;
  width: 22px;
}

.nk-header__menu .nk-menu__burger::after {
  top: 7px;
  width: 22px;
}

/* wide, always-visible search bar (kill the toggle behaviour) */
.nk-header__search #search {
  display: block;
  width: 100%;
}

.nk-header__search #search .search_button,
.nk-header__search #search .search-title {
  display: none !important;
}

.nk-header__search #search .search_toggle {
  display: block !important;
  position: static !important;
  width: 100% !important;
  top: auto;
  right: auto;
}

.nk-header__search #searchbox {
  display: flex;
  width: 100%;
  position: relative;
}

.nk-header__search #searchbox input.form-control {
  width: 100%;
  height: 48px;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 0 52px 0 18px;
  font-size: 15px;
  box-shadow: none;
  background: #fff;
}

.nk-header__search #searchbox .input-group-btn {
  position: absolute;
  right: 0;
  top: 0;
}

.nk-header__search #searchbox .input-group-btn .btn {
  height: 48px;
  width: 48px;
  min-width: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #111;
  font-size: 0;
  border-radius: 0 10px 10px 0;
}

.nk-header__search #searchbox .input-group-btn .btn i {
  font-size: 18px;
}

/* cart button sizing inside the flex row */
.nk-header__cart #cart.btn-block {
  width: auto;
}

.nk-header__cart #cart .dropdown-toggle {
  width: auto;
  height: 48px;
  border-radius: 10px;
  padding: 0 20px;
  background: #111;
  border: 0;
}

@media (max-width: 991px) {
  .nk-header {
    gap: 12px;
    flex-wrap: wrap;
  }

  .nk-header__logo img {
    /* shrink with viewport so icons always fit, but never below a legible size */
    width: min(180px, 42vw);
  }

  .nk-header__search {
    order: 5;
    flex-basis: 100%;
  }
}

/* ===== Native catalog menu drawer — Figma "Menu Opened" (323:2052) ======== */
.nk-menu {
  position: relative;
  display: inline-block;
  font-family: 'Montserrat', 'Open Sans', sans-serif;
}

/* trigger base (the header restyles this to a plain burger icon) */
.nk-menu__trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #111111;
  color: #fff;
  border: 0;
  cursor: pointer;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
}

.nk-menu__burger {
  width: 18px;
  height: 2px;
  background: #fff;
  position: relative;
  display: inline-block;
}

.nk-menu__burger::before,
.nk-menu__burger::after {
  content: '';
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: #fff;
}

.nk-menu__burger::before { top: -6px; }
.nk-menu__burger::after { top: 6px; }

/* overlay */
.nk-menu__overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 1090;
}

/* left drawer panel — white */
.nk-menu__panel {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1100;
  width: 340px;
  max-width: 90vw;
  height: 100vh;
  height: 100dvh; /* dvh: avoid mobile 100vh overshoot that hid the last menu item («Автори») below the browser UI */
  background: #fff;
  color: #111;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .25);
}

/* header bar — dark */
.nk-menu__head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  background: #111111;
}

.nk-menu__title {
  font-family: 'Poppins', 'Montserrat', sans-serif;
  font-size: 26px;
  line-height: 36.4px;
  font-weight: 700;
  color: #fff;
}

.nk-menu__social {
  display: flex; align-items: center; gap: 8px;
  list-style: none; margin: 0; padding: 0;
}
.nk-menu__social a {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  color: #fff; font-size: 16px; text-decoration: none;
  background: rgba(255,255,255,.15); transition: background .15s;
}
.nk-menu__social a:hover { background: rgba(255,255,255,.35); }

.nk-menu__close {
  background: 0;
  border: 0;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  opacity: .85;
}

.nk-menu__close:hover { opacity: 1; }

.nk-menu__scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

.nk-menu__section { padding: 24px; }
.nk-menu__section:first-child { border-bottom: 1px solid #E5E7EB; }

.nk-menu__section-title {
  font-family: 'Poppins', 'Montserrat', sans-serif;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  letter-spacing: .025em;
  text-transform: uppercase;
  color: #111;
}

/* Тип книг — segmented */
.nk-menu__types {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
}

.nk-menu__type {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  font-family: inherit;
  cursor: pointer;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
  text-decoration: none;
  background: #F3F4F6;
  color: #111 !important;
}

.nk-menu__type:hover { background: #e8e9ee; }

.nk-menu__type.is-active {
  background: #111111;
  color: #fff !important;
  box-shadow: 0 2px 4px -2px rgba(0, 0, 0, .1), 0 4px 6px -1px rgba(0, 0, 0, .1);
}

/* Категорії — list */
.nk-menu__list,
.nk-menu__sublist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nk-menu__list { padding-top: 12px; }
.nk-menu__item + .nk-menu__item { margin-top: 4px; }

.nk-menu__cat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  background: 0;
  border: 0;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  text-decoration: none;
  padding: 12px 16px;
  border-radius: 10px;
  color: #111 !important;
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
}

.nk-menu__cat:hover { background: #F3F4F6; }
.nk-menu__cat-name { flex: 1; }

.nk-menu__chevron {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  margin-left: 8px;
  border-right: 2px solid #9CA3AF;
  border-bottom: 2px solid #9CA3AF;
  transform: rotate(-45deg);
}

/* flyout / drill-down — white */
.nk-menu__flyout {
  background: #fff;
  color: #111;
}

.nk-menu__flyout-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 24px 14px;
  border-bottom: 1px solid #E5E7EB;
}

.nk-menu__flyout-title {
  font-family: 'Poppins', 'Montserrat', sans-serif;
  font-size: 20px;
  line-height: 28px;
  font-weight: 700;
  color: #111;
}

.nk-menu__back {
  display: none;
  align-items: center;
  gap: 8px;
  background: 0;
  border: 0;
  color: #6B7280;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  padding: 0;
}

.nk-menu__back-arrow {
  width: 8px;
  height: 8px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  display: inline-block;
}

.nk-menu__viewall {
  display: block;
  padding: 14px 24px;
  color: #111 !important;
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  border-bottom: 1px solid #E5E7EB;
}

.nk-menu__viewall:hover { background: #F3F4F6; }

.nk-menu__sublist { padding: 8px; }

.nk-menu__sublink {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  color: #111 !important;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  border-radius: 10px;
}

.nk-menu__sublink:hover { background: #F3F4F6; }
.nk-menu__sublink span:first-child { flex: 1; }

.nk-menu__count {
  color: #9CA3AF;
  font-size: 13px;
}

body.nk-menu-open { overflow: hidden; }

/* ---- Desktop (>=1024): hover opens flyout to the RIGHT of the drawer ---- */
@media (min-width: 1024px) {
  .nk-menu__flyout {
    position: fixed;
    top: 0;
    left: 340px;
    width: 320px;
    height: 100vh;
    height: 100dvh;
    z-index: 1099;
    overflow-y: auto;
    background: #fff;
    border-left: 1px solid #E5E7EB;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .25);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-8px);
    transition: opacity .15s, transform .15s, visibility .15s;
  }

  .nk-menu__item:hover > .nk-menu__flyout,
  .nk-menu__item.is-open > .nk-menu__flyout {
    opacity: 1;
    visibility: visible;
    transform: none;
  }
}

/* ---- Tablet/mobile (<1024): tap drills down — flyout slides over the drawer ---- */
@media (max-width: 1023px) {
  .nk-menu__panel { overflow: hidden; }

  .nk-menu__flyout {
    position: absolute;
    inset: 0;
    z-index: 5;
    background: #fff;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform .25s ease;
  }

  .nk-menu__item.is-open > .nk-menu__flyout { transform: translateX(0); }
  .nk-menu__back { display: inline-flex; }
}

/* phones: drawer takes the full screen (feels like a new window) */
@media (max-width: 480px) {
  .nk-menu__panel { width: 100%; max-width: 100%; }
}

/* ===== Header cart dropdown ============================================== */
.nk-header__cart #cart .dropdown-menu.cart-menu {
  width: 720px;
  max-width: calc(100vw - 30px);
  padding: 16px;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .12);
  margin: 0;
  top: calc(100% + 8px);
}

.nk-header__cart #cart .cart-menu > li {
  padding: 0;
}

.nk-header__cart #cart .cart-menu .table {
  margin-bottom: 8px;
}

.nk-header__cart #cart .cart-menu .table td {
  padding: 8px 4px;
  vertical-align: top;
}

.nk-header__cart #cart .cart-menu .img-thumbnail {
  width: 48px;
  min-width: 48px;
  padding: 0;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
}

/* long book titles: cap at two lines */
.nk-header__cart #cart .cart-menu .text-left > a {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.35;
  color: #111;
  font-family: 'Montserrat', 'Open Sans', sans-serif;
  font-weight: 600;
  text-decoration: none;
}

.nk-header__cart #cart .cart-menu .text-right {
  white-space: nowrap;
}

/* remove-item button: quiet gray instead of loud red */
.nk-header__cart #cart .cart-menu .btn-danger.btn-xs {
  background: transparent;
  border: 0;
  color: #9CA3AF;
  padding: 2px 4px;
  box-shadow: none;
}

.nk-header__cart #cart .cart-menu .btn-danger.btn-xs:hover {
  color: #111;
  background: transparent;
}

.nk-header__cart #cart .cart-menu .table-bordered td {
  border: 0;
  padding: 4px;
  font-size: 14px;
}

/* action buttons: outlined "to cart" + solid "checkout", readable on white */
.nk-header__cart #cart .cart-menu .button-container {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.nk-header__cart #cart .cart-menu .button-container > a {
  flex: 1 1 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  border-radius: 10px;
  white-space: normal;
  font-family: 'Montserrat', 'Open Sans', sans-serif;
  font-size: 13px;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: background-color .2s ease, color .2s ease;
}

.nk-header__cart #cart .cart-menu .button-container > a.addtocart {
  background: #fff;
  color: #111;
  border: 1px solid #111;
}

.nk-header__cart #cart .cart-menu .button-container > a.addtocart:hover {
  background: #F3F4F6;
  color: #111;
}

.nk-header__cart #cart .cart-menu .button-container > a.checkout {
  background: #111;
  color: #fff;
  border: 1px solid #111;
}

.nk-header__cart #cart .cart-menu .button-container > a.checkout:hover {
  background: #333;
  color: #fff;
}

.nk-header__cart #cart .cart-menu .button-container > a strong {
  font-weight: 600;
  color: inherit;
  font-size: inherit;
  text-transform: none;
}

/* ===== App-only «read in app» warning ==================================== */
.nk-apponly { margin: 12px 0; font-family: 'Montserrat', 'Open Sans', sans-serif; }
.nk-apponly__toggle {
  display: inline-flex; align-items: center; gap: 8px;
  background: #F3F4F6; border: 1px solid #E5E7EB; border-radius: 10px;
  padding: 10px 14px; cursor: pointer; color: #111; font-size: 14px; font-weight: 600;
}
.nk-apponly__toggle:hover { background: #e9eaee; }
.nk-apponly__toggle .fa { font-size: 18px; }
.nk-apponly__q { color: #9CA3AF; }
.nk-apponly__popup {
  margin-top: 8px; background: #111; color: #fff; border-radius: 10px;
  padding: 14px 16px; font-size: 13px; line-height: 1.5; max-width: 420px;
}
.nk-apponly__popup p { margin: 0 0 10px; }
.nk-apponly__link {
  display: inline-block; background: #fff; color: #111 !important; text-decoration: none;
  padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 13px;
}
/* compact note for cart / checkout rows */
.nk-apponly-note {
  display: inline-flex; align-items: center; gap: 5px;
  color: #9333EA; font-size: 12px; font-weight: 600; margin-top: 4px;
}
.nk-apponly-note .fa { font-size: 14px; }

/* badge over product thumbnail in category/search/special listings */
.nk-apponly-badge {
  position: absolute; left: 10px; bottom: 10px; z-index: 3;
  display: inline-flex; align-items: center; gap: 5px;
  background: #9333EA; color: #fff; font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 6px;
}
.nk-apponly-badge .fa { font-size: 13px; }

/* "already purchased" overlay icon for app-only products */
.product-thumb:hover .image .product_hover_block a.category_app {
  background-image: none;
  font-family: 'FontAwesome';
}
.product-thumb:hover .image .product_hover_block a.category_app::before {
  content: "\f10b";
  color: #fff;
  font-size: 20px;
}

/* account/download: app-only card button */
.download-card.nk-apponly-card .download-button .btn {
  background: #9333EA;
  border-color: #9333EA;
  color: #fff;
}
.download-card.nk-apponly-card .download-button .btn:hover {
  background: #7e22ce;
  border-color: #7e22ce;
}

/* ===== Live-search grouped results ======================================== */
/* the dropdown anchors to #searchbox and by default inherits the input width —
   too narrow at 100% zoom, so widen it on desktop and style like the cart */
.nk-header__search .live-search {
  top: calc(100% + 8px);
  padding: 0;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .12);
  overflow: hidden;
}

@media (min-width: 768px) {
  .nk-header__search .live-search {
    width: 680px;
    max-width: calc(100vw - 40px);
  }
}

.live-search ul .ls-group {
  padding: 10px 16px 4px;
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #9333EA;
  background: #fafafa;
  border-top: 1px solid #eee;
  clear: both;
}

.live-search ul .ls-group:first-child { border-top: 0; }

.live-search ul .ls-facet a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  color: #111;
  text-decoration: none;
  font-family: 'Montserrat', 'Open Sans', sans-serif;
  font-size: 15px;
}

.live-search ul .ls-facet a:hover { background: #f4f4f5; }
.live-search ul .ls-facet-name { flex: 1; }
.live-search ul .ls-facet-count { color: #999; font-size: 12px; }

/* Книги — 2-column grid on tablet/desktop, 1 column on mobile */
.live-search ul::after { content: ''; display: block; clear: both; }

.live-search ul .ls-product { float: left; width: 50%; box-sizing: border-box; }

.live-search ul .ls-product a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin: 0;
  text-decoration: none;
  color: #111;
  float: none;
  width: auto;
}

.live-search ul .ls-product a:hover { background: #f5f5f5; }

.live-search ul .ls-product .product-image {
  width: 70px;
  min-width: 70px;
  flex: 0 0 70px;
  padding: 0;
  float: none;
}

.live-search ul .ls-product .product-image img {
  width: 70px;
  height: 95px;
  object-fit: cover;
  border-radius: 4px;
}

.live-search ul .ls-product .search-description {
  width: auto;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  float: none;
}

.live-search ul .ls-product .product-name {
  font-family: 'Montserrat', 'Open Sans', sans-serif;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  color: #111;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.live-search ul .ls-product .product-price { margin-top: 5px; }

.live-search ul .ls-product .product-price .price {
  font-family: 'Montserrat', 'Open Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: #111;
}

.live-search .result-text,
.live-search .view-all-results {
  font-family: 'Montserrat', 'Open Sans', sans-serif;
  font-size: 14px;
}

/* phones: single column + larger type for readability */
@media (max-width: 767px) {
  .live-search ul .ls-product { width: 100%; }

  .live-search ul .ls-product .product-name {
    font-size: 16px;
  }

  .live-search ul .ls-product .product-price .price {
    font-size: 16px;
  }

  .live-search ul .ls-facet a {
    font-size: 16px;
    padding: 11px 16px;
  }

  .live-search ul .ls-group {
    font-size: 13px;
  }
}

/* ===== Mobile header account icon (hidden on desktop where header_nav shows) = */
.nk-header__account {
  display: none;
  flex: 0 0 auto;
  align-items: center;
  position: relative;
}
.nk-header__account-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; color: #111; font-size: 24px;
  border-radius: 8px; background: none; border: 0; cursor: pointer; padding: 0;
}
.nk-header__account-btn:hover,
.nk-header__account.open .nk-header__account-btn { background: #F3F4F6; }
.nk-header__account-btn .fa { font-size: 24px !important; }
@media (max-width: 991px) {
  .nk-header__account { display: flex; }
  .nk-header { justify-content: space-between; }
}
@media (max-width: 390px) {
  /* keep the logo visible — just let it shrink further so the icons still fit */
  .nk-header__logo img { width: min(150px, 36vw); }
  /* burger stays next to the logo (DOM order), account+cart pushed right */
  .nk-header__menu { margin-right: auto; }
}

/* ===== App-only popup: Android notice + iOS notify form =================== */
.nk-apponly__android {
  display: flex; align-items: center; gap: 6px;
  margin: 2px 0 12px; font-size: 13px; color: #86EFAC;
}
.nk-apponly__android .fa { font-size: 16px; }
.nk-apponly__ios {
  margin-top: 14px; border-top: 1px solid rgba(255,255,255,.15); padding-top: 12px;
}
.nk-apponly__ios-row {
  display: flex; gap: 8px; margin-bottom: 6px;
}
.nk-apponly__ios-email {
  flex: 1; padding: 7px 10px; border-radius: 6px; border: 0;
  font-size: 13px; background: rgba(255,255,255,.15); color: #fff;
}
.nk-apponly__ios-email::placeholder { color: rgba(255,255,255,.5); }
.nk-apponly__ios-btn {
  padding: 7px 12px; border-radius: 6px; border: 0;
  background: #9333EA; color: #fff; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.nk-apponly__ios-btn:hover { background: #7e22ce; }
.nk-apponly__ios-label { margin: 0 0 8px; font-size: 12px; color: rgba(255,255,255,.7); }
.nk-apponly__ios-consent {
  display: flex; align-items: flex-start; gap: 8px;
  margin-top: 8px; font-size: 11px; color: rgba(255,255,255,.65); cursor: pointer;
}
.nk-apponly__ios-consent input[type=checkbox] { margin-top: 2px; flex-shrink: 0; }
.nk-apponly__ios-consent a { color: rgba(255,255,255,.85); }
.nk-apponly__ios-done { margin: 6px 0 0; font-size: 12px; color: #86EFAC; }
