/* Enhanced Search Modal */
.search-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  padding-top: 5vh;
}

.search-modal.active {
  opacity: 1;
  visibility: visible;
}

.search-modal-content {
  background: var(--white, #ffffff);
  padding: 0;
  border-radius: 20px;
  width: 90%;
  max-width: 700px;
  position: relative;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
  max-height: 80vh;
  overflow: hidden;
  transform: translateY(-50px) scale(0.9);
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.search-modal.active .search-modal-content {
  transform: translateY(0) scale(1);
}

.search-header {
  padding: 2rem 2rem 1rem;
  border-bottom: 1px solid #e5e5e5;
  background: linear-gradient(135deg, #355eb9, #2a4a94);
  color: white;
}

.search-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  color: white;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.search-form {
  position: relative;
  margin-top: 1rem;
}

.search-input {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50px;
  font-size: 1.1rem;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  box-sizing: border-box;
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.search-input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.2);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.2rem;
}

.search-results {
  max-height: 50vh;
  overflow-y: auto;
  padding: 1rem 0;
}

.search-results::-webkit-scrollbar {
  width: 6px;
}

.search-results::-webkit-scrollbar-track {
  background: #f5f5f5;
}

.search-results::-webkit-scrollbar-thumb {
  background: #355eb9;
  border-radius: 3px;
}

.search-category {
  margin-bottom: 1.5rem;
}

.search-category-title {
  padding: 0.5rem 2rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #f8f9fa;
  margin-bottom: 0.5rem;
  border-left: 4px solid #355eb9;
}

.search-result-item {
  padding: 1rem 2rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.search-result-item:hover {
  background: #f8f9fa;
  transform: translateX(5px);
}

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

.search-result-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #355eb9, #2a4a94);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.search-result-content {
  flex: 1;
}

.search-result-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 0.3rem;
  line-height: 1.3;
}

.search-result-description {
  font-size: 0.9rem;
  color: #666;
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.search-result-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: #999;
  flex-wrap: wrap;
}

.search-result-type {
  background: #355eb9;
  color: white;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 500;
}

.search-no-results {
  text-align: center;
  padding: 3rem 2rem;
  color: #999;
}

.search-no-results i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.search-suggestions {
  padding: 1rem 2rem;
  background: #f8f9fa;
  border-top: 1px solid #e5e5e5;
}

.search-suggestions-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 0.5rem;
}

.search-suggestion-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.search-suggestion-tag {
  background: white;
  color: #355eb9;
  padding: 0.3rem 0.8rem;
  border-radius: 15px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid #e5e5e5;
}

.search-suggestion-tag:hover {
  background: #355eb9;
  color: white;
  transform: translateY(-1px);
}

.search-loading {
  text-align: center;
  padding: 2rem;
  color: #999;
}

