/**
 * FCA Widgets Pro — Presets frontend styles.
 *
 * Ported from the legacy fca-widgets stylesheet, deduplicated, and
 * aligned with the new renderer markup:
 *   <section class="app_side_widget fca-widget fca-widget--{type}">
 *     <div class="widget_header"><h3>…</h3></div>
 *     <div class="widget_body">…</div>
 *   </section>
 *
 * Widget type modifiers use the raw type slug (underscores), e.g.
 * .fca-widget--community_stats. Theming rides FluentCommunity's
 * --fcom-* CSS variables with light fallbacks; html.dark fallbacks are
 * provided for the few spots that need them.
 */

/* ==========================================================================
   Widget container — matches FC's .app_side_widget card
   ========================================================================== */
.fca-widget.app_side_widget {
    margin: 0 0 16px 0;
    padding: 16px;
    background: var(--fcom-primary-bg, #ffffff);
    border-radius: 12px;
    border: none;
}

.fca-widget .widget_header h3 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 12px 0;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--fcom-primary-border, #e5e7eb);
    font-size: 15px;
    font-weight: 600;
    color: var(--fcom-primary-text, #1a1a1a);
}

.fca-widget .widget_body {
    color: var(--fcom-secondary-text, #65676b);
}

/* ==========================================================================
   Empty state
   ========================================================================== */
.fca-widget-empty {
    text-align: center;
    padding: 24px 16px;
    margin: 0;
    font-size: 14px;
    color: var(--fcom-secondary-text, #65676b);
    line-height: 1.5;
}

/* ==========================================================================
   Stats grid — shared by Community Stats + Space Stats
   ========================================================================== */
.fca-widget .fca-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    text-align: center;
}

.fca-widget .fca-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 8px;
    background: var(--fcom-secondary-bg, #f3f4f6);
    border-radius: 8px;
}

.fca-widget .fca-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--fcom-text-link, #3b82f6);
    line-height: 1.2;
}

.fca-widget .fca-stat-label {
    font-size: 11px;
    color: var(--fcom-secondary-text, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
    font-weight: 500;
}

/* Space Stats: two wider columns with larger values */
.fca-widget--space_stats .fca-stats-grid {
    grid-template-columns: repeat(2, 1fr);
}

.fca-widget--space_stats .fca-stat-item {
    padding: 20px 12px;
}

.fca-widget--space_stats .fca-stat-value {
    font-size: 28px;
}

/* ==========================================================================
   Member list — shared by Online Members + New Members
   ========================================================================== */
.fca-widget .fca-member-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fca-widget .fca-member-item {
    margin-bottom: 4px;
}

.fca-widget .fca-member-item:last-child {
    margin-bottom: 0;
}

.fca-widget .fca-member-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    padding: 10px 12px;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.fca-widget .fca-member-link:hover {
    background: var(--fcom-secondary-bg, #f3f4f6);
}

.fca-widget .fca-member-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.fca-widget .fca-member-avatar--default {
    background: var(--fcom-secondary-bg, #f3f4f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: var(--fcom-primary-text, #1a1a1a);
}

.fca-widget .fca-member-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--fcom-primary-text, #1a1a1a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* New Members: larger avatar + stacked name/joined info */
.fca-widget--new_members .fca-member-avatar {
    width: 40px;
    height: 40px;
}

.fca-widget--new_members .fca-member-avatar--default {
    font-size: 16px;
}

.fca-widget--new_members .fca-member-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.fca-widget--new_members .fca-member-name {
    flex: none;
}

.fca-widget--new_members .fca-member-joined {
    font-size: 12px;
    color: var(--fcom-text-off, #9ca3af);
}

/* Online Members: presence dot */
.fca-widget--online_members .fca-online-indicator {
    width: 10px;
    height: 10px;
    background: #31a24c;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid var(--fcom-primary-bg, #ffffff);
}

/* ==========================================================================
   Top Contributors
   ========================================================================== */
.fca-widget--top_contributors .fca-contributor-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fca-widget--top_contributors .fca-contributor-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.fca-widget--top_contributors .fca-contributor-item:last-child {
    margin-bottom: 0;
}

.fca-widget--top_contributors .fca-contributor-item:hover {
    background: var(--fcom-secondary-bg, #f3f4f6);
}

.fca-widget--top_contributors .fca-contributor-rank {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--fcom-secondary-bg, #f3f4f6);
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    color: var(--fcom-secondary-text, #6b7280);
    flex-shrink: 0;
}

.fca-widget--top_contributors .fca-contributor-rank.gold {
    background: linear-gradient(135deg, #ffd700, #ffb700);
    color: #ffffff;
}

.fca-widget--top_contributors .fca-contributor-rank.silver {
    background: linear-gradient(135deg, #c0c0c0, #a8a8a8);
    color: #ffffff;
}

.fca-widget--top_contributors .fca-contributor-rank.bronze {
    background: linear-gradient(135deg, #cd7f32, #b87333);
    color: #ffffff;
}

.fca-widget--top_contributors .fca-contributor-link {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.fca-widget--top_contributors .fca-contributor-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.fca-widget--top_contributors .fca-contributor-avatar--default {
    background: var(--fcom-secondary-bg, #f3f4f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: var(--fcom-primary-text, #1a1a1a);
}

.fca-widget--top_contributors .fca-contributor-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--fcom-primary-text, #1a1a1a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fca-widget--top_contributors .fca-contributor-count {
    font-size: 13px;
    color: var(--fcom-secondary-text, #6b7280);
    font-weight: 600;
    white-space: nowrap;
    padding: 4px 8px;
    background: var(--fcom-secondary-bg, #f3f4f6);
    border-radius: 6px;
}

/* ==========================================================================
   Quick Links
   ========================================================================== */
.fca-widget--quick_links .fca-quick-links {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fca-widget--quick_links .fca-quick-links li {
    margin-bottom: 4px;
}

.fca-widget--quick_links .fca-quick-links li:last-child {
    margin-bottom: 0;
}

.fca-widget--quick_links .fca-quick-links a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--fcom-primary-text, #1a1a1a);
    font-size: 14px;
    transition: background 0.15s ease;
}

.fca-widget--quick_links .fca-quick-links a:hover {
    background: var(--fcom-secondary-bg, #f3f4f6);
}

.fca-widget--quick_links .fca-quick-links svg {
    width: 18px;
    height: 18px;
    color: var(--fcom-secondary-text, #6b7280);
    flex-shrink: 0;
}

.fca-widget--quick_links .fca-link-icon {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.fca-widget--quick_links .fca-link-text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   Activity list — shared by Recent Activity + Activity Feed
   ========================================================================== */
.fca-widget .fca-activity-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fca-widget .fca-activity-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--fcom-primary-border, #e5e7eb);
}

.fca-widget .fca-activity-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.fca-widget .fca-activity-item:first-child {
    padding-top: 0;
}

.fca-widget .fca-activity-main {
    font-size: 14px;
    line-height: 1.5;
    color: var(--fcom-secondary-text, #65676b);
}

.fca-widget .fca-activity-user {
    font-weight: 600;
    color: var(--fcom-primary-text, #1a1a1a);
}

.fca-widget .fca-activity-post,
.fca-widget .fca-activity-space {
    color: var(--fcom-text-link, #3b82f6);
    text-decoration: none;
}

.fca-widget a.fca-activity-post:hover,
.fca-widget a.fca-activity-space:hover {
    text-decoration: underline;
}

.fca-widget .fca-activity-meta {
    margin-top: 2px;
    font-size: 12px;
    color: var(--fcom-text-off, #9ca3af);
}

.fca-widget .fca-activity-time {
    font-size: 12px;
    color: var(--fcom-text-off, #9ca3af);
}

/* Activity Feed: avatar + content layout */
.fca-widget--activity_feed .fca-activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.fca-widget--activity_feed .fca-activity-avatar {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.fca-widget--activity_feed .fca-activity-avatar img,
.fca-widget--activity_feed .fca-activity-avatar .fca-avatar-default {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.fca-widget--activity_feed .fca-activity-avatar .fca-avatar-default {
    background: var(--fcom-secondary-bg, #f3f4f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: var(--fcom-primary-text, #1a1a1a);
}

.fca-widget--activity_feed .fca-activity-content {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--fcom-secondary-text, #65676b);
}

/* ==========================================================================
   Analytics — shared by Members Analytics + Spaces Analytics
   ========================================================================== */
.fca-analytics-widget .fca-analytics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.fca-analytics-widget .fca-analytics-grid--two {
    grid-template-columns: repeat(2, 1fr);
}

.fca-analytics-widget .fca-analytics-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 16px 12px;
    background: var(--fcom-secondary-bg, #f3f4f6);
    border-radius: 8px;
}

.fca-analytics-widget .fca-analytics-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--fcom-text-link, #3b82f6);
    line-height: 1.2;
}

.fca-analytics-widget .fca-analytics-value.fca-analytics-new {
    color: #31a24c;
}

.fca-analytics-widget .fca-analytics-label {
    font-size: 11px;
    color: var(--fcom-secondary-text, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
    font-weight: 500;
}

.fca-analytics-widget .fca-analytics-highlight {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--fcom-primary-border, #e5e7eb);
    font-size: 14px;
    text-align: center;
}

.fca-analytics-widget .fca-analytics-highlight-label {
    color: var(--fcom-secondary-text, #6b7280);
    margin-right: 4px;
}

.fca-analytics-widget .fca-analytics-highlight a {
    color: var(--fcom-text-link, #3b82f6);
    text-decoration: none;
    font-weight: 600;
}

.fca-analytics-widget .fca-analytics-highlight a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Overview
   ========================================================================== */
.fca-widget--overview .fca-overview-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fca-widget--overview .fca-overview-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--fcom-secondary-bg, #f3f4f6);
    border-radius: 8px;
}

.fca-widget--overview .fca-overview-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--fcom-primary-bg, #ffffff);
    border-radius: 8px;
    color: var(--fcom-text-link, #3b82f6);
    flex-shrink: 0;
}

.fca-widget--overview .fca-overview-icon svg {
    width: 22px;
    height: 22px;
}

.fca-widget--overview .fca-overview-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--fcom-primary-text, #1a1a1a);
    min-width: 50px;
}

.fca-widget--overview .fca-overview-label {
    font-size: 14px;
    color: var(--fcom-secondary-text, #6b7280);
    flex: 1;
}

/* ==========================================================================
   Topic Filter
   ========================================================================== */
.fca-widget--topic_filter .fca-topic-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fca-widget--topic_filter .fca-topic-item {
    margin-bottom: 4px;
}

.fca-widget--topic_filter .fca-topic-item:last-child {
    margin-bottom: 0;
}

.fca-widget--topic_filter .fca-topic-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--fcom-primary-text, #1a1a1a);
    font-size: 14px;
    transition: background 0.15s ease;
}

.fca-widget--topic_filter .fca-topic-link:hover {
    background: var(--fcom-secondary-bg, #f3f4f6);
}

.fca-widget--topic_filter .fca-topic-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--topic-color, var(--fcom-text-link, #3b82f6));
    flex-shrink: 0;
}

.fca-widget--topic_filter .fca-topic-name {
    flex: 1;
}

/* ==========================================================================
   Widget area containers (renderer emits --top / --bottom positions)
   ========================================================================== */
.fca-widget-area {
    margin: 0;
}

.fca-widget-area--top {
    margin-bottom: 16px;
}

.fca-widget-area--bottom {
    margin-top: 16px;
}

.fca-widget-area--portal_sidebar,
.fca-widget-area--portal_footer {
    margin-top: 0;
}

/* ==========================================================================
   Dark mode fallbacks — FC variables already flip in html.dark; these
   only cover the hardcoded light fallbacks when the variables are
   missing.
   ========================================================================== */
html.dark .fca-widget.app_side_widget {
    background: var(--fcom-primary-bg, #1e2022);
}

html.dark .fca-widget .widget_header h3 {
    color: var(--fcom-primary-text, #e4e6eb);
    border-bottom-color: var(--fcom-primary-border, #3a3b3c);
}

html.dark .fca-widget .widget_body,
html.dark .fca-widget-empty,
html.dark .fca-widget .fca-activity-main {
    color: var(--fcom-secondary-text, #b0b3b8);
}

html.dark .fca-widget .fca-stat-item,
html.dark .fca-widget .fca-member-link:hover,
html.dark .fca-widget .fca-member-avatar--default,
html.dark .fca-widget--top_contributors .fca-contributor-item:hover,
html.dark .fca-widget--top_contributors .fca-contributor-rank,
html.dark .fca-widget--top_contributors .fca-contributor-avatar--default,
html.dark .fca-widget--top_contributors .fca-contributor-count,
html.dark .fca-widget--quick_links .fca-quick-links a:hover,
html.dark .fca-widget--activity_feed .fca-activity-avatar .fca-avatar-default,
html.dark .fca-analytics-widget .fca-analytics-item,
html.dark .fca-widget--overview .fca-overview-item,
html.dark .fca-widget--topic_filter .fca-topic-link:hover {
    background: var(--fcom-secondary-bg, #2c2e30);
}

html.dark .fca-widget .fca-member-name,
html.dark .fca-widget .fca-member-avatar--default,
html.dark .fca-widget .fca-activity-user,
html.dark .fca-widget--top_contributors .fca-contributor-name,
html.dark .fca-widget--top_contributors .fca-contributor-avatar--default,
html.dark .fca-widget--quick_links .fca-quick-links a,
html.dark .fca-widget--activity_feed .fca-activity-avatar .fca-avatar-default,
html.dark .fca-widget--overview .fca-overview-value,
html.dark .fca-widget--topic_filter .fca-topic-link {
    color: var(--fcom-primary-text, #e4e6eb);
}

html.dark .fca-widget .fca-activity-item {
    border-bottom-color: var(--fcom-primary-border, #3a3b3c);
}

html.dark .fca-analytics-widget .fca-analytics-highlight {
    border-top-color: var(--fcom-primary-border, #3a3b3c);
}

html.dark .fca-widget--online_members .fca-online-indicator {
    border-color: var(--fcom-primary-bg, #1e2022);
}

html.dark .fca-widget--overview .fca-overview-icon {
    background: var(--fcom-primary-bg, #1e2022);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 768px) {
    .fca-widget.app_side_widget {
        padding: 12px;
        margin-bottom: 12px;
    }

    .fca-widget .widget_header h3 {
        font-size: 14px;
        margin-bottom: 10px;
        padding-bottom: 10px;
    }

    .fca-widget .fca-stats-grid {
        gap: 8px;
    }

    .fca-widget .fca-stat-item {
        padding: 12px 4px;
    }

    .fca-widget .fca-stat-value {
        font-size: 20px;
    }

    .fca-analytics-widget .fca-analytics-grid {
        gap: 8px;
    }

    .fca-analytics-widget .fca-analytics-item {
        padding: 12px 8px;
    }

    .fca-analytics-widget .fca-analytics-value {
        font-size: 20px;
    }

    .fca-widget--overview .fca-overview-item {
        padding: 12px;
        gap: 12px;
    }

    .fca-widget--overview .fca-overview-icon {
        width: 40px;
        height: 40px;
    }

    .fca-widget--overview .fca-overview-icon svg {
        width: 20px;
        height: 20px;
    }

    .fca-widget--overview .fca-overview-value {
        font-size: 18px;
    }
}
