/* Header icon */
#fitz-search-toggle {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #3a3a3a;
  box-sizing: border-box;
  overflow: hidden;
  height: 100%;            /* fill the parent's height like the bag widget does */
  align-self: center;      /* center within the flex row regardless of siblings */
}

#fitz-search-toggle svg {
  display: block;
  overflow: hidden;
}

/* Mobile */
#fitz-search-toggle svg {
  width: 28px;
  height: 28px;
}

/* Tablet */
@media (min-width: 601px) and (max-width: 1024px) {
  #fitz-search-toggle svg {
    width: 36px;
    height: 36px;
  }
}

/* Desktop */
@media (min-width: 1025px) {
  #fitz-search-toggle svg {
    width: 40px;
    height: 40px;
  }
}

/* Overlay */
#fitz-search-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99999;
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding-top: 8vh;
}

#fitz-search-modal.is-open {
  display: flex;
}

/* Box hugs its content — no forced height */
#fitz-search-modal-inner {
  background: #f4f4f4;
  width: 90%;
  max-width: 700px;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

/* Flush search row — no outer padding, no inner box */
#fitz-search-modal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 0;
  background: #fff;
}

#fitz-search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: none;
  padding: 16px 14px;
}

#fitz-search-input-wrap svg {
  flex-shrink: 0;
  color: #888;
}

#fitz-search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px; /* prevents iOS zoom-on-focus */
}

#fitz-search-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  color: #333;
  flex-shrink: 0;
}

/* Results — hidden entirely until JS adds .has-results */
#fitz-search-results {
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 0;
  overflow-y: auto;
  max-height: 80vh;
  border-top: 1px solid #e2e2e2;
}

#fitz-search-results.has-results {
  display: grid;
  padding: 16px;
}

.fitz-search-result-item {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}

.fitz-search-result-item:hover .fitz-result-title {
  text-decoration: underline;
}

.fitz-search-result-item img,
.fitz-no-image {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: #ddd;
  border-radius: 3px;
  margin-bottom: 6px;
}

.fitz-result-info {
  display: flex;
  flex-direction: column;
}

.fitz-result-title {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
}

.fitz-result-price {
  font-size: 12px;
  color: #777;
  margin-top: 3px;
}

.fitz-no-results {
  padding: 16px;
  color: #888;
  text-align: center;
  grid-column: 1 / -1;
}

body.fitz-search-open {
  overflow: hidden;
}

/* Mobile */
@media (max-width: 480px) {
  #fitz-search-modal {
    padding-top: 8vh;
  }

  #fitz-search-modal-inner {
    width: 90%;
    max-width: 90%;
    border-radius: 8px;
  }

  #fitz-search-input-wrap {
    padding: 14px 12px;
  }

  #fitz-search-results {
    grid-template-columns: repeat(2, 1fr);
    max-height: 80vh;
  }

  #fitz-search-results.has-results {
    padding: 12px;
  }
}