/**
 * Modern updates for BuddyPress Reactions
 * Clean, professional UI improvements
 */

/* Modernize the reaction count display */
.reacted-count.content-actions {
    margin: 6px 0;
    display: inline-block;
}

.reacted-count .content-action {
    display: inline-flex;
    align-items: center;
    transition: all 0.2s ease;
}

/* Clean up the meta-line */
.reacted-count .meta-line {
    display: flex;
    align-items: center;
    gap: 2px; /* Reduced gap to bring items closer */
}

/* Modernize reaction list */
.reaction-item-list {
    display: flex;
    align-items: center;
    margin-right: 2px; /* Closer to count */
}

.reaction-item-wrap {
    position: relative;
    margin-left: -4px !important; /* Subtle overlap for clean look */
    transition: all 0.2s ease;
}

.reaction-item-wrap:first-child {
    margin-left: 0 !important;
}

.reaction-item-wrap:hover {
    transform: translateY(-2px) scale(1.15);
    z-index: 10;
}

/* Style reaction items */
.reaction-item {
    width: 26px;
    height: 26px;
    background: transparent;
    border-radius: 50%;
    padding: 0;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Add subtle background on hover */
.reaction-item::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.reaction-item:hover::before {
    opacity: 1;
}

.reaction-item .reaction-image {
    width: 20px !important;
    height: 20px !important;
    object-fit: contain;
}

/* Modernize dropdown */
.reaction-item .simple-dropdown {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 12px;
    min-width: 160px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 99999;
}

.reaction-item:hover .simple-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-12px);
}

/* Arrow for dropdown */
.reaction-item .simple-dropdown::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: white;
}

/* Clean dropdown content */
.simple-dropdown-text {
    margin-bottom: 8px;
}

.simple-dropdown-text:last-child {
    margin-bottom: 0;
}

.reacted-emoji {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    margin-bottom: 8px;
}

.reacted-emoji .reaction {
    width: 20px !important;
    height: 20px !important;
}

.reacted-emoji .bold {
    font-weight: 600;
    font-size: 13px;
    color: #333;
}

/* User list styling */
.reacted-users {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 120px;
    overflow-y: auto;
}

.reacted-user {
    padding: 3px 0;
    font-size: 12px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reacted-user:hover {
    color: #333;
}

/* Total count styling */
.total-reaction-counts {
    font-size: 14px;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.4;
    position: relative;
    display: inline-flex;
    align-items: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    border-radius: 12px;
}

/* Add same hover effect as emojis */
.total-reaction-counts::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: -1;
}

/* Fallback for browsers that don't support text gradients */
@supports not (-webkit-background-clip: text) {
    .total-reaction-counts {
        background: none;
        color: #667eea;
        -webkit-text-fill-color: initial;
    }
}

.total-reaction-counts:hover {
    background: linear-gradient(135deg, #764ba2 0%, #f093fb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transform: translateY(-1px) scale(1.05);
}

.total-reaction-counts:hover::after {
    opacity: 1;
}

/* Hide waiting spinner by default */
.wbreacted-waiting {
    display: none !important;
}

/* Loading state */
.bp-reactions-loading .reaction-item-list {
    opacity: 0.5;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .reaction-item {
        width: 24px;
        height: 24px;
        padding: 3px;
    }
    
    .reaction-item .reaction-image {
        width: 16px !important;
        height: 16px !important;
    }
    
    .reaction-item .simple-dropdown {
        position: fixed;
        bottom: auto;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        z-index: 9999;
    }
    
    .reaction-item:hover .simple-dropdown {
        transform: translate(-50%, -50%);
    }
    
    .reaction-item .simple-dropdown::after {
        display: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    
    .reaction-item {
        background: transparent;
    }
    
    .reaction-item::before {
        background: rgba(255, 255, 255, 0.08);
    }
    
    .reaction-item .simple-dropdown {
        background: #2a2a2a;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    }
    
    .reaction-item .simple-dropdown::after {
        border-top-color: #2a2a2a;
    }
    
    .reacted-emoji {
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }
    
    .reacted-emoji .bold {
        color: #fff;
    }
    
    .reacted-user {
        color: #ccc;
    }
    
    .reacted-user:hover {
        color: #fff;
    }
    
    .total-reaction-counts {
        color: #aaa;
        font-weight: 500;
    }
    
    .total-reaction-counts::after {
        background: rgba(255, 255, 255, 0.08);
    }
    
    .total-reaction-counts:hover {
        color: #58a6ff; /* GitHub-like blue for dark mode */
    }
}

/* ===== HANDLING LARGE NUMBERS OF REACTIONS ===== */

/* Optimize popup for many reactions */
.reaction-box .reaction-box-options {
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.reaction-box .reaction-box-options::-webkit-scrollbar {
    height: 6px;
}

.reaction-box .reaction-box-options::-webkit-scrollbar-track {
    background: transparent;
}

.reaction-box .reaction-box-options::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

/* When there are many emoji types, make tabs scrollable */
.reaction-box .reaction-box-options ul {
    flex-wrap: nowrap \!important;
    min-width: max-content;
}

/* Limit inline reaction display to prevent layout break */
.reacted-count .reaction-item-wrap:nth-child(n+4) {
    display: none \!important;
}

/* Show count for remaining reactions */
.reacted-count .reaction-item-list {
    position: relative;
}

/* Performance optimizations for large lists */
.reaction-box .user-status {
    contain: layout style;
}

.reaction-box-content .reaction-box-item {
    max-height: 500px \!important;
}

/* Summary for very large numbers */
.total-reaction-counts {
    min-width: 20px;
    text-align: center;
}

/* Format large numbers */
[data-reaction-count="1000+"]:not(.total-reaction-counts)::after {
    content: "1k+";
    font-size: 11px;
}

[data-reaction-count="10000+"]:not(.total-reaction-counts)::after {
    content: "10k+";
    font-size: 11px;
}
