/**
 * Search Interface Styling
 * Modern, responsive design cho tính năng tìm kiếm
 */

/* Search Toggle Button */
.search-toggle {
  background: none;
  border: none;
  color: #515151;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
}

.search-toggle:hover {
  background-color: rgba(81, 81, 81, 0.1);
  color: #268bd2;
}

.search-toggle svg {
  width: 20px;
  height: 20px;
}

/* Search Overlay */
.search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 20px 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

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

/* Search Container */
.search-container {
  width: 100%;
  max-width: 600px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  transform: translateY(-20px);
  transition: transform 0.3s ease;
}

.search-overlay.active .search-container {
  transform: translateY(0);
}

/* Search Box */
.search-box {
  position: relative;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  padding: 20px 60px 20px 20px;
  border: none;
  outline: none;
  font-size: 18px;
  font-family: inherit;
  background: transparent;
  color: #333;
}

.search-input::placeholder {
  color: #999;
}

.search-clear {
  position: absolute;
  right: 15px;
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-clear:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: #666;
}

/* Search Results */
.search-results {
  max-height: 400px;
  overflow-y: auto;
  border-top: 1px solid #eee;
}

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

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

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

.search-results::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Results Header */
.search-results-header {
  padding: 15px 20px 10px;
  border-bottom: 1px solid #f0f0f0;
  background: #fafafa;
}

.search-results-count {
  font-size: 14px;
  color: #666;
  font-weight: 500;
}

/* Results List */
.search-results-list {
  padding: 0;
}

/* Individual Result Item */
.search-result-item {
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.search-result-item:hover {
  background-color: #f8f9fa;
}

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

/* Result Header */
.search-result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 12px;
}

.search-result-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #268bd2;
  line-height: 1.3;
  flex: 1;
}

.search-result-chapter {
  font-size: 12px;
  background: #268bd2;
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  white-space: nowrap;
  font-weight: 500;
}

/* Result Content */
.search-result-content {
  margin: 0 0 8px 0;
  font-size: 14px;
  line-height: 1.5;
  color: #666;
}

/* Result Meta */
.search-result-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: #999;
}

.search-result-owner,
.search-result-type {
  padding: 2px 6px;
  background: #f0f0f0;
  border-radius: 4px;
}

.search-result-type {
  text-transform: capitalize;
}

/* Highlight */
mark {
  background: #fff3cd;
  color: #856404;
  padding: 1px 2px;
  border-radius: 2px;
}

/* No Results */
.search-no-results {
  padding: 40px 20px;
  text-align: center;
  color: #666;
}

.search-no-results p {
  margin: 0 0 8px 0;
  font-size: 16px;
}

.search-no-results small {
  font-size: 14px;
  color: #999;
}

/* Error State */
.search-error {
  padding: 40px 20px;
  text-align: center;
  color: #dc3545;
}

.search-error p {
  margin: 0;
  font-size: 16px;
}

/* Body class khi search active */
body.search-active {
  overflow: hidden;
}

/* Responsive Design */
@media (max-width: 768px) {
  .search-overlay {
    padding: 60px 15px 15px;
  }
  
  .search-input {
    padding: 16px 50px 16px 16px;
    font-size: 16px; /* Prevent zoom on iOS */
  }
  
  .search-results {
    max-height: 300px;
  }
  
  .search-result-item {
    padding: 12px 16px;
  }
  
  .search-result-header {
    flex-direction: column;
    gap: 6px;
  }
  
  .search-result-title {
    font-size: 15px;
  }
  
  .search-result-chapter {
    align-self: flex-start;
  }
}

@media (max-width: 480px) {
  .search-overlay {
    padding: 40px 10px 10px;
  }
  
  .search-container {
    border-radius: 8px;
  }
  
  .search-input {
    padding: 14px 45px 14px 14px;
    font-size: 16px;
  }
  
  .search-results {
    max-height: 250px;
  }
}

/* Dark mode support (nếu có) */
@media (prefers-color-scheme: dark) {
  .search-container {
    background: #2d3748;
    color: #e2e8f0;
  }
  
  .search-input {
    color: #e2e8f0;
  }
  
  .search-input::placeholder {
    color: #a0aec0;
  }
  
  .search-results {
    border-top-color: #4a5568;
  }
  
  .search-results-header {
    background: #1a202c;
    border-bottom-color: #4a5568;
  }
  
  .search-result-item {
    border-bottom-color: #4a5568;
  }
  
  .search-result-item:hover {
    background-color: #4a5568;
  }
  
  .search-result-title {
    color: #63b3ed;
  }
  
  .search-result-content {
    color: #cbd5e0;
  }
  
  .search-result-meta {
    color: #a0aec0;
  }
  
  .search-result-owner,
  .search-result-type {
    background: #4a5568;
    color: #e2e8f0;
  }
  
  mark {
    background: #d69e2e;
    color: #1a202c;
  }
}

/* Animation cho loading state */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.search-loading {
  animation: pulse 1.5s ease-in-out infinite;
}

/* Focus styles */
.search-result-item:focus {
  outline: 2px solid #268bd2;
  outline-offset: -2px;
}

/* Keyboard navigation hints */
.search-overlay::after {
  content: "Press Esc to close";
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  pointer-events: none;
}

@media (max-width: 768px) {
  .search-overlay::after {
    display: none;
  }
}
