advanced-search-library
Version:
Intelligent search library with typo correction, autocomplete, and flexible data structure support
990 lines (848 loc) • 17.5 kB
CSS
/* Advanced Search Library Demo Styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6;
color: #333;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
/* Header */
.header {
text-align: center;
margin-bottom: 40px;
color: white;
}
.header-content {
display: flex;
flex-direction: column;
align-items: center;
gap: 10px;
}
.header h1 {
font-size: 2.5rem;
font-weight: 700;
display: flex;
align-items: center;
gap: 15px;
}
.logo {
display: flex;
align-items: center;
justify-content: center;
gap: 15px;
margin-bottom: 10px;
}
.logo i {
font-size: 2.5rem;
}
.logo h1 {
font-size: 2.5rem;
font-weight: 700;
}
.subtitle {
font-size: 1.1rem;
opacity: 0.9;
}
/* Main Content */
.main-content {
width: 100%;
}
.content-grid {
display: grid;
grid-template-columns: 300px 1fr;
gap: 30px;
margin-top: 20px;
}
/* Search Section */
.search-section {
background: white;
border-radius: 20px;
padding: 30px;
margin-bottom: 30px;
box-shadow: 0 20px 60px rgba(0,0,0,0.1);
}
.search-container {
position: relative;
margin-bottom: 25px;
}
.search-box {
position: relative;
display: flex;
align-items: center;
}
.search-icon {
position: absolute;
left: 20px;
color: #666;
font-size: 1.2rem;
z-index: 2;
}
.search-input, #searchInput {
width: 100%;
padding: 18px 60px 18px 55px;
border: 2px solid #e1e5e9;
border-radius: 50px;
font-size: 1.1rem;
transition: all 0.3s ease;
outline: none;
}
.search-input:focus, #searchInput:focus {
border-color: #667eea;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.search-button {
position: absolute;
right: 15px;
background: #667eea;
color: white;
border: none;
padding: 12px 15px;
border-radius: 50%;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
}
.search-button:hover {
background: #5a6fd8;
transform: scale(1.05);
}
.clear-btn {
position: absolute;
right: 15px;
background: none;
border: none;
color: #999;
font-size: 1.2rem;
cursor: pointer;
padding: 5px;
border-radius: 50%;
transition: all 0.3s ease;
}
.clear-btn:hover {
background: #f1f3f4;
color: #666;
}
/* Autocomplete */
.autocomplete-container {
position: absolute;
top: 100%;
left: 0;
right: 0;
background: white;
border: 1px solid #e1e5e9;
border-radius: 15px;
margin-top: 5px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
z-index: 1000;
display: none;
max-height: 200px;
overflow-y: auto;
}
.autocomplete-item {
padding: 12px 20px;
cursor: pointer;
border-bottom: 1px solid #f1f3f4;
transition: background 0.2s ease;
}
.autocomplete-item:hover {
background: #f8f9fa;
}
.autocomplete-item:last-child {
border-bottom: none;
}
/* Suggestions (legacy) */
.suggestions {
position: absolute;
top: 100%;
left: 0;
right: 0;
background: white;
border: 1px solid #e1e5e9;
border-radius: 15px;
margin-top: 5px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
z-index: 1000;
display: none;
}
.suggestion-item {
padding: 12px 20px;
cursor: pointer;
border-bottom: 1px solid #f1f3f4;
transition: background 0.2s ease;
}
.suggestion-item:hover {
background: #f8f9fa;
}
.suggestion-item:last-child {
border-bottom: none;
}
/* Search Tips */
.search-tips {
margin-top: 15px;
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 10px;
}
.tip-label {
font-weight: 600;
color: #667eea;
font-size: 0.9rem;
}
.tip-item {
background: #f8f9fa;
color: #667eea;
padding: 6px 12px;
border-radius: 15px;
font-size: 0.9rem;
cursor: pointer;
transition: all 0.3s ease;
border: 1px solid #e9ecef;
}
.tip-item:hover {
background: #667eea;
color: white;
transform: translateY(-2px);
}
/* Filters Section */
.filters-section {
background: white;
border-radius: 15px;
padding: 20px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
height: fit-content;
position: sticky;
top: 20px;
}
.filters-container {
margin-bottom: 25px;
}
.filters-container h3 {
color: #333;
margin-bottom: 20px;
display: flex;
align-items: center;
gap: 10px;
font-size: 1.2rem;
}
.filters-container h3 i {
color: #667eea;
}
.price-inputs {
display: flex;
flex-direction: column;
gap: 10px;
}
.price-inputs input {
flex: 1;
}
.price-inputs span {
color: #666;
font-weight: 500;
}
.clear-filters-btn {
width: 100%;
background: #ff6b6b;
color: white;
border: none;
padding: 12px 15px;
border-radius: 8px;
cursor: pointer;
font-weight: 600;
transition: all 0.3s ease;
display: flex;
align-items: center;
gap: 8px;
justify-content: center;
margin-top: 15px;
}
.clear-filters-btn:hover {
background: #ff5252;
transform: translateY(-2px);
}
/* Filters (legacy) */
.filters {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 15px;
align-items: end;
}
.filter-group {
display: flex;
flex-direction: column;
gap: 5px;
}
.filter-group label {
font-weight: 600;
color: #555;
font-size: 0.9rem;
}
.filter-group select,
.filter-group input {
padding: 10px 12px;
border: 1px solid #ddd;
border-radius: 8px;
font-size: 0.95rem;
transition: border-color 0.3s ease;
}
.filter-group select:focus,
.filter-group input:focus {
outline: none;
border-color: #667eea;
}
.reset-btn {
background: #ff6b6b;
color: white;
border: none;
padding: 10px 15px;
border-radius: 8px;
cursor: pointer;
font-weight: 600;
transition: all 0.3s ease;
display: flex;
align-items: center;
gap: 8px;
justify-content: center;
white-space: nowrap;
}
.reset-btn:hover {
background: #ff5252;
transform: translateY(-2px);
}
/* Statistics Container */
.stats-container {
background: #f8f9fa;
border-radius: 12px;
padding: 20px;
margin-bottom: 25px;
border: 1px solid #e9ecef;
}
.stats-container h3 {
color: #333;
margin-bottom: 15px;
display: flex;
align-items: center;
gap: 10px;
font-size: 1.1rem;
}
.stats-container h3 i {
color: #667eea;
}
.stats-content {
display: flex;
flex-direction: column;
gap: 8px;
}
.stats-content div {
display: flex;
justify-content: space-between;
align-items: center;
padding: 8px 0;
border-bottom: 1px solid #e9ecef;
font-size: 0.9rem;
}
.stats-content div:last-child {
border-bottom: none;
}
.stat-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 8px 0;
border-bottom: 1px solid #e9ecef;
font-size: 0.9rem;
}
.stat-item:last-child {
border-bottom: none;
}
.stat-label {
color: #666;
font-weight: 500;
}
.stat-value {
color: #333;
font-weight: 600;
}
/* History Container */
.history-container {
background: #f8f9fa;
border-radius: 12px;
padding: 20px;
border: 1px solid #e9ecef;
}
.history-container h3 {
color: #333;
margin-bottom: 15px;
display: flex;
align-items: center;
gap: 10px;
font-size: 1.1rem;
}
.history-container h3 i {
color: #667eea;
}
.history-content {
display: flex;
flex-direction: column;
gap: 8px;
}
.history-content .history-item {
background: white;
padding: 8px 12px;
border-radius: 8px;
border: 1px solid #e9ecef;
cursor: pointer;
transition: all 0.3s ease;
font-size: 0.9rem;
}
.history-content .history-item:hover {
background: #667eea;
color: white;
}
.history-query {
font-weight: 500;
flex: 1;
}
.history-time {
font-size: 0.8rem;
opacity: 0.7;
margin-left: 10px;
}
/* Results Section */
.results-section {
background: white;
border-radius: 20px;
padding: 30px;
box-shadow: 0 20px 60px rgba(0,0,0,0.1);
min-height: 400px;
}
.results-container {
width: 100%;
}
.results-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 25px;
flex-wrap: wrap;
gap: 15px;
}
.results-header h3 {
color: #333;
font-size: 1.3rem;
}
.results-count {
background: #667eea;
color: white;
padding: 8px 15px;
border-radius: 20px;
font-size: 0.9rem;
font-weight: 600;
}
.results-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
gap: 25px;
margin-top: 20px;
}
.product-card {
background: #f8f9fa;
border-radius: 15px;
padding: 20px;
transition: all 0.3s ease;
border: 1px solid #e9ecef;
height: fit-content;
margin-bottom: 20px;
}
.product-card:hover {
transform: translateY(-5px);
box-shadow: 0 15px 40px rgba(0,0,0,0.1);
border-color: #667eea;
}
.product-header {
margin-bottom: 15px;
border-bottom: 1px solid #e9ecef;
padding-bottom: 10px;
}
.product-name {
font-size: 1.2rem;
font-weight: 700;
color: #2c3e50;
margin-bottom: 5px;
line-height: 1.4;
}
.product-category {
background: #667eea;
color: white;
padding: 4px 12px;
border-radius: 15px;
font-size: 0.8rem;
font-weight: 600;
display: inline-block;
}
.product-body {
margin-bottom: 15px;
}
.product-description {
color: #6c757d;
margin-bottom: 15px;
line-height: 1.5;
font-size: 0.95rem;
}
.product-details {
display: flex;
flex-wrap: wrap;
gap: 15px;
margin-bottom: 15px;
}
.detail-item {
display: flex;
align-items: center;
gap: 8px;
font-size: 0.9rem;
color: #555;
background: white;
padding: 6px 12px;
border-radius: 8px;
border: 1px solid #e9ecef;
}
.detail-item i {
color: #667eea;
}
.product-details {
display: flex;
flex-wrap: wrap;
gap: 15px;
margin-bottom: 15px;
}
.product-brand {
display: flex;
align-items: center;
gap: 8px;
font-size: 0.9rem;
color: #555;
background: white;
padding: 6px 12px;
border-radius: 8px;
border: 1px solid #e9ecef;
}
.product-rating {
display: flex;
align-items: center;
gap: 5px;
color: #ffc107;
}
.stars {
color: #ffc107;
font-size: 1.1rem;
}
.rating-value {
color: #666;
font-size: 0.9rem;
}
.product-tags {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-bottom: 15px;
}
.tag {
background: #e3f2fd;
color: #1976d2;
padding: 4px 8px;
border-radius: 12px;
font-size: 0.8rem;
font-weight: 500;
}
.product-stats {
margin-top: 10px;
padding-top: 10px;
border-top: 1px solid #e9ecef;
}
.product-stats small {
color: #999;
font-size: 0.8rem;
}
.product-footer {
display: flex;
justify-content: space-between;
align-items: center;
padding-top: 15px;
border-top: 1px solid #e9ecef;
flex-wrap: wrap;
gap: 10px;
}
.product-price {
font-size: 1.3rem;
font-weight: 700;
color: #28a745;
}
.product-rating {
display: flex;
align-items: center;
gap: 5px;
color: #ffc107;
}
.relevance-score {
background: #17a2b8;
color: white;
padding: 4px 8px;
border-radius: 10px;
font-size: 0.8rem;
font-weight: 600;
}
/* No Results */
.no-results {
text-align: center;
padding: 60px 20px;
color: #6c757d;
background: #f8f9fa;
border-radius: 15px;
margin: 20px 0;
}
.no-results h3 {
font-size: 1.5rem;
color: #495057;
margin-bottom: 15px;
}
.no-results i {
font-size: 4rem;
margin-bottom: 20px;
opacity: 0.5;
}
.no-results p {
font-size: 1.1rem;
margin-bottom: 10px;
color: #6c757d;
}
.suggestion {
color: #667eea;
font-weight: 600;
}
/* Info Section */
.info-section {
margin-bottom: 30px;
}
.info-cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 20px;
}
.info-card {
background: white;
padding: 25px;
border-radius: 15px;
text-align: center;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
transition: transform 0.3s ease;
}
.info-card:hover {
transform: translateY(-5px);
}
.info-card h4 {
color: #667eea;
margin-bottom: 10px;
font-size: 1.1rem;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
}
.info-card h4 i {
font-size: 1.3rem;
}
.info-card p {
color: #6c757d;
line-height: 1.5;
font-size: 0.95rem;
}
/* History Section */
.history-section {
background: white;
border-radius: 15px;
padding: 25px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
margin-bottom: 30px;
}
.history-section h3 {
color: #333;
margin-bottom: 20px;
display: flex;
align-items: center;
gap: 10px;
}
.history-section h3 i {
color: #667eea;
}
.search-history {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin-bottom: 20px;
}
.history-item {
background: #f8f9fa;
padding: 8px 15px;
border-radius: 20px;
cursor: pointer;
transition: all 0.3s ease;
border: 1px solid #e9ecef;
font-size: 0.9rem;
}
.history-item:hover {
background: #667eea;
color: white;
transform: translateY(-2px);
}
.clear-history-btn {
background: #dc3545;
color: white;
border: none;
padding: 10px 20px;
border-radius: 8px;
cursor: pointer;
font-size: 0.9rem;
transition: all 0.3s ease;
display: flex;
align-items: center;
gap: 8px;
}
.clear-history-btn:hover {
background: #c82333;
transform: translateY(-2px);
}
/* Footer */
.footer {
background: rgba(255,255,255,0.1);
color: white;
text-align: center;
padding: 30px 20px;
border-radius: 20px;
backdrop-filter: blur(10px);
}
.footer-content {
display: flex;
justify-content: center;
align-items: center;
gap: 20px;
flex-wrap: wrap;
}
.footer-links {
display: flex;
gap: 20px;
flex-wrap: wrap;
}
.footer-links a {
color: white;
text-decoration: none;
transition: all 0.3s ease;
display: flex;
align-items: center;
gap: 8px;
opacity: 0.8;
}
.footer-links a:hover {
opacity: 1;
transform: translateY(-2px);
}
/* Responsive Design */
@media (max-width: 768px) {
.container {
padding: 15px;
}
.header h1, .logo h1 {
font-size: 2rem;
}
.content-grid {
grid-template-columns: 1fr;
gap: 20px;
}
.filters-section {
position: static;
order: 2;
}
.results-section {
order: 1;
}
.filters {
grid-template-columns: 1fr;
}
.results-grid {
grid-template-columns: 1fr;
}
.results-header {
flex-direction: column;
align-items: flex-start;
}
.footer-content {
flex-direction: column;
}
.search-section,
.results-section,
.info-section,
.history-section,
.filters-section {
padding: 20px;
}
.search-tips {
justify-content: center;
}
}
@media (max-width: 480px) {
.results-grid {
grid-template-columns: 1fr;
}
.product-card {
padding: 15px;
}
.product-details {
flex-direction: column;
gap: 10px;
}
.product-footer {
flex-direction: column;
align-items: flex-start;
}
}
/* Animation */
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.product-card {
animation: fadeIn 0.5s ease forwards;
}
.loading {
display: flex;
justify-content: center;
align-items: center;
height: 200px;
font-size: 1.2rem;
color: #667eea;
}
.loading i {
animation: spin 1s linear infinite;
margin-right: 10px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}