/* =============================================
   community.css – مجتمع بيتوريا (Facebook-style)
   ============================================= */

/* ─── Feed Container ─── */
.community-feed {
    max-width: 680px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ─── Tab Bar ─── */
.tab-bar {
    display: flex;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, .08);
    margin-bottom: 24px;
    overflow: hidden;
    position: relative;
    z-index: 10;
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 12px;
    font-size: 15px;
    font-weight: 600;
    color: #65716f;
    text-decoration: none;
    border-bottom: 3px solid transparent;
    transition: all .2s ease;
}

.tab-btn:hover {
    background: #f5f9f8;
    color: #1e6b5a;
}

.tab-btn.active {
    color: #1e6b5a;
    border-bottom-color: #1e6b5a;
    background: #f0faf7;
}

.tab-btn i {
    font-size: 16px;
}

/* ─── Members Prompt ─── */
.members-prompt {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #e8f5f2 0%, #fff 100%);
    border: 1px solid #c8e6df;
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #2d4a44;
}

.members-prompt i {
    font-size: 20px;
    color: #1e6b5a;
}

.members-prompt a {
    color: #1e6b5a;
    font-weight: 700;
    text-decoration: underline;
}

/* ─── Post Create Card ─── */
.post-create-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
    margin-bottom: 20px;
    overflow: hidden;
}

.post-create-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px 10px;
}

.post-create-header textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.6;
    color: #1a2e2c;
    padding: 8px 0;
    min-height: 44px;
    max-height: 200px;
    overflow-y: auto;
}

.post-create-header textarea::placeholder {
    color: #98a8a5;
}

/* Attachment Preview */
.attachment-preview {
    display: flex;
    gap: 8px;
    padding: 0 20px;
    flex-wrap: wrap;
}

.attachment-preview .preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #e8f0ee;
}

.attachment-preview .preview-item img,
.attachment-preview .preview-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attachment-preview .preview-remove {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .65);
    color: #fff;
    border: none;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.post-create-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px 14px;
    border-top: 1px solid #e8f0ee;
}

.attach-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #1e6b5a;
    cursor: pointer;
    transition: background .15s;
}

.attach-btn:hover {
    background: #e8f5f2;
}

.attach-btn i {
    font-size: 18px;
}

.publish-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 24px;
    border-radius: 8px;
    border: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #1e6b5a 0%, #0d2321 100%);
    cursor: pointer;
    transition: all .2s ease;
    opacity: .5;
    pointer-events: none;
}

.publish-btn.enabled {
    opacity: 1;
    pointer-events: all;
}

.publish-btn:hover {
    box-shadow: 0 4px 12px rgba(30, 107, 90, .35);
    transform: translateY(-1px);
}

/* ─── Post Card ─── */
.post-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .06);
    margin-bottom: 20px;
    overflow: hidden;
    transition: box-shadow .25s ease;
}

.post-card:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, .1), 0 2px 6px rgba(0, 0, 0, .06);
}

/* ─── Post Header ─── */
.post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px 0;
}

.post-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e8f5f2;
    flex-shrink: 0;
}

.post-avatar-placeholder {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e6b5a 0%, #0d2321 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}

.post-author-name {
    font-weight: 600;
    font-size: 15px;
    color: #0d2321;
    line-height: 1.3;
}

.post-time {
    font-size: 13px;
    color: #65716f;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ─── Post Body ─── */
.post-body {
    padding: 14px 20px;
    font-size: 15px;
    line-height: 1.75;
    color: #1a2e2c;
    white-space: pre-line;
    word-wrap: break-word;
}

/* ─── Post Attachments ─── */
.post-attachments {
    display: grid;
    gap: 3px;
}

.post-attachments.single {
    grid-template-columns: 1fr;
}

.post-attachments.double {
    grid-template-columns: 1fr 1fr;
}

.post-attachments.triple {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.post-attachments.triple> :first-child {
    grid-row: 1 / 3;
}

.post-attachments.multi {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.post-attachment-img {
    width: 100%;
    height: 100%;
    min-height: 200px;
    max-height: 520px;
    object-fit: cover;
    cursor: pointer;
    transition: filter .2s ease;
}

.post-attachment-img:hover {
    filter: brightness(.93);
}

.post-attachment-video {
    width: 100%;
    max-height: 520px;
    background: #000;
}

.post-attachments .extra-overlay {
    position: relative;
}

.post-attachments .extra-overlay::after {
    content: attr(data-extra);
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .52);
    color: #fff;
    font-size: 28px;
    font-weight: 700;
}

/* ─── Post Stats ─── */
.post-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px 0;
    font-size: 14px;
    color: #65716f;
}

.stats-comments {
    cursor: pointer;
    transition: color .15s;
}

.stats-comments:hover {
    color: #1e6b5a;
}

/* ─── Post Actions ─── */
.post-actions {
    display: flex;
    border-top: 1px solid #e8f0ee;
    margin: 8px 20px 0;
    padding: 4px 0;
}

.post-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #4b5a58;
    cursor: pointer;
    transition: all .15s ease;
    border: none;
    background: none;
    text-decoration: none;
    font-family: inherit;
}

.post-action-btn:hover {
    background: #f0f6f5;
}

.post-action-btn i {
    font-size: 18px;
}

/* Like button active state */
.like-btn.liked {
    color: #e74c3c;
}

.like-btn.liked i {
    animation: likePopIn .35s ease;
}

/* Comment button active state */
.comment-btn.commented {
    color: #1e6b5a;
    background: #f0faf7;
}

.comment-btn.commented i {
    color: #1e6b5a;
}

/* Action Count Badge */
.action-count-badge {
    background: #e8f0ee;
    color: #0d2321;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    margin-right: 4px;
    min-width: 18px;
    text-align: center;
}

.like-btn.liked .action-count-badge {
    background: #fceceb;
    color: #e74c3c;
}

.comment-btn.commented .action-count-badge {
    background: #d4e9e4;
    color: #1e6b5a;
}

@keyframes likePopIn {
    0% {
        transform: scale(1);
    }

    40% {
        transform: scale(1.35);
    }

    100% {
        transform: scale(1);
    }
}

/* ─── Comments Section ─── */
.comments-section {
    border-top: 1px solid #e8f0ee;
    padding: 12px 20px 16px;
    background: #fafcfb;
}

.comments-list {
    max-height: 400px;
    overflow-y: auto;
}

.comment-item {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    animation: fadeSlideUp .3s ease both;
}

.comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.comment-avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e6b5a 0%, #0d2321 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.comment-bubble {
    background: #e8f0ee;
    border-radius: 14px;
    padding: 8px 14px;
    max-width: 85%;
}

