/* ============================================================
   Younxin Search — Global Search Bar
   ============================================================ */

/* ---------- Container ---------- */
.sw-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

/* ---------- Icon (default state) ---------- */
.sw-search-icon {
  width: 24px;
  height: 24px;
  cursor: pointer;
  color: inherit;
  transition: color .2s;
  flex-shrink: 0;
}
.sw-search-icon:hover {
  color: #F26B2C;
}

/* ---------- Input wrapper ---------- */
.sw-search-box {
  display: none;
  position: relative;
  align-items: center;
}
.sw-search-wrap.expanded .sw-search-box {
  display: flex;
}
.sw-search-wrap.expanded .sw-search-icon--trigger {
  display: none;
}

.sw-search-input {
  width: 320px;
  height: 40px;
  padding: 0 40px 0 16px;
  border: 2px solid transparent;
  border-radius: 20px;
  background: #f5f7fa;
  font-size: 14px;
  color: #0E1E3F;
  outline: none;
  transition: border-color .2s, background .2s;
  font-family: inherit;
}
.sw-search-input::placeholder {
  color: #9aa5b4;
}
.sw-search-input:focus {
  border-color: #1E5BB8;
  background: #fff;
}

/* Close (×) button inside input */
.sw-search-close {
  position: absolute;
  right: 10px;
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  cursor: pointer;
  color: #9aa5b4;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sw-search-close:hover {
  color: #0E1E3F;
}

/* Search icon inside expanded box */
.sw-search-box .sw-search-icon--inner {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  color: #9aa5b4;
  pointer-events: none;
}
.sw-search-input {
  padding-left: 36px;
}

/* ============================================================
   Dropdown Panel
   ============================================================ */
.sw-search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 480px;
  max-height: 480px;
  overflow-y: auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(14, 30, 63, 0.12);
  z-index: 9999;
  display: none;
  padding: 8px 0;
}
.sw-search-dropdown.open {
  display: block;
}

/* ---- Group ---- */
.sw-search-group {
  margin-bottom: 4px;
}
.sw-search-group:last-child {
  margin-bottom: 0;
}
.sw-search-group-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #9aa5b4;
  padding: 8px 16px 4px;
}

/* ---- Item ---- */
.sw-search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background .15s;
}
.sw-search-item:hover,
.sw-search-item.active {
  background: #f5f7fa;
}
.sw-search-item.active {
  background: #edf2fa;
}

.sw-search-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: #f0f2f5;
  flex-shrink: 0;
}
.sw-search-thumb--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #c5cdd8;
}

.sw-search-info {
  flex: 1;
  min-width: 0;
}
.sw-search-title {
  font-size: 14px;
  font-weight: 500;
  color: #0E1E3F;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sw-search-subtitle {
  font-size: 12px;
  color: #9aa5b4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* Highlight match */
.sw-hl {
  background: #FFF0E6;
  color: #F26B2C;
  border-radius: 2px;
  padding: 0 1px;
}

/* ---- Footer ---- */
.sw-search-footer {
  border-top: 1px solid #f0f2f5;
  padding: 10px 16px;
  text-align: center;
}
.sw-search-footer a {
  font-size: 13px;
  font-weight: 500;
  color: #1E5BB8;
  text-decoration: none;
  transition: color .2s;
}
.sw-search-footer a:hover {
  color: #F26B2C;
}

/* ---- Empty state ---- */
.sw-search-empty {
  padding: 24px 16px;
  text-align: center;
  color: #9aa5b4;
  font-size: 14px;
}

/* ============================================================
   Skeleton Loading
   ============================================================ */
.sw-skeleton-group {
  padding: 8px 16px 4px;
}
.sw-skeleton-bar {
  height: 11px;
  border-radius: 4px;
  background: linear-gradient(90deg, #f0f2f5 25%, #e8ecf1 50%, #f0f2f5 75%);
  background-size: 200% 100%;
  animation: sw-shimmer 1.5s ease-in-out infinite;
}
.sw-skeleton-bar--short {
  width: 60px;
}
.sw-skeleton-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
}
.sw-skeleton-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: linear-gradient(90deg, #f0f2f5 25%, #e8ecf1 50%, #f0f2f5 75%);
  background-size: 200% 100%;
  animation: sw-shimmer 1.5s ease-in-out infinite;
  flex-shrink: 0;
}
.sw-skeleton-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sw-skeleton-bar--title {
  height: 14px;
  width: 70%;
}
.sw-skeleton-bar--sub {
  height: 12px;
  width: 45%;
}

@keyframes sw-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   Mobile Backdrop
   ============================================================ */
.sw-search-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 30, 63, 0.5);
  z-index: 99998;
  display: none;
}
.sw-search-backdrop.active {
  display: block;
}

