/* ==========================================================================
   GLOBAL SEARCH STYLES (Spotlight & Sidebar Integration)
   ========================================================================== */

/* --- Sidebar Search Trigger (Desktop) --- */
.sidebar-search-box {
    width: 100%;
    margin-top: 4px;
    margin-bottom: 8px;
}

.sidebar-search-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 9px 14px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    text-align: left;
}

.sidebar-search-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    transform: translateY(-1px);
}

.sidebar-search-icon {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.75);
}

.sidebar-search-placeholder {
    flex: 1;
    font-weight: 400;
}

.sidebar-search-kbd {
    font-size: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.65);
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    padding: 2px 6px;
    line-height: 1;
}

/* --- Page Header Search Trigger Button (Desktop & Tablet) --- */
.global-search-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    color: #475569;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.global-search-trigger-btn:hover {
    border-color: #6366f1;
    color: #4f46e5;
    background: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(99, 102, 241, 0.15);
}

.btn-sm.global-search-trigger-btn {
    padding: 4px 10px;
    font-size: 12.5px;
    border-radius: 6px;
}

.search-kbd-badge {
    display: inline-block;
    padding: 2px 6px;
    font-size: 10px;
    font-family: inherit;
    font-weight: 600;
    line-height: 1;
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

[data-theme="dark"] .global-search-trigger-btn,
[data-bs-theme="dark"] .global-search-trigger-btn,
body.dark-theme .global-search-trigger-btn,
.dark .global-search-trigger-btn {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.75);
    box-shadow: none;
}

[data-theme="dark"] .global-search-trigger-btn:hover,
[data-bs-theme="dark"] .global-search-trigger-btn:hover,
body.dark-theme .global-search-trigger-btn:hover,
.dark .global-search-trigger-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(129, 140, 248, 0.6);
    color: #ffffff;
    box-shadow: 0 3px 12px rgba(99, 102, 241, 0.25);
}

[data-theme="dark"] .search-kbd-badge,
[data-bs-theme="dark"] .search-kbd-badge,
body.dark-theme .search-kbd-badge,
.dark .search-kbd-badge {
    background: rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.65);
}

/* Collapsed Sidebar Search (if present) */
.sidebar.collapsed .sidebar-search-box {
    padding-left: 8px !important;
    padding-right: 8px !important;
    display: flex;
    justify-content: center;
}

.sidebar.collapsed .sidebar-search-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
    border-radius: 10px;
}

.sidebar.collapsed .sidebar-search-placeholder,
.sidebar.collapsed .sidebar-search-kbd {
    display: none !important;
}

.sidebar.collapsed .sidebar-search-icon {
    margin: 0;
    font-size: 15px;
}

