/* ============================================
   MODERN ANIMATED SEARCH - POSITIONED CORRECTLY
   ============================================ */

/* Desktop search - Trong header-right, trước Sign In */
.header-search {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  position: relative;
}

/* Desktop search - Collapsed state (icon only) */
.desktop-search .search-form {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  background: transparent;
  border: none;
  border-radius: 50px;
  overflow: visible;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  width: 44px;
  height: 44px;
  position: relative;
  margin-right: 10px;
}

/* Desktop search button - Clean & Simple */
.desktop-search .search-button {
  background: transparent;
  border: none;
  padding: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
  z-index: 5;
  position: relative;
  order: 2;
}

.desktop-search .search-button:hover {
  color: #188ffe;
  transform: scale(1.1);
}

.desktop-search .search-button i {
  font-size: 18px;
  transition: all 0.3s ease;
}

.desktop-search .search-form.search-expanded .search-button {
  color: #188ffe;
}

.desktop-search .search-form.search-expanded .search-button i {
  transform: rotate(90deg);
}

/* Desktop input - Clean border, no shadow overflow */
.desktop-search .search-input {
  position: absolute;
  right: 0;
  top: 0;
  height: 44px;
  border: 1px solid #d1d5db;
  background: white;
  padding: 0 54px 0 20px;
  font-size: 15px;
  color: #1e293b;
  outline: none !important;
  border-radius: 50px;
  width: 44px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  order: 1;
  box-shadow: none !important;
}

.desktop-search .search-input:focus {
  outline: none !important;
  box-shadow: none !important;
  border: 1px solid #d1d5db !important;
}

/* Desktop expanded state */
.desktop-search .search-form.search-expanded,
.desktop-search .search-form:focus-within {
  width: 320px;
  z-index: 150;
}

.desktop-search .search-form.search-expanded .search-input,
.desktop-search .search-form:focus-within .search-input {
  width: 320px;
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  border-color: #d1d5db;
  box-shadow: none !important;
}

.desktop-search .search-input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

/* ============================================
   SEARCH DROPDOWN - ALIGNED RIGHT
   ============================================ */
.search-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  background: white;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
  display: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transform-origin: top right;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  max-height: 600px;
  overflow-y: auto;
  overflow-x: hidden;
  width: 420px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.search-dropdown::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.search-dropdown.search-dropdown-visible {
  display: block;
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.search-dropdown-content {
  padding: 16px;
}

/* Loading State */
.search-loading,
.search-empty,
.search-error {
  display: none;
  text-align: center;
  padding: 60px 24px;
  color: #666;
}

.search-results {
  display: block;
}

/* Show/Hide states */
.search-dropdown.loading .search-loading {
  display: block;
}
.search-dropdown.loading .search-results,
.search-dropdown.loading .search-empty,
.search-dropdown.loading .search-error {
  display: none;
}

.search-dropdown.empty .search-empty {
  display: block;
}
.search-dropdown.empty .search-results,
.search-dropdown.empty .search-loading,
.search-dropdown.empty .search-error {
  display: none;
}

.search-dropdown.error .search-error {
  display: block;
}
.search-dropdown.error .search-results,
.search-dropdown.error .search-loading,
.search-dropdown.error .search-empty {
  display: none;
}

.search-dropdown:not(.loading):not(.empty):not(.error) .search-loading,
.search-dropdown:not(.loading):not(.empty):not(.error) .search-empty,
.search-dropdown:not(.loading):not(.empty):not(.error) .search-error {
  display: none;
}

.search-dropdown:not(.loading):not(.empty):not(.error) .search-results {
  display: block;
}

/* Loading animation */
.search-loading i {
  font-size: 40px;
  color: #188ffe;
  margin-bottom: 16px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.search-loading span {
  font-size: 14px;
  color: #999;
  font-weight: 500;
}

.search-empty i,
.search-error i {
  font-size: 48px;
  color: #ddd;
  margin-bottom: 16px;
}

.search-empty p,
.search-error p {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 600;
  color: #333;
}

.search-empty span,
.error-details {
  font-size: 14px;
  color: #999;
}

/* Search Sections */
.search-section {
  margin-bottom: 24px;
}

.search-section:last-child {
  margin-bottom: 0;
}

.search-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 10px 0;
  margin-bottom: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #999;
  border-bottom: 2px solid #f0f0f0;
}

.search-section-header i {
  font-size: 14px;
  color: #188ffe;
}

/* Search Result Items */
.search-result-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  background: #fafafa;
  margin-bottom: 8px;
}

.search-result-item:last-child {
  margin-bottom: 0;
}

.search-result-item:hover {
  background: white;
  border-color: #188ffe;
  box-shadow: 0 4px 16px rgba(68, 157, 240, 0.1);
  transform: translateY(-2px);
}

