.feed-flex-wrapper {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    gap: 2rem;
    padding: 1rem;
}

.main-feed {
    flex: 1;
    max-width: 650px;
    height: 70vh;
}

.create-post-section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid rgba(30, 83, 89, 0.1);
    max-width: 500px;
    width: 100%;
    box-sizing: border-box;
    margin-top: 3.5rem !important;
}

.post-input-container {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(30, 83, 89, 0.1);
}

.post-input {
    flex: 1;
    border: none;
    outline: none;
    resize: vertical;
    min-height: 60px;
    font-size: 1rem;
    font-family: inherit;
    background: transparent;
    padding: 0.5rem 0;
}

.post-input::placeholder {
    color: #999;
}

.post-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid rgba(30, 83, 89, 0.1);
}

.media-upload-buttons {
    display: flex;
    gap: 0.5rem;
}

.post-submit-btn {
    background: #1e5359;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease;
}

.post-submit-btn:hover {
    background: #153c40;
}

.post-card {
    background: white;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid rgba(30, 83, 89, 0.1);
    overflow: hidden;
}

.post-header {
    padding: 1rem 1.5rem 0.5rem 1.5rem;
}

.post-user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.post-meta {
    flex: 1;
}

.user-name-container {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.username {
    font-weight: 600;
    color: #1e5359;
    text-decoration: none;
}

.username:hover {
    text-decoration: underline;
}

.post-time {
    color: #666;
    font-size: 0.875rem;
}

.post-content {
    padding: 0 1.5rem 1rem 1.5rem;
}

.post-text {
    margin: 0.5rem 0;
    line-height: 1.6;
    color: #333;
}

.post-image, .post-video {
    width: 100%;
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: 8px;
    margin: 1rem 0;
}

.link-preview {
    border: 1px solid rgba(30, 83, 89, 0.2);
    border-radius: 8px;
    overflow: hidden;
    margin: 1rem 0;
}

.link-image {
    width: 100%;
    max-width: 100%;
    height: 200px;
    object-fit: cover;
}

.link-content {
    padding: 1rem;
}

.link-title {
    font-weight: 600;
    color: #1e5359;
    text-decoration: none;
    display: block;
    margin-bottom: 0.5rem;
}

.link-title:hover {
    text-decoration: underline;
}

.link-description {
    color: #666;
    font-size: 0.875rem;
    margin: 0;
}

.post-stats {
    padding: 0 1.5rem;
    display: flex;
    gap: 1rem;
    color: #666;
    font-size: 0.875rem;
    border-bottom: 1px solid rgba(30, 83, 89, 0.1);
    padding-bottom: 0.5rem;
}

.post-stats a {
    color: inherit;
    text-decoration: none;
}

.post-stats a:hover {
    text-decoration: underline;
}

.post-actions {
    padding: 0.75rem 1.5rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.like-btn, .comment-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.like-btn:hover, .comment-btn:hover {
    background: rgba(30, 83, 89, 0.1);
    color: #1e5359;
}

.like-btn.liked {
    color: #e74c3c;
}

.like-btn.liked i {
    color: #e74c3c;
}

.trending-sidebar {
    width: 320px;
    border-radius: 12px;
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid rgba(30, 83, 89, 0.1);
}

.trending-sidebar h3 {
    color: #1e5359;
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.trending-post {
    padding: 1rem 0;
    padding-bottom: 2rem;
    border-bottom: 1px solid rgba(30, 83, 89, 0.1);
}

.trending-post:last-child {
    border-bottom: none;
}

.trending-post-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.user-avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(30, 83, 89, 0.1);
}

.trending-post-meta {
    flex: 1;
}

.trending-post-meta .username {
    font-size: 0.875rem;
    font-weight: 600;
}

.trending-post-meta .post-time {
    font-size: 0.75rem;
    color: #999;
}

.trending-post-text {
    color: #333;
    font-size: 0.875rem;
    line-height: 1.5;
    margin: 0.5rem 0;
}

.trending-post-stats {
    display: flex;
    gap: 1rem;
    color: #666;
    font-size: 0.75rem;
}

.trending-post-stats span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.no-posts {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

.no-posts p {
    font-size: 1.125rem;
    margin: 0;
}

.media-preview {
    margin-top: 1rem;
}

/* Mobile responsive attachment handling */
@media (max-width: 700px) {
    .attachment-grid {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }
    
    .attachment-item {
        padding: 0.5rem !important;
    }
    
    .attachment-image,
    .attachment-video {
        max-height: 300px !important;
        max-width: 100% !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
    }
    
    .file-attachment {
        height: 150px !important;
        padding: 0.75rem !important;
    }
    
    .file-icon {
        width: 40px !important;
        height: 40px !important;
    }
    
    .file-name {
        font-size: 0.8rem !important;
    }
    
    .download-btn {
        padding: 0.4rem 0.8rem !important;
        font-size: 0.8rem !important;
    }
    
    .two-attachments {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
    }
    
    .multiple-attachments .attachments-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
    }
    
    /* Ensure images display fully without cropping */
    .post-image, 
    .post-video,
    .attachment-image,
    .attachment-video {
        max-width: 100% !important;
        max-height: none !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
        border-radius: 8px !important;
    }
    
    /* Fix grid layout for mobile */
    .two-attachments {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
        border-radius: 8px !important;
        overflow: hidden !important;
        background: #f8f9fa !important;
        border: 1px solid #e9ecef !important;
    }
    
    .multiple-attachments .attachments-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: auto auto !important;
        gap: 0.5rem !important;
        padding: 0.5rem !important;
    }
    
    /* Ensure proper image container sizing */
    .image-container,
    .video-container {
        text-align: center !important;
        padding: 0.5rem !important;
    }
    
    .image-container img,
    .video-container video {
        max-width: 100% !important;
        max-height: 250px !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
        border-radius: 8px !important;
    }
}

@media (max-width: 768px) {
    .feed-flex-wrapper {
        flex-direction: column;
        padding: 0.5rem;
        gap: 1rem;
    }

    .main-feed {
        max-width: 100%;
    }

    .trending-sidebar {
        width: 100%;
        position: static;
    }

    .post-card {
        margin-bottom: 1rem;
    }

    .create-post-section {
        margin-top: 4.5rem;
        padding: 1rem;
    }

    .post-input-container {
        gap: 0.75rem;
    }

    .user-avatar {
        width: 40px;
        height: 40px;
    }

    /* Mobile-specific image constraints - ensure full display */
    .post-image, .post-video {
        max-width: 100% !important;
        max-height: none !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
    }

    .link-image {
        max-width: 100% !important;
        height: auto !important;
        max-height: 200px !important;
        object-fit: contain !important;
    }
    
    /* Fix attachment grids for mobile */
    .two-attachments {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
    }
    
    .multiple-attachments .attachments-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
    }
    
    /* Ensure images in attachments display fully */
    .attachment-item img,
    .attachment-item video {
        max-width: 100% !important;
        max-height: 200px !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
    }

    /* Mobile optimizations for post actions */
    .post-actions {
        gap: 0.5rem;
        padding: 0.5rem 1rem;
    }

    .like-btn, .comment-btn, .repost-btn, .edit-btn, .delete-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
        gap: 0.3rem;
    }

    .edit-btn, .delete-btn {
        padding: 0.4rem 0.6rem;
    }

    /* Ensure delete button is always visible for own posts */
    .delete-btn {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: static !important;
    }
}

/* Additional responsive image constraints */
.post-content img,
.post-item img,
.feed-post img {
    max-width: 100% !important;
    height: auto !important;
    box-sizing: border-box;
}

/* Ensure container doesn't overflow */
.post-item,
.feed-post,
.post-card {
    overflow: hidden;
    word-wrap: break-word;
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure post content area is responsive */
.post-content {
    max-width: 100%;
    overflow: hidden;
}

/* Extra small screen optimizations */
@media (max-width: 480px) {
    .post-actions {
        gap: 0.3rem;
        padding: 0.4rem 0.8rem;
        flex-wrap: wrap;
        justify-content: flex-start;
        min-height: auto;
        overflow: visible;
    }

    .like-btn, .comment-btn, .repost-btn, .edit-btn, .delete-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.85rem;
        gap: 0.2rem;
        min-width: auto;
    }

    .edit-btn, .delete-btn {
        padding: 0.3rem 0.5rem;
    }

    /* Ensure delete button is always visible for own posts */
    .delete-btn {
        display: inline-flex !important;
        visibility: visible !important;
    }

    /* Ensure buttons don't overflow */
    .post-actions button {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}
