/* css/emotes.css - Updated Styles for Better Keyboard Navigation */

/* Base Emote Images */
.emote-img {
    display: inline-block;
    vertical-align: middle;
    margin: 0 2px;
    border-radius: 2px;
    transition: transform 0.1s ease;
    object-fit: contain;
}

.emote-img:hover {
    transform: scale(1.2);
    z-index: 10;
    position: relative;
}

/* Context-specific emote styling */
.emote-title {
    margin: 0 4px;
    vertical-align: baseline;
}

.emote-description {
    margin: 0 2px;
    vertical-align: text-bottom;
}

.emote-suggestion {
    margin: 0 1px;
    vertical-align: middle;
}

/* Emote Suggestions Dropdown */
#emote-suggestions {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    padding: 4px;
    margin-top: 4px;
    min-width: 280px;
    max-width: 400px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 1000;
}

#emote-suggestions::before {
    content: "↑↓ Navigate • Enter Select • Esc Close";
    display: block;
    padding: 6px 12px;
    font-size: 11px;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 4px;
    font-style: italic;
    text-align: center;
    background: #f9fafb;
    margin: -4px -4px 4px -4px;
    border-radius: 8px 8px 0 0;
}

.emote-suggestion {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 40px;
    border: 2px solid transparent;
    position: relative;
    margin: 2px 0;
}

.emote-suggestion:hover:not(.bg-indigo-600) {
    background-color: #f3f4f6;
    border-color: #e5e7eb;
}

/* Selected state - ensure it's clearly visible */
.emote-suggestion.bg-indigo-600 {
    background-color: #4f46e5 !important;
    border-color: #3730a3 !important;
    color: white !important;
    transform: scale(1.02);
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.3);
}

.emote-suggestion.bg-indigo-600 span {
    color: white !important;
}

.emote-suggestion.bg-indigo-600 .text-gray-500,
.emote-suggestion.bg-indigo-600 .text-indigo-200 {
    color: #c7d2fe !important;
}

/* Smooth scrolling for keyboard navigation */
#emote-suggestions {
    scroll-behavior: smooth;
}

.emote-suggestion img {
    flex-shrink: 0;
    object-fit: contain;
}

.emote-suggestion span {
    font-size: 14px;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Enhanced line height for emote-containing text */
.emote-enabled {
    line-height: 1.6;
}

/* Messages container */
.bg-gray-50 .emote-img {
    vertical-align: text-bottom;
}

/* Meetup titles */
#meetupTitle .emote-img {
    margin: 0 4px;
    vertical-align: baseline;
}

#meetupTitle {
    line-height: 1.4;
}

/* Descriptions */
#descriptionText .emote-img {
    margin: 0 2px;
    vertical-align: text-bottom;
}

#descriptionText {
    line-height: 1.6;
}

/* Message content */
.text-gray-900.break-words {
    line-height: 1.7;
    word-break: break-word;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .emote-img:hover {
        transform: scale(1.1);
    }
    
    #emote-suggestions {
        max-width: 90vw;
        min-width: 250px;
        font-size: 13px;
    }
    
    #emote-suggestions::before {
        font-size: 10px;
        padding: 4px 8px;
    }
    
    .emote-suggestion {
        padding: 6px 10px;
        min-height: 36px;
    }
    
    .emote-suggestion span {
        font-size: 13px;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .emote-img {
        margin: 0 1px;
    }
    
    #meetupTitle .emote-img {
        margin: 0 2px;
    }
    
    #emote-suggestions {
        padding: 2px;
        min-width: 200px;
    }
    
    .emote-suggestion {
        padding: 6px 8px;
        gap: 8px;
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    #emote-suggestions {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }
    
    #emote-suggestions::before {
        background: #111827;
        color: #9ca3af;
        border-bottom-color: #374151;
    }
    
    .emote-suggestion:hover:not(.bg-indigo-600) {
        background-color: #374151;
        border-color: #4b5563;
    }
    
    .emote-suggestion span {
        color: #f9fafb;
    }
    
    .emote-suggestion.bg-indigo-600 {
        background-color: #4f46e5 !important;
        border-color: #6366f1 !important;
    }
}

/* Loading state for emotes */
.emote-img[src=""] {
    display: none;
}

.emote-loading {
    background: #f3f4f6;
    border-radius: 2px;
    display: inline-block;
    vertical-align: middle;
    margin: 0 2px;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Prevent text selection on emote images */
.emote-img {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Accessibility: High contrast mode */
@media (prefers-contrast: high) {
    .emote-img {
        border: 1px solid #000;
    }
    
    #emote-suggestions {
        border: 2px solid #000;
    }
    
    .emote-suggestion:hover:not(.bg-indigo-600) {
        background-color: #000;
        color: #fff;
    }
    
    .emote-suggestion:hover:not(.bg-indigo-600) span {
        color: #fff;
    }
    
    .emote-suggestion.bg-indigo-600 {
        background-color: #000 !important;
        color: #fff !important;
        border: 2px solid #fff !important;
    }
}

/* Print styles */
@media print {
    .emote-img {
        display: none;
    }
    
    .emote-img::after {
        content: "[" attr(alt) "]";
        font-weight: bold;
        display: inline;
    }
    
    #emote-suggestions {
        display: none !important;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .emote-img {
        transition: none;
    }
    
    .emote-img:hover {
        transform: none;
    }
    
    .emote-suggestion {
        transition: none;
    }
    
    .emote-suggestion.bg-indigo-600 {
        transform: none;
    }
    
    #emote-suggestions {
        scroll-behavior: auto;
    }
}

/* Custom scrollbar for emote suggestions */
#emote-suggestions::-webkit-scrollbar {
    width: 6px;
}

#emote-suggestions::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

#emote-suggestions::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

#emote-suggestions::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Focus states for keyboard navigation */
.emote-suggestion:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: -2px;
}

/* Performance optimizations */
.emote-img {
    will-change: transform;
}

/* Smooth transition for selection changes */
.emote-suggestion * {
    transition: color 0.15s ease;
}