/* ==========================================================================
   HEADER – topbar, logo, vyhledávání, akce, hlavní navigace, mega menu
   ========================================================================== */

/* ---------- Top bar ---------- */
.topbar {
  background: var(--c-bg-soft);
  border-bottom: 1px solid var(--c-border);
  font-size: var(--fs-xs);
  font-weight: 500;
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 40px;
}

.topbar__group {
  display: flex;
  align-items: center;
  gap: 28px;
}

.topbar__item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.topbar__item .bi { font-size: 15px; color: var(--c-primary); }
a.topbar__item:hover { color: var(--c-primary); }

/* ---------- Header ---------- */
.header {
  position: relative; /* hlavička je pevně nahoře na stránce, při scrollu odjede */
  z-index: 50;
  background: #fff;
  padding-bottom: 14px;
}

.header__inner {
  display: flex;
  align-items: center;
  gap: 32px;
  min-height: 88px;
}

/* Logo + štítek Milwaukee */
.header__brand {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}

.header__logo img { width: 190px; height: auto; }

.header__badge {
  height: 40px;
  width: auto;
  padding-left: 20px;
  border-left: 1px solid var(--c-border);
  box-sizing: content-box;
}

/* ---------- Vyhledávání ---------- */
.search {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  max-width: 620px;
  height: 52px;
  margin-inline: auto;
  padding: 5px;
  background: #fff;
  border: 1.5px solid #cfd6e0;
  border-radius: var(--radius-lg);
  transition: border-color var(--t), box-shadow var(--t);
}

.search:focus-within {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 4px rgba(8, 82, 215, .1);
}

.search__icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 17px;
  color: var(--c-muted);
  pointer-events: none;
}

.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 14px 0 42px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: var(--fs-base);
}

.search input::placeholder { color: #8a93a1; }

.search__btn {
  height: 100%;
  padding-inline: 26px;
  border-radius: 7px;
  background: var(--c-primary);
  color: #fff;
  font-size: var(--fs-sm);
  font-weight: 700;
  transition: background var(--t);
}

.search__btn:hover { background: var(--c-primary-dark); }

/* ---------- Akce (účet, oblíbené, košík) ---------- */
.header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-right: -10px;       /* text košíku lícuje s pravým okrajem menu */
}

.header__action {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;              /* stejná výška jako vyhledávání */
  padding: 0 10px;
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  line-height: 1.2;
  transition: background-color .15s, color .15s;
}

/* Ikony ve stejně velkém boxu → všechny tři položky sedí na jedné ose */
.header__icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.header__icon .bi { font-size: 22px; line-height: 1; }
.header__label { display: flex; flex-direction: column; gap: 1px; white-space: nowrap; }
.header__action strong { font-weight: 600; }
.header__action small { color: var(--c-muted); font-size: var(--fs-xs); }
.header__action:hover { background: var(--c-bg-soft); color: var(--c-primary); }

.badge {
  position: absolute;
  top: -5px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--c-primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.badge--fav { background: var(--c-red); }
.badge.is-bump { animation: bump .35s ease; }

@keyframes bump {
  50% { transform: scale(1.35); }
}

.header__burger { display: none; font-size: 28px; }

/* ---------- Hlavní navigace ---------- */
.nav { position: relative; }

.nav__list {
  display: flex;
  align-items: stretch;
  background: var(--c-dark);
  border-radius: var(--radius-lg);
}

.nav__item { flex: 1; }
.nav__item--mega { flex: 0 0 280px; }

.nav__link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  height: 48px;
  padding-inline: 16px;
  color: #fff;
  font-family: var(--f-head);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
  transition: background var(--t), color var(--t);
}

.nav__link .bi { font-size: 15px; opacity: .85; }
.nav__item:last-child .nav__link { border-radius: 0 var(--radius-lg) var(--radius-lg) 0; }
.nav__link:hover { background: var(--c-dark-2); }

.nav__link--all {
  justify-content: flex-start;
  padding-inline: 20px;
  background: var(--c-primary);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.nav__link--all .bi { opacity: 1; }
.nav__caret { margin-left: auto; font-size: 13px !important; transition: transform var(--t); }
.nav__link--all:hover,
.nav__item--mega.is-open .nav__link--all { background: var(--c-primary-dark); }
.nav__item--mega.is-open .nav__caret { transform: rotate(180deg); }

/* ---------- Mega menu ----------
   Styl "katalog": bílý panel, 4 sloupce bez rámečků. Každá položka =
   obrázek produktu vlevo, tučný název a podkategorie oddělené čárkou
   (max. 3 řádky). Položky bez podkategorií mají název svisle na střed. */
.mega {
  position: absolute;
  top: calc(100% + 8px);
  left: var(--gutter);
  right: var(--gutter);
  z-index: 60;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 48px rgba(20, 30, 50, .18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s;
}

/* neviditelný "most" přes mezeru mezi lištou a panelem, aby hover nepřerušil */
.mega::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -10px;
  height: 10px;
}

.nav__item--mega.is-open .mega {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .18s ease, transform .18s ease, visibility 0s;
}

.mega__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px 16px;
}

