/* Flock Feed Styles - Mobile-First Responsive Design */
/* Similar to Inside Talk but optimized for performance */
/* CRITICAL: Mobile-first approach to prevent layout breaks */

/* Theme Variables - Classy Dark Grey */
:root {
    --flock-bg-primary: #1a1a1a;
    --flock-bg-secondary: #2a2a2a;
    --flock-bg-card: #252525;
    --flock-border: rgba(255, 255, 255, 0.1);
    --flock-text-primary: rgba(255, 255, 255, 0.95);
    --flock-text-secondary: rgba(255, 255, 255, 0.7);
    --flock-text-muted: rgba(255, 255, 255, 0.5);
    --flock-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
    --flock-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.4), 0 4px 8px rgba(0, 0, 0, 0.3);
    --flock-accent: #fbbf24;
    --flock-accent-hover: #f59e0b;
}

/* Light Theme - Applied to posts container only */
.flock-posts-container.light-theme {
    --flock-bg-primary: #f8f9fa;
    --flock-bg-secondary: #e9ecef;
    --flock-bg-card: #ffffff;
    --flock-border: rgba(139, 92, 246, 0.2);
    --flock-text-primary: rgba(0, 0, 0, 0.9);
    --flock-text-secondary: rgba(0, 0, 0, 0.7);
    --flock-text-muted: rgba(0, 0, 0, 0.5);
    --flock-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --flock-shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.flock-posts-container.light-theme .flock-post {
    background: var(--flock-bg-card) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.flock-posts-container.light-theme .flock-post-text {
    color: var(--flock-text-primary);
}

.flock-posts-container.light-theme .flock-author-name {
    color: #9d7e3a;
    text-shadow: 0 1px 2px rgba(157, 126, 58, 0.15);
}

.flock-posts-container.light-theme .flock-post-header:hover .flock-author-name {
    color: #b8944d;
}

.flock-posts-container.light-theme .flock-author-name::after {
    background: linear-gradient(90deg, transparent, #9d7e3a, transparent);
}

.flock-posts-container.light-theme .flock-author-handle,
.flock-posts-container.light-theme .flock-post-time {
    color: var(--flock-text-secondary);
}

.flock-posts-container.light-theme .flock-action-btn {
    color: var(--flock-text-secondary);
}

.flock-posts-container.light-theme .flock-create-post-card {
    background: linear-gradient(135deg, var(--flock-bg-card), var(--flock-bg-secondary));
}

.flock-posts-container.light-theme .flock-create-post-body textarea {
    background: rgba(0, 0, 0, 0.05);
    color: var(--flock-text-primary);
    border-color: rgba(139, 92, 246, 0.2);
}

.flock-posts-container.light-theme .flock-editor-toolbar {
    background: rgba(139, 92, 246, 0.05);
}

.flock-posts-container.light-theme .flock-toolbar-btn {
    color: var(--flock-text-primary);
}

.flock-posts-container.light-theme .flock-emoji-picker {
    background: var(--flock-bg-card);
}


/* Container - Mobile First - uses website theme */
.flock-feed-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 10px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden; /* Prevent horizontal scroll on mobile */
    overflow-y: auto; /* Enable vertical scrolling on mobile */
    /* No background - let website theme show through */
    min-height: 100vh;
    position: relative;
    /* Enable smooth scrolling with hardware acceleration */
    -webkit-overflow-scrolling: touch;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Ensure section background - uses website theme, not flock feed theme */
#flock-feedSection {
    /* Let website theme apply to section background */
    min-height: 100vh;
    position: relative;
    z-index: 1;
    width: 100%;
    margin: 0;
    /* Add padding to prevent header from being hidden under navbar */
    padding-top: 80px;
    padding-bottom: 20px;
}

/* When Flock Feed is active, ensure it's the only visible section */
#flock-feedSection[style*="display: block"] {
    position: relative;
    z-index: 10;
}

/* Ensure container doesn't hide header */
#flock-feedSection .container {
    position: relative;
    z-index: 1;
}

/* Note: Body background is handled by JavaScript to avoid affecting other sections */

/* Fallback for browsers that don't support :has() - only apply to flock feed section */
@supports not (selector(:has(*))) {
    #flock-feedSection {
        background: var(--flock-bg-primary) !important;
    }
}

