/* Suggestion styles - Add to your CSS file */
.search-suggestions {
  display: none;
  position: absolute;
  background-color: white;
  border: 1px solid #ddd;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  max-height: 350px;
  overflow-y: auto;
  z-index: 1000;
  width: 223px
}
#search-icon button {
  padding-right: 1px;
}
.suggestion-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover, .suggestion-item.active {
  background-color: #f5f5f5;
}

.suggestion-item img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  margin-right: 10px;
  border-radius: 3px;
}

.suggestion-info {
  display: flex;
  flex-direction: column;
}

.suggestion-title {
  font-weight: bold;
  margin-bottom: 2px;
  font-size: 14px;
}

.suggestion-artist {
  font-size: 12px;
  color: #666;
}

.highlight {
  background-color: #ffffcc;
  font-weight: bold;
}

/* Standard search container styling */
.search-container {
  position: relative;
  display: inline-block;
}

#search-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#search-icon svg {
  pointer-events: none; /* This ensures clicks on the SVG propagate to the button */
  width: 16px;
  height: 16px;
}

#search-wrapper {
  display: none; /* Hidden by default */
  position: absolute;
  right: 0;
  top: 100%;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  z-index: 1000;
}

#search-wrapper.search-appear {
  display: block;
}

#product-search {
  width: 200px;
  padding: 8px 12px;
  border: none;
  font-size: 14px;
  outline: none;
}

/* Base styles for search wrapper */
#search-wrapper {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
}

/* Single mobile media query */
@media only screen and (max-width: 700px) {
    #search-wrapper {
        display: none;
        position: absolute;
        right: 0;
        top: 100%;
        background: white;
        border: 1px solid #ddd;
        border-radius: 4px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        z-index: 1000;
        width: 223px; /* Match desktop width */
    }

    #product-search {
        width: 200px;
        padding: 8px 12px;
        border: none;
        font-size: 14px;
        outline: none;
    }

    .search-suggestions {
        width: 223px; /* Match search wrapper width */
        right: 0;
    }
}

.search-appear {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Search results container positioning */
.search-results {
  position: absolute;
  top: 100%; /* Position right below the search input */
  left: 0;
  right: 0;
  z-index: 1000;
  background: white;
  border: 1px solid #ddd;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  max-height: 300px;
  overflow-y: auto;
  width: 100%;
}

/* Search Modal for Mobile */
.search-modal {
  display: none;
    position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
    width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  overflow-y: auto;
  }
  .search-modal-content {
  position: relative;
  background-color: white;
    margin: 20% auto;
  padding: 20px;
  width: 90%;
  max-width: 500px;
  border-radius: 10px;
  }

.close-search {
  position: absolute;
  top: 10px;
  right: 15px;
  color: #888;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close-search:hover {
  color: #000;
}

.search-results-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0 0;
}

.search-result-item {
  display: flex;
  justify-content: space-between;
  padding: 10px;
  border-bottom: 1px solid #eee;
  text-decoration: none;
  color: #333;
}

.search-result-item:hover {
  background-color: #f5f5f5;
}

.result-name {
  font-weight: bold;
}

.result-price {
  color: #666;
}

/* Adjust search input in modal for mobile */
.search-modal-content #product-search {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 16px;
  margin-bottom: 10px;
}


@media only screen and (max-width: 480px) {
  .search-container {
    margin-right: 5px;
  }

  #search-wrapper {
    width: 180px;
  }

  .right-nav {
    flex-wrap: nowrap;
  }

  #search-wrapper {
    position: absolute;
  }

  .search-container,
  .right-nav-home,
  .right-nav-cart,
  #nav-toggle {
    margin: 5px;
  }

  /* Make search modal more mobile friendly */
  .search-modal-content {
    width: 90%;
    margin: 20% auto;
  }

  /* Additional fixes for very small screens */
  #search-form {
    width: 100%;
  }

  /* Ensure input doesn't get hidden when focused */
  input[type="search"]:focus,
  #search-input:focus {
    position: relative;
    box-shadow: none;
    transition: none;
  }
}

/* Mobile styles for 480px and below */
@media only screen and (max-width: 480px) {
  .right-nav {
    display: flex;
    justify-content: space-between; /* Spreads items to both ends */
    align-items: center;
    width: 100%;
    padding: 0 10px;
  }

  /* Left group: Search */
  .search-container {
    margin: 0;
    order: 1; /* Places search on the left */
  }

  /* Right group: Cart and Menu */
  .right-nav-cart,
  #nav-toggle {
    order: 2; /* Places these items on the right */
  }

  /* Adjust search wrapper positioning for mobile */
  #search-wrapper {
    position: absolute;
    top: calc(100% + 5px);
    left: 0; /* Align with left edge */
    width: calc(100vw - 20px); /* Full viewport width minus padding */
    max-width: none;
    margin: 0 10px;
    z-index: 1001;
  }

  /* Make search input full width of wrapper */
  #product-search {
    width: 100%;
    padding: 12px; /* Slightly larger touch target */
    font-size: 16px; /* Prevent iOS zoom on focus */
  }

  /* Adjust search suggestions container for mobile */
  .search-suggestions {
    width: calc(100vw - 20px);
    left: 10px;
    right: 10px;
    max-height: 60vh; /* Limit height on mobile */
  }

  /* Ensure search icon remains clickable */
  #search-icon {
    padding: 8px;
    margin: 0;
  }

  /* Adjust icon sizes for better touch targets */
  #search-icon svg,
  .right-nav-cart svg {
    width: 20px;
    height: 20px;
  }

  /* Add spacing between cart and menu toggle */
  .right-nav-cart {
    margin-right: 15px;
  }

  /* Ensure menu toggle is properly sized */
  #nav-toggle {
    padding: 8px;
    margin: 0;
  }
}

/* Additional adjustments for very small screens */
@media only screen and (max-width: 360px) {
  .right-nav {
    padding: 0 5px;
  }

  #search-wrapper {
    width: calc(100vw - 10px);
    margin: 0 5px;
  }

  .right-nav-cart {
    margin-right: 10px;
  }

  /* Reduce padding/margins further if needed */
  #search-icon,
  .right-nav-cart,
  #nav-toggle {
    padding: 6px;
  }
}
