/**
 * Social Newsfeed CSS - Facebook/LinkedIn Style Posts
 * Individual posts with interactions
 */

/* ===== NEWSFEED CONTAINER ===== */
.newsfeed-container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* ===== POST CREATION BOX ===== */
.post-creation-box {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    padding: 16px;
}

.post-creation-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.post-creation-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
}

.post-creation-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    resize: none;
    min-height: 20px;
    max-height: 120px;
    font-family: inherit;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s ease;
    background: #f8fafc;
}

.post-creation-input:focus {
    border-color: #4f46e5;
    background: white;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.post-creation-input::placeholder {
    color: #64748b;
}

.post-creation-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
    margin-top: 12px;
}

.post-media-options {
    display: flex;
    gap: 8px;
}

.media-btn {
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: #64748b;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.media-btn:hover {
    background: #f1f5f9;
    color: #4f46e5;
}

.post-submit-btn {
    padding: 8px 20px;
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s ease;
}

.post-submit-btn:hover:not(:disabled) {
    background: #4338ca;
}

.post-submit-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
}

/* ===== NEWSFEED POSTS ===== */
.newsfeed-posts {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.newsfeed-post {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.newsfeed-post:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.post-header {
    display: flex;
    align-items: center;
    padding: 16px 16px 12px;
    gap: 12px;
}

.post-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
}

.post-author-info {
    flex: 1;
    min-width: 0;
}

.post-author-name {
    font-weight: 600;
    font-size: 15px;
    color: #2d3748;
    margin-bottom: 2px;
}

.post-time {
    font-size: 13px;
    color: #64748b;
}

.post-menu-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #64748b;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    position: relative;
}

.post-menu-btn:hover {
    background: #f1f5f9;
}

/* Post dropdown menu */
.post-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    min-width: 120px;
    z-index: 1000;
    display: none;
}

.post-dropdown-menu.show {
    display: block;
}

.post-dropdown-item {
    padding: 8px 16px;
    color: #2d3748;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.post-dropdown-item:hover {
    background: #f1f5f9;
    color: #4f46e5;
}

.post-dropdown-item.delete:hover {
    background: #fed7d7;
    color: #e53e3e;
}

/* Edit mode styles */
.post-content.editing {
    display: none;
}

.post-edit-form {
    display: none;
    padding: 0 16px 12px;
}

.post-edit-form.active {
    display: block;
}

.post-edit-textarea {
    width: 100%;
    min-height: 60px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s ease;
}

.post-edit-textarea:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.post-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.post-edit-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.post-edit-save {
    background: #4f46e5;
    color: white;
}

.post-edit-save:hover {
    background: #4338ca;
}

.post-edit-cancel {
    background: #f1f5f9;
    color: #64748b;
}

.post-edit-cancel:hover {
    background: #e2e8f0;
    color: #4a5568;
}

.post-content {
    padding: 0 16px 12px;
    font-size: 15px;
    line-height: 1.5;
    color: #2d3748;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.post-media {
    margin: 12px 0;
}

.post-image {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
}

.post-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    border-top: 1px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    color: #64748b;
}

.post-likes {
    display: flex;
    align-items: center;
    gap: 4px;
}

.like-emoji {
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #e53e3e 0%, #fc8181 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
}

.post-actions {
    display: flex;
    padding: 8px 4px;
    position: relative;
}

.action-btn {
    flex: 1;
    padding: 10px 8px;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.action-btn:hover {
    background: #f1f5f9;
    color: #4f46e5;
}

.action-btn.liked {
    color: #e53e3e;
}

.action-btn.liked:hover {
    color: #c53030;
    background: #fed7d7;
}

/* ===== EMOJI REACTIONS ===== */
.emoji-reactions-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: white;
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 8px 12px;
    display: none;
    z-index: 1000;
    margin-bottom: 8px;
    min-width: 280px;
}

.emoji-reactions-picker.show {
    display: flex;
    gap: 4px;
    animation: reactionsBounceIn 0.3s ease;
}

.reaction-emoji {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    transition: transform 0.2s ease;
    position: relative;
}

.reaction-emoji:hover {
    transform: scale(1.3);
}

.reaction-emoji::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #2d3748;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    margin-bottom: 4px;
}

.reaction-emoji:hover::before {
    opacity: 1;
}

.post-reactions-summary {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 8px;
}

.reaction-count {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
}

.reaction-count .emoji {
    font-size: 14px;
}

.user-reacted {
    background: #e6fffa;
    color: #234e52;
    border: 1px solid #38b2ac;
}

@keyframes reactionsBounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(10px);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ===== COMMENTS SECTION ===== */
.post-comments {
    border-top: 1px solid #f1f5f9;
    background: #fafafa;
}

.comments-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 0 16px;
}

.comment-item {
    display: flex;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

.comment-item:last-child {
    border-bottom: none;
}

.comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
}

.comment-content {
    flex: 1;
    min-width: 0;
}

.comment-bubble {
    background: #f1f5f9;
    border-radius: 16px;
    padding: 8px 12px;
    margin-bottom: 4px;
}

.comment-author {
    font-weight: 600;
    font-size: 13px;
    color: #2d3748;
    margin-bottom: 2px;
}

.comment-text {
    font-size: 14px;
    line-height: 1.4;
    color: #2d3748;
}

.comment-time {
    font-size: 12px;
    color: #64748b;
    margin-left: 12px;
}

.comment-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    align-items: flex-end;
}