/* --- Spotlight Modal / Command Palette --- */
.global-spotlight-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 8vh 16px 24px;
    animation: spotlightFadeIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.global-spotlight-dialog {
    width: 100%;
    max-width: 680px;
    background: var(--surface-card, #ffffff);
    border: 1px solid var(--surface-border, #e2e8f0);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: spotlightSlideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.global-spotlight-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--surface-border, #f1f5f9);
    background: var(--surface-card, #ffffff);
}

.global-spotlight-icon {
    font-size: 18px;
    color: var(--primary-color, #4f46e5);
}

.global-spotlight-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 16px;
    color: var(--surface-text, #1e293b);
    font-family: inherit;
    padding: 4px 0;
}

.global-spotlight-input::placeholder {
    color: var(--surface-text-muted, #94a3b8);
}

.global-spotlight-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.global-spotlight-clear {
    background: none;
    border: none;
    color: var(--surface-text-muted, #94a3b8);
    font-size: 14px;
    padding: 4px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.global-spotlight-clear:hover {
    color: var(--surface-text, #1e293b);
    background: var(--surface-hover, #f1f5f9);
}

.global-spotlight-spinner {
    color: var(--primary-color, #4f46e5);
    width: 1.1rem;
    height: 1.1rem;
    border-width: 0.15em;
}

.global-spotlight-esc {
    font-size: 11px;
    font-weight: 700;
    color: var(--surface-text-muted, #64748b);
    background: var(--surface-sunken, #f1f5f9);
    border: 1px solid var(--surface-border, #cbd5e1);
    border-radius: 6px;
    padding: 3px 7px;
    cursor: pointer;
    user-select: none;
}

.global-spotlight-esc:hover {
    background: var(--surface-hover, #e2e8f0);
}

.global-spotlight-hints {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    background: var(--surface-card, #ffffff);
    flex-wrap: wrap;
}

.spotlight-hint-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--surface-text-muted, #94a3b8);
    margin-right: 4px;
}

.spotlight-hint-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--surface-sunken, #f8fafc);
    border: 1px solid var(--surface-border, #f1f5f9);
    color: var(--surface-text, #475569);
}

.global-spotlight-results {
    max-height: 440px;
    overflow-y: auto;
    background: var(--surface-card, #ffffff);
}

.global-spotlight-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--surface-sunken, #f8fafc);
    border-top: 1px solid var(--surface-border, #f1f5f9);
    font-size: 12px;
    color: var(--surface-text-muted, #64748b);
}

.spotlight-shortcuts {
    display: flex;
    align-items: center;
    gap: 12px;
}

.spotlight-shortcuts kbd {
    background: var(--surface-card, #ffffff);
    border: 1px solid var(--surface-border, #cbd5e1);
    color: var(--surface-text-muted, #64748b);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 10px;
    margin-right: 3px;
}

.spotlight-more-link {
    font-weight: 600;
    color: var(--primary-color, #4f46e5);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.spotlight-more-link:hover {
    text-decoration: underline;
}

/* --- Dropdown Results & Groups --- */
.search-dropdown-group {
    border-bottom: 1px solid var(--surface-border, #f1f5f9);
    padding: 6px 0;
}

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

.search-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 18px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--surface-text-muted, #64748b);
}

.search-group-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--surface-sunken, #f1f5f9);
    color: var(--surface-text-muted, #64748b);
}

.search-dropdown-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 18px;
    text-decoration: none;
    color: var(--surface-text, #1e293b);
    transition: background 0.15s ease;
    cursor: pointer;
}

.search-dropdown-item:hover,
.search-dropdown-item.is-selected {
    background: var(--surface-hover, #f8fafc);
    text-decoration: none;
    color: var(--surface-text, #1e293b);
}

.search-item-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    margin-top: 2px;
}

.search-item-icon.task-icon {
    background: rgba(79, 70, 229, 0.1);
    color: #4f46e5;
}

.search-item-icon.comment-icon {
    background: rgba(14, 165, 233, 0.1);
    color: #0ea5e9;
}

.search-item-icon.message-icon {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.search-item-icon.project-icon {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.search-item-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    margin-top: 2px;
}

.search-item-avatar-placeholder {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-color, #4f46e5);
    color: white;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

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

.search-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
}

.search-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--surface-text, #1e293b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-item-snippet {
    font-size: 12px;
    color: var(--surface-text-muted, #64748b);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-dropdown-empty {
    padding: 28px 20px;
    text-align: center;
    color: var(--surface-text-muted, #64748b);
    font-size: 14px;
}

/* --- Search Highlight --- */
mark.search-highlight {
    background-color: rgba(254, 240, 138, 0.85);
    color: #854d0e;
    padding: 1px 4px;
    border-radius: 4px;
    font-weight: 600;
}

/* --- Search Results Page --- */
.search-results-page {
    max-width: 1100px;
    margin: 0 auto;
    padding-bottom: 60px;
}

.search-hero-card {
    background: var(--surface-card, #ffffff);
    border: 1px solid var(--surface-border, #e2e8f0);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
}

.search-page-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--surface-sunken, #f8fafc);
    border: 2px solid var(--surface-border, #e2e8f0);
    border-radius: 12px;
    padding: 4px 16px;
    transition: all 0.2s ease;
}

.search-page-input-wrapper:focus-within {
    border-color: var(--primary-color, #4f46e5);
    background: var(--surface-card, #ffffff);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.search-page-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 16px;
    color: var(--surface-text, #1e293b);
    padding: 10px 0;
    font-family: inherit;
}

.search-page-btn {
    border-radius: 10px;
    padding: 10px 22px;
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Filter Tabs */
.search-filter-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--surface-border, #f1f5f9);
}

.search-filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--surface-text, #475569);
    background: var(--surface-sunken, #f1f5f9);
    border: 1px solid var(--surface-border, #e2e8f0);
    text-decoration: none;
    transition: all 0.2s ease;
}

.search-filter-tab:hover {
    background: var(--surface-hover, #e2e8f0);
    color: var(--surface-text, #1e293b);
    text-decoration: none;
}

.search-filter-tab.active {
    background: var(--primary-color, #4f46e5);
    color: #ffffff;
    border-color: var(--primary-color, #4f46e5);
}

.search-tab-count {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.08);
    font-weight: 600;
}

.search-filter-tab.active .search-tab-count {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* Section Header */
.search-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 28px 0 16px 0;
}

.search-section-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--surface-text, #1e293b);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.search-section-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    background: var(--surface-sunken, #f1f5f9);
    color: var(--surface-text-muted, #64748b);
}

/* Result Cards */
.search-card {
    background: var(--surface-card, #ffffff);
    border: 1px solid var(--surface-border, #e2e8f0);
    border-radius: 14px;
    padding: 18px 20px;
    margin-bottom: 12px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    display: block;
    color: inherit;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.search-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
    border-color: rgba(79, 70, 229, 0.3);
    text-decoration: none;
    color: inherit;
}

.search-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.search-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--surface-text, #1e293b);
    margin: 0;
    line-height: 1.4;
}

.search-card-snippet {
    font-size: 13px;
    color: var(--surface-text-muted, #64748b);
    line-height: 1.5;
    margin-bottom: 12px;
}

.search-card-footer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: var(--surface-text-muted, #64748b);
}

.search-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* User search card */
.user-search-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
}

.user-search-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.user-search-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.user-search-avatar-placeholder {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary-color, #4f46e5);
    color: white;
    font-weight: 700;
    font-size: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Empty State */
.search-empty-state {
    text-align: center;
    padding: 48px 24px;
    background: var(--surface-card, #ffffff);
    border: 1px dashed var(--surface-border, #cbd5e1);
    border-radius: 16px;
    margin: 32px 0;
}

.search-empty-icon {
    font-size: 44px;
    color: var(--surface-text-muted, #94a3b8);
    margin-bottom: 16px;
}

.search-empty-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--surface-text, #1e293b);
    margin-bottom: 8px;
}

.search-empty-desc {
    font-size: 14px;
    color: var(--surface-text-muted, #64748b);
    max-width: 480px;
    margin: 0 auto;
}

/* --- Dark Theme Overrides --- */
[data-theme="dark"] .global-spotlight-backdrop {
    background: rgba(10, 15, 26, 0.72);
}

[data-theme="dark"] .global-spotlight-dialog,
[data-theme="dark"] .global-spotlight-header,
[data-theme="dark"] .global-spotlight-hints,
[data-theme="dark"] .global-spotlight-results {
    background: var(--surface-card, #1e293b);
    border-color: var(--surface-border, #334155);
}

[data-theme="dark"] .global-spotlight-footer {
    background: var(--surface-sunken, #0f172a);
    border-color: var(--surface-border, #334155);
}

[data-theme="dark"] .global-spotlight-esc,
[data-theme="dark"] .spotlight-shortcuts kbd,
[data-theme="dark"] .spotlight-hint-chip {
    background: var(--surface-sunken, #0f172a);
    border-color: var(--surface-border, #334155);
    color: #94a3b8;
}

[data-theme="dark"] .search-dropdown-group {
    border-bottom-color: var(--surface-border, #334155);
}

[data-theme="dark"] .search-dropdown-item:hover,
[data-theme="dark"] .search-dropdown-item.is-selected {
    background: var(--surface-hover, #283548);
}

[data-theme="dark"] mark.search-highlight {
    background-color: rgba(234, 179, 8, 0.25);
    color: #fef08a;
    border: 1px solid rgba(234, 179, 8, 0.35);
}

[data-theme="dark"] .search-hero-card {
    background: var(--surface-card, #1e293b);
    border-color: var(--surface-border, #334155);
}

[data-theme="dark"] .search-page-input-wrapper {
    background: var(--surface-sunken, #0f172a);
    border-color: var(--surface-border, #334155);
}

[data-theme="dark"] .search-filter-tab {
    background: var(--surface-sunken, #0f172a);
    border-color: var(--surface-border, #334155);
    color: #cbd5e1;
}

[data-theme="dark"] .search-filter-tab:hover {
    background: var(--surface-hover, #283548);
    color: #ffffff;
}

[data-theme="dark"] .search-filter-tab.active {
    background: var(--primary-color, #4f46e5);
    color: #ffffff;
}

[data-theme="dark"] .search-card {
    background: var(--surface-card, #1e293b);
    border-color: var(--surface-border, #334155);
}

[data-theme="dark"] .search-card:hover {
    background: var(--surface-card, #1e293b);
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .search-empty-state {
    background: var(--surface-card, #1e293b);
    border-color: var(--surface-border, #334155);
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    /* Скрываем кнопки быстрого поиска в контенте страниц на мобильных (поиск остаётся ТОЛЬКО в мобильной шапке) */
    .global-search-trigger-btn {
        display: none !important;
    }

    /* Скрываем пункт "Поиск" в мобильном меню-сайдбаре (иконка поиска уже есть в шапке) */
    .mobile-hide-search,
    #sidebarSearchNavLink {
        display: none !important;
    }

    /* Оптимизация всплывающего окна Spotlight для мобильных */
    .global-spotlight-backdrop {
        padding: 8px 8px 16px;
        align-items: flex-start;
    }

    .global-spotlight-dialog {
        border-radius: 14px;
        max-height: calc(100vh - 16px);
    }

    .global-spotlight-header {
        padding: 10px 14px;
        gap: 10px;
    }

    .global-spotlight-input {
        font-size: 16px; /* 16px предотвращает нежелательный зум страницы на iOS Safari */
    }

    .global-spotlight-esc {
        font-size: 11px;
        padding: 4px 8px;
    }

    /* Скрываем горячие клавиши стрелок и Esc на мобильных устройствах */
    .spotlight-shortcuts {
        display: none !important;
    }

    .global-spotlight-footer {
        padding: 8px 14px;
        justify-content: flex-end;
    }

    .global-spotlight-hints {
        padding: 8px 14px;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .global-spotlight-hints::-webkit-scrollbar {
        display: none;
    }

    .spotlight-hint-chip {
        white-space: nowrap;
        font-size: 11.5px;
    }

    .search-hero-card {
        padding: 16px;
    }

    .search-filter-tabs {
        gap: 6px;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .search-filter-tab {
        padding: 5px 11px;
        font-size: 12px;
        white-space: nowrap;
    }
}

