/* =============================================================
   Global Search (Ctrl+K) — Spotlight-style modal
   ============================================================= */

.global-search-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
}

.global-search-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.global-search-wrapper {
    position: relative;
    width: 100%;
    max-width: 680px;
}

.global-search-container {
    position: relative;
    width: 100%;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    animation: globalSearchFadeIn 0.15s ease-out;
    display: flex;
    flex-direction: column;
    max-height: 70vh;
}

@keyframes globalSearchFadeIn {
    from { opacity: 0; transform: scale(0.98) translateY(-8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Input */
.global-search-input-wrapper {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #f1f1f4;
    gap: 12px;
}

.global-search-icon {
    flex-shrink: 0;
}

.global-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1.1rem;
    font-weight: 500;
    color: #1b1b28;
    background: transparent;
    line-height: 1.5;
}

.global-search-input::placeholder {
    color: #a1a5b7;
    font-weight: 400;
}

.global-search-kbd {
    flex-shrink: 0;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #a1a5b7;
    background: #f9f9f9;
    border: 1px solid #e8e8e8;
    border-radius: 4px;
    font-family: inherit;
}

/* Body/Results */
.global-search-body {
    overflow-y: auto;
    padding: 12px 8px;
    flex: 1;
    min-height: 80px;
    max-height: calc(70vh - 120px);
}

.global-search-section-title {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #a1a5b7;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.global-search-category-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #7e8299;
}

.global-search-category-icon {
    width: 18px;
    text-align: center;
}

/* Result Item */
.global-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: background 0.1s;
}

.global-search-item:hover,
.global-search-item.active {
    background: #f1f1f4;
    color: inherit;
    text-decoration: none;
}

.global-search-item-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    flex-shrink: 0;
    font-size: 1rem;
}

.global-search-item-icon.bg-offer { background: rgba(0, 158, 247, 0.1); color: #009ef7; }
.global-search-item-icon.bg-client { background: rgba(80, 205, 137, 0.1); color: #50cd89; }
.global-search-item-icon.bg-work_order { background: rgba(255, 199, 0, 0.1); color: #ffc700; }
.global-search-item-icon.bg-grant_application { background: rgba(114, 57, 234, 0.1); color: #7239ea; }
.global-search-item-icon.bg-tag { background: rgba(241, 65, 108, 0.1); color: #f1416c; }

.global-search-item-content {
    flex: 1;
    min-width: 0;
}

.global-search-item-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1b1b28;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.global-search-item-subtitle {
    font-size: 0.8rem;
    color: #a1a5b7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.global-search-item-status {
    flex-shrink: 0;
}

.global-search-item-tags {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* Text highlight */
.global-search-item mark {
    background: rgba(0, 158, 247, 0.2);
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

/* Empty / Hint */
.global-search-empty-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}

/* Preview Card — positioned relative to wrapper (outside container to avoid overflow:hidden) */
.global-search-preview {
    position: absolute;
    left: calc(100% + 20px);
    top: 80px;
    width: 260px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    animation: globalSearchPreviewIn 0.12s ease-out;
}

@keyframes globalSearchPreviewIn {
    from { opacity: 0; transform: translateX(-4px); }
    to { opacity: 1; transform: translateX(0); }
}

.global-search-preview-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f1f4;
    font-size: 0.85rem;
}

.global-search-preview-body {
    padding: 12px 16px;
}

.global-search-preview-field {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.8rem;
}

.global-search-preview-field-label {
    color: #a1a5b7;
    font-weight: 500;
}

.global-search-preview-field-value {
    color: #1b1b28;
    font-weight: 600;
    text-align: right;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Footer */
.global-search-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-top: 1px solid #f1f1f4;
    gap: 12px;
}

.global-search-footer kbd {
    padding: 1px 6px;
    font-size: 0.65rem;
    font-weight: 700;
    color: #a1a5b7;
    background: #f9f9f9;
    border: 1px solid #e8e8e8;
    border-radius: 3px;
    font-family: inherit;
    margin: 0 2px;
}

/* ==========================================
   Dark Mode
   ========================================== */

[data-bs-theme="dark"] .global-search-backdrop {
    background: rgba(0, 0, 0, 0.65);
}

[data-bs-theme="dark"] .global-search-container {
    background: #1e1e2d;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

[data-bs-theme="dark"] .global-search-input-wrapper {
    border-bottom-color: #2b2b40;
}

[data-bs-theme="dark"] .global-search-input {
    color: #cdcdde;
}

[data-bs-theme="dark"] .global-search-input::placeholder {
    color: #636674;
}

[data-bs-theme="dark"] .global-search-kbd {
    background: #2b2b40;
    border-color: #363653;
    color: #636674;
}

[data-bs-theme="dark"] .global-search-item:hover,
[data-bs-theme="dark"] .global-search-item.active {
    background: #2b2b40;
}

[data-bs-theme="dark"] .global-search-item-label {
    color: #cdcdde;
}

[data-bs-theme="dark"] .global-search-item-subtitle {
    color: #636674;
}

[data-bs-theme="dark"] .global-search-category-title {
    color: #636674;
}

[data-bs-theme="dark"] .global-search-section-title {
    color: #636674;
}

[data-bs-theme="dark"] .global-search-footer {
    border-top-color: #2b2b40;
}

[data-bs-theme="dark"] .global-search-footer kbd {
    background: #2b2b40;
    border-color: #363653;
    color: #636674;
}

[data-bs-theme="dark"] .global-search-preview {
    background: #1e1e2d;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .global-search-preview-header {
    border-bottom-color: #2b2b40;
}

[data-bs-theme="dark"] .global-search-preview-field-value {
    color: #cdcdde;
}

[data-bs-theme="dark"] .global-search-item mark {
    background: rgba(0, 158, 247, 0.3);
}

/* ==========================================
   Responsive
   ========================================== */

@media (max-width: 1100px) {
    .global-search-preview {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .global-search-overlay {
        padding-top: 0;
    }

    .global-search-container {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .global-search-body {
        max-height: calc(100vh - 120px);
    }
}
