/* Global Search Styles */
:root {
    --search-width: 500px;
    --search-height: 42px;
    --search-bg: #fff;
    --search-border: #e2e8f0;
    --search-text: #1e293b;
    --search-placeholder: #94a3b8;
    --search-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --search-dropdown-width: 520px;
    --search-highlight: #f1f5f9;
    --search-category-bg: #f8fafc;
    --search-category-text: #64748b;
    --search-shortcut-bg: #f1f5f9;
    --search-shortcut-text: #64748b;
}

/* Global Search Container - Inline layout, NOT absolute */
.global-search-container {
    position: relative;
    width: var(--search-width);
    flex-shrink: 0;
}

.global-search-input-wrapper {
    position: relative;
    width: 100%;
    height: var(--search-height);
    display: flex;
    align-items: center;
}

.global-search-input {
    width: 100%;
    height: 100%;
    padding: 0 56px 0 40px;
    border: 1px solid var(--search-border);
    border-radius: 9999px;
    background-color: var(--search-bg);
    color: var(--search-text);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.global-search-input::placeholder {
    color: var(--search-placeholder);
    font-weight: 400;
}

.global-search-input:focus {
    outline: none;
    border-color: var(--primary-500, #4f46e5);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.global-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--search-placeholder);
    font-size: 1.1rem;
    pointer-events: none;
}

.global-search-shortcut {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 22px;
    padding: 0 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--search-shortcut-text);
    background-color: var(--search-shortcut-bg);
    border-radius: 4px;
    pointer-events: none;
    border: 1px solid #e2e8f0;
}

.global-search-spinner {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-500, #4f46e5);
    display: none;
}

.global-search-spinner.active {
    display: block;
    animation: spin 1s linear infinite;
}

/* Hide shortcut when spinner is active */
.global-search-spinner.active+.global-search-shortcut,
.global-search-input:focus~.global-search-shortcut {
    display: none;
}

/* Search Dropdown Results */
.global-search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: var(--search-dropdown-width);
    max-height: 70vh;
    overflow-y: auto;
    background-color: #fff;
    border: 1px solid var(--search-border);
    border-radius: 12px;
    box-shadow: var(--search-shadow);
    display: none;
    flex-direction: column;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.global-search-dropdown.show {
    display: flex;
    opacity: 1;
}

/* Category Sections */
.search-category {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
    border-bottom: 1px solid var(--search-border);
}

.search-category:last-child {
    border-bottom: none;
}

.search-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px 4px 16px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--search-category-text);
}

.search-view-all {
    font-size: 0.7rem;
    color: var(--primary-500, #4f46e5);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.search-view-all:hover {
    text-decoration: underline;
}

/* Result Items */
.search-result-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--search-text);
    transition: background-color 0.1s ease;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.search-result-item:hover,
.search-result-item.selected {
    background-color: var(--search-highlight);
    border-left-color: var(--primary-500, #4f46e5);
}

.search-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background-color: #f1f5f9;
    border-radius: 8px;
    color: #64748b;
    margin-right: 12px;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.search-result-item:hover .search-item-icon,
.search-result-item.selected .search-item-icon {
    background-color: #e0e7ff;
    color: #4f46e5;
}

.search-item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.search-item-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-item-subtitle {
    font-size: 0.75rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-item-status {
    padding: 2px 8px;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 9999px;
    background-color: #f1f5f9;
    color: #64748b;
    margin-left: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Status Colors */
.status-paid,
.status-active,
.status-confirmed,
.status-delivered {
    background-color: #dcfce7;
    color: #166534;
}

.status-unpaid,
.status-cancelled,
.status-void {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-pending,
.status-partial,
.status-received {
    background-color: #fef3c7;
    color: #92400e;
}

/* Empty State */
.search-empty-state {
    padding: 32px;
    text-align: center;
    color: #64748b;
}

.search-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Mobile Responsiveness */
@media (max-width: 991px) {
    .global-search-container {
        width: 100%;
        max-width: 300px;
    }

    .global-search-shortcut {
        display: none;
    }

    .global-search-dropdown {
        width: 100%;
        min-width: 300px;
    }
}

@media (max-width: 767px) {
    .global-search-container {
        display: none;
    }
}

@keyframes spin {
    from {
        transform: translateY(-50%) rotate(0deg);
    }

    to {
        transform: translateY(-50%) rotate(360deg);
    }
}