/* Mobile/PWA specific background fix - highest priority */
@media (max-width: 768px) {
    #flock-feedSection {
        background: var(--flock-bg-primary) !important;
        background-image: none !important;
        /* Adjust padding for mobile navbar */
        padding-top: 70px;
    }
    
    .flock-feed-header {
        padding: 20px 15px;
        margin-bottom: 30px;
    }
    
    /* PWA standalone mode - only affect flock feed section */
    @media (display-mode: standalone) {
        #flock-feedSection {
            background: var(--flock-bg-primary) !important;
            background-image: none !important;
        }
    }
}

/* Desktop override */
@media (min-width: 769px) {
    .flock-feed-container {
        max-width: 850px;
        padding: 20px;
    }
}

/* Header - Mobile Optimized */
.flock-feed-header {
    display: flex !important;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    padding: 30px 20px 10px 20px;
    /* Safe area for notched phones */
    padding-top: max(30px, env(safe-area-inset-top));
    position: relative;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 100;
}

.flock-header-content {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.flock-header-content h1 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #fbbf24 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    letter-spacing: -0.5px;
    line-height: 1.2;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    overflow: visible !important;
}

.flock-header-content p {
    color: var(--flock-text-primary);
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto;
    padding: 0 20px;
}

/* CRITICAL: Ensure light theme header text is visible */
.flock-feed-container.light-theme .flock-header-content h1 {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #f59e0b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.flock-feed-container.light-theme .flock-header-content p {
    color: var(--flock-text-primary);
    font-weight: 500;
}

/* Theme Toggle */
.flock-theme-toggle {
    position: absolute;
    top: 20px;
    right: 10px;
    display: flex !important;
    align-items: center;
    gap: 8px;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 101;
}

.flock-theme-btn {
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.3s;
    padding: 0;
}

.flock-theme-btn:hover {
    background: rgba(139, 92, 246, 0.3);
    transform: scale(1.05);
}

/* Desktop override */
@media (min-width: 769px) {
    .flock-feed-header {
        margin-bottom: 40px;
        padding: 30px 20px;
    }
    
    .flock-header-content h1 {
        font-size: 2.5rem;
    }
    
    .flock-header-content p {
        font-size: 1.125rem;
    }
}

@media (max-width: 768px) {
    .flock-header-content h1 {
        font-size: 1.75rem;
    }
    
    .flock-header-content p {
        font-size: 0.9375rem;
    }
    
    .flock-theme-toggle {
        top: 15px;
        right: 5px;
    }
}

/* Admin Create Post Section - Mobile Safe */
.flock-create-post-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 10px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    /* Prevent body scroll when modal is open */
    overscroll-behavior: contain;
}

.flock-create-post-card {
    background: linear-gradient(135deg, rgba(30, 27, 75, 0.98) 0%, rgba(55, 48, 107, 0.98) 100%);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 12px; /* Smaller radius on mobile */
    max-width: 100%;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Safe areas for notched phones */
    margin: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

@media (min-width: 769px) {
    .flock-create-post-card {
        max-width: 600px;
        border-radius: 16px;
        margin: 0;
    }
}

.flock-create-post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
}

.flock-create-post-header h3 {
    color: #fff;
    font-size: 1.25rem;
    margin: 0;
}

.close-flock-create-post {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.3s;
}

.close-flock-create-post:hover {
    color: #fff;
}

.flock-create-post-body {
    padding: 20px;
}

/* Rich Text Editor Toolbar */
.flock-editor-toolbar {
    display: flex;
    gap: 8px;
    padding: 8px;
    background: transparent;
    border: none;
    margin-bottom: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.flock-toolbar-btn {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 4px;
    color: #60a5fa;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s;
    padding: 0;
}

.flock-toolbar-btn:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.5);
    transform: scale(1.05);
}

.flock-toolbar-btn:active,
.flock-toolbar-btn.active {
    background: rgba(59, 130, 246, 0.35);
    border-color: rgba(59, 130, 246, 0.7);
}

.flock-emoji-toggle-btn {
    margin-left: auto;
    font-size: 1.25rem;
}

/* Emoji Picker */
.flock-emoji-picker {
    background: rgba(30, 27, 75, 0.98);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    max-height: 200px;
    overflow-y: auto;
}

.flock-emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 5px;
}

.flock-emoji-item {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 8px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.flock-emoji-item:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.3);
    transform: scale(1.1);
}

