/**
 * FCA Multi-Reactions Styles
 * All styles for reaction picker, summary, modal, and comments
 * 
 * @package FCA_Multi_Reactions
 */

/* ============================================
   CSS Variables (inherit from Fluent Community)
   ============================================ */

:root {
    --fca-border-radius: 8px;
    --fca-transition: 0.2s ease;
    --fca-shadow: 0 4px 12px rgba(0,0,0,0.15);
    --fca-shadow-modal: 0 2px 12px rgba(0, 0, 0, 0.1);
}

/* ============================================
   Reaction Wrapper (for single button)
   ============================================ */

.fca-reaction-wrapper {
    display: inline-flex;
    align-items: center;
}

.fca-single-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform var(--fca-transition), opacity var(--fca-transition);
}

.fca-single-btn:hover {
    transform: scale(1.1);
}

.fca-single-btn.fca-inactive {
    opacity: 0.6;
    filter: grayscale(100%);
}

.fca-single-btn.fca-active {
    opacity: 1;
    filter: none;
}

/* ============================================
   Reaction Picker Dropdown
   ============================================ */

.fca-picker {
    position: fixed;
    display: flex;
    gap: 4px;
    padding: 8px;
    background: var(--fcom-primary-bg, #fff);
    border: 1px solid var(--fcom-primary-border, #e1e4e8);
    border-radius: var(--fca-border-radius);
    box-shadow: var(--fca-shadow);
    z-index: 99999;
}

.fca-picker.fca-wrap {
    flex-wrap: wrap;
    max-width: 280px;
}

.fca-picker-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: transform var(--fca-transition), background var(--fca-transition);
}

.fca-picker-btn:hover {
    transform: scale(1.3);
    background: var(--fcom-hover-bg, #f0f0f0);
}

.fca-picker-btn img {
    width: 24px;
    height: 24px;
}

/* Dark mode picker */
html.dark .fca-picker {
    background: var(--fcom-primary-bg, #2a2a2a);
    border-color: var(--fcom-primary-border, #444);
}

html.dark .fca-picker-btn:hover {
    background: var(--fcom-hover-bg, #3a3a3a);
}

/* ============================================
   Emoji Summary (replaces reaction avatars)
   ============================================ */

.fca-emoji-summary {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    position: relative;
    z-index: 1;
}

.fca-emoji-summary:hover {
    opacity: 0.8;
}

.fca-summary-emoji {
    --fca-stroke: 1px; /* Default, overridden by inline style */
    width: 18px;
    height: 18px;
    vertical-align: middle;
    display: inline-block;
    position: relative;
    /* Shape-following border using CSS variable */
    filter: 
        drop-shadow(var(--fca-stroke) 0 0 var(--fcom-primary-bg, #fff)) 
        drop-shadow(calc(var(--fca-stroke) * -1) 0 0 var(--fcom-primary-bg, #fff)) 
        drop-shadow(0 var(--fca-stroke) 0 var(--fcom-primary-bg, #fff)) 
        drop-shadow(0 calc(var(--fca-stroke) * -1) 0 var(--fcom-primary-bg, #fff));
}

.fca-summary-count {
    margin-left: 0.5rem; /* 8px at 16px base - increased to prevent overlap */
    color: var(--fcom-secondary-text, #65676b);
    font-size: 0.875rem; /* 14px at 16px base */
    white-space: nowrap;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

/* Dark mode summary */
html.dark .fca-summary-emoji {
    filter: 
        drop-shadow(var(--fca-stroke) 0 0 var(--fcom-primary-bg, #1a1a1a)) 
        drop-shadow(calc(var(--fca-stroke) * -1) 0 0 var(--fcom-primary-bg, #1a1a1a)) 
        drop-shadow(0 var(--fca-stroke) 0 var(--fcom-primary-bg, #1a1a1a)) 
        drop-shadow(0 calc(var(--fca-stroke) * -1) 0 var(--fcom-primary-bg, #1a1a1a));
}

/* List view positioning */
.feed_outer .fca-emoji-summary,
.fcom_feed_list .fca-emoji-summary {
    margin-right: 12px;
    margin-bottom: 4px;
}

/* ============================================
   Hide FC Core Like Counter (we use our own)
   ============================================ */

/* Hide the "X likes" text span in reaction count area */
.fcom_reactions_count > span:not(.fca-reaction-count):not(.el-tooltip__trigger),
.fcom_reactions_count > .fcom_reaction_list > span:not(.fca-reaction-count) {
    display: none !important;
    }

/* Hide FC's default reaction avatars/images (we show emojis instead) */
.fcom_reactions_count > img,
.fcom_reactions_count .fcom_reaction_list > img:not(.fca-summary-emoji) {
    display: none !important;
}

/* ============================================
   Skeleton Loaders
   ============================================ */

@keyframes fca-skeleton-pulse {
    0%, 100% { background-position: 200% 0; }
    50% { background-position: -200% 0; }
    }

.fca-skeleton {
    background: linear-gradient(90deg, 
        var(--fcom-secondary-bg, #f0f0f0) 25%, 
        var(--fcom-light-bg, #e0e0e0) 50%, 
        var(--fcom-secondary-bg, #f0f0f0) 75%);
    background-size: 200% 100%;
    animation: fca-skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 4px;
}

html.dark .fca-skeleton {
    background: linear-gradient(90deg, 
        var(--fcom-secondary-bg, #2a2a2a) 25%, 
        var(--fcom-light-bg, #3a3a3a) 50%, 
        var(--fcom-secondary-bg, #2a2a2a) 75%);
    background-size: 200% 100%;
}

/* ============================================
   Breakdown Modal
   ============================================ */

.fca-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.fca-modal-content,
.fca-reaction-breakdown-modal {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: var(--fcom-primary-bg, #fff);
    border-radius: var(--fca-border-radius);
    box-shadow: var(--fca-shadow-modal);
    border: 1px solid var(--fcom-primary-border, #DADDE1);
    width: 500px;
    max-width: 90vw;
    height: 450px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
}

.fca-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--fcom-primary-border, #DADDE1);
}

.fca-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--fcom-primary-text, #050505);
}

.fca-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--fcom-secondary-text, #65676b);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background var(--fca-transition);
}

.fca-modal-close:hover {
    background: var(--fcom-hover-bg, #F2F3F5);
}

.fca-modal-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 !important;
}

.fca-modal-body.fca-loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Spinner */
.fca-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--fcom-primary-border, #e0e0e0);
    border-top-color: var(--fcom-text-link, #1da1f2);
    border-radius: 50%;
    animation: fca-spin 0.8s linear infinite;
}

@keyframes fca-spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Modal Tabs
   ============================================ */

.fca-tabs {
    display: flex;
    padding: 0 16px;
    overflow-x: auto;
    gap: 8px;
    border-bottom: 1px solid var(--fcom-primary-border, #e1e4e8);
    margin-bottom: 8px; /* Add space below tabs */
}

.fca-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 14px;
    font-weight: 600;
    color: var(--fcom-menu-text, #65676B);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--fca-transition);
    flex-shrink: 0; /* Prevent tabs from squishing */
}

.fca-tab:hover {
    background: var(--fcom-hover-bg, #F2F3F5);
    border-radius: 4px 4px 0 0;
    color: var(--fcom-primary-text, #050505);
}

.fca-tab.active {
    color: var(--fcom-text-link, #216FDB);
    border-bottom-color: var(--fcom-text-link, #216FDB);
}

.fca-tab img {
    width: 18px;
    height: 18px;
}

/* ============================================
   Modal Panels (User List)
   ============================================ */

.fca-panels {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.fca-panel {
    display: none;
}

.fca-panel.active {
    display: block;
}

.fca-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px; /* Increased padding */
    text-decoration: none;
    color: inherit;
    transition: background var(--fca-transition);
    border-bottom: 1px solid var(--fcom-secondary-border, #f0f2f5);
}

.fca-user:last-child {
    border-bottom: none;
}

.fca-user:hover {
    background: var(--fcom-hover-bg, #F2F3F5);
}

.fca-user-avatar {
    width: 40px; /* Larger avatar */
    height: 40px;
    flex-shrink: 0;
    position: relative;
}

.fca-user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.fca-user-reaction {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: var(--fcom-primary-bg, #fff);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--fcom-primary-bg, #fff); /* White border to separate from avatar */
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.fca-user-reaction img {
    width: 14px;
    height: 14px;
}

.fca-user-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--fcom-primary-text, #050505);
}

.fca-user-reaction img {
    width: 12px;
    height: 12px;
    border-radius: 0;
}

.fca-user-name {
    color: var(--fcom-primary-text, #050505);
    font-size: 14px;
    font-weight: 500;
}

.fca-no-data,
.fca-error {
    padding: 16px;
    text-align: center;
    color: var(--fcom-secondary-text, #65676b);
    font-size: 13px;
}

.fca-more {
    padding: 8px 12px;
    text-align: center;
    color: var(--fcom-secondary-text, #65676b);
    font-size: 13px;
}

/* Dark mode modal */
html.dark .fca-modal-close:hover {
    background: var(--fcom-hover-bg, #3a3a3a);
}

html.dark .fca-tab:hover {
    background: var(--fcom-hover-bg, #3a3a3a);
}

html.dark .fca-user:hover {
    background: var(--fcom-hover-bg, #3a3a3a);
}

/* ============================================
   Comment Reactions (Simple Icon)
   ============================================ */

.fca-comment-emoji {
    width: 15px !important;
    height: 15px !important;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .fca-modal-content {
        width: 95vw;
        height: 70vh;
}

    .fca-picker {
        flex-wrap: wrap;
        max-width: calc(100vw - 20px);
}

    .fca-picker-btn img {
        width: 20px;
        height: 20px;
    }
}

/* ============================================
   Accessibility
   ============================================ */

.fca-single-btn:focus,
.fca-picker-btn:focus,
.fca-tab:focus,
.fca-modal-close:focus {
    outline: 2px solid var(--fcom-text-link, #1da1f2);
    outline-offset: 2px;
}

.fca-single-btn:focus:not(:focus-visible),
.fca-picker-btn:focus:not(:focus-visible),
.fca-tab:focus:not(:focus-visible),
.fca-modal-close:focus:not(:focus-visible) {
    outline: none;
}

/* ============================================
   Animation Effects
   ============================================ */

@keyframes fca-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.fca-single-btn.fca-animating {
    animation: fca-pop 0.3s ease;
}

/* ============================================
   Legacy Compatibility (old class names)
   ============================================ */

.fca-reaction-dropdown { /* same as .fca-picker */ }
.fca-reaction-emoji-summary { /* same as .fca-emoji-summary */ }
.fca-reaction-breakdown-modal { /* same as .fca-modal */ }
