/**
 * Search functionality styles
 * Responsive design with dark mode support
 */

/* Search Container */
.search-container {
    position: relative;
    max-width: 300px;
    margin-left: auto;
}

.search-input {
    width: 100%;
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color, #e2e8f0);
    border-radius: 0.5rem;
    background: var(--card-background, #ffffff);
    color: var(--text-color, #2d3748);
    font-size: 0.9rem;
    transition: all 0.2s ease;
    outline: none;
}

.search-input:focus {
    border-color: var(--primary-color, #3182ce);
    box-shadow: 0 0 0 3px var(--primary-color-alpha, rgba(49, 130, 206, 0.1));
}

.search-input::placeholder {
    color: var(--text-muted, #a0aec0);
}

/* Search Overlay */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 5rem;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.search-results {
    background: var(--card-background, #ffffff);
    border-radius: 0.75rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 
                0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 600px;
    width: 90%;
    max-height: 70vh;
    overflow-y: auto;
    border: 1px solid var(--border-color, #e2e8f0);
}

/* Search Results Header */
.search-results-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.search-results-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color, #2d3748);
}

.search-count {
    background: var(--primary-color, #3182ce);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Search Sections */
.search-section {
    padding: 1rem 0;
}

.search-section:not(:last-child) {
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.search-section h4 {
    margin: 0 0 1rem 0;
    padding: 0 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color, #2d3748);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-section h4 i {
    color: var(--primary-color, #3182ce);
    width: 1.25rem;
}

/* Search Items */
.search-items {
    display: flex;
    flex-direction: column;
}

.search-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.2s ease;
    border-left: 3px solid transparent;
}

.search-item:hover {
    background: var(--hover-background, #f7fafc);
    border-left-color: var(--primary-color, #3182ce);
}

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

.search-item-title {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color, #2d3748);
    line-height: 1.4;
}

.search-item-title mark {
    background: var(--highlight-background, #fef5e7);
    color: var(--highlight-text, #d69e2e);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
}

.search-item-excerpt {
    margin: 0 0 0.75rem 0;
    color: var(--text-muted, #718096);
    font-size: 0.875rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-item-excerpt mark {
    background: var(--highlight-background, #fef5e7);
    color: var(--highlight-text, #d69e2e);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
}

.search-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-muted, #a0aec0);
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
}

.search-meta i {
    width: 0.875rem;
}

.search-tags, .search-techs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.search-tag, .search-tech {
    background: var(--tag-background, #edf2f7);
    color: var(--tag-text, #4a5568);
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.search-tech {
    background: var(--secondary-background, #e6fffa);
    color: var(--secondary-text, #234e52);
}

.search-item-arrow {
    color: var(--text-muted, #a0aec0);
    font-size: 0.875rem;
    transition: transform 0.2s ease;
}

.search-item:hover .search-item-arrow {
    transform: translateX(0.25rem);
    color: var(--primary-color, #3182ce);
}

/* Loading, Error, and No Results States */
.search-loading,
.search-error,
.search-no-results {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--text-muted, #718096);
}

.search-loading i {
    font-size: 2rem;
    color: var(--primary-color, #3182ce);
    margin-bottom: 1rem;
}

.search-error i,
.search-no-results i {
    font-size: 2rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.search-error h4,
.search-no-results h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    color: var(--text-color, #2d3748);
}

.search-error p,
.search-no-results p {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.5;
}

.search-no-results a {
    color: var(--primary-color, #3182ce);
    text-decoration: none;
    font-weight: 500;
}

.search-no-results a:hover {
    text-decoration: underline;
}

/* Dark Mode */
[data-theme="dark"] {
    --card-background: #2d3748;
    --border-color: #4a5568;
    --text-color: #e2e8f0;
    --text-muted: #a0aec0;
    --hover-background: #4a5568;
    --highlight-background: #744210;
    --highlight-text: #fbd38d;
    --tag-background: #4a5568;
    --tag-text: #e2e8f0;
    --secondary-background: #234e52;
    --secondary-text: #81e6d9;
    --primary-color-alpha: rgba(129, 230, 217, 0.1);
}

/* Responsive Design */
@media (max-width: 768px) {
    .search-container {
        max-width: 100%;
        margin: 0;
    }
    
    .search-overlay {
        padding-top: 2rem;
        align-items: flex-start;
    }
    
    .search-results {
        width: 95%;
        max-height: 80vh;
        border-radius: 0.5rem;
    }
    
    .search-results-header {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .search-results-header h3 {
        font-size: 1.125rem;
    }
    
    .search-item {
        padding: 0.75rem 1rem;
    }
    
    .search-item-title {
        font-size: 0.95rem;
    }
    
    .search-item-excerpt {
        font-size: 0.8rem;
    }
    
    .search-section h4 {
        padding: 0 1rem;
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .search-input {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 0.75rem;
    }
    
    .search-overlay {
        padding-top: 1rem;
    }
    
    .search-results {
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }
    
    .search-tags,
    .search-techs {
        justify-content: flex-start;
    }
}

/* Animation */
.search-overlay {
    animation: fadeIn 0.2s ease-out;
}

.search-results {
    animation: slideIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-1rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Focus management */
body.search-active {
    overflow: hidden;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .search-input {
        border-width: 2px;
    }
    
    .search-item {
        border-bottom: 1px solid var(--border-color);
    }
    
    .search-item-title mark,
    .search-item-excerpt mark {
        outline: 2px solid var(--highlight-text);
    }
}