    /* CSS Variables */
    /* Accent colors are defined in globals.css */
    :root {
        /* Light mode */
        --search-bg: #ffffff;
        --search-border: #e5e7eb;
        --search-text: #1f2937;
        --search-placeholder: #9ca3af;
        --search-shadow: rgba(0, 0, 0, 0.1);
        --dropdown-bg: #ffffff;
        --dropdown-border: #e5e7eb;
        --hover-bg: #f9fafb;
        
        /* Chat colors */
        --bg-primary: #ffffff;
        --bg-secondary: #f8f9fa;
        --bg-tertiary: #e9ecef;
        --text-primary: #1a1a1a;
        --text-secondary: #6c757d;
        --text-tertiary: #adb5bd;
        --border-color: #dee2e6;
        --shadow: rgba(0, 0, 0, 0.1);
    }

    @media (prefers-color-scheme: dark) {
        :root {
            --accent-light: rgba(224, 120, 86, 0.15);
            --search-bg: #18181b;
            --search-border: #3f3f46;
            --search-text: #fafafa;
            --search-placeholder: #71717a;
            --search-shadow: rgba(0, 0, 0, 0.5);
            --dropdown-bg: #27272a;
            --dropdown-border: #3f3f46;
            --hover-bg: #3f3f46;
            
            --bg-primary: #18181b;
            --bg-secondary: #27272a;
            --bg-tertiary: #3f3f46;
            --text-primary: #fafafa;
            --text-secondary: #a1a1aa;
            --text-tertiary: #71717a;
            --border-color: #3f3f46;
            --shadow: rgba(0, 0, 0, 0.5);
        }
    }

    .dark {
        --accent-light: rgba(224, 120, 86, 0.15);
        --search-bg: #18181b;
        --search-border: #3f3f46;
        --search-text: #fafafa;
        --search-placeholder: #71717a;
        --search-shadow: rgba(0, 0, 0, 0.5);
        --dropdown-bg: #27272a;
        --dropdown-border: #3f3f46;
        --hover-bg: #3f3f46;
        
        --bg-primary: #18181b;
        --bg-secondary: #27272a;
        --bg-tertiary: #3f3f46;
        --text-primary: #fafafa;
        --text-secondary: #a1a1aa;
        --text-tertiary: #71717a;
        --border-color: #3f3f46;
        --shadow: rgba(0, 0, 0, 0.5);
    }

    /* Search Container */
    .search-chat-container {
        position: relative;
        width: 100%;
        max-width: 700px;
        margin: 0 auto;
    }
    
    .search-chat-wrapper {
        position: relative;
        display: flex;
        align-items: center;
    }
    
    .search-chat-input {
        width: 100%;
        padding: 14px 120px 14px 44px;
        background: var(--search-bg);
        border: 2px solid var(--search-border);
        border-radius: 16px;
        font-size: 15px;
        color: var(--search-text);
        transition: all 0.3s ease;
        outline: none;
        box-shadow: 0 1px 3px var(--search-shadow);
    }
    
    .search-chat-input::placeholder {
        color: var(--search-placeholder);
    }
    
    .search-chat-input:focus {
        border-color: var(--accent-color);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-color) 20%, transparent), 0 4px 6px var(--search-shadow);
        transform: translateY(-1px);
        outline: none;
    }
    
    .search-chat-container.ai-mode .search-chat-input {
        background: linear-gradient(135deg, rgba(224, 120, 86, 0.05) 0%, rgba(245, 158, 11, 0.05) 100%);
        border-color: var(--accent-color);
    }
    
    .search-chat-icon {
        position: absolute;
        left: 14px;
        top: 50%;
        transform: translateY(-50%);
        width: 20px;
        height: 20px;
        color: var(--search-placeholder);
        pointer-events: none;
        transition: color 0.3s ease;
    }
    
    .search-chat-container.ai-mode .search-chat-icon {
        color: var(--accent-color);
    }
    
    .search-chat-loading {
        position: absolute;
        right: 120px;
        top: 50%;
        transform: translateY(-50%);
        display: none;
    }
    
    .search-chat-loading.active {
        display: block;
    }
    
    .search-chat-loading svg {
        width: 18px;
        height: 18px;
        color: var(--accent-color);
        animation: spin 1s linear infinite;
    }
    
    @keyframes spin {
        from { transform: rotate(0deg); }
        to { transform: rotate(360deg); }
    }
    
    .shoey-badge-inline {
        position: absolute;
        right: 12px;
        top: 50%;
        transform: translateY(-50%);
        padding: 6px 14px;
        background: transparent;
        border: 2px solid var(--search-border);
        border-radius: 12px;
        font-size: 13px;
        font-weight: 600;
        color: var(--search-placeholder);
        cursor: pointer;
        transition: all 0.2s ease;
        display: flex;
        align-items: center;
        gap: 6px;
        white-space: nowrap;
        z-index: 10;
    }
    
    .shoey-badge-inline:hover {
        background: color-mix(in srgb, var(--accent-color) 15%, transparent);
        border-color: var(--accent-color);
        color: var(--accent-color);
        transform: translateY(-50%) scale(1.05);
    }
    
    .shoey-badge-inline svg {
        width: 14px;
        height: 14px;
    }
    
    .search-chat-container.ai-mode .shoey-badge-inline {
        background: linear-gradient(135deg, #E07856 0%, #f59e0b 100%);
        border-color: var(--accent-color);
        color: white;
        box-shadow: 0 2px 8px rgba(224, 120, 86, 0.3);
        animation: pulse 2s ease-in-out infinite;
    }
    
    @keyframes pulse {
        0%, 100% { box-shadow: 0 2px 8px rgba(224, 120, 86, 0.3); }
        50% { box-shadow: 0 2px 16px rgba(224, 120, 86, 0.5); }
    }
    
    /* Search Dropdown */
    .search-chat-dropdown {
        position: absolute;
        top: calc(100% + 8px);
        left: 0;
        right: 0;
        background: var(--dropdown-bg);
        border: 1px solid var(--dropdown-border);
        border-radius: 16px;
        box-shadow: 0 10px 25px var(--search-shadow);
        max-height: 480px;
        overflow-y: auto;
        z-index: 1000;
        opacity: 0;
        transform: translateY(-10px);
        pointer-events: none;
        transition: opacity 0.2s ease, transform 0.2s ease;
    }
    
    .search-chat-dropdown.active {
        opacity: 1;
        transform: translateY(0);
        pointer-events: all;
    }
    
    .search-chat-container.ai-mode .search-chat-dropdown {
        display: none;
    }
    
    .search-result-item {
        padding: 12px 16px;
        cursor: pointer;
        transition: background-color 0.15s ease;
        border-bottom: 1px solid var(--dropdown-border);
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .search-result-item:hover {
        background-color: var(--hover-bg);
    }
    
    .search-result-icon {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
    }
    
    .search-result-content {
        flex: 1;
        min-width: 0;
    }
    
    .search-result-name {
        font-weight: 500;
        font-size: 14px;
        color: var(--search-text);
        margin-bottom: 2px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .search-result-subtitle {
        font-size: 12px;
        color: var(--search-placeholder);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .search-result-badge {
        padding: 4px 10px;
        border-radius: 12px;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        flex-shrink: 0;
        /* Colors are set via inline styles for gender-specific badges */
    }
    
    /* CHAT MODAL - No overlay, always visible when open */
    .chat-modal-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(4px);
        z-index: 9997;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
        pointer-events: none;
    }
    
    /* Show backdrop only when maximized and first opening */
    .chat-modal-overlay.initial-open {
        display: block;
        opacity: 1;
        pointer-events: all;
    }
    
    .chat-modal {
        position: fixed;
        width: 500px;
        height: 600px;
        min-width: 400px;
        min-height: 400px;
        max-width: 90vw;
        max-height: 90vh;
        background: var(--bg-primary);
        border-radius: 16px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
        display: none;
        flex-direction: column;
        overflow: hidden;
        z-index: 9998;
        
        /* Bottom-right by default */
        right: 20px;
        bottom: 20px;
        
        transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                    height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    /* Disable transitions during drag/resize */
    .chat-modal.dragging,
    .chat-modal.resizing {
        transition: none !important;
    }
    
    .chat-modal.open {
        display: flex;
    }
    
    /* Minimized state - shows header + input only */
    .chat-modal.minimized {
        height: 130px !important;
        min-height: 130px !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    }
    
    .chat-modal.minimized:hover {
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    }
    
    /* Hide only messages when minimized */
    .chat-modal.minimized .chat-modal-messages {
        display: none !important;
    }
    
    .chat-modal.minimized .resize-handle,
    .chat-modal.minimized .resize-indicator {
        display: none !important;
    }
    
    .chat-modal.minimized .chat-modal-header {
        cursor: pointer;
    }
    
    /* Draggable Header */
    .chat-modal-header {
        padding: 16px 20px;
        background: var(--bg-primary);
        border-bottom: 1px solid var(--border-color);
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-shrink: 0;
        cursor: move;
        user-select: none;
    }
    
    .chat-modal-header:active {
        cursor: grabbing;
    }
    
    .chat-modal-title {
        font-size: 16px;
        font-weight: 600;
        color: var(--text-primary);
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .chat-modal-controls {
        display: flex;
        gap: 6px;
        align-items: center;
    }
    
    .chat-modal-btn {
        width: 32px;
        height: 32px;
        border-radius: 6px;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        color: var(--text-secondary);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s;
        flex-shrink: 0;
    }
    
    .chat-modal-btn:hover {
        background: var(--bg-tertiary);
        color: var(--text-primary);
    }
    
    .chat-modal-btn.minimize-btn:hover {
        background: var(--accent-light);
        color: var(--accent-color);
    }
    
    .chat-modal-btn.close-btn:hover {
        background: #fee2e2;
        color: #dc2626;
        border-color: #fecaca;
    }
    
    /* Unread indicator */
    .unread-indicator {
        width: 8px;
        height: 8px;
        background: var(--accent-color);
        border-radius: 50%;
        margin-left: 8px;
        animation: pulse-dot 2s ease-in-out infinite;
    }
    
    @keyframes pulse-dot {
        0%, 100% { opacity: 1; }
        50% { opacity: 0.5; }
    }
    
    /* Resize handles */
    .resize-handle {
        position: absolute;
        background: transparent;
        z-index: 10;
    }
    
    .resize-handle-n {
        top: 0;
        left: 0;
        right: 0;
        height: 8px;
        cursor: ns-resize;
    }
    
    .resize-handle-s {
        bottom: 0;
        left: 0;
        right: 0;
        height: 8px;
        cursor: ns-resize;
    }
    
    .resize-handle-e {
        top: 0;
        right: 0;
        bottom: 0;
        width: 8px;
        cursor: ew-resize;
    }
    
    .resize-handle-w {
        top: 0;
        left: 0;
        bottom: 0;
        width: 8px;
        cursor: ew-resize;
    }
    
    .resize-handle-ne {
        top: 0;
        right: 0;
        width: 16px;
        height: 16px;
        cursor: nesw-resize;
    }
    
    .resize-handle-nw {
        top: 0;
        left: 0;
        width: 16px;
        height: 16px;
        cursor: nwse-resize;
    }
    
    .resize-handle-se {
        bottom: 0;
        right: 0;
        width: 16px;
        height: 16px;
        cursor: nwse-resize;
    }
    
    .resize-handle-sw {
        bottom: 0;
        left: 0;
        width: 16px;
        height: 16px;
        cursor: nesw-resize;
    }
    
    .resize-indicator {
        position: absolute;
        bottom: 4px;
        right: 4px;
        width: 12px;
        height: 12px;
        pointer-events: none;
    }
    
    .resize-indicator::before,
    .resize-indicator::after {
        content: '';
        position: absolute;
        background: var(--text-tertiary);
        border-radius: 1px;
    }
    
    .resize-indicator::before {
        bottom: 4px;
        right: 0;
        width: 2px;
        height: 8px;
    }
    
    .resize-indicator::after {
        bottom: 0;
        right: 4px;
        width: 8px;
        height: 2px;
    }
    
    /* Chat Messages Area */
    .chat-modal-messages {
        flex: 1;
        overflow-y: auto;
        padding: 20px;
        background: var(--bg-secondary);
    }
    
    .chat-modal-messages::-webkit-scrollbar {
        width: 6px;
    }
    
    .chat-modal-messages::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .chat-modal-messages::-webkit-scrollbar-thumb {
        background: var(--border-color);
        border-radius: 3px;
    }
    
    /* Message bubbles */
    .chat-message {
        margin-bottom: 16px;
        animation: slideIn 0.3s ease-out;
    }
    
    @keyframes slideIn {
        from {
            opacity: 0;
            transform: translateY(10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .chat-message-user {
        display: flex;
        justify-content: flex-end;
    }
    
    .chat-message-ai {
        display: flex;
        justify-content: flex-start;
    }
    
    .chat-bubble {
        max-width: 75%;
        padding: 10px 14px;
        border-radius: 14px;
        line-height: 1.5;
        word-wrap: break-word;
        font-size: 14px;
    }
    
    .chat-bubble-user {
        background: var(--accent-color);
        color: white;
    }
    
    .chat-bubble-ai {
        background: var(--bg-primary);
        color: var(--text-primary);
        border: 1px solid var(--border-color);
        box-shadow: 0 1px 3px var(--shadow);
    }
    
    .shoey-avatar-modal {
        min-width: 56px;
        height: 28px;
        background: var(--bg-tertiary);
        border: 1px solid var(--border-color);
        border-radius: 14px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--text-secondary);
        font-weight: 600;
        font-size: 12px;
        flex-shrink: 0;
        box-shadow: 0 1px 2px var(--shadow);
        padding: 0 10px;
        margin-right: 10px;
    }
    
    .chat-message-time {
        font-size: 10px;
        color: var(--text-tertiary);
        margin-top: 4px;
        margin-left: 66px;
    }
    
    /* Typing indicator */
    .typing-indicator-modal {
        display: flex;
        gap: 4px;
    }
    
    .typing-indicator-modal span {
        width: 7px;
        height: 7px;
        background: var(--accent-color);
        border-radius: 50%;
        animation: typing 1.4s infinite;
    }
    
    .typing-indicator-modal span:nth-child(2) {
        animation-delay: 0.2s;
    }
    
    .typing-indicator-modal span:nth-child(3) {
        animation-delay: 0.4s;
    }
    
    @keyframes typing {
        0%, 60%, 100% {
            transform: translateY(0);
            opacity: 0.4;
        }
        30% {
            transform: translateY(-8px);
            opacity: 1;
        }
    }
    
    /* Chat Input */
    .chat-modal-input-container {
        padding: 16px;
        background: var(--bg-primary);
        border-top: 1px solid var(--border-color);
        flex-shrink: 0;
    }
    
    .chat-modal-input-wrapper {
        display: flex;
        gap: 10px;
        align-items: flex-end;
    }
    
    .chat-modal-textarea {
        flex: 1;
        min-height: 42px;
        max-height: 100px;
        padding: 10px 14px;
        background: var(--bg-secondary);
        border: 2px solid var(--border-color);
        border-radius: 10px;
        font-size: 14px;
        color: var(--text-primary);
        resize: none;
        outline: none;
        transition: all 0.2s;
        font-family: inherit;
    }
    
    .chat-modal-textarea:focus {
        border-color: var(--accent-color);
        background: var(--bg-primary);
    }
    
    .chat-modal-send-btn {
        width: 42px;
        height: 42px;
        border-radius: 10px;
        background: var(--accent-color);
        color: white;
        border: none;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s;
        flex-shrink: 0;
    }
    
    .chat-modal-send-btn:hover:not(:disabled) {
        background: var(--accent-hover);
        transform: translateY(-2px);
    }
    
    .chat-modal-send-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }
    
    /* Mobile responsive */
    @media (max-width: 768px) {
        .chat-modal {
            width: calc(100vw - 20px) !important;
            height: calc(100vh - 100px) !important;
            right: 10px !important;
            bottom: 10px !important;
            min-width: 300px;
        }
        
        .chat-modal.minimized {
            width: calc(100vw - 40px) !important;
            height: 56px !important;
        }
        
        .chat-bubble {
            max-width: 85%;
        }
        
        .resize-handle {
            display: none;
        }
    }
</style>

<!-- Search Widget -->
<div class="search-chat-container" id="search-chat-container">
    <div class="search-chat-wrapper">
        <input 
            type="text" 
            id="search-chat-input"
            class="search-chat-input"
            placeholder="Search athletes, teams, meets..."
            autocomplete="off"
            aria-label="Search"
        />
        
        <svg id="search-chat-icon" class="search-chat-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" 
                  d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
        </svg>
        
        <div id="search-chat-loading" class="search-chat-loading">
            <svg fill="none" viewBox="0 0 24 24">
                <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
                <path class="opacity-75" fill="currentColor" 
                      d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">
                </path>
            </svg>
        </div>
        
        <div class="shoey-badge-inline" id="shoey-badge-inline" title="Click to ask Shoey AI">
            <svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" 
                      d="M13 10V3L4 14h7v7l9-11h-7z" />
            </svg>
            <span id="shoey-badge-text">Ask Shoey</span>
        </div>
    </div>
    
    <div id="search-chat-dropdown" class="search-chat-dropdown"></div>
</div>

