/* Pokrocile vyhledavani - dropdown suggest pro majkl3d.cz */
/* Verze: F2 init, design dle eshop-search-dropdown-mockup-v2.html */

.m3d-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.12);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.m3d-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.m3d-suggest {
  position: fixed;
  z-index: 1002;
  background: #fff;
  border: 1px solid #E5E5E5;
  border-radius: 0.75rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12), 0 4px 8px rgba(0, 0, 0, 0.05);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: #000100;
  display: none;
  overflow: hidden;
}
.m3d-suggest.is-open { display: block; }
.m3d-suggest::before {
  content: '';
  position: absolute;
  top: -7px;
  left: var(--m3d-arrow-left, 50%);
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: #fff;
  border-left: 1px solid #E5E5E5;
  border-top: 1px solid #E5E5E5;
}

.m3d-suggest-body {
  max-height: 75vh;
  overflow-y: auto;
}

.m3d-section { padding: 14px 18px; }
.m3d-section + .m3d-section { border-top: 1px solid #F0F0F0; }

.m3d-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.m3d-col-title {
  font-size: 0.875rem;
  font-weight: 800;
  color: #0F1B09;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.m3d-col-count {
  font-size: 0.6875rem;
  color: #525252;
  font-weight: 700;
  background: #F5F5F5;
  padding: 2px 8px;
  border-radius: 999px;
}

/* Product grid */
.m3d-prod-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.m3d-prod-card {
  background: #fff;
  border: 1px solid #E5E5E5;
  border-radius: 0.45rem;
  padding: 8px;
  text-decoration: none !important;
  color: inherit !important;
  display: flex;
  flex-direction: column;
  transition: border-color 0.12s;
}
.m3d-prod-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.m3d-prod-card:hover,
.m3d-prod-card.is-active {
  border-color: #2acc1f;
  background: #f8fcf7;
}
.m3d-prod-img {
  aspect-ratio: 1;
  background: #f5f5f5;
  border-radius: 0.3rem;
  margin-bottom: 6px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.m3d-prod-title {
  font-size: 0.75rem;
  line-height: 1.3;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
  color: #000100;
}
.m3d-prod-mfr {
  font-size: 0.625rem;
  color: #999;
  font-weight: 500;
  margin-top: auto;
  padding-top: 4px;
}

/* Secondary strip: kategorie + slovnik */
.m3d-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.m3d-strip h4 {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #525252;
  margin: 0 0 8px;
}
.m3d-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.m3d-chip {
  background: #eaf7e9;
  color: #0F1B09 !important;
  border: 1px solid #d2edd0;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none !important;
  transition: background 0.12s;
}
.m3d-chip:hover,
.m3d-chip.is-active {
  background: #d2edd0;
  border-color: #2acc1f;
}
.m3d-dict-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
}
.m3d-dict-item {
  display: block;
  padding: 7px 10px;
  background: #fafafa;
  border-radius: 0.3rem;
  text-decoration: none !important;
  color: #0F1B09 !important;
  font-size: 0.8125rem;
  font-weight: 600;
}
.m3d-dict-item:hover,
.m3d-dict-item.is-active {
  background: #eaf7e9;
}

.m3d-empty {
  text-align: center;
  padding: 24px 12px;
  color: #525252;
  font-size: 0.875rem;
}
.m3d-empty strong { color: #0F1B09; }

.m3d-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 18px;
  background: #fafafa;
  border-top: 1px solid #F0F0F0;
  font-size: 0.6875rem;
  color: #525252;
}
.m3d-footer a {
  color: #0F1B09 !important;
  font-weight: 700;
  text-decoration: none !important;
}
.m3d-footer kbd {
  background: #fff;
  border: 1px solid #E5E5E5;
  border-radius: 3px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 0.6875rem;
  margin: 0 2px;
}

.m3d-suggest mark {
  background: #eaf7e9;
  color: #0F1B09;
  padding: 0 2px;
  border-radius: 2px;
}

/* ===== Initial state (focus, prazdny dotaz) ===== */
.m3d-initial-body {
  display: flex;
  flex-direction: column;
}
.m3d-initial-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.m3d-initial-bottom {
  border-top: 1px solid #F0F0F0;
  background: #fafafa;
  padding: 12px 16px;
}
.m3d-initial-col {
  padding: 14px 16px;
}
.m3d-initial-col + .m3d-initial-col {
  border-left: 1px solid #F0F0F0;
}
.m3d-initial-section { margin-bottom: 16px; }
.m3d-initial-section:last-child { margin-bottom: 0; }
.m3d-mini-header {
  font-size: 0.75rem;
  font-weight: 800;
  color: #525252;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Trending chips - cislovane */
.m3d-trend-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.m3d-trend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eaf7e9;
  color: #0F1B09 !important;
  border: 1px solid #d2edd0;
  padding: 5px 10px 5px 5px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none !important;
}
.m3d-trend-chip:hover, .m3d-trend-chip.is-active {
  background: #d2edd0;
  border-color: #2acc1f;
}
.m3d-trend-chip .n {
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  font-size: 0.625rem;
  font-weight: 800;
  color: #2acc1f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Categories list - se sipkou */
.m3d-cat-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.m3d-cat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #fff;
  border-radius: 6px;
  text-decoration: none !important;
  color: #0F1B09 !important;
  font-size: 0.875rem;
  font-weight: 600;
}
.m3d-cat-item:hover, .m3d-cat-item.is-active {
  background: #eaf7e9;
}

/* Recent searches */
.m3d-recent-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.m3d-recent-item {
  padding: 6px 10px;
  background: #fff;
  border-radius: 6px;
  text-decoration: none !important;
  color: #0F1B09 !important;
  font-size: 0.8125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m3d-recent-item:hover, .m3d-recent-item.is-active {
  background: #eaf7e9;
}

/* Featured product grid - 5 mensich dlazdice ve spodni casti initial state */
.m3d-prod-grid--featured {
  display: grid !important;
  grid-template-columns: repeat(5, 1fr) !important;
  gap: 6px;
}
.m3d-prod-grid--featured .m3d-prod-card {
  flex-direction: column !important;
  align-items: stretch;
  background: #fff;
  border: 1px solid #E5E5E5 !important;
  padding: 6px;
}
.m3d-prod-grid--featured .m3d-prod-card:hover,
.m3d-prod-grid--featured .m3d-prod-card.is-active {
  border-color: #2acc1f !important;
  background: #f8fcf7;
}
.m3d-prod-grid--featured .m3d-prod-img {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  margin-bottom: 4px;
  border-radius: 3px;
}
.m3d-prod-grid--featured .m3d-prod-info {
  flex: 1;
}
.m3d-prod-grid--featured .m3d-prod-title {
  font-size: 0.6875rem;
  line-height: 1.25;
  -webkit-line-clamp: 2;
  white-space: normal;
  display: -webkit-box;
  margin: 0 0 2px;
}
.m3d-prod-grid--featured .m3d-prod-mfr {
  font-size: 0.5625rem;
  margin-top: auto;
}

/* === Mobile - tablet 900px === */
@media (max-width: 900px) {
  .m3d-suggest { left: 8px !important; right: 8px !important; width: auto !important; }
  .m3d-prod-grid { grid-template-columns: repeat(3, 1fr); }
  .m3d-strip { grid-template-columns: 1fr; }
  /* Initial state: stack 1 sloupec */
  .m3d-initial-top { grid-template-columns: 1fr; }
  .m3d-initial-col + .m3d-initial-col { border-left: 0; border-top: 1px solid #F0F0F0; }
  .m3d-initial-col { padding: 12px 14px; }
  /* Featured grid: na telefonu 3 sloupce */
  .m3d-prod-grid--featured { grid-template-columns: repeat(3, 1fr) !important; gap: 6px; }
  .m3d-prod-grid--featured .m3d-prod-card { padding: 6px; }
  .m3d-prod-grid--featured .m3d-prod-title { font-size: 0.6875rem; }
}

/* === Mobile - telefon 600px === */
@media (max-width: 600px) {
  .m3d-suggest {
    left: 4px !important; right: 4px !important;
    /* top + max-height nastavuje JS dle visualViewport (kvuli klavesnici) */
    border-radius: 0.5rem;
  }
  /* Backdrop na mobilu skryt - dimovani branilo otevreni klavesnice
     (lift parent.zIndex zpusoboval ztratu focus na inputu). Mobil bez backdropu. */
  .m3d-backdrop { display: none !important; }
  /* Sipka nahoru ke vstupu nedava na malem displeji smysl */
  .m3d-suggest::before { display: none; }
  /* Body je scrollovatelne, max-height = dropdown vyska minus header sekce */
  .m3d-suggest-body { max-height: inherit; }

  .m3d-section { padding: 6px 8px; }
  /* Telefon: produkty jako uzke radky misto dlazdic */
  .m3d-prod-grid {
    display: flex;
    flex-direction: column;
    gap: 1px;
  }
  .m3d-prod-card {
    flex-direction: row !important;
    align-items: center;
    padding: 6px 8px;
    gap: 10px;
    border-color: transparent !important;
    border-radius: 6px;
    background: transparent;
  }
  .m3d-prod-card + .m3d-prod-card { border-top: 1px solid #f5f5f5; border-radius: 0; }
  .m3d-prod-card:hover,
  .m3d-prod-card.is-active {
    background: #f5f5f5;
  }
  .m3d-prod-img {
    width: 40px; height: 40px;
    aspect-ratio: unset;
    flex: none;
    margin: 0;
    border-radius: 4px;
    background-color: #f5f5f5;
  }
  .m3d-prod-info {
    align-items: flex-start;
    justify-content: center;
    gap: 1px;
    text-align: left;
  }
  .m3d-prod-title {
    font-size: 0.8125rem;
    display: block !important;
    -webkit-line-clamp: 1;
    margin: 0;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: left;
  }
  .m3d-prod-mfr {
    font-size: 0.6875rem;
    margin-top: 0;
    padding-top: 0;
    text-align: left;
  }

  /* Kompaktnejsi header sekce */
  .m3d-col-header { margin-bottom: 4px; padding: 0 4px; }
  .m3d-col-title { font-size: 0.8125rem; }

  /* Vetsi tap target pro chip kategorie/slovniku */
  .m3d-chip { padding: 8px 12px; font-size: 0.8125rem; }
  .m3d-dict-item { padding: 10px 12px; font-size: 0.875rem; }

  /* Footer - skryj klavesove zkratky, jen "Vsechny vysledky" */
  .m3d-footer { padding: 10px 14px; font-size: 0.75rem; }
  .m3d-footer span:first-child { display: none; }
  .m3d-footer a { font-size: 0.8125rem; }

  /* Vetsi nadpis sekce */
  .m3d-col-title { font-size: 0.9rem; }
}