.comment-input-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 11px;
    flex-shrink: 0;
}

.comment-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    resize: none;
    min-height: 20px;
    max-height: 80px;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.comment-input:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.comment-submit-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: #4f46e5;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    font-size: 12px;
}

.comment-submit-btn:hover:not(:disabled) {
    background: #4338ca;
}

.comment-submit-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
}

/* ===== LOADING STATES ===== */
.loading-posts {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #64748b;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-radius: 50%;
    border-top-color: #4f46e5;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
}

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

.no-posts {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
}

.no-posts-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.no-posts h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: #4a5568;
}

.no-posts p {
    margin: 0;
    font-size: 14px;
}

/* ===== PINNED POST ===== */
.newsfeed-post.pinned {
    border: 2px solid #4f46e5;
    position: relative;
}

.pinned-badge {
    position: absolute;
    top: -1px;
    right: 12px;
    background: #4f46e5;
    color: white;
    padding: 4px 8px;
    border-radius: 0 0 6px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

/* ===== LOGIN REQUIRED ===== */
.login-required {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-size: 14px;
}

.login-required a {
    color: #4f46e5;
    text-decoration: none;
    font-weight: 600;
}

.login-required a:hover {
    text-decoration: underline;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .newsfeed-container {
        padding: 0 8px;
    }
    
    .post-creation-box,
    .newsfeed-post {
        border-radius: 8px;
        margin-bottom: 16px;
    }
    
    .post-creation-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .post-header {
        padding: 12px 12px 8px;
    }
    
    .post-content {
        padding: 0 12px 8px;
        font-size: 14px;
    }
    
    .post-actions {
        padding: 6px 2px;
    }
    
    .action-btn {
        padding: 8px 4px;
        font-size: 13px;
    }
    
    .comment-input-area {
        padding: 8px 12px;
    }
    
    .comments-list {
        padding: 0 12px;
    }
}

@media (max-width: 480px) {
    .post-creation-header {
        gap: 8px;
    }
    
    .post-creation-avatar,
    .post-avatar {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    
    .post-author-name {
        font-size: 14px;
    }
    
    .post-time {
        font-size: 12px;
    }
    
    .post-media-options {
        gap: 4px;
    }
    
    .media-btn {
        padding: 6px 8px;
        font-size: 12px;
    }
    
    .post-submit-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .emoji-reactions-picker {
        min-width: 260px;
        padding: 6px 8px;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .reaction-emoji {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
}

/* ===== SCROLLBAR STYLING ===== */
.comments-list::-webkit-scrollbar {
    width: 6px;
}

.comments-list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.comments-list::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.comments-list::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    .newsfeed-post,
    .action-btn,
    .media-btn,
    .loading-spinner {
        animation: none;
        transition: none;
    }
}

@media (prefers-contrast: high) {
    .newsfeed-post {
        border: 1px solid #2d3748;
    }
    
    .action-btn:hover {
        background: #e2e8f0;
    }
    
    .post-submit-btn {
        background: #2d3748;
    }
}

/* ===== MEDIA UPLOAD STYLES ===== */
.media-preview-container {
    margin: 12px 0;
    padding: 0;
    display: none;
}

.media-preview {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.media-preview img {
    max-width: 100px;
    max-height: 80px;
    object-fit: cover;
    border-radius: 6px;
}

.video-icon,
.link-icon {
    width: 50px;
    height: 50px;
    background: #eef2ff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #4f46e5;
}

.media-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.media-name {
    font-weight: 500;
    color: #2d3748;
    font-size: 14px;
    word-break: break-all;
}

.media-size,
.media-type {
    font-size: 12px;
    color: #64748b;
}

.remove-media-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.remove-media-btn:hover {
    background: #dc2626;
}

/* Media in posts */
.post-media {
    margin: 12px 0;
    border-radius: 8px;
    overflow: hidden;
}

.post-image {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.post-image:hover {
    transform: scale(1.02);
}

.post-video {
    width: 100%;
    max-height: 400px;
    border-radius: 8px;
}

.post-link-preview {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s ease;
}

.post-link-preview:hover {
    background: #f1f5f9;
}

.post-link-icon {
    width: 40px;
    height: 40px;
    background: #eef2ff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #4f46e5;
}

.post-link-info {
    flex: 1;
}

.post-link-title {
    font-weight: 500;
    color: #2d3748;
    margin-bottom: 2px;
}

.post-link-url {
    font-size: 12px;
    color: #64748b;
    word-break: break-all;
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    .newsfeed-container {
        background: #1a202c;
    }
    
    .post-creation-box,
    .newsfeed-post {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .post-creation-input {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    .post-creation-input::placeholder {
        color: #a0aec0;
    }
    
    .post-author-name,
    .post-content,
    .comment-author,
    .comment-text {
        color: #e2e8f0;
    }
    
    .post-time,
    .comment-time {
        color: #a0aec0;
    }
    
    .action-btn,
    .media-btn {
        color: #cbd5e0;
    }
    
    .action-btn:hover,
    .media-btn:hover {
        background: #4a5568;
        color: #e2e8f0;
    }
    
    .post-comments {
        background: #1a202c;
        border-top-color: #4a5568;
    }
    
    .comment-bubble {
        background: #4a5568;
    }
    
    .comment-input {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    .media-preview {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .media-name {
        color: #e2e8f0;
    }
    
    .post-link-preview {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .post-link-preview:hover {
        background: #374151;
    }
    
    .post-link-title {
        color: #e2e8f0;
    }
}