.comment-author {
    font-weight: 600;
    font-size: 13px;
    color: #0d2321;
    display: block;
    margin-bottom: 2px;
}

.comment-text {
    font-size: 14px;
    color: #1a2e2c;
    line-height: 1.5;
    display: block;
    word-wrap: break-word;
}

.comment-time {
    font-size: 11px;
    color: #8ca39f;
    display: block;
    margin-top: 4px;
}

/* Comment Input */
.comment-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 12px;
}

.comment-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: #e8f0ee;
    border-radius: 24px;
    padding: 0 6px 0 14px;
    transition: box-shadow .2s;
}

.comment-input-wrapper:focus-within {
    box-shadow: 0 0 0 2px #1e6b5a40;
}

.comment-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    font-family: inherit;
    padding: 10px 0;
    color: #1a2e2c;
}

.comment-input::placeholder {
    color: #8ca39f;
}

.comment-send-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: none;
    color: #1e6b5a;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    font-size: 14px;
}

.comment-send-btn:hover {
    background: #d0e8e2;
}

.comment-login-prompt {
    text-align: center;
    padding: 12px;
    font-size: 14px;
    color: #65716f;
}

.comment-login-prompt a {
    color: #1e6b5a;
    font-weight: 700;
    text-decoration: underline;
}

/* ─── Empty State ─── */
.community-empty {
    text-align: center;
    padding: 80px 20px;
    color: #65716f;
}

.community-empty i {
    font-size: 56px;
    margin-bottom: 16px;
    color: #b8c7c4;
}

.community-empty h3 {
    font-size: 20px;
    font-weight: 600;
    color: #0d2321;
    margin-bottom: 8px;
}

/* ─── Lightbox ─── */
.lb-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, .92);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}

.lb-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.lb-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
    object-fit: contain;
}

.lb-close {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    background: rgba(0, 0, 0, .4);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
}

.lb-close:hover {
    background: rgba(255, 255, 255, .15);
}

/* ─── Pagination ─── */
.community-pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 24px 0 48px;
    flex-wrap: wrap;
}

.community-pagination a,
.community-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all .2s ease;
}

.community-pagination a {
    color: #0d2321;
    background: #fff;
    border: 1px solid #dde6e4;
}

.community-pagination a:hover {
    background: #e8f5f2;
    border-color: #1e6b5a;
    color: #1e6b5a;
}

.community-pagination span.active-page {
    background: #1e6b5a;
    color: #fff;
    border: 1px solid #1e6b5a;
}

.community-pagination span.disabled {
    color: #b3bfbd;
    background: #f5f7f7;
    border: 1px solid #e8f0ee;
}

/* ─── Animations ─── */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.post-card {
    animation: fadeSlideUp .45s ease both;
}

.post-card:nth-child(2) {
    animation-delay: .06s;
}

.post-card:nth-child(3) {
    animation-delay: .12s;
}

.post-card:nth-child(4) {
    animation-delay: .18s;
}

.post-card:nth-child(5) {
    animation-delay: .24s;
}

/* ─── Toast ─── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #0d2321;
    color: #fff;
    padding: 12px 28px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transition: all .35s ease;
    pointer-events: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
    .community-feed {
        padding: 0 8px;
    }

    .post-header {
        padding: 12px 14px 0;
    }

    .post-body {
        padding: 10px 14px;
        font-size: 14px;
    }

    .post-stats {
        padding: 6px 14px 0;
    }

    .post-actions {
        margin: 6px 14px 0;
    }

    .post-attachment-img {
        min-height: 160px;
    }

    .comments-section {
        padding: 10px 14px 12px;
    }

    .post-create-header {
        padding: 12px 14px 8px;
    }

    .post-create-footer {
        padding: 8px 14px 12px;
    }

    .tab-btn {
        font-size: 14px;
        padding: 12px 8px;
    }
}