/* Enhanced ToolTag CSS Styles */

/* Dropdown styling enhancements */
.tooltag-dropdown {
    position: absolute;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    min-width: 280px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.tooltag-dropdown::-webkit-scrollbar {
    width: 6px;
}

.tooltag-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.tooltag-dropdown::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.tooltag-dropdown::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Enhanced dropdown items */
.tooltag-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.15s ease;
    user-select: none;
    background: white;
}

.tooltag-item:hover,
.tooltag-item.selected {
    background-color: #e8f4fd;
    border-left: 3px solid #007bff;
}

.tooltag-item:last-child {
    border-bottom: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.tooltag-item:first-child {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

/* Role icons and styling */
.tooltag-item .role-icon {
    font-size: 20px;
    line-height: 1;
    min-width: 24px;
    text-align: center;
}

.tooltag-item .user-info {
    flex: 1;
    min-width: 0;
}

.tooltag-item .user-name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tooltag-item .user-details {
    font-size: 12px;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tooltag-item .selection-hint {
    font-size: 11px;
    color: #28a745;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.tooltag-item.selected .selection-hint,
.tooltag-item:hover .selection-hint {
    opacity: 1;
}

/* Mention styling in textareas */
.has-mentions {
    position: relative;
}

.mention-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    padding: inherit;
    margin: inherit;
    border: inherit;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow: hidden;
    color: transparent;
    z-index: 1;
    background: transparent;
}

.mention-overlay span {
    color: #28a745 !important;
    font-weight: 600 !important;
    background-color: rgba(40, 167, 69, 0.1);
    border-radius: 3px;
    padding: 1px 2px;
}

/* Textarea with mentions styling */
textarea.has-mentions {
    background: transparent !important;
    position: relative;
    z-index: 2;
    color: #495057;
}

/* Enhanced mention formatting in chat messages */
.chat-message .mention,
.job-message .mention {
    color: #28a745;
    font-weight: 600;
    background-color: rgba(40, 167, 69, 0.1);
    border-radius: 4px;
    padding: 2px 4px;
    text-decoration: none;
    border: 1px solid rgba(40, 167, 69, 0.2);
    display: inline-block;
    margin: 0 2px;
    transition: all 0.2s ease;
}

.chat-message .mention:hover,
.job-message .mention:hover {
    background-color: rgba(40, 167, 69, 0.2);
    border-color: rgba(40, 167, 69, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.2);
}

/* Animation for dropdown appearance */
@keyframes tooltag-dropdown-appear {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.tooltag-dropdown {
    animation: tooltag-dropdown-appear 0.2s ease-out;
}

/* Loading state for dropdown */
.tooltag-dropdown.loading {
    padding: 20px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
}

.tooltag-dropdown.loading::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty state for no results */
.tooltag-dropdown.empty {
    padding: 16px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
    font-style: italic;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .tooltag-dropdown {
        min-width: 250px;
        max-height: 200px;
        border-radius: 6px;
    }
    
    .tooltag-item {
        padding: 10px 12px;
        gap: 10px;
    }
    
    .tooltag-item .role-icon {
        font-size: 18px;
        min-width: 20px;
    }
    
    .tooltag-item .user-name {
        font-size: 13px;
    }
    
    .tooltag-item .user-details {
        font-size: 11px;
    }
    
    .tooltag-item .selection-hint {
        display: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .tooltag-dropdown {
        background: #2d3748;
        border-color: #4a5568;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    }
    
    .tooltag-item {
        border-bottom-color: #4a5568;
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .tooltag-item:hover,
    .tooltag-item.selected {
        background-color: #3182ce;
        border-left-color: #63b3ed;
    }
    
    .tooltag-item .user-name {
        color: #e2e8f0;
    }
    
    .tooltag-item .user-details {
        color: #a0aec0;
    }
    
    .tooltag-item .selection-hint {
        color: #68d391;
    }
    
    .mention-overlay span {
        color: #68d391 !important;
        background-color: rgba(104, 211, 145, 0.1);
    }
    
    .chat-message .mention,
    .job-message .mention {
        color: #68d391;
        background-color: rgba(104, 211, 145, 0.1);
        border-color: rgba(104, 211, 145, 0.2);
    }
    
    .chat-message .mention:hover,
    .job-message .mention:hover {
        background-color: rgba(104, 211, 145, 0.2);
        border-color: rgba(104, 211, 145, 0.4);
        box-shadow: 0 2px 4px rgba(104, 211, 145, 0.2);
    }
    
    textarea.has-mentions {
        color: #e2e8f0;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .tooltag-dropdown {
        border-width: 2px;
        border-color: #000;
    }
    
    .tooltag-item:hover,
    .tooltag-item.selected {
        background-color: #000;
        color: #fff;
        border-left-color: #fff;
    }
    
    .chat-message .mention,
    .job-message .mention {
        border-width: 2px;
        font-weight: 700;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .tooltag-dropdown {
        animation: none;
    }
    
    .tooltag-item {
        transition: none;
    }
    
    .chat-message .mention,
    .job-message .mention {
        transition: none;
    }
    
    .chat-message .mention:hover,
    .job-message .mention:hover {
        transform: none;
    }
}

/* Focus management for accessibility */
.tooltag-dropdown:focus-within {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.tooltag-item:focus {
    outline: 2px solid #007bff;
    outline-offset: -2px;
}

/* Print styles */
@media print {
    .tooltag-dropdown {
        display: none !important;
    }
    
    .chat-message .mention,
    .job-message .mention {
        background: none !important;
        border: none !important;
        color: #000 !important;
        font-weight: 600;
    }
}