.mega__item {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 112px;
  padding: 14px;
  border-radius: var(--radius-lg);
  transition: background var(--t);
}

.mega__item:hover { background: var(--c-bg-soft); }

.mega__img {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
}

.mega__img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform .25s ease;
}

.mega__item:hover .mega__img img { transform: scale(1.08); }

.mega__text { min-width: 0; }

.mega__name {
  display: block;
  font-family: var(--f-head);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.3;
  transition: color var(--t);
}

.mega__name:hover { color: var(--c-primary); }

.mega__subs {
  display: -webkit-box;
  margin-top: 6px;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--c-muted);
}

/* podkategorie i s čárkou se nedělí – celá přejde na další řádek */
.mega__sub { display: inline-block; max-width: 100%; }

.mega__subs a { color: #4a5361; transition: color var(--t); }
.mega__subs a:hover { color: var(--c-primary); text-decoration: underline; }

/* Akční nabídky – decentně odlišená položka: jemný teplý podklad a červený název */
.mega__item--sale { background: #fdf6f6; }
.mega__item--sale:hover { background: #fbeeee; }
.mega__item--sale .mega__name { color: var(--c-red); }
.mega__item--sale .mega__name:hover { color: #b0151e; }
.mega__item--sale .mega__subs { color: var(--c-muted); }

/* GECOCHEM – externí partnerský web, poslední záložka */
.mega__item--partner { padding: 0; grid-column: span 2; }
.mega__item--partner:hover { background: none; }

.mega__partner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  height: 100%;
  padding: 14px 28px;
  border-radius: var(--radius-lg);
  background: #f5f9f1;
  transition: background var(--t);
}

.mega__partner:hover { background: #edf5e6; }
.mega__partner img { width: 160px; height: auto; }

.mega__partner-text {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 12.5px;
  text-align: right;
}

.mega__partner-text strong { color: var(--c-muted); font-weight: 600; }
.mega__partner-text span { color: #4d8a1e; font-weight: 700; white-space: nowrap; }
.mega__partner-text .bi { font-size: 11px; margin-left: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 1400px) {
  .header__inner { gap: 24px; }
  .header__logo img { width: 170px; }
  .header__badge { height: 34px; padding-left: 16px; }
  .header__brand { gap: 16px; }
  .header__actions { gap: 4px; }
  .nav__item--mega { flex-basis: 250px; }
  .nav__link { padding-inline: 12px; font-size: 13.5px; }
  .mega__grid { grid-template-columns: repeat(3, 1fr); }
  .mega__img { width: 60px; height: 60px; }
}

@media (max-width: 1100px) {
  .topbar__group:first-child .topbar__item:nth-child(3) { display: none; }
  .header__label { display: none; }
  .header__badge { display: none; }
  .nav__item--mega { flex-basis: 220px; }
  .nav__link { white-space: normal; text-align: center; line-height: 1.1; padding-inline: 8px; }
  .nav__link .bi:not(.nav__caret) { display: none; }
  .nav__link--all .bi { display: inline-block !important; }
  .mega__grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .topbar__group:first-child { display: none; }
  .topbar__inner { justify-content: center; }
  .topbar__item .muted { display: none; }

  .header__inner { flex-wrap: wrap; gap: 14px; min-height: 0; padding-block: 12px; }
  .header__logo img { width: 160px; }
  .header__actions { margin-left: auto; }
  .search { order: 3; flex-basis: 100%; max-width: none; height: 48px; }
  .header__burger { display: block; }

  /* navigace v rozbalovacím menu */
  .nav { display: none; }
  .nav.is-open { display: block; }
  .nav__list { flex-direction: column; }
  .nav__item--mega { flex-basis: auto; }
  .nav__link { justify-content: flex-start; height: 48px; padding-inline: 18px; text-align: left; }
  .nav__link .bi { display: inline-block !important; }
  .nav__link--all,
  .nav__item:last-child .nav__link { border-radius: 0; }
  .nav__item:first-child .nav__link { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }

  /* mega menu = jednoduchý seznam kategorií bez podkategorií */
  .mega {
    position: static;
    display: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
  }
  .nav__item--mega.is-open .mega { display: block; }
  .mega { padding: 6px 8px; }
  .mega__grid { grid-template-columns: 1fr; gap: 0; }
  .mega__item { min-height: 0; padding: 8px; gap: 14px; }
  .mega__img { width: 40px; height: 40px; }
  .mega__name { font-size: var(--fs-sm); }
  .mega__subs { display: none; }
  .mega__item--partner { grid-column: auto; }
  .mega__partner { padding: 12px 14px; gap: 12px; }
  .mega__partner img { width: 120px; }
}

@media (max-width: 480px) {
  .topbar__group:last-child .topbar__item:last-child { display: none; }
  .header__actions { gap: 4px; }
  .header__action { padding: 0 6px; height: 44px; }
  .search__btn { padding-inline: 16px; }
}

