:root {
    --community-bg: #121212;
    /* Match bg-darker */
    --community-card-bg: #1e1e1e;
    /* Match bg-dark */
    --community-text: #ffffff;
    --community-text-muted: #a0aec0;
    /* Balanced for readability in dark mode */
    --community-primary: #d7003d;
    /* Match site primary */
    --community-success: #28a745;
    --community-danger: #dc3545;
    --community-border: #333333;
    --community-sidebar-bg: #1e1e1e;
    --brand-primary: #d7003d;
}

body.community-page {
    background-color: var(--community-bg);
    color: var(--community-text);
}

.community-page .text-muted,
.auth-page .text-muted {
    color: #a0aec0 !important;
}

.community-container {
    display: flex;
    max-width: 1200px;
    margin: 20px auto;
    gap: 20px;
    padding: 0 15px;
}

/* Sidebar */
.community-sidebar {
    width: 250px;
    flex-shrink: 0;
    position: sticky;
    top: 80px;
    align-self: flex-start;
}

.sidebar-card {
    background: var(--community-sidebar-bg);
    border-radius: 12px;
    border: 1px solid var(--community-border);
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li a {
    display: block;
    padding: 10px;
    border-radius: 8px;
    color: var(--community-text-muted);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: rgba(215, 0, 61, 0.1);
    color: var(--community-primary);
}

/* Feed */
.community-feed {
    flex-grow: 1;
}

.post-card {
    background: var(--community-card-bg);
    border-radius: 12px;
    border: 1px solid var(--community-border);
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    gap: 20px;
    transition: transform 0.2s, border-color 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.vote-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--community-text-muted);
    min-width: 40px;
}

.vote-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.6rem;
    color: var(--community-text-muted);
    transition: all 0.2s ease;
    padding: 0;
}

.vote-btn:active {
    transform: scale(1.2);
}

.vote-btn:hover.up {
    color: var(--community-primary);
}

.vote-btn:hover.down {
    color: #007bff;
}

/* Blue for downvote often looks good too, or keep danger */

.post-content-area {
    flex-grow: 1;
}

.post-meta {
    font-size: 0.85rem;
    color: var(--community-text-muted);
    margin-bottom: 10px;
}

.post-title {
    font-size: 1.4rem;
    margin: 0 0 12px 0;
    font-weight: 700;
}

.post-title a {
    color: var(--community-text);
    text-decoration: none;
    transition: color 0.2s;
}

.post-title a:hover {
    color: var(--community-primary);
}

.post-footer {
    display: flex;
    gap: 25px;
    font-size: 0.9rem;
    color: var(--community-text-muted);
    margin-top: 20px;
    border-top: 1px solid var(--community-border);
    padding-top: 15px;
}

.post-footer span,
.post-footer a {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    cursor: pointer;
    transition: all 0.2s ease-in-out !important;
    /* Unified transition */
    text-decoration: none !important;
    color: var(--community-text-muted) !important;
    white-space: nowrap;
}

.post-footer span:hover,
.post-footer a:hover {
    color: var(--community-primary) !important;
}

.post-footer span:hover *,
.post-footer a:hover * {
    color: inherit !important;
    /* Inherit color from parent hover state */
    transition: none !important;
    /* Avoid sub-element delay */
}

.like-btn-wrapper:hover,
.like-btn-wrapper:hover *,
.like-btn-wrapper.active,
.like-btn-wrapper.active * {
    color: var(--community-primary) !important;
}

.like-btn-wrapper i.fa-thumbs-up,
.comment-actions i.fa-thumbs-up {
    transition: transform 0.2s;
}

.like-btn-wrapper:hover i.fa-thumbs-up {
    transform: scale(1.2);
}

.post-footer i {
    color: inherit;
}

.post-footer span:hover i {
    color: var(--community-primary);
}

/* Forms */
.create-post-card {
    background: var(--community-card-bg);
    border-radius: 12px;
    border: 1px solid var(--community-border);
    padding: 30px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #cbd5e0;
}

.form-control {
    background-color: #2a2a2a;
    color: white;
    border: 1px solid var(--community-border);
    border-radius: 8px;
    padding: 12px;
    transition: border-color 0.2s;
}

.form-control:focus {
    background-color: #333333;
    border-color: var(--brand-primary);
    color: white;
    box-shadow: none;
}

.form-control::placeholder {
    color: #a0aec0 !important;
    opacity: 1;
}

/* Override text-primary for auth links */
.auth-page .text-primary {
    color: var(--brand-primary) !important;
}

.btn-primary {
    background: var(--community-primary);
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    font-weight: 700;
    transition: opacity 0.2s;
}

.btn-primary:hover {
    background: #b00032;
}

/* Comments */
.comments-section {
    margin-top: 40px;
}

.comment {
    margin-top: 15px;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    border-left: 2px solid rgba(255, 255, 255, 0.1);
    transition: border-color 0.2s;
}

.comment:hover {
    border-left-color: var(--community-primary);
}

.comment-meta {
    font-size: 0.85rem;
    color: var(--community-text-muted);
    margin-bottom: 8px;
}

.comment-body {
    margin-bottom: 12px;
    line-height: 1.5;
}

.comment-actions {
    font-size: 0.85rem;
    display: flex;
    gap: 20px;
    color: var(--community-text-muted);
}

.comment-actions i {
    cursor: pointer;
}

.replies {
    margin-left: 15px;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    padding-left: 10px;
}

/* Collapse Button */
.collapse-btn {
    background: none;
    border: none;
    color: var(--community-text-muted);
    font-family: monospace;
    cursor: pointer;
    padding: 0 5px;
    font-size: 0.9rem;
    line-height: 1;
}

.collapse-btn:hover {
    color: var(--community-text);
}

.reply-form {
    margin-top: 15px;
    display: none;
}

/* Inline Comments Expansion */
.inline-comments-wrapper {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed var(--community-border);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.inline-comments-container .comment {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 10px;
}

.comment-toggle-btn:hover {
    color: var(--community-primary) !important;
}

.loading-info {
    color: var(--community-text-muted);
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .community-container {
        flex-direction: column;
    }

    .community-sidebar {
        width: 100%;
        position: static;
    }
}/* Community Mobile Adjustments */
@media (max-width: 991.98px) {
    .community-container {
        flex-direction: column !important;
        gap: 0 !important;
        margin-top: 10px !important;
        padding-bottom: 80px !important;
        padding-top: 0 !important;
    }

    .community-sidebar {
        display: none !important;
    }

    .community-feed {
        width: 100% !important;
        padding: 0 10px !important;
    }

    .community-page header {
        margin-bottom: 0 !important;
    }
}

/* Fixed Bottom Navigation */
.community-mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background: #1a1a1a;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid #333;
    z-index: 1050;
    padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #a0aec0 !important;
    text-decoration: none !important;
    font-size: 0.7rem;
    gap: 4px;
    transition: all 0.2s;
    flex: 1;
    height: 100%;
    justify-content: center;
}

.mobile-nav-item i {
    font-size: 1.4rem;
}

.mobile-nav-item.active {
    color: #d7003d !important;
}

.mobile-nav-item.create-btn i {
    font-size: 2.3rem;
    color: #d7003d !important;
    margin-top: -5px;
}

.mobile-nav-item span {
    font-weight: 500;
}