.search-loading i {
  font-size: 2rem;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Highlight matched text */
.search-highlight {
  background: linear-gradient(120deg, #fbbf24 0%, #f59e0b 100%);
  color: white;
  padding: 0.1rem 0.2rem;
  border-radius: 3px;
  font-weight: 600;
}

/* MOBILE RESPONSIVE FIXES - SCREENS BELOW 1024px */
@media (max-width: 1024px) {
  .search-modal {
    padding: 0;
    align-items: stretch;
  }

  .search-modal-content {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }

  .search-modal.active .search-modal-content {
    transform: translateY(0);
  }

  .search-header {
    padding: 1.5rem 1rem 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .search-header h3 {
    font-size: 1.3rem !important;
    margin: 0 0 1rem 0 !important;
  }

  .search-input {
    padding: 1rem 1rem 1rem 3rem;
    font-size: 16px !important; /* Prevents zoom on iOS */
    border-radius: 25px;
  }

  .search-icon {
    left: 1rem;
    font-size: 1.1rem;
  }

  .search-close {
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }

  .search-results {
    max-height: calc(100vh - 160px);
    padding: 0.5rem 0;
  }

  .search-category-title {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-left-width: 3px;
  }

  .search-result-item {
    padding: 1rem;
    gap: 1rem;
  }

  .search-result-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
    border-radius: 8px;
  }

  .search-result-title {
    font-size: 1rem;
    line-height: 1.2;
  }

  .search-result-description {
    font-size: 0.9rem;
    line-height: 1.3;
  }

  .search-result-meta {
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.75rem;
  }

  .search-result-type {
    padding: 0.15rem 0.5rem;
    font-size: 0.65rem;
    border-radius: 10px;
  }

  .search-suggestions {
    padding: 1rem;
  }

  .search-suggestions-title {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
  }

  .search-suggestion-tags {
    gap: 0.4rem;
  }

  .search-suggestion-tag {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 12px;
    min-height: 36px;
    display: flex;
    align-items: center;
  }

  .search-no-results {
    padding: 2rem 1rem;
  }

  .search-no-results i {
    font-size: 2.5rem;
  }

  .search-no-results h3 {
    font-size: 1.2rem;
    margin: 1rem 0 0.5rem;
  }

  .search-loading {
    padding: 1.5rem;
  }

  .search-loading i {
    font-size: 1.8rem;
  }
}

/* TABLET SPECIFIC (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .search-modal-content {
    width: 90%;
    height: 85vh;
    max-height: 85vh;
    border-radius: 20px;
    margin: 2rem auto;
    transform: translateY(-50px) scale(0.9);
  }

  .search-modal.active .search-modal-content {
    transform: translateY(0) scale(1);
  }

  .search-header {
    padding: 1.8rem 1.5rem 1.2rem;
  }

  .search-results {
    max-height: calc(85vh - 140px);
  }
}

/* MOBILE SPECIFIC (below 768px) */
@media (max-width: 768px) {
  .search-input {
    padding: 0.9rem 0.9rem 0.9rem 2.8rem;
    font-size: 16px !important;
  }

  .search-icon {
    left: 0.9rem;
    font-size: 1rem;
  }

  .search-result-item {
    padding: 0.9rem;
  }

  .search-result-icon {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  .search-result-title {
    font-size: 0.95rem;
  }

  .search-result-description {
    font-size: 0.85rem;
  }
}

/* Enhanced Search Button Styles - MOBILE RESPONSIVE */
.search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 45px;
  height: 45px;
  background: linear-gradient(135deg, #f5f5f5, #e5e5e5);
  border: 2px solid #ddd;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
  overflow: hidden;
  color: #666;
  font-size: 1.1rem;
}

.search-btn:hover {
  background: linear-gradient(135deg, #355eb9, #2a4a94);
  color: white;
  border-color: #355eb9;
  transform: scale(1.1);
  box-shadow: 0 8px 25px rgba(53, 94, 185, 0.3);
}

.search-btn:active {
  transform: scale(0.95);
  transition: transform 0.1s ease;
}

.search-btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.3s ease, height 0.3s ease;
}

.search-btn:active::before {
  width: 100px;
  height: 100px;
}

.search-btn.pulse {
  animation: search-pulse 2s infinite;
}

@keyframes search-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(53, 94, 185, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(53, 94, 185, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(53, 94, 185, 0);
  }
}

.search-btn i {
  transition: transform 0.3s ease;
}

.search-btn:hover i {
  transform: scale(1.2) rotate(15deg);
}

.search-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(53, 94, 185, 0.3);
}

/* MOBILE SEARCH BUTTON */
@media (max-width: 1024px) {
  .search-btn {
    width: 42px;
    height: 42px;
    font-size: 1rem;
  }
}

@media (max-width: 768px) {
  .search-btn {
    width: 40px;
    height: 40px;
    font-size: 0.95rem;
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  .search-result-item {
    padding: 1.2rem 1rem;
    min-height: 60px;
  }

  .search-suggestion-tag {
    padding: 0.5rem 1rem;
    min-height: 40px;
  }

  .search-close {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
  }
}
