/* ============================================
   Global Search Styles
   ============================================ */

/* Hide native browser clear button on search inputs */
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration {
    display: none;
    -webkit-appearance: none;
}

/* Search Wrapper States */
.search-wrapper {
    position: relative;
    transition: all 0.2s ease;
}

.search-wrapper.focused {
    z-index: 1050;
}

.search-wrapper .clear-btn {
    display: none;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.search-wrapper .clear-btn:hover {
    opacity: 1;
}

/* Results Dropdown */
.search-results-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    max-height: 600px;
    overflow-y: auto;
    z-index: 1051;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar styling */
.search-results-dropdown::-webkit-scrollbar {
    width: 8px;
}

.search-results-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.search-results-dropdown::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.search-results-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Results Header */
.search-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-body);
    border-radius: 6px 6px 0 0;
    position: sticky;
    top: 0;
    z-index: 1;
    gap: 12px;
    flex-wrap: wrap;
}

.search-results-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-scope-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-color);
    background: rgba(var(--accent-rgb), 0.1);
    padding: 4px 10px;
    border-radius: 8px;
}

.search-scope-badge i {
    font-size: 11px;
}

/* Results Footer */
.search-results-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-body);
    position: sticky;
    bottom: 0;
    z-index: 1;
}

.search-communities-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    justify-content: center;
}

.search-communities-summary i {
    font-size: 13px;
    opacity: 0.7;
}

/* Community Badge in Results */
.community-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    /*padding: 3px 8px;*/
    border-radius: 12px;
    background: rgba(var(--accent-rgb), 0.15);
    color: var(--accent-color);
    white-space: nowrap;
}

.community-badge i {
    font-size: 10px;
}

.clear-history-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.clear-history-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

[data-theme="dark"] .clear-history-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Section Headers */
.search-results-section {
    border-bottom: 1px solid var(--border-color);
}

.search-results-section:last-child {
    border-bottom: none;
}

.search-results-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-body);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 45px;
    z-index: 1;
}

.search-results-section-header i {
    font-size: 14px;
}

.search-results-section-count {
    margin-left: auto;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}

[data-theme="dark"] .search-results-section-count {
    background: rgba(255, 255, 255, 0.05);
}

/* Result Items */
.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.15s ease;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.search-result-item:hover,
.search-result-item.focused {
    background: rgba(0, 0, 0, 0.03);
    border-left-color: var(--primary);
}

[data-theme="dark"] .search-result-item:hover,
[data-theme="dark"] .search-result-item.focused {
    background: rgba(255, 255, 255, 0.05);
}

.search-result-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.property-icon {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.resident-icon {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
}

.contact-icon {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.community-icon {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.poll-icon {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.vehicle-icon {
    background: rgba(249, 115, 22, 0.1);
    color: #f97316;
}

.parkingspace-icon {
    background: rgba(13, 148, 136, 0.1);
    color: #0d9488;
}

.search-result-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.search-result-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    word-spacing: 0;
    letter-spacing: 0;
}

.search-result-title mark {
    background: rgba(var(--accent-rgb), 0.2);
    color: var(--accent-color);
    padding: 0;
    border-radius: 0;
    display: inline;
    margin: 0;
    border: 0;
    word-spacing: 0;
    letter-spacing: 0;
    font: inherit;
    line-height: inherit;
}

.search-result-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
    line-height: 1.4;
    margin-bottom: 4px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary);
    flex-wrap: wrap;
    margin-top: 6px;
}

.search-result-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.search-result-meta i {
    font-size: 11px;
    opacity: 0.7;
}

.search-result-meta mark {
    background: rgba(var(--accent-rgb), 0.15);
    color: var(--accent-color);
    padding: 1px 3px;
    border-radius: 3px;
}

.visit-time {
    color: var(--text-muted);
    font-size: 11px;
    opacity: 0.8;
}

.recent-visit-item {
    opacity: 0.95;
}

.recent-visit-item:hover {
    opacity: 1;
}

.search-result-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 8px;
    background: var(--bg-body);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.owner-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 8px;
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.owner-badge i {
    font-size: 10px;
}

/* Contact Type Badges */
.contact-type-general {
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
}

.contact-type-vendor {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.contact-type-contractor {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.contact-type-emergency {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.contact-type-service-provider {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

/* Poll Status Badges */
.poll-status-active {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 8px;
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.poll-status-closed {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 8px;
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
}

/* Search History */
.search-history-list {
    padding: 4px;
}

.search-history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s ease;
    color: var(--text-primary);
}

.search-history-item:hover,
.search-history-item.focused {
    background: rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .search-history-item:hover,
[data-theme="dark"] .search-history-item.focused {
    background: rgba(255, 255, 255, 0.05);
}

.search-history-item i {
    color: var(--text-muted);
    font-size: 14px;
}

.search-history-text {
    flex: 1;
    font-size: 14px;
}

.search-history-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-history-item:hover .search-history-remove {
    opacity: 1;
}

.search-history-remove:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

[data-theme="dark"] .search-history-remove:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Loading State */
.search-loading {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-loading-skeleton {
    height: 60px;
    background: linear-gradient(
        90deg,
        var(--surface-secondary) 0%,
        var(--surface-hover) 50%,
        var(--surface-secondary) 100%
    );
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
    border-radius: 10px;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Info, Empty, Error States */
.search-info,
.search-empty,
.search-error {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-secondary);
}

.search-info i,
.search-empty i,
.search-error i {
    font-size: 32px;
    opacity: 0.5;
    margin-bottom: 12px;
    display: block;
}

.search-empty-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.search-empty-text {
    font-size: 14px;
}

.search-error {
    color: var(--danger-color);
}

.search-error i {
    color: var(--danger-color);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .search-results-dropdown {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: none;
        border-radius: 0;
        border: none;
        border-top: 1px solid var(--border-color);
    }

    .search-results-section-header {
        top: 0;
    }

    .search-result-item {
        padding: 16px;
    }

    .search-result-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
}

/* Dark mode adjustments */
[data-theme="dark"] .search-results-dropdown {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .search-result-title mark {
    background: rgba(var(--accent-rgb), 0.3);
}

/* Keyboard navigation highlight */
.search-result-item.focused::before,
.search-history-item.focused::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-color);
}

/* Ensure proper positioning for ::before pseudo-element */
.search-result-item,
.search-history-item {
    position: relative;
}
