/* ==========================================
   search.css - រចនាបទលទ្ធផលស្វែងរក
   ========================================== */

/* Search Results Items */
.search-result-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.search-result-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(66, 133, 244, 0.15);
    border-color: #4285f4;
}

.search-result-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: linear-gradient(to bottom, #4285f4, #34a853);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.search-result-item:hover::before {
    opacity: 1;
}

.result-title {
    margin-bottom: 10px;
}

.result-title a {
    color: #1a0dab;
    text-decoration: none;
    font-size: 1.3rem;
    font-weight: 500;
    line-height: 1.4;
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.result-title a:hover {
    color: #4285f4;
    text-decoration: underline;
}

.result-title i {
    color: #34a853;
    font-size: 1rem;
}

.result-url {
    color: #0d652d;
    font-size: 0.9rem;
    margin-bottom: 10px;
    font-family: monospace;
    word-break: break-all;
}

.result-snippet {
    color: #4d5156;
    line-height: 1.6;
    margin-bottom: 15px;
    font-size: 1rem;
}

.result-meta {
    display: flex;
    gap: 20px;
    color: #70757a;
    font-size: 0.9rem;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.meta-item i {
    font-size: 0.9rem;
}

/* Image Results */
.image-result-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    aspect-ratio: 1;
}

.image-result-item:hover {
    transform: scale(1.05);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}

.image-result-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.image-result-item:hover img {
    transform: scale(1.1);
}

.image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 15px;
    color: white;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.image-result-item:hover .image-overlay {
    transform: translateY(0);
}

.image-title {
    font-size: 0.9rem;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-source {
    font-size: 0.8rem;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* No Results State */
.no-results {
    text-align: center;
    padding: 60px 20px;
    background: #f8f9fa;
    border-radius: 15px;
    border: 2px dashed #dee2e6;
}

.no-results-icon {
    font-size: 4rem;
    color: #adb5bd;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.no-results h3 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.no-results p {
    color: #6c757d;
    margin-bottom: 20px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* Loading Results */
.results-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    gap: 20px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4285f4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    color: #4285f4;
    font-size: 1.1rem;
}

/* Search History */
.search-history {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    margin-top: 20px;
}

.history-title {
    color: #4285f4;
    margin-bottom: 15px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.history-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.9rem;
    color: #4285f4;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-item:hover {
    background: #4285f4;
    color: white;
    transform: translateY(-2px);
}

.clear-history {
    margin-top: 15px;
    padding: 8px 16px;
    background: #f8f9fa;
    border: 1px solid #dc3545;
    border-radius: 20px;
    color: #dc3545;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.clear-history:hover {
    background: #dc3545;
    color: white;
}

/* Voice Search */
.voice-search-active {
    animation: voicePulse 1.5s infinite;
}

@keyframes voicePulse {
    0% { box-shadow: 0 0 0 0 rgba(66, 133, 244, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(66, 133, 244, 0); }
    100% { box-shadow: 0 0 0 0 rgba(66, 133, 244, 0); }
}

.voice-result {
    background: #e8f0fe;
    border: 1px solid #4285f4;
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.voice-result-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    color: #4285f4;
}

.voice-text {
    background: white;
    padding: 15px;
    border-radius: 8px;
    font-size: 1.1rem;
    line-height: 1.6;
}

/* Error States */
.error-message {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 12px;
    padding: 25px;
    color: #721c24;
    margin-bottom: 20px;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.error-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.error-header i {
    font-size: 1.5rem;
}

.error-details {
    background: rgba(255, 255, 255, 0.5);
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    font-family: monospace;
    font-size: 0.9rem;
    word-break: break-all;
}

/* Success States */
.success-message {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 12px;
    padding: 25px;
    color: #155724;
    margin-bottom: 20px;
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.success-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

/* Tooltips */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltip-text {
    visibility: hidden;
    width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.9rem;
    font-weight: normal;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Animations for new results */
.new-result {
    animation: highlightResult 1.5s ease;
}

@keyframes highlightResult {
    0% { background-color: rgba(66, 133, 244, 0.2); }
    100% { background-color: transparent; }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .search-result-item {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .result-title a {
        color: #63b3ed;
    }
    
    .result-snippet {
        color: #cbd5e0;
    }
    
    .result-meta {
        color: #a0aec0;
        border-color: #4a5568;
    }
    
    .no-results {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .no-results h3 {
        color: #e2e8f0;
    }
    
    .no-results p {
        color: #a0aec0;
    }
}
