/* ═══════════════════════════════════════════════
   STUDIOMASTER CUSTOM SEARCH – search.css
   ═══════════════════════════════════════════════ */

/* ── Wrapper ── */
#custom-search-wrapper, #mobile-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  z-index: 99999;
}

/* ── Input ── */
#custom-search-input, #mobile-search-input {
  width: 300px;
  height: 38px;
  padding: 0 42px 0 16px;
  font-size: 13px;
  font-family: inherit;
  border: 1.5px solid #ddd;
  border-radius: 20px;
  background: #f7f7f7;
  color: #222;
  outline: none;
  transition: width 0.3s ease, border-color 0.2s, background 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  margin:0;
}

#custom-search-input:focus {
  border-color: #999;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

#custom-search-input::placeholder { color: #bbb; }

/* ── Submit button ── */
#custom-search-submit, #mobile-search-submit {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: #888;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}
#custom-search-submit:hover { color: #222; }
#custom-search-submit svg { display: block; }

/* ═══════════════════════════════════════════════
   DROPDOWN
   ═══════════════════════════════════════════════ */
#search-dropdown {
  position: absolute;
  top: calc(100% + -12px);
  right: -80;
  width: 360px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
  border: 1px solid #ebebeb;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 9999;
}

#search-dropdown.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(15px);
}

.sd-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  text-decoration: none;
  color: #222;
  border-bottom: 1px solid #f5f5f5;
  transition: background 0.12s;
}
.sd-item:last-of-type { border-bottom: none; }
.sd-item:hover { background: #f9f9f9; }

.sd-thumb {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 6px;
  background: #f5f5f5;
  flex-shrink: 0;
}
.sd-no-img {
  width: 44px;
  height: 44px;
  background: #f0f0f0;
  border-radius: 6px;
  flex-shrink: 0;
}

.sd-title {
  flex: 1;
  font-size: 13px;
  line-height: 1.4;
  color: #222;
}
.sd-title mark {
  background: #fff3cd;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.sd-arrow { color: #bbb; flex-shrink: 0; }
.sd-item:hover .sd-arrow { color: #555; }

.sd-see-all {
    display: block;
    width: 90%;
    justify-content: center;
    padding: 11px 14px;
    background: #000000;
    border: none;
    border-top: 1px solid #ebebeb;
    font-size: 13px;
    color: #fff;
    text-align: center;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    align-items: center;
    margin: 0 auto;
    margin-bottom: 20px;
}
.sd-see-all:hover { background: #333; color: #fff; }

.sd-empty {
  padding: 14px 16px;
  font-size: 13px;
  color: #888;
  background: #fff;
  border-radius: 12px;
}

/* ═══════════════════════════════════════════════
   FULL RESULTS SECTION
   ═══════════════════════════════════════════════ */
#search-results-section {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99999;
  overflow-y: auto;
  padding: 60px 20px 40px;
}

#search-results-section.active { display: block; }

/* ✅ ADDED: Hide mobile results section by default */
#mobile-search-results-section {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99999;
  overflow-y: auto;
  padding: 60px 20px 40px;
}

/* ✅ ADDED: Show only when active class is added by JS */
#mobile-search-results-section.active { display: block; }

body.search-open { overflow: hidden; }

#search-results-inner, #mobile-search-results-inner {
  max-width: 1100px;
  margin: 0 auto;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

#search-results-header, #mobile-search-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 28px;
  border-bottom: 1px solid #ebebeb;
  background: #fff;
}

#search-results-count, #mobile-search-results-count {
  font-size: 15px;
  font-weight: 600;
  color: #222;
}

#search-results-close, #mobile-search-results-close {
  background: #000;
  border: none;
  cursor: pointer;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  margin: 0;
}
#search-results-close:hover,
#mobile-search-results-close:hover { background: #f5f5f5; color: #222; }

/* ── Results grid ── */
#search-results-grid, #mobile-search-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1px;
  background: #ebebeb;
  padding: 1px;
}

.sr-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s;
}
.sr-card:hover { box-shadow: inset 0 0 0 2px #222; }

.sr-card-img {
  aspect-ratio: 1;
  background: #f9f9f9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 12px;
}
.sr-card-img img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.sr-no-img {
  font-size: 11px;
  color: #ccc;
}

.sr-card-body {
  padding: 12px 14px 16px;
}

.sr-card-title {
  font-size: 13px;
  font-weight: 500;
  color: #111;
  line-height: 1.4;
  margin: 0 0 4px;
}
.sr-card-title mark {
  background: #fff3cd;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.sr-card-exc {
  font-size: 12px;
  color: #888;
  margin: 0;
  line-height: 1.4;
}

/* ── Loading dots ── */
.sr-loading {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  padding: 60px;
}
.sr-loading span {
  width: 10px;
  height: 10px;
  background: #ccc;
  border-radius: 50%;
  animation: sr-bounce 0.9s infinite ease-in-out both;
}
.sr-loading span:nth-child(1) { animation-delay: -0.32s; }
.sr-loading span:nth-child(2) { animation-delay: -0.16s; }
@keyframes sr-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40%           { transform: scale(1); }
}

.sr-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  font-size: 15px;
  color: #888;
}

/* ═══════════════════════════════════════════════
   MOBILE
   ═══════════════════════════════════════════════ */
@media (max-width: 600px) {
  #custom-search-input, #mobile-search-input { width: 100% !important; }
  #custom-search-input:focus { width: 100%; }

  #search-dropdown { width: calc(100vw - 24px); right: -12px; }

  #search-results-section,
  #mobile-search-results-section { padding: 20px 0 0; }

  #search-results-inner,
  #mobile-search-results-inner { border-radius: 16px 16px 0 0; min-height: 80vh; }

  #search-results-grid,
  #mobile-search-results-grid { grid-template-columns: repeat(2, 1fr); }

  /* ✅ Mobile dropdown — floats over content, does not push layout */
  #mobile-search-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 100vw;
    right: auto;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 99999;
    max-height: 400px;
    overflow-y: auto;
    display: none;           /* ✅ Hidden by default */
    opacity: 1;
    pointer-events: none;
  }

  #mobile-search-dropdown.active {
    display: block;          /* ✅ Show on search */
    pointer-events: all;
  }
}