/**
 * Infinite Scroll Feed Styles
 * TikTok-inspired modern feed with easy interactions
 */

/* ============================================================================
   FEED CONTAINER
   ============================================================================ */

.feed-container {
    max-width: 680px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Home page feed should be full width */
#homePage .feed-container {
    max-width: 1400px;
}

#homePage .feed-item {
    max-width: 100%;
}

.feed-header {
    text-align: center;
    margin-bottom: 2rem;
}

.feed-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #a855f7, #d946ef);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.feed-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ============================================================================
   FEED CARDS
   ============================================================================ */

.feed-item {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.feed-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(168, 85, 247, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* Feed Item Header */
.feed-item-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
}

.feed-user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(168, 85, 247, 0.4);
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.feed-user-avatar:hover {
    border-color: #a855f7;
    transform: scale(1.05);
}

.feed-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.feed-user-avatar i {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #a855f7, #d946ef);
    color: white;
    font-size: 1.5rem;
}

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

.feed-user-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.feed-user-name:hover {
    color: #a855f7;
}

.feed-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 0.125rem;
}

.feed-meta-separator {
    color: rgba(255, 255, 255, 0.2);
}

.feed-category-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--bg-dark);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color);
    transition: all 0.3s;
}

.feed-category-badge:hover {
    background: var(--primary-color);
    color: white;
}

/* Feed Item Content */
.feed-item-content {
    cursor: pointer;
}

.feed-item-media {
    position: relative;
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.feed-item-media img,
.feed-item-media video {
    width: 100%;
    height: auto;
    display: block;
    max-height: 600px;
    object-fit: cover;
}

.feed-content-type-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.feed-content-type-badge i {
    font-size: 1rem;
}

.feed-item-text {
    padding: 1.25rem;
}

.feed-item-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.feed-item-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.feed-item-game-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    transition: all 0.2s ease;
}

.feed-item-game-tag:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transform: translateY(-1px);
}

.feed-item-game-tag i {
    font-size: 0.8rem;
}

/* TikTok-Style Action Bar */
.feed-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.feed-action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.feed-action-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.feed-action-btn i {
    font-size: 1.25rem;
    transition: all 0.2s ease;
}

.feed-action-btn.liked {
    color: #ef4444;
}

.feed-action-btn.liked i {
    animation: likeAnimation 0.4s ease;
}

@keyframes likeAnimation {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

.feed-action-btn .action-count {
    font-size: 0.9rem;
    font-weight: 600;
}

.feed-action-btn:hover i {
    transform: scale(1.1);
}

/* Share button special styling */
.feed-action-btn.share-btn:hover {
    color: #3b82f6;
}

/* Activity Feed Items */
.feed-item.activity-item {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.05), rgba(217, 70, 239, 0.05));
    border-color: rgba(168, 85, 247, 0.2);
}

.activity-content {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.activity-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a855f7, #d946ef);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.activity-text {
    flex: 1;
}

.activity-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.activity-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============================================================================
   LOADING & END STATES
   ============================================================================ */

.feed-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    gap: 1rem;
}

.feed-loading i {
    font-size: 2.5rem;
    background: linear-gradient(135deg, #a855f7, #d946ef);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.feed-loading-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* You're All Caught Up */
.feed-end-message {
    text-align: center;
    padding: 3rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    margin-bottom: 2rem;
}

.feed-end-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: linear-gradient(135deg, #a855f7, #d946ef);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.feed-end-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #a855f7, #d946ef);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.feed-end-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

.feed-end-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, #a855f7, #d946ef);
    color: white;
    padding: 0.875rem 1.75rem;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

.feed-end-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(168, 85, 247, 0.4);
}

/* Intersection Observer Sentinel */
.feed-sentinel {
    height: 1px;
    width: 100%;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .feed-container {
        padding: 1rem 0.5rem;
    }

    .feed-item {
        border-radius: 12px;
        margin-bottom: 1rem;
    }

    .feed-item-header {
        padding: 0.875rem 1rem;
    }

    .feed-item-text {
        padding: 1rem;
    }

    .feed-actions {
        padding: 0.875rem 1rem;
        gap: 0.5rem;
    }

    .feed-action-btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.85rem;
    }

    .feed-action-btn i {
        font-size: 1.125rem;
    }

    .feed-item-title {
        font-size: 1rem;
    }

    .feed-item-description {
        font-size: 0.875rem;
    }

    .feed-end-icon {
        width: 64px;
        height: 64px;
        font-size: 2rem;
    }

    .feed-end-title {
        font-size: 1.25rem;
    }
}

/* Dark theme adjustments */
[data-theme="light"] .feed-item {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .feed-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .feed-actions {
    border-top-color: rgba(0, 0, 0, 0.05);
}

/* ============================================================================
   GALLERY FEED LAYOUT
   ============================================================================ */

.gallery-feed {
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
}

/* When gallery is in forum-content, adjust spacing */
.forum-content .gallery-feed {
    max-width: 100%;
    padding: 0;
}

.gallery-item {
    /* Additional gallery-specific styles can go here */
}

/* Adjust feed-item width when inside forum-content */
.forum-content .feed-item {
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* Feed items in gallery should use available space */
#galleryPage .forum-content .feed-item {
    max-width: 100%;
}

/* Gallery sidebar behavior */
/* On desktop, always show sidebar regardless of collapsed class */
@media (min-width: 769px) {
    #gallerySidebar.forum-sidebar.collapsed {
        display: flex !important;
        flex-direction: column;
    }
}

/* Latest Comment Preview in Feed Items - Full Width */
.feed-item .post-last-comment-preview {
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 0;
    margin-top: 0;
    padding: 18px 24px;
    background: var(--bg-dark);
    border-left: 3px solid var(--primary-color);
    border-radius: 0;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.feed-item .last-comment-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.feed-item .last-comment-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.feed-item .last-comment-avatar i {
    font-size: 32px;
    color: var(--text-secondary);
}

.feed-item .last-comment-details {
    flex: 1;
    min-width: 0;
}

.feed-item .last-comment-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    flex-wrap: wrap;
}

.feed-item .last-comment-author {
    font-weight: 600;
    color: var(--text-primary);
}

.feed-item .last-comment-time {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.feed-item .last-comment-snippet {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
}

.feed-item .post-last-activity {
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 0;
    margin-top: 0;
    padding: 18px 24px;
    background: var(--bg-dark);
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.feed-item .post-last-activity i {
    margin-right: 5px;
}

/* On mobile, ensure proper display states */
@media (max-width: 768px) {
    #gallerySidebar.forum-sidebar {
        display: flex;
        flex-direction: column;
    }

    #gallerySidebar.forum-sidebar.collapsed {
        display: none !important;
    }

    .feed-item .post-last-comment-preview,
    .feed-item .post-last-activity {
        margin-left: 0;
        margin-right: 0;
        margin-top: 0;
        margin-bottom: 0;
        padding: 16px 20px;
    }
}
