/* =====================================================
   OBUJU GLOBALISER SEARCH - Search Component
   ===================================================== */

/* --- Wrapper --- */
.obuju-search-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
}

/* --- Mobile toggle button (icon only, hidden on desktop) --- */
.obuju-search-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: #666;
  transition: color 0.2s;
}
.obuju-search-toggle:hover {
  color: #333;
}

/* --- Form / Input bar --- */
.obuju-search-form {
  display: flex;
  align-items: center;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 50px;
  padding: 0 16px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.obuju-search-form:focus-within {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
  background: #fff;
}

.obuju-search-icon {
  flex-shrink: 0;
  color: #999;
  margin-right: 10px;
}
.obuju-search-form:focus-within .obuju-search-icon {
  color: #7c3aed;
}

.obuju-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 15px;
  padding: 12px 0;
  outline: none;
  color: #333;
  min-width: 0;
}
.obuju-search-input::placeholder {
  color: #aaa;
}
/* Remove browser default search clear button */
.obuju-search-input::-webkit-search-cancel-button,
.obuju-search-input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.obuju-search-clear {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #999;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.obuju-search-clear:hover {
  color: #333;
}

/* --- Dropdown --- */
.obuju-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  z-index: 99999;
  max-height: 480px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* --- Result list --- */
.obuju-sr-list {
  padding: 6px 0;
}

/* --- Single result item --- */
.obuju-sr-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  text-decoration: none;
  color: inherit;
  transition: background 0.12s;
}
.obuju-sr-item a:hover,
.obuju-sr-item.obuju-sr-selected a {
  background: #f7f3ff;
}

/* --- Thumbnail --- */
.obuju-sr-img {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
}
.obuju-sr-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.obuju-sr-noimg {
  width: 100%;
  height: 100%;
  background: #eee;
}

/* --- Info block --- */
.obuju-sr-info {
  flex: 1;
  min-width: 0;
}
.obuju-sr-title {
  font-size: 14px;
  font-weight: 500;
  color: #222;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.obuju-sr-cat {
  font-size: 12px;
  color: #888;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Prices --- */
.obuju-sr-price {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1;
}
.obuju-sr-price-current {
  font-weight: 600;
  color: #222;
}
.obuju-sr-price-old {
  text-decoration: line-through;
  color: #aaa;
  font-size: 12px;
}
.obuju-sr-price-sale {
  font-weight: 600;
  color: #e53e3e;
}
.obuju-sr-discount {
  font-size: 11px;
  font-weight: 600;
  color: #e53e3e;
}

/* --- Out of stock --- */
.obuju-sr-outofstock a {
  opacity: 0.5;
}

/* --- See all link --- */
.obuju-sr-seeall {
  display: block;
  text-align: center;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  color: #7c3aed;
  text-decoration: none;
  border-top: 1px solid #f0f0f0;
  transition: background 0.12s;
}
.obuju-sr-seeall:hover {
  background: #f7f3ff;
}

/* --- Loading --- */
.obuju-sr-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 14px;
  font-size: 14px;
  color: #888;
}
.obuju-sr-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #e0e0e0;
  border-top-color: #7c3aed;
  border-radius: 50%;
  animation: obuju-spin 0.6s linear infinite;
}
@keyframes obuju-spin {
  to { transform: rotate(360deg); }
}

/* --- No results --- */
.obuju-sr-empty {
  padding: 24px 14px;
  text-align: center;
  font-size: 14px;
  color: #888;
}

/* --- Responsive: mid-range desktops (1024–1440px) --- */
@media (min-width: 1025px) and (max-width: 1440px) {
  .obuju-search-wrap {
    max-width: 288px; /* 60% of 480px */
    margin-left: auto;
  }
}

/* --- Responsive (matches Impreza tablet breakpoint) --- */
@media (max-width: 1024px) {
  .obuju-search-wrap {
    max-width: none;
    position: static;
  }

  /* Show the toggle icon button on mobile */
  .obuju-search-toggle {
    display: flex;
  }

  /* Hide form by default on mobile */
  .obuju-search-form {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100000;
    border-radius: 0;
    background: #fff;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    padding: 8px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  }
  .obuju-search-form:focus-within {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #e0e0e0;
  }

  /* When expanded on mobile */
  .obuju-search-wrap.obuju-search-open .obuju-search-form {
    display: flex;
  }

  /* Overlay behind the expanded search */
  .obuju-search-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 99999;
  }
  .obuju-search-wrap.obuju-search-open .obuju-search-overlay {
    display: block;
  }

  .obuju-search-dropdown {
    position: fixed;
    top: auto;
    left: 8px;
    right: 8px;
    max-height: 60vh;
    border-radius: 12px;
  }
  .obuju-sr-img {
    width: 48px;
    height: 48px;
  }
}