/* ============================================================
   Mobile ≤768px
   ============================================================ */
@media (max-width: 768px) {
  /* Allow nav items to wrap on mobile */
  nav.sw-navbar .sw-container {
    flex-wrap: wrap;
  }
  /* The JS-injected wrapper div must span full width */
  .sw-search-nav-slot {
    flex: 0 0 100% !important;
    margin: 8px 0 0 0 !important;
    order: 10;
  }
  /* Always show full search bar on mobile */
  .sw-search-wrap {
    width: 100%;
  }
  .sw-search-wrap .sw-search-icon--trigger {
    display: none;
  }
  .sw-search-wrap .sw-search-box {
    display: flex;
    width: 100%;
  }
  .sw-search-input {
    width: 100%;
    flex: 1;
  }
  .sw-search-dropdown {
    position: fixed;
    left: 8px;
    right: 8px;
    width: auto;
    top: auto;
    bottom: 0;
    max-height: 70vh;
    border-radius: 12px 12px 0 0;
    background: #FFFFFF !important;
    z-index: 99999;
  }
  .sw-search-footer {
    position: sticky;
    bottom: 0;
    background: #FFFFFF;
    border-top: 1px solid #e5e8ee;
    padding: 14px 16px;
    z-index: 1;
  }
}

/* ============================================================
   Nav hero mode (transparent nav on homepage)
   ============================================================ */
.sw-nav-hero .sw-search-icon {
  color: #fff;
}
.sw-nav-hero .sw-search-icon:hover {
  color: #F26B2C;
}
.sw-nav-hero .sw-search-input {
  background: rgba(255,255,255,.15);
  color: #fff;
  border-color: transparent;
}
.sw-nav-hero .sw-search-input::placeholder {
  color: rgba(255,255,255,.6);
}
.sw-nav-hero .sw-search-input:focus {
  background: #fff;
  color: #0E1E3F;
  border-color: #1E5BB8;
}
.sw-nav-hero .sw-search-input:focus::placeholder {
  color: #9aa5b4;
}
.sw-nav-hero .sw-search-close {
  color: rgba(255,255,255,.6);
}
.sw-nav-hero .sw-search-close:hover {
  color: #fff;
}
.sw-nav-hero .sw-search-box .sw-search-icon--inner {
  color: rgba(255,255,255,.6);
}

/* Image Search */
.sw-search-camera{position:absolute;right:36px;top:50%;transform:translateY(-50%);background:none;border:none;padding:4px;cursor:pointer;color:#64748b;display:flex;align-items:center;transition:color .2s;z-index:2}
.sw-search-camera:hover{color:#1A4FA3}
.sw-search-camera svg{display:block}
.sw-search-file{display:none}
.sw-search-dropdown .sw-img-preview{padding:12px;text-align:center;border-bottom:1px solid #E5E7EB}
.sw-search-dropdown .sw-img-preview img{max-height:120px;max-width:200px;border-radius:6px;object-fit:contain}
.sw-search-dropdown .sw-img-labels{padding:8px 12px;font-size:12px;color:#64748b;border-bottom:1px solid #E5E7EB}
.sw-search-dropdown .sw-img-labels span{display:inline-block;background:#EFF6FF;color:#1A4FA3;padding:2px 8px;border-radius:10px;margin:2px;font-size:11px}
