/* =====================================
   Bloc global
===================================== */
.lc-search-block {
  position: relative;
  flex: 1 1 auto;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
}

/* =====================================
   Formulaire
===================================== */
.lc-search-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* =====================================
   Wrapper input + bouton
===================================== */
.lc-search-input-wrapper {
  display: flex;
  width: 100%;
  align-items: stretch;
  border-radius: 2px;
  background: #fff;
  height: 100%;
  box-sizing: border-box;
  position: relative;
}

/* =====================================
   Champ texte
===================================== */
.lc-search-field {
  flex: 1 1 auto;
  border: solid 1px #27415933;
  border-right: none;
  min-width: 0;
  padding: 8px;
  font-size: 15px;
  outline: none;
  font-style: italic;
}

.lc-search-field::placeholder {
  color: #777;
  font-size: var(--wp--preset--font-size--14);
  font-style: italic;
}

/* Supprime la croix native du navigateur */
.lc-search-field::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}
.lc-search-field[type="search"]::-moz-search-clear {
  display: none;
}

/* =====================================
   Croix personnalisée (clear)
===================================== */
.lc-search-clear {
  position: absolute;
  right: 46px; /* juste avant le bouton loupe */
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  margin-right: 8px;
  padding: 0;
  display: none; /* cachée par défaut */
  line-height: 0;
}

