/* ============================================================================
   Global Search Styles
   ============================================================================
   Styles for the global search bar in the header
   Works on both mobile and desktop with responsive design
============================================================================ */

/* ============================================================================
   Search Container
============================================================================ */
.header-search-container {
    flex-shrink: 0;
    position: relative;
    min-width: 180px;
}

/* Target the Mantine TextInput wrapper */
.global-search-input {
    background-color: white !important;
}

/* Target the actual input element */
.global-search-input input {
    background-color: white !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 6px !important;
    transition: all 0.2s ease;
    font-size: 13px;
    height: 32px;
    color: #212529 !important;
}

.global-search-input input:hover {
    border-color: #adb5bd !important;
    background-color: white !important;
}

.global-search-input input:focus {
    background-color: white !important;
    border-color: #4c6ef5 !important;
    box-shadow: 0 0 0 2px rgba(76, 110, 245, 0.1) !important;
}

.global-search-input input::placeholder {
    color: #adb5bd;
    font-size: 13px;
}

/* Ensure Mantine wrapper doesn't add extra backgrounds */
.global-search-input .mantine-TextInput-wrapper {
    background-color: transparent !important;
}

.global-search-input .mantine-Input-wrapper {
    background-color: transparent !important;
}

/* ============================================================================
   Search Results Dropdown
============================================================================ */
.global-search-results-dropdown {
    animation: fadeInDown 0.2s ease;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    z-index: 10000;
    min-width: 300px;
    background-color: white !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 8px !important;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    max-height: 400px;
    overflow-y: auto;
    color: #212529 !important;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Search result items */
.global-search-result-item {
    transition: all 0.15s ease;
    cursor: pointer;
    background-color: white !important;
    color: #212529 !important;
}

.global-search-result-item:hover {
    background-color: #f8f9fa !important;
    color: #212529 !important;
}

.global-search-result-item:active {
    background-color: #e9ecef !important;
    color: #212529 !important;
}

.global-search-result-item:last-child {
    border-bottom: none !important;
}

/* ============================================================================
   Responsive Design - Desktop
============================================================================ */
@media (min-width: 1200px) {
    .header-search-container {
        display: block;
    }
    
    .global-search-input {
        width: 180px;
    }
}

/* ============================================================================
   Responsive Design - Tablet
============================================================================ */
@media (max-width: 1199px) and (min-width: 768px) {
    .header-search-container {
        display: block;
    }
    
    .global-search-input {
        width: 160px;
    }
    
    .global-search-input input::placeholder {
        font-size: 12px;
    }
}

/* ============================================================================
   Responsive Design - Mobile
============================================================================ */
@media (max-width: 767px) {
    /* Hide desktop search completely on mobile - target header context */
    .mantine-AppShell-header .header-search-container,
    .mantine-Group-root .header-search-container {
        display: none !important;
    }
    
    /* Mobile drawer search wrapper */
    .mobile-drawer-search-wrapper {
        display: block !important;
        width: 100%;
        margin-bottom: 8px;
    }
    
    /* Mobile search in drawer - full width and integrated */
    .mobile-drawer-search-wrapper .header-search-container,
    .mantine-Drawer-body .header-search-container,
    [class*="Drawer-body"] .header-search-container {
        display: block !important;
        position: static !important;
        width: 100% !important;
    }
    
    .mobile-drawer-search-wrapper .global-search-input,
    .mantine-Drawer-body .global-search-input,
    [class*="Drawer-body"] .global-search-input {
        width: 100%;
    }
    
    .mobile-drawer-search-wrapper .global-search-input input,
    .mantine-Drawer-body .global-search-input input,
    [class*="Drawer-body"] .global-search-input input {
        font-size: 14px;
        height: 40px;
        background-color: white !important;
        width: 100%;
        border: 1px solid #dee2e6 !important;
        border-radius: 8px !important;
    }
    
    .mobile-drawer-search-wrapper .global-search-input input:focus,
    .mantine-Drawer-body .global-search-input input:focus,
    [class*="Drawer-body"] .global-search-input input:focus {
        border-color: #228be6 !important;
        box-shadow: 0 0 0 2px rgba(34, 139, 230, 0.1) !important;
    }
    
    /* Results dropdown in drawer - integrated layout */
    .mobile-drawer-search-wrapper .global-search-results-dropdown,
    .mantine-Drawer-body .global-search-results-dropdown,
    [class*="Drawer-body"] .global-search-results-dropdown {
        position: static !important;
        margin-top: 8px;
        left: auto !important;
        right: auto !important;
        width: 100%;
        z-index: 1 !important;
        border: 1px solid #e9ecef !important;
        border-radius: 8px !important;
        box-shadow: none !important;
        background-color: white !important;
    }
    
    /* Force visibility when results should show */
    .mobile-drawer-search-wrapper .global-search-results-dropdown[style*="display: block"],
    .mantine-Drawer-body .global-search-results-dropdown[style*="display: block"],
    [class*="Drawer-body"] .global-search-results-dropdown[style*="display: block"] {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* Search results styling for mobile drawer */
    .mobile-drawer-search-wrapper .global-search-result-item,
    .mantine-Drawer-body .global-search-result-item,
    [class*="Drawer-body"] .global-search-result-item {
        padding: 12px !important;
        border-bottom: 1px solid #f1f3f5 !important;
        transition: background-color 0.15s ease;
    }
    
    .mobile-drawer-search-wrapper .global-search-result-item:hover,
    .mantine-Drawer-body .global-search-result-item:hover,
    [class*="Drawer-body"] .global-search-result-item:hover {
        background-color: #f8f9fa !important;
    }
    
    .mobile-drawer-search-wrapper .global-search-result-item:last-child,
    .mantine-Drawer-body .global-search-result-item:last-child,
    [class*="Drawer-body"] .global-search-result-item:last-child {
        border-bottom: none !important;
    }
    
    /* Hide mobile-only sections in header */
    .mobile-only-section {
        display: none !important;
    }
    
    .mobile-search-container {
        display: none !important;
    }
}

/* Hide mobile search container on desktop */
@media (min-width: 768px) {
    .mobile-search-container {
        display: none;
    }
    
    .mobile-only-section {
        display: none !important;
    }
    
    .desktop-only-section {
        display: flex !important;
    }
}

/* ============================================================================
   Search Result Categories
============================================================================ */
.search-category-header {
    padding: 8px 12px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #868e96 !important;
    letter-spacing: 0.5px;
    background-color: white !important;
}

/* ============================================================================
   Search Loading State
============================================================================ */
.global-search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background-color: white !important;
    color: #212529 !important;
}
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* ============================================================================
   Clear Button
============================================================================ */
.global-search-clear {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.global-search-clear:hover {
    opacity: 1;
}

/* ============================================================================
   Keyboard Navigation Support
============================================================================ */
.global-search-result-item:focus {
    outline: 2px solid #4c6ef5;
    outline-offset: -2px;
    background-color: #f1f3f5 !important;
}

/* ============================================================================
   Badge Styles in Search Results
============================================================================ */
.global-search-result-item .mantine-Badge-root {
    font-size: 10px;
    height: 18px;
    padding: 0 6px;
}

/* ============================================================================
   Icon Styles in Search Results
============================================================================ */
.global-search-result-item svg {
    flex-shrink: 0;
    color: inherit !important;
}

/* Ensure all text elements in search results are visible */
.global-search-results-dropdown * {
    color: inherit;
}

.global-search-results-dropdown a {
    color: #212529 !important;
    text-decoration: none;
}

.global-search-results-dropdown a:hover {
    text-decoration: none;
}

/* ============================================================================
   Accessibility - High Contrast Mode
============================================================================ */
/* prefers-contrast media query not widely supported - omitted */

/* ============================================================================
   Dark Mode Support (future-proofing) - DISABLED by default
   Only applies when explicitly enabled via data-theme attribute
============================================================================ */
[data-theme="dark"] .global-search-input input {
    background-color: #25262b;
    border-color: #373a40;
    color: #c1c2c5;
}

[data-theme="dark"] .global-search-input input:focus {
    background-color: #1a1b1e;
    border-color: #5c7cfa;
}

[data-theme="dark"] .global-search-result-item:hover {
    background-color: #25262b !important;
}

[data-theme="dark"] .global-search-results-dropdown {
    background-color: #1a1b1e;
    border-color: #373a40;
}