@media (max-width: 768px) {
    .flock-toolbar-btn,
    .flock-media-btn {
        width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }
    
    .flock-emoji-grid {
        grid-template-columns: repeat(auto-fill, minmax(35px, 1fr));
    }
    
    .flock-emoji-item {
        font-size: 1.25rem;
        padding: 6px;
    }
    
    .flock-publish-btn {
        padding: 10px 20px;
        font-size: 0.8125rem;
    }
}

.flock-create-post-body textarea {
    width: 100%;
    min-height: 150px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 8px;
    color: #fff;
    padding: 15px;
    font-size: 16px; /* Prevent zoom on iOS */
    font-family: inherit;
    resize: none;
    margin-bottom: 10px;
    line-height: 1.5;
    box-sizing: border-box;
    /* Better mobile input */
    -webkit-appearance: none;
    appearance: none;
    /* CRITICAL: Enable line breaks and text selection */
    white-space: pre-wrap;
    word-wrap: break-word;
    /* Enable text selection and copy/paste on mobile */
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
    /* Enable long-press context menu on mobile */
    -webkit-touch-callout: default !important;
    touch-action: auto !important;
}

.flock-create-post-body textarea:focus {
    outline: none;
    border-color: rgba(139, 92, 246, 0.6);
}

/* CRITICAL: Specific ID selector for flockPostText to ensure highest specificity */
#flockPostText {
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
    -webkit-touch-callout: default !important;
    touch-action: auto !important;
}

/* Bottom Bar */
.flock-bottom-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    margin-bottom: 15px;
}

.flock-media-actions {
    display: flex;
    gap: 10px;
}

.flock-media-btn {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 4px;
    color: #60a5fa;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.2s;
    padding: 0;
}

.flock-media-btn:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.5);
    transform: scale(1.05);
}

.flock-char-count {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.875rem;
    font-weight: 500;
}

/* Publish Button */
.flock-publish-btn {
    width: 100%;
    background: linear-gradient(135deg, rgba(100, 100, 100, 0.3), rgba(120, 120, 120, 0.3));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.5);
    padding: 12px 24px;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: not-allowed;
    transition: all 0.3s;
    margin-top: 10px;
}

.flock-publish-btn.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.8), rgba(37, 99, 235, 0.8));
    border-color: rgba(59, 130, 246, 0.5);
    color: #fff;
    cursor: pointer;
}

.flock-publish-btn.active:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 1), rgba(37, 99, 235, 1));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Media Preview */
.flock-media-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.flock-media-preview-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1;
    background: rgba(0, 0, 0, 0.3);
}

.flock-media-preview-item img,
.flock-media-preview-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.flock-media-preview-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: #fff;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.flock-media-preview-remove:hover {
    background: rgba(239, 68, 68, 0.9);
    transform: scale(1.1);
}

.flock-media-upload-section {
    margin-top: 20px;
}

.flock-media-upload-label {
    display: block;
    color: #fff;
    font-weight: 500;
    margin-bottom: 10px;
}

.flock-media-upload-input {
    /* Hide visually but keep accessible for mobile file picker */
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
    /* DO NOT use pointer-events: none - it breaks mobile file picker */
}

.flock-media-upload-info {
    margin-top: 5px;
}

.flock-media-upload-info small {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
}

.flock-media-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.flock-media-preview-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1;
}