.lc-search-clear img {
  width: 19px;
  height: 19px;
  color: var(--wp--preset--color--dark-blue, #023047);
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.lc-search-clear:hover img {
  opacity: 1;
}

/* Affiche la croix uniquement si du texte est présent */
.lc-search-input-wrapper.has-text .lc-search-clear {
  display: flex;
}

/* =====================================
   Spinner
===================================== */
.lc-search-spinner {
  position: absolute;
  right: 100px;
  top: 50%;
  transform: translateY(-50%);
  width: 19px;
  height: 19px;
  pointer-events: none;
}

.spinner-circle {
  width: 100%;
  height: 100%;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-top-color: #000;
  border-radius: 50%;
  animation: lc-spin 0.6s linear infinite;
}

@keyframes lc-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* =====================================
   Bouton (loupe)
===================================== */
.lc-search-submit {
  background: #f5f5f5;
  border: solid 1px #27415933;
  border-left: none;
  border-radius: 2px 2px 0px 0px;
  padding: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
  box-sizing: border-box;
  width: 46px;
  height: 46px;
}

.lc-search-submit:hover {
  background: #e9e9e9;
}

/* =====================================
   Suggestions
===================================== */
.lc-search-suggestions {
  background: #fff;
  border-top: none;
  border-radius: 0 0 6px 6px;
  list-style: none;
  margin: 0;
  padding: 0;
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  font-size: 0.95rem;
  line-height: 1.4;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

/* =====================================
   Groupes (Produits, Pages, Articles)
===================================== */
.lc-suggestion-group {
  font-weight: 600;
  font-size: 0.85rem;
  color: #666;
  padding: 6px 12px;
  background: #f9f9f9;
  border-bottom: 1px solid #eee;
  cursor: default;
}

/* =====================================
   Sous-listes
===================================== */
.lc-suggestion-sublist {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* =====================================
   Items
===================================== */
.lc-suggestion-item a {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 16px;
  text-decoration: none;
  color: var(--wp--preset--color--dark-blue);
  font-weight: 400;
}

.lc-suggestion-item.active a,
.lc-suggestion-item a:hover {
  background: #f2f2f2;
}

.lc-suggestion-text {
  display: flex;
  flex-direction: column;
}

.lc-suggestion-sku {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 2px;
}

/* =====================================
   Highlight
===================================== */
.lc-search-suggestions mark {
  background: transparent;
  font-weight: 600;
  color: #000;
}

/* =====================================
   Badges type (Produit, Page, Article)
===================================== */
.lc-badge {
  display: inline-block;
  font-size: 0.8em;
  font-weight: 500;
  color: #334155;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 2px 8px;
  margin-left: 8px;
  vertical-align: middle;
}

.lc-badge--produits {
  background: #e0f2fe;
  border-color: #bae6fd;
  color: #075985;
}

.lc-badge--pages {
  background: #ede9fe;
  border-color: #ddd6fe;
  color: #5b21b6;
}

.lc-badge--articles {
  background: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
}

.lc-badge--médias,
.lc-badge--media {
  background: #fce7f3;
  border-color: #fbcfe8;
  color: #9d174d;
}

/* =====================================
   Alignement titre + badge
===================================== */
.lc-suggestion-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.lc-suggestion-info {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-direction: column;
  flex: 1 1 auto;
}

.lc-suggestion-type {
  flex-shrink: 0;
}

.lc-badge::before {
  display: none;
  content: none;
}

/* =====================================
   === Mobile (slide-in-left) ===
===================================== */
@media screen and (max-width: 1366px) {
  .lc-search-form {
    max-width: 90%;
  }
}

@media (max-width: 1024px) {
  .lc-search-input-wrapper {
    position: relative;
    transition: width 0.3s ease;
  }

  /* Champ caché par défaut */
  .lc-search-field {
    position: relative;
    width: 260px;
    background: #fff;
    border: 1px solid #27415933;
    border-right: none;
    padding: 10px 14px;
    font-size: 15px;
    font-style: italic;
    box-sizing: border-box;
  }

  .header-search .lc-search-field {
    position: absolute;
    top: 0px;
    right: 100%;
    opacity: 0;
    height: 100%;
    transform: translateX(20px);
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: -1;
  }

  .lc-search-submit {
    border: solid 1px #27415933;
  }

  /* visible une fois actif */
  .lc-search-block.header-search.active .lc-search-field {
    opacity: 1;
    transform: translateX(0);
    z-index: 99;
  }

  /* suggestions sous le champ même en mobile */
  .lc-search-suggestions {
    left: auto;
    right: 0;
    width: 270px;
  }
}

.lc-suggestion-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid #eaeaea;
}

.lc-suggestion-thumb {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.lc-search-history {
  padding: 10px;
  border-top: 1px solid #eaeaea;
}

.lc-history-item {
  background: #f5f7f9;
  border: none;
  border-radius: 6px;
  margin: 3px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--wp--preset--color--dark-blue);
  font-size: var(--wp--preset--font-size--12);
}
.lc-history-item:hover {
  background: #e1eaf0;
}

@media (max-width: 1024px) {
  /* État FERMÉ (par défaut) */
  .header-search .lc-search-field {
    position: absolute;
    top: 0;
    right: 46px; /* juste derrière la loupe */
    width: 0;
    opacity: 0;
    padding: 0;
    border-width: 0;
    pointer-events: none;
    z-index: -1;
    transition: width 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
  }

  /* État OUVERT */
  .lc-search-block.header-search.active .lc-search-field {
    width: 225px;
    opacity: 1;
    padding: 10px 14px;
    border: 1px solid #27415933;
    border-right: none;
    pointer-events: auto;
    z-index: 10;
  }
}

/* =====================================
   Native Search Override
===================================== */

.wp-block-search__inside-wrapper {
  padding: 0px;
}

.wp-block-search__input {
  padding: 8px;
}

.wp-block-search__button.has-icon {
  background-color: #f5f5f5;
  border: none;
}

.wp-block-search__button svg {
  display: none !important;
}

.wp-block-search__button {
  border-radius: 2px 2px 0px 0px;
  background-image: url("/wp-content/plugins/lecosinus-master/blocks/lc-search/search.svg");
  background-size: 20px;
  background-repeat: no-repeat;
  background-position: center;
  width: 46px;
  height: 46px;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background 0.2s;
  padding: 13px;
}

.wp-block-search__button:hover {
  background-color: #e9e9e9;
}
