/**
 * TexMeta - Advanced Search Styles
 * Facebook-style search dropdown
 */

/* Search Container */
#search-container {
    position: relative;
    flex: 1;
    max-width: 400px;
    margin: 0 16px;
}

#search-container.search-active {
    z-index: 1001;
}

/* Search Input */
#global-search {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: none;
    border-radius: 24px;
    background: var(--gray-100, #f3f4f6);
    font-size: 14px;
    color: var(--text-primary, #1f2937);
    transition: all 0.2s ease;
    outline: none;
}

#global-search:focus {
    background: white;
    box-shadow: 0 0 0 2px var(--primary, #7c3aed);
}

#global-search::placeholder {
    color: var(--text-muted, #9ca3af);
}

/* Search Icon */
.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted, #9ca3af);
    pointer-events: none;
}

#search-container.search-active .search-icon {
    color: var(--primary, #7c3aed);
}

/* Dropdown */
.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    max-height: 480px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.search-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Filters */
.search-filters {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border, #e5e7eb);
    background: var(--gray-50, #f9fafb);
    flex-shrink: 0;
}

.search-filter {
    padding: 6px 14px;
    border: none;
    border-radius: 16px;
    background: transparent;
    color: var(--text-secondary, #6b7280);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.search-filter:hover {
    background: var(--gray-200, #e5e7eb);
}

.search-filter.active {
    background: var(--primary, #7c3aed);
    color: white;
}

/* Results Container */
.search-results-container {
    flex: 1;
    overflow-y: auto;
    max-height: 360px;
}

.search-results {
    padding: 8px 0;
}

/* Category badges */
.search-categories {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    flex-wrap: wrap;
}

.cat-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.cat-people { background: #dbeafe; color: #1e40af; }
.cat-jobs { background: #dcfce7; color: #166534; }
.cat-orgs { background: #fef3c7; color: #92400e; }

/* Result Item */
.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    text-decoration: none;
    color: inherit;
    transition: background 0.1s ease;
    cursor: pointer;
}

.search-result-item:hover,
.search-result-item.highlighted {
    background: var(--gray-50, #f9fafb);
}

/* Avatar */
.result-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    background: var(--gray-100, #f3f4f6);
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.result-avatar.result-icon {
    background: var(--gray-100, #f3f4f6);
    color: var(--text-muted, #9ca3af);
}

.result-avatar.result-icon svg {
    width: 22px;
    height: 22px;
}

.result-avatar.result-org {
    border-radius: 8px;
}

.result-avatar .verified-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: var(--primary, #7c3aed);
    color: white;
    border-radius: 50%;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

.result-avatar.recent-icon {
    background: transparent;
    color: var(--text-muted, #9ca3af);
}

/* Result Info */
.result-info {
    flex: 1;
    min-width: 0;
}

.result-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary, #1f2937);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-title mark {
    background: #fef3c7;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

.result-subtitle {
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.result-meta {
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
    margin-top: 2px;
}

/* Type Badge */
.result-type-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.type-person { background: #dbeafe; color: #1e40af; }
.type-job { background: #dcfce7; color: #166534; }
.type-org { background: #fef3c7; color: #92400e; }
.type-post { background: #fce7f3; color: #9d174d; }

/* Recent Search Item */
.search-recent-item {
    position: relative;
}

.remove-recent {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--text-muted, #9ca3af);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.remove-recent svg {
    width: 16px;
    height: 16px;
}

.search-recent-item:hover .remove-recent {
    opacity: 1;
}

.remove-recent:hover {
    color: var(--danger, #ef4444);
}

/* Section Title */
.search-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted, #9ca3af);
    padding: 12px 16px 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Empty State */
.search-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-secondary, #6b7280);
}

.search-empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.search-empty p {
    font-size: 14px;
    font-weight: 500;
    margin: 0 0 4px;
}

.search-empty span {
    font-size: 12px;
    color: var(--text-muted, #9ca3af);
}

/* Loading */
.search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px 16px;
    color: var(--text-muted, #9ca3af);
}

.search-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200, #e5e7eb);
    border-top-color: var(--primary, #7c3aed);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Footer */
.search-footer {
    border-top: 1px solid var(--border, #e5e7eb);
    padding: 12px 16px;
    background: var(--gray-50, #f9fafb);
    flex-shrink: 0;
}

.search-see-all {
    display: block;
    text-align: center;
    color: var(--primary, #7c3aed);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.search-see-all:hover {
    text-decoration: underline;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #search-container {
        position: static;
        max-width: none;
        margin: 0;
    }
    
    #search-container.search-active {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: white;
        z-index: 9999;
        padding: 12px;
        display: flex;
        flex-direction: column;
    }
    
    #search-container.search-active #global-search {
        border-radius: 8px;
        background: var(--gray-100, #f3f4f6);
    }
    
    .search-dropdown {
        position: static;
        flex: 1;
        box-shadow: none;
        border-radius: 0;
        margin-top: 12px;
        max-height: none;
    }
    
    .search-dropdown.open {
        transform: none;
    }
    
    .search-results-container {
        max-height: none;
        flex: 1;
    }
    
    .search-filters {
        overflow-x: auto;
        padding: 8px 12px;
        gap: 6px;
    }
    
    .search-filter {
        padding: 8px 16px;
    }
    
    .result-avatar {
        width: 48px;
        height: 48px;
    }
    
    .search-result-item {
        padding: 12px 16px;
    }
    
    /* Mobile close button */
    #search-container.search-active::before {
        content: '←';
        position: absolute;
        left: 16px;
        top: 22px;
        font-size: 20px;
        cursor: pointer;
        z-index: 10;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    #search-container.search-active #global-search {
        padding-left: 48px;
    }
}

@media (max-width: 480px) {
    .result-type-badge {
        display: none;
    }
    
    .search-categories {
        padding: 6px 12px;
    }
    
    .cat-badge {
        font-size: 10px;
        padding: 2px 6px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .search-dropdown {
        background: #1f2937;
        border: 1px solid #374151;
    }
    
    #global-search {
        background: #374151;
        color: white;
    }
    
    #global-search:focus {
        background: #1f2937;
    }
    
    .search-result-item:hover,
    .search-result-item.highlighted {
        background: #374151;
    }
    
    .result-title {
        color: white;
    }
    
    .search-filters {
        background: #111827;
        border-color: #374151;
    }
    
    .search-footer {
        background: #111827;
        border-color: #374151;
    }
}