.flock-media-preview-item img,
.flock-media-preview-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.flock-remove-media {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flock-create-post-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.flock-create-post-actions button {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

/* Admin Actions */
.flock-admin-actions {
    margin-bottom: 20px;
    margin-top: 10px;
    text-align: center;
    padding: 5px 10px;
    position: relative;
    z-index: 10;
    /* DO NOT use display: block !important - it breaks admin-only visibility */
}

.flock-create-post-btn {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #000;
    border: none;
    padding: 14px 28px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(251, 191, 36, 0.4);
    width: auto;
    min-width: 200px;
    display: inline-block;
}

.flock-create-post-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(251, 191, 36, 0.6);
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* Mobile-specific button styling */
@media (max-width: 768px) {
    .flock-admin-actions {
        margin-bottom: 20px;
        margin-top: 5px;
        padding: 5px 10px;
    }
    
    .flock-create-post-btn {
        width: calc(100% - 40px);
        max-width: 400px;
        padding: 16px 24px;
        font-size: 1.1rem;
        margin: 5px auto;
        display: block;
        /* DO NOT use !important - it breaks admin-only visibility */
    }
}

/* Posts Container - Mobile Safe - Theme applies here */
.flock-posts-container {
    width: 100%;
    overflow-x: hidden; /* Prevent horizontal scroll */
    /* Better rendering on mobile */
    contain: layout style paint;
    /* Add background and padding to create themed area */
    background: var(--flock-bg-primary);
    padding: 24px;
    border-radius: 12px;
    margin-top: 20px;
    /* Enable smooth scrolling */
    -webkit-overflow-scrolling: touch;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Individual Post - Mobile Optimized with Classy Dark Grey */
.flock-post {
    background: var(--flock-bg-card) !important;
    border: 1px solid var(--flock-border);
    border-radius: 14px;
    padding: 0;
    margin-bottom: 24px;
    box-shadow: var(--flock-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    animation: slideInUp 0.4s ease-out forwards;
    opacity: 0;
    contain: layout style paint;
    background-image: none !important;
    backdrop-filter: blur(10px);
    /* Hardware acceleration for smooth rendering */
    transform: translateZ(0);
    backface-visibility: hidden;
}

@media (min-width: 769px) {
    .flock-post {
        border-radius: 16px;
        margin-bottom: 32px;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        animation: slideInUp 0.5s ease-out forwards;
        /* Enable will-change only on desktop */
        will-change: transform;
    }
}

/* Hover effects only on desktop */
@media (min-width: 769px) and (hover: hover) {
    .flock-post:hover {
        transform: translateY(-4px);
        box-shadow: var(--flock-shadow-hover);
        border-color: rgba(255, 255, 255, 0.15);
    }
}

/* Active state for mobile touch */
@media (max-width: 768px) {
    .flock-post:active {
        transform: scale(0.98);
        transition: transform 0.1s;
    }
}

.flock-post::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #c9a961, #d4b574, #c9a961, transparent);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.flock-post:hover::before {
    opacity: 0.6;
}

.flock-posts-container.light-theme .flock-post::before {
    background: linear-gradient(90deg, transparent, #9d7e3a, #b8944d, #9d7e3a, transparent);
}

.flock-post-container {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 18px;
    align-items: flex-start;
}

@media (min-width: 769px) {
    .flock-post-container {
        gap: 16px;
        padding: 24px;
    }
}

/* Avatar - Mobile Optimized */
.flock-post-avatar {
    flex-shrink: 0;
}

.flock-profile-pic {
    width: 44px; /* Slightly larger for better visibility */
    height: 44px;
    border-radius: 10px; /* Classy rounded square */
    border: 2.5px solid rgba(201, 169, 97, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 10px rgba(201, 169, 97, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.06);
    /* Ensure image fits properly */
    object-fit: cover;
    object-position: center;
    /* Better image rendering */
    image-rendering: -webkit-optimize-contrast;
    background: linear-gradient(135deg, rgba(201, 169, 97, 0.08), rgba(212, 181, 116, 0.08));
}

@media (min-width: 769px) {
    .flock-profile-pic {
        width: 52px;
        height: 52px;
        border-radius: 12px; /* Slightly larger radius for desktop */
    }
}

.flock-post-avatar:hover .flock-profile-pic {
    border-color: rgba(201, 169, 97, 0.6);
    transform: scale(1.05) rotate(1deg);
    box-shadow: 0 4px 18px rgba(201, 169, 97, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.flock-posts-container.light-theme .flock-profile-pic {
    border-color: rgba(157, 126, 58, 0.4);
    box-shadow: 0 2px 10px rgba(157, 126, 58, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.06);
    background: linear-gradient(135deg, rgba(157, 126, 58, 0.06), rgba(184, 148, 77, 0.06));
}

.flock-posts-container.light-theme .flock-post-avatar:hover .flock-profile-pic {
    border-color: rgba(157, 126, 58, 0.6);
    box-shadow: 0 4px 18px rgba(157, 126, 58, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.08);
}

/* Content */
.flock-post-content {
    flex: 1;
    min-width: 0;
}

.flock-post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.flock-author-name {
    color: #c9a961;
    font-weight: 700;
    font-size: 1.0625rem;
    letter-spacing: 0.3px;
    position: relative;
    display: inline-block;
    transition: all 0.3s ease;
    text-shadow: 0 1px 3px rgba(201, 169, 97, 0.2);
}

.flock-author-name::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #c9a961, transparent);
    transition: width 0.3s ease;
}

.flock-post-header:hover .flock-author-name {
    color: #d4b574;
}

.flock-post-header:hover .flock-author-name::after {
    width: 100%;
}

.flock-author-handle {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.875rem;
    display: none; /* Hidden as per requirement */
}

.flock-post-time {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    font-weight: 500;
}

.flock-post-text {
    color: #e8e8e8;
    font-size: 1.0625rem;
    line-height: 1.7;
    margin-bottom: 16px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-weight: 400;
    letter-spacing: 0.3px;
    /* CRITICAL: Preserve spaces and line breaks in posts */
    white-space: pre-wrap !important;
    word-break: break-word;
}

.flock-posts-container.light-theme .flock-post-text {
    color: rgba(0, 0, 0, 0.87);
    font-weight: 450;
}

/* Media Grid */
.flock-post-media {
    margin-top: 15px;
    border-radius: 12px;
    overflow: hidden;
}

.flock-media-grid {
    display: grid;
    gap: 4px;
}

.flock-media-grid.grid-1 {
    grid-template-columns: 1fr;
}

.flock-media-grid.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.flock-media-grid.grid-3 {
    grid-template-columns: repeat(2, 1fr);
}

.flock-media-grid.grid-3 .flock-media-item:first-child {
    grid-column: 1 / -1;
}

.flock-media-grid.grid-4 {
    grid-template-columns: repeat(2, 1fr);
}

.flock-media-item {
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    /* Remove fixed aspect ratio to show full images */
    max-height: 500px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flock-media-item img,
.flock-media-item video {
    width: 100%;
    height: auto;
    max-height: 500px;
    object-fit: contain; /* Show full image without cropping */
    transition: transform 0.3s;
}

.flock-media-item:hover img,
.flock-media-item:hover video {
    transform: scale(1.05);
}

/* Post Actions - Mobile Touch Optimized */
.flock-post-actions {
    display: flex;
    gap: 12px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(201, 169, 97, 0.12);
    flex-wrap: wrap; /* Wrap on very small screens */
}

.flock-posts-container.light-theme .flock-post-actions {
    border-top-color: rgba(157, 126, 58, 0.15);
}

@media (min-width: 769px) {
    .flock-post-actions {
        gap: 20px;
        margin-top: 15px;
        padding-top: 15px;
    }
}

.flock-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.65);
    cursor: pointer;
    font-size: 0.8125rem; /* Slightly smaller on mobile */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 8px 12px; /* Larger touch target */
    border-radius: 8px;
    /* Better touch target */
    min-height: 44px; /* iOS recommended touch target */
    min-width: 44px;
    justify-content: center;
    /* Prevent text selection on tap */
    -webkit-tap-highlight-color: rgba(251, 191, 36, 0.15);
    user-select: none;
    font-weight: 500;
}

@media (min-width: 769px) {
    .flock-action-btn {
        padding: 6px 12px;
        min-height: auto;
        min-width: auto;
        font-size: 0.875rem;
    }
}

.flock-action-btn:hover {
    color: #c9a961;
    background: rgba(201, 169, 97, 0.1);
    border-color: rgba(201, 169, 97, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(201, 169, 97, 0.15);
}

.flock-action-btn:active {
    transform: translateY(0);
}

.flock-action-btn.liked {
    color: #ec4899;
    background: rgba(236, 72, 153, 0.12);
    border-color: rgba(236, 72, 153, 0.3);
}

.flock-posts-container.light-theme .flock-action-btn {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
    color: rgba(0, 0, 0, 0.65);
}

.flock-posts-container.light-theme .flock-action-btn:hover {
    color: #9d7e3a;
    background: rgba(157, 126, 58, 0.08);
    border-color: rgba(157, 126, 58, 0.25);
    box-shadow: 0 2px 8px rgba(157, 126, 58, 0.12);
}

.flock-action-count {
    font-weight: 600;
}

/* Loading States */
.flock-loading {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.7);
}

.flock-loading-spinner {
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top: 3px solid #8b5cf6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

/* Empty State */
.flock-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: rgba(255, 255, 255, 0.7);
}

.flock-empty-state h3 {
    color: #fff;
    margin-bottom: 10px;
}

/* Animations */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinning {
    display: inline-block;
    animation: spin 1s linear infinite;
}

/* Mobile Optimizations - CRITICAL FOR PREVENTING LAYOUT BREAKS */
@media (max-width: 768px) {
    /* Prevent horizontal scroll */
    .flock-feed-container,
    .flock-posts-container,
    .flock-post,
    .flock-post-container,
    .flock-post-content,
    .flock-post-text {
        max-width: 100%;
        overflow-x: hidden;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Full width containers - minimal side padding for breathing room */
    .flock-feed-container {
        padding: 0 8px !important;
        margin: 0 !important;
        /* Enhanced mobile scrolling */
        -webkit-overflow-scrolling: touch !important;
        transform: translate3d(0, 0, 0) !important;
        backface-visibility: hidden !important;
    }
    
    .flock-posts-container {
        padding: 16px 12px !important;
        margin: 0 !important;
        border-radius: 0 !important;
        /* Enhanced mobile scrolling */
        -webkit-overflow-scrolling: touch !important;
        transform: translate3d(0, 0, 0) !important;
    }

    .flock-feed-header {
        padding: 15px 16px 10px 16px !important;
    }
    
    /* CRITICAL: Prevent posts from sticking during scroll */
    .flock-post {
        /* Remove will-change on mobile */
        will-change: auto !important;
        /* Use translate3d for hardware acceleration */
        transform: translate3d(0, 0, 0) !important;
        backface-visibility: hidden !important;
        /* Disable transitions on mobile for smoother scroll */
        transition: none !important;
    }
    
    /* Disable hover transforms on mobile */
    .flock-post:hover {
        transform: translate3d(0, 0, 0) !important;
    }
    
    /* Prevent action buttons from causing layout shifts */
    .flock-action-btn {
        transform: translate3d(0, 0, 0) !important;
        backface-visibility: hidden !important;
    }
    
    .flock-action-btn:hover {
        transform: translate3d(0, 0, 0) !important;
    }

    .flock-feed-header h1 {
        font-size: 1.5rem;
    }

    .flock-feed-header p {
        font-size: 0.875rem;
        padding: 0 !important;
    }
    
    /* Posts - proper spacing on mobile (don't override margin-bottom) */
    .flock-post {
        border-radius: 12px !important;
        border: 1px solid var(--flock-border) !important;
        padding: 0 !important;
        /* Ensure stable positioning */
        position: relative !important;
    }

    .flock-post-container {
        padding: 16px !important;
        gap: 12px;
    }

    .flock-profile-pic {
        width: 40px;
        height: 40px;
        /* Prevent image rendering issues */
        transform: translate3d(0, 0, 0);
        backface-visibility: hidden;
    }

    .flock-author-name {
        font-size: 0.9375rem;
    }

    .flock-author-handle,
    .flock-post-time {
        font-size: 0.8125rem;
    }

    .flock-post-text {
        font-size: 0.9375rem;
        line-height: 1.5;
    }
    
    /* Ensure content container has no offset on mobile */
    .flock-post-content {
        padding: 0;
        margin: 0;
        width: 100%;
    }

    .flock-post-actions {
        gap: 10px;
        margin-top: 16px;
        padding-top: 16px;
    }

    .flock-action-btn {
        font-size: 0.8125rem;
        padding: 8px 10px;
    }

    .flock-create-post-container {
        padding: 5px;
    }

    .flock-create-post-card {
        max-height: 95vh;
        border-radius: 12px;
    }

    .flock-create-post-header,
    .flock-create-post-body {
        padding: 15px;
    }

    /* Media grid - stack vertically on mobile */
    .flock-media-grid.grid-2,
    .flock-media-grid.grid-3,
    .flock-media-grid.grid-4 {
        grid-template-columns: 1fr !important;
        gap: 8px;
    }

    .flock-media-grid.grid-3 .flock-media-item:first-child {
        grid-column: 1;
    }
    
    /* Ensure media doesn't overflow */
    .flock-post-media {
        max-width: 100%;
        overflow: hidden;
    }
    
    .flock-media-item {
        max-width: 100%;
    }
    
    .flock-media-item {
        max-height: 400px; /* Smaller max height on mobile */
    }
    
    .flock-media-item img,
    .flock-media-item video {
        max-width: 100%;
        max-height: 400px;
        height: auto;
        object-fit: contain; /* Ensure full image on mobile */
    }
}

/* Small Mobile Devices - Extra Safety */
@media (max-width: 480px) {
    .flock-feed-container {
        padding: 8px 3px;
    }

    .flock-post {
        border-radius: 10px;
        margin-bottom: 20px;
    }

    .flock-post-container {
        padding: 10px;
        gap: 8px;
    }

    .flock-profile-pic {
        width: 36px;
        height: 36px;
    }
    
    .flock-author-name {
        font-size: 0.875rem;
    }
    
    .flock-author-handle,
    .flock-post-time {
        font-size: 0.75rem;
    }
    
    .flock-post-text {
        font-size: 0.875rem;
    }

    .flock-post-actions {
        gap: 8px;
        margin-top: 14px;
        padding-top: 14px;
        flex-wrap: wrap;
    }
    
    .flock-action-btn {
        padding: 6px 8px;
        font-size: 0.75rem;
        min-height: 40px;
        min-width: 40px;
    }
    
    .flock-feed-header h1 {
        font-size: 1.25rem;
    }
    
    .flock-feed-header p {
        font-size: 0.8125rem;
    }
}

/* Tablet and Desktop */
@media (min-width: 769px) {
    .flock-feed-container {
        padding: 30px 20px;
    }

    .flock-post:nth-child(even) {
        animation-delay: 0.1s;
    }
}

/* High Resolution Displays */
@media (min-width: 1200px) {
    .flock-feed-container {
        max-width: 900px;
    }
}

/* Dark Mode Support (if needed) */
@media (prefers-color-scheme: dark) {
    .flock-post {
        background: linear-gradient(135deg, rgba(20, 17, 55, 0.95) 0%, rgba(45, 38, 87, 0.95) 100%);
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .flock-post,
    .flock-action-btn,
    .flock-profile-pic,
    .flock-media-item img,
    .flock-media-item video {
        animation: none !important;
        transition: none !important;
    }
}

/* Landscape Mobile - Optimize for horizontal space */
@media (max-width: 768px) and (orientation: landscape) {
    .flock-create-post-card {
        max-height: 85vh;
    }
    
    .flock-create-post-body textarea {
        min-height: 80px;
    }
}

/* iOS Safe Area Support */
@supports (padding: max(0px)) {
    .flock-feed-container {
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    
    .flock-create-post-container {
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
}

/* Prevent zoom on input focus (iOS) */
@media (max-width: 768px) {
    .flock-create-post-body textarea,
    .flock-media-upload-input {
        font-size: 16px !important; /* Prevents iOS zoom */
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .flock-profile-pic {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print Styles */
@media print {
    .flock-admin-actions,
    .flock-create-post-container,
    .flock-post-actions {
        display: none;
    }

    .flock-post {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* Delete Button (Admin Only) - Inline with actions */
.flock-delete-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.3s;
    min-height: 44px;
    font-weight: 500;
}

.flock-delete-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.flock-delete-btn:active {
    transform: scale(0.95);
}

/* Reply Modal */
.flock-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.flock-modal-content {
    background: var(--flock-bg-card);
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--flock-shadow-hover);
    animation: slideInUp 0.3s ease;
}

.flock-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--flock-border);
}

.flock-modal-header h3 {
    margin: 0;
    color: var(--flock-text-primary);
    font-size: 20px;
}

.flock-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--flock-text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.flock-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--flock-text-primary);
}

.flock-modal-body {
    padding: 20px;
}

.flock-reply-original {
    background: var(--flock-bg-secondary);
    border-left: 3px solid var(--flock-accent);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.flock-reply-original strong {
    color: var(--flock-text-primary);
    display: block;
    margin-bottom: 6px;
}

.flock-reply-original p {
    color: var(--flock-text-secondary);
    margin: 0;
    font-size: 14px;
}

.flock-modal-body textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 1px solid var(--flock-border);
    border-radius: 8px;
    background: var(--flock-bg-secondary);
    color: var(--flock-text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.flock-modal-body textarea:focus {
    outline: none;
    border-color: var(--flock-accent);
}

.flock-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid var(--flock-border);
}

.flock-modal-footer button {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.flock-modal-footer .btn-secondary {
    background: var(--flock-bg-secondary);
    color: var(--flock-text-primary);
}

.flock-modal-footer .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.flock-modal-footer .btn-primary {
    background: var(--flock-accent);
    color: #000;
}

.flock-modal-footer .btn-primary:hover {
    background: var(--flock-accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);
}

.flock-modal-footer .btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Share Options */
.flock-share-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.flock-share-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.3s;
    cursor: pointer;
}

.flock-share-btn:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.4);
    color: rgba(255, 255, 255, 0.9);
}

.flock-share-btn span:first-child {
    font-size: 16px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .flock-modal {
        padding: 10px;
    }
    
    .flock-modal-content {
        max-height: 95vh;
    }
    
    .flock-modal-header,
    .flock-modal-body,
    .flock-modal-footer {
        padding: 16px;
    }
    
    .flock-delete-btn {
        padding: 6px 8px;
        font-size: 0.75rem;
        min-height: 40px;
    }
    
    .flock-share-btn {
        padding: 10px 12px;
        font-size: 0.8125rem;
    }
}

/* Hide footer when Flock Feed is active */
#flock-feedSection[style*="display: block"] ~ footer,
#flock-feedSection[style*="display:block"] ~ footer {
    display: none !important;
}

/* CRITICAL: Mobile background override - must be at end of file */
@media (max-width: 768px) {
    /* Note: Body background is handled by JavaScript to prevent affecting other sections */
    
    #flock-feedSection,
    #flock-feedSection.page-section {
        background: var(--flock-bg-primary) !important;
        background-image: none !important;
    }
    
    .flock-feed-container {
        background: var(--flock-bg-primary) !important;
        background-image: none !important;
    }
    
    /* CRITICAL: Override any blue gradient backgrounds on posts */
    .flock-post {
        background: var(--flock-bg-card) !important;
        background-image: none !important;
    }
    
    .flock-post-container {
        background: transparent !important;
        background-image: none !important;
    }
    
    /* Ensure create post card uses theme colors */
    .flock-feed-container:not(.light-theme) .flock-create-post-card {
        background: linear-gradient(135deg, rgba(30, 27, 75, 0.98) 0%, rgba(55, 48, 107, 0.98) 100%) !important;
    }
    
    /* Light theme specific mobile overrides */
    .flock-feed-container.light-theme .flock-post {
        background: #ffffff !important;
        border: 1px solid rgba(0, 0, 0, 0.1) !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    }
    
    .flock-feed-container.light-theme .flock-create-post-card {
        background: #ffffff !important;
        border: 1px solid rgba(139, 92, 246, 0.2) !important;
    }
    
    .flock-feed-container.light-theme .flock-action-btn {
        color: rgba(0, 0, 0, 0.6) !important;
    }
    
    .flock-feed-container.light-theme .flock-action-btn:hover,
    .flock-feed-container.light-theme .flock-action-btn:active {
        color: #8b5cf6 !important;
        background: rgba(139, 92, 246, 0.1) !important;
    }
}

/* Pinned Post Styles */
.flock-pinned-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(212, 175, 55, 0.05));
    border-left: 3px solid #d4af37;
    border-radius: 8px 8px 0 0;
    font-size: 13px;
    font-weight: 600;
    color: #d4af37;
    margin-bottom: 8px;
    width: 100%;
    flex-basis: 100%;
}

.flock-pin-icon {
    font-size: 14px;
}

.flock-pinned-post {
    border: 2px solid rgba(212, 175, 55, 0.3) !important;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.2) !important;
}

.flock-pin-btn.pinned {
    background: rgba(212, 175, 55, 0.2) !important;
    border-color: #d4af37 !important;
    color: #d4af37 !important;
}

.flock-pin-btn.pinned span {
    animation: pinPulse 2s ease-in-out infinite;
}

@keyframes pinPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Light theme pinned styles */
.flock-posts-container.light-theme .flock-pinned-indicator {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.2), rgba(212, 175, 55, 0.08));
    color: #b8860b;
    border-left-color: #b8860b;
}

.flock-posts-container.light-theme .flock-pinned-post {
    border-color: rgba(212, 175, 55, 0.4) !important;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.25) !important;
}

.flock-posts-container.light-theme .flock-pin-btn.pinned {
    background: rgba(212, 175, 55, 0.25) !important;
    color: #b8860b !important;
}
