/**
 * Search Interface Styles
 * Styling untuk sistem pencarian website statis
 * Berdasarkan dokumentasi static-website-search-implementation-guide.md
 */

/* Search Results Container */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    margin-top: 4px;
}

/* Search Result Item */
.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover,
.search-result-item.selected {
    background-color: #f8f9fa;
}

/* Search Result Header */
.search-result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.search-result-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #007bff;
    line-height: 1.3;
    flex: 1;
    margin-right: 8px;
}

.search-result-type {
    background: #e9ecef;
    color: #6c757d;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

/* Content Type Specific Colors */
.search-result-item[data-type="product"] .search-result-type {
    background: #d4edda;
    color: #155724;
}

.search-result-item[data-type="article"] .search-result-type {
    background: #d1ecf1;
    color: #0c5460;
}

.search-result-item[data-type="brand"] .search-result-type {
    background: #f8d7da;
    color: #721c24;
}

/* Search Result Content */
.search-result-excerpt {
    margin: 0 0 6px 0;
    font-size: 14px;
    color: #6c757d;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-result-url {
    font-size: 12px;
    color: #28a745;
    font-family: monospace;
}

/* Text Highlighting */
mark {
    background-color: #fff3cd;
    color: #856404;
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* No Results Message */
.search-no-results {
    padding: 20px;
    text-align: center;
    color: #6c757d;
}

.search-no-results p {
    margin: 0;
    font-size: 14px;
}

/* Loading State */
.search-loading {
    padding: 20px;
    text-align: center;
    color: #6c757d;
}

.search-loading::after {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #e0e0e0;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Search Input Enhancements */
#search-modal-input {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#search-modal-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
    outline: none;
}

/* Search Modal Enhancements */
.gp-search-modal .gp-modal__container {
    position: relative;
}

.search-modal-fields {
    position: relative;
}

/* Responsive Design */
@media (max-width: 768px) {
    .search-results {
        max-height: 300px;
        border-radius: 6px;
    }
    
    .search-result-item {
        padding: 10px 12px;
    }
    
    .search-result-title {
        font-size: 15px;
    }
    
    .search-result-excerpt {
        font-size: 13px;
        -webkit-line-clamp: 3;
    }
    
    .search-result-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .search-result-type {
        margin-top: 4px;
        align-self: flex-start;
    }
}

@media (max-width: 480px) {
    .search-results {
        max-height: 250px;
        left: -10px;
        right: -10px;
    }
    
    .search-result-item {
        padding: 8px 10px;
    }
    
    .search-result-title {
        font-size: 14px;
    }
    
    .search-result-excerpt {
        font-size: 12px;
    }
}

/* Accessibility Improvements */
.search-result-item:focus {
    outline: 2px solid #007bff;
    outline-offset: -2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .search-results {
        border: 2px solid #000;
    }
    
    .search-result-item:hover,
    .search-result-item.selected {
        background-color: #000;
        color: #fff;
    }
    
    .search-result-title {
        color: #0066cc;
    }
    
    mark {
        background-color: #ffff00;
        color: #000;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .search-result-item {
        transition: none;
    }
    
    #search-modal-input {
        transition: none;
    }
    
    .search-loading::after {
        animation: none;
    }
}

/* Print Styles */
@media print {
    .search-results {
        display: none !important;
    }
}

/* Dark Mode Support (if implemented) */
@media (prefers-color-scheme: dark) {
    .search-results {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .search-result-item {
        border-bottom-color: #4a5568;
    }
    
    .search-result-item:hover,
    .search-result-item.selected {
        background-color: #4a5568;
    }
    
    .search-result-title {
        color: #63b3ed;
    }
    
    .search-result-excerpt {
        color: #a0aec0;
    }
    
    .search-result-url {
        color: #68d391;
    }
    
    .search-result-type {
        background: #4a5568;
        color: #e2e8f0;
    }
    
    mark {
        background-color: #d69e2e;
        color: #1a202c;
    }
    
    .search-no-results,
    .search-loading {
        color: #a0aec0;
    }
}

/* Custom Scrollbar for Search Results */
.search-results::-webkit-scrollbar {
    width: 6px;
}

.search-results::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Animation for Results Appearance */
.search-results {
    animation: fadeInDown 0.2s ease-out;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Search History Styles (for future implementation) */
.search-history {
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
}

.search-history-title {
    padding: 0 16px 4px;
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-history-item {
    padding: 6px 16px;
    font-size: 14px;
    color: #495057;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-history-item:hover {
    background-color: #f8f9fa;
}

.search-history-item::before {
    content: "🕒";
    margin-right: 8px;
    opacity: 0.6;
}