.search-result-item.selected {
  background: #e8f4fd;
  border-color: #188ffe;
}

.search-result-image {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  overflow: hidden;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #f0f0f0;
}

.search-result-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.search-result-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-size: 22px;
}

.search-result-content {
  flex: 1;
  min-width: 0;
}

.search-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.search-result-title {
  font-size: 15px;
  font-weight: 600;
  color: #222;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-title mark {
  background: linear-gradient(120deg, #fff3cd 0%, #ffeaa7 100%);
  color: #333;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.search-result-rating {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
  color: #ffc107;
  white-space: nowrap;
  background: #fff9e6;
  padding: 2px 8px;
  border-radius: 20px;
}

.search-result-rating i {
  font-size: 12px;
}

.search-result-excerpt {
  font-size: 13px;
  color: #666;
  margin: 0;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-result-price {
  font-size: 14px;
  font-weight: 700;
  color: #188ffe;
  display: inline-block;
  background: #e8f4fd;
  padding: 4px 10px;
  border-radius: 6px;
}

/* Category Tag */
.search-result-category {
  font-size: 11px;
  font-weight: 600;
  color: white;
  margin-top: 8px;
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  margin-left: 6px;
  text-transform: capitalize;
  letter-spacing: 0.3px;
}

.search-result-category.budget {
  background: #b6771d;
  color: white;
}

.search-result-category.premium {
  background: #ffc50f;
  color: white;
}

.search-result-category.mid-range {
  background: #b6ceb4;
  color: white;
}

.search-result-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #999;
  margin-top: 8px;
}

.search-result-meta i {
  font-size: 11px;
}

.search-result-arrow {
  flex-shrink: 0;
  color: #ddd;
  font-size: 16px;
  transition: all 0.2s ease;
}

.search-result-item:hover .search-result-arrow {
  color: #188ffe;
  transform: translateX(4px);
}

/* ============================================
   TABLET (≤1024px) - Desktop search vẫn hiển thị nhưng thu gọn
   ============================================ */
@media (max-width: 1024px) {
  /* Hide desktop search on tablet */
  .desktop-search {
    display: none !important;
  }

  /* Show mobile search on tablet */
  .mobile-search {
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    position: fixed;
    right: 70px;
    top: 13.5px;
    z-index: 999;
  }

  .mobile-search .header-search {
    width: auto;
  }

  .mobile-search .search-form {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 48px;
    background: transparent;
    border: none;
    padding: 0;
    height: 48px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
  }

  .mobile-search .search-button {
    background: transparent;
    border: none;
    padding: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    z-index: 3;
    transition: all 0.3s ease;
    position: relative;
  }

  .mobile-search .search-button:active {
    transform: scale(0.9);
  }

  .mobile-search .search-form.search-expanded .search-button {
    color: #188ffe;
  }

  .mobile-search .search-button i {
    font-size: 18px;
    transition: all 0.3s ease;
  }

  .mobile-search .search-form.search-expanded .search-button i {
    transform: rotate(90deg);
  }

  .mobile-search .search-input {
    position: absolute;
    right: 0;
    top: 0;
    height: 48px;
    border: 1px solid #d1d5db;
    background: white;
    padding: 0 58px 0 20px;
    font-size: 15px;
    color: #1e293b;
    outline: none !important;
    border-radius: 50px;
    width: 48px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    box-shadow: none !important;
  }

  .mobile-search .search-input:focus {
    outline: none !important;
    box-shadow: none !important;
    border: 1px solid #d1d5db !important;
  }

  .mobile-search .search-form.search-expanded .search-input {
    width: calc(85vw - 145px);
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    border-color: #d1d5db;
    box-shadow: none !important;
  }

  .mobile-search .search-input::placeholder {
    color: #94a3b8;
  }

  .mobile-search .search-dropdown {
    position: fixed !important;
    top: 85px !important;
    left: 20px !important;
    right: 20px !important;
    width: auto !important;
    max-height: 75vh !important;
    border-radius: 16px;
    z-index: 10000 !important;
  }

  .search-dropdown-content {
    padding: 14px;
  }

  .search-result-item {
    padding: 12px;
    gap: 12px;
    border-radius: 12px;
    margin-bottom: 6px;
  }

  .search-result-image {
    width: 48px;
    height: 48px;
  }
}

/* ============================================
   MOBILE (≤430px) - Icon căn chỉnh đúng với logo
   ============================================ */
@media (max-width: 430px) {
  /* Mobile search - Aligned với logo */
  .mobile-search {
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    position: fixed;
    right: 60px;
    top: 15.5px;
    z-index: 999;
  }

  .mobile-search .header-search {
    width: auto;
    display: flex;
    align-items: center;
  }

  .mobile-search .search-form {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    background: transparent;
    border: none;
    padding: 0;
    height: 44px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
  }

  .mobile-search .search-button {
    background: transparent;
    border: none;
    padding: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    z-index: 3;
    transition: all 0.3s ease;
    position: relative;
  }

  .mobile-search .search-button:active {
    transform: scale(0.9);
  }

  .mobile-search .search-form.search-expanded .search-button {
    color: #188ffe;
  }

  .mobile-search .search-button i {
    font-size: 17px;
    transition: all 0.3s ease;
  }

  .mobile-search .search-form.search-expanded .search-button i {
    transform: rotate(90deg);
  }

  .mobile-search .search-input {
    position: absolute;
    right: 0;
    top: 0;
    height: 44px;
    border: 1px solid #d1d5db;
    background: white;
    padding: 0 54px 0 18px;
    font-size: 14px;
    color: #1e293b;
    outline: none !important;
    border-radius: 50px;
    width: 44px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    box-shadow: none !important;
  }

  .mobile-search .search-input:focus {
    outline: none !important;
    box-shadow: none !important;
    border: 1px solid #d1d5db !important;
  }

  .mobile-search .search-form.search-expanded .search-input {
    width: calc(100vw - 130px);
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    border-color: #d1d5db;
    box-shadow: none !important;
  }

  .mobile-search .search-input::placeholder {
    color: #94a3b8;
  }

  .mobile-search .search-dropdown {
    position: fixed !important;
    top: 70px !important;
    left: 15px !important;
    right: 15px !important;
    width: auto !important;
    max-height: 75vh !important;
    border-radius: 16px;
    z-index: 10000 !important;
  }

  .search-dropdown-content {
    padding: 14px;
  }

  .search-result-item {
    padding: 12px;
    gap: 12px;
    border-radius: 12px;
    margin-bottom: 6px;
  }

  .search-result-image {
    width: 48px;
    height: 48px;
  }

  .search-result-title {
    font-size: 14px;
  }

  .search-result-excerpt {
    font-size: 12px;
  }

  .search-section {
    margin-bottom: 20px;
  }

  .search-section-header {
    padding: 0 0 8px 0;
    margin-bottom: 10px;
  }
}

/* ============================================
   SMALL MOBILE (≤375px)
   ============================================ */
@media (max-width: 375px) {
  .mobile-search .search-form {
    height: 46px;
    width: 46px;
  }

  .mobile-search .search-button {
    width: 46px;
    height: 46px;
  }

  .mobile-search .search-button i {
    font-size: 17px;
  }

  .mobile-search .search-input {
    height: 46px;
    width: 46px;
    font-size: 14px;
    padding: 0 56px 0 18px;
    border-radius: 46px;
  }

  .mobile-search .search-form.search-expanded .search-input {
    width: calc(100vw - 100px);
  }

  .mobile-search .search-dropdown {
    border-radius: 14px;
    max-height: 70vh !important;
  }

  .search-dropdown-content {
    padding: 12px;
  }

  .search-result-item {
    padding: 10px;
    gap: 10px;
    border-radius: 10px;
  }

  .search-result-image {
    width: 44px;
    height: 44px;
  }

  .search-result-title {
    font-size: 13px;
  }

  .search-result-excerpt {
    font-size: 11px;
    -webkit-line-clamp: 2;
  }

  .search-result-category {
    font-size: 10px;
    padding: 3px 8px;
    margin-left: 4px;
  }

  .search-result-rating {
    font-size: 11px;
    padding: 2px 6px;
  }

  .search-section-header {
    font-size: 10px;
  }
}

/* ============================================
   EXTRA SMALL (≤360px)
   ============================================ */
@media (max-width: 360px) {
  .mobile-search .search-form {
    height: 44px;
    width: 44px;
  }

  .mobile-search .search-button {
    width: 44px;
    height: 44px;
  }

  .mobile-search .search-input {
    height: 44px;
    width: 44px;
    font-size: 13px;
    padding: 0 54px 0 16px;
  }

  .mobile-search .search-form.search-expanded .search-input {
    width: calc(100vw - 90px);
  }

  .search-result-item {
    padding: 8px;
    gap: 8px;
  }

  .search-result-image {
    width: 40px;
    height: 40px;
  }

  .search-result-title {
    font-size: 12px;
  }

  .search-result-excerpt {
    -webkit-line-clamp: 1;
  }

  .search-result-arrow {
    display: none;
  }
}

/* Footer chứa price + category */
.search-result-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* Style cho price */
.search-result-price {
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

/* Style cho category badge */
.provider-category {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.provider-category.premium {
  background: #ffc50f;
  color: white;
}

.provider-category.mid-range {
  background: #b6ceb4;
  color: white;
}

.provider-category.budget {
  background: #b6771d;
  color: white;
}
