/* static/community.css */

/* Base styles for all devices */
.community-page {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px;
    background: #1a1a1a;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

/* Sidebar styles */
.community-sidebar {
    background: #222222;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    height: auto; /* Ensure height is only as tall as content */
}

/* Community header */
.community-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.community-image {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #50c878;
}

.community-header-info {
    flex-grow: 1;
}

h2 {
    margin: 0;
    font-size: 1.6em;
    color: #50c878;
    font-weight: 700;
}

.community-header p {
    margin: 8px 0;
    color: #bbbbbb;
    font-size: 0.9em;
}

.community-header p a {
    color: #50c878;
    text-decoration: none;
    font-weight: 500;
}

.community-header p a:hover {
    text-decoration: underline;
}

/* Actions and buttons */
.community-actions {
    display: flex;
    flex-direction: column; /* Stack buttons vertically by default */
    gap: 10px;
    margin: 10px 0;
    align-items: center; /* Center buttons vertically */
}

.community-actions .btn-subscribe {
    background: linear-gradient(90deg, #23825f, #1c664b);
    color: #fff;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.9em;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    width: 150px; /* Fixed exact width to match Create Post */
    white-space: nowrap; /* Prevent text wrapping */
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.community-actions .btn-subscribe:hover {
    background: linear-gradient(90deg, #1c664b, #144e3a);
    transform: translateY(-2px);
}

.community-actions .btn-unsubscribe {
    background: linear-gradient(90deg, #ff5555, #e04b4b);
    color: #fff;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.9em;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(255, 85, 85, 0.1);
    width: 150px; /* Fixed exact width to match Create Post */
    white-space: nowrap; /* Prevent text wrapping */
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.community-actions .btn-unsubscribe:hover {
    background: linear-gradient(90deg, #e04b4b, #cc4040);
    transform: translateY(-2px);
}

.community-actions button.btn-subscribe,
.community-actions button.btn-unsubscribe {
    border: none; /* Remove default button border */
    outline: none; /* Remove default button outline */
    cursor: pointer; /* Maintain pointer cursor */
    width: 150px; /* Match the width of <a> tags and Create Post */
    min-width: 150px; /* Force minimum width to prevent shrinking */
    padding: 10px 20px; /* Match the padding of <a> tags and Create Post */
    font-weight: bold;
    font-size: 0.9em;
    border-radius: 8px;
    transition: all 0.3s ease;
    box-sizing: border-box; /* Ensure padding is included in width */
    display: flex;
    justify-content: center;
    align-items: center;
    white-space: nowrap; /* Prevent text wrapping */
    text-decoration: none; /* Ensure no underline */
    background: none; /* Let the specific class handle the background */
}

.community-actions button.btn-subscribe {
    background: linear-gradient(90deg, #23825f, #1c664b);
    color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.community-actions button.btn-subscribe:hover {
    background: linear-gradient(90deg, #1c664b, #144e3a);
    transform: translateY(-2px);
}

.community-actions button.btn-unsubscribe {
    background: linear-gradient(90deg, #ff5555, #e04b4b);
    color: #fff;
    box-shadow: 0 2px 4px rgba(255, 85, 85, 0.1);
}

.community-actions button.btn-unsubscribe:hover {
    background: linear-gradient(90deg, #e04b4b, #cc4040);
    transform: translateY(-2px);
}

.community-actions .mod-btn {
    background: linear-gradient(90deg, #ffa500, #cc8400);
    color: #fff;
    padding: 10px 20px;
    text-decoration: none; /* Ensure no underline */
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.9em;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    width: 150px; /* Match Create Post width */
    white-space: nowrap; /* Prevent text wrapping */
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.community-actions .mod-btn:hover {
    background: linear-gradient(90deg, #cc8400, #a86500);
    transform: translateY(-2px);
}

/* Submit Post Button Enhancement */
.submit-post-action {
    margin: 15px 0;
    text-align: center; /* Center the button on desktop */
}

.submit-post-action .btn {
    background: linear-gradient(90deg, #50c878, #3da660);
    color: #fff;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.9em;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    width: 150px; /* Match other buttons */
    white-space: nowrap; /* Prevent text wrapping */
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.submit-post-action .btn:hover {
    background: linear-gradient(90deg, #3da660, #2f8050);
    transform: translateY(-2px);
}

/* Moderators section */
.moderators h3 {
    margin: 0 0 10px;
    font-size: 1.2em;
    color: #50c878;
    font-weight: 700;
    border-bottom: 1px solid #3a3a3a;
    padding-bottom: 5px;
}

.moderators ul {
    list-style: none;
    padding: 0;
}

.moderators li {
    margin-bottom: 8px;
    color: #bbbbbb;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.moderators li a {
    color: #50c878;
    text-decoration: none;
    font-weight: 500;
}

.moderators li a:hover {
    text-decoration: underline;
}

.mod-badge {
    height: 0.9em; /* Match username text height */
    vertical-align: middle;
    margin-left: 5px;
}

.moderators .flair {
    display: inline-block;
    padding: 2px 5px;
    margin-left: 5px;
    font-size: 0.7em;
    border-radius: 3px;
    vertical-align: middle;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Main content styles */
.community-main {
    background: #222222;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

/* Search bar */
.search-bar form {
    display: flex;
    margin-bottom: 20px;
    background: #2a2a2a;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-bar input {
    flex-grow: 1;
    padding: 10px;
    background: #2a2a2a;
    border: none;
    color: #f0f0f0;
    font-size: 0.9em;
}

.search-bar .search-btn {
    padding: 10px;
    background: linear-gradient(90deg, #50c878, #3da660);
    border: none;
    cursor: pointer;
    transition: background 0.3s ease;
}

.search-bar .search-btn img {
    width: 18px;
    height: 18px;
}

.search-bar .search-btn:hover {
    background: linear-gradient(90deg, #3da660, #2f8050);
}

/* Sort options with added space */
.sort-options {
    margin: 20px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.sort-options a {
    color: #50c878;
    text-decoration: none;
    font-size: 0.9em;
    padding: 8px 15px;
    border: 2px solid #50c878;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.sort-options a.active {
    background: transparent;
    color: #50c878;
    font-weight: bold;
}

.time-filters {
    margin-top: 10px;
    display: flex;
    flex-direction: row;
    gap: 12px;
    border: none !important;
}

.time-filters a {
    color: #ffffff;
    text-decoration: none;
    font-size: 0.85em;
    padding: 6px 10px;
    transition: color 0.3s ease;
    border: none !important;
}

.time-filters a.active {
    color: #50c878;
    font-weight: bold;
    border: none !important;
}

/* Posts list */
.posts-list {
    margin: 20px 0;
}

.post-item {
    display: flex;
    padding: 20px;
    background: #2a2a2a;
    border-radius: 10px;
    margin-bottom: 20px;
    align-items: flex-start;
    position: relative;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.post-item:hover {
    transform: translateY(-2px);
}

.post-actions-top {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px; /* Add space between buttons */
}

/* Pinned post indicator */
.pinned-post {
    border-left: 4px solid #50c878; /* Highlight pinned posts */
    background: #2f2f2f; /* Slightly lighter background for pinned posts */
}

/* Pin button for moderators */
.pin-form {
    display: inline;
}

.pin-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.pin-btn img {
    width: 24px;
    height: 24px;
}

.pin-btn:hover {
    transform: scale(1.1);
}

/* Pinned indicator for regular users */
.pinned-indicator {
    display: inline-block;
}

.pinned-indicator img {
    width: 24px;
    height: 24px;
}

.delete-form {
    display: inline;
}

.delete-btn {
    background: linear-gradient(90deg, #ff5555, #e04b4b);
    color: #fff;
    padding: 6px 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8em;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(255, 85, 85, 0.3);
}

.delete-btn:hover {
    background: linear-gradient(90deg, #e04b4b, #cc4040);
    transform: translateY(-1px);
}

.vote-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 20px;
    min-width: 50px;
}

.vote-arrow {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.vote-arrow img {
    width: 25px;
    height: 25px;
}

.vote-arrow.voted img {
    filter: hue-rotate(0deg) brightness(1.2);
}

.vote-section span {
    margin: 8px 0;
    font-weight: bold;
    color: #f0f0f0;
    font-size: 1.1em;
}

.post-content {
    flex-grow: 1;
}

.post-content h3 {
    margin: 0 0 12px;
    font-size: 1.3em;
    font-weight: 700;
}

.post-content h3 a {
    color: #50c878;
    text-decoration: none;
}

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

.post-content p {
    margin: 8px 0;
    color: #bbbbbb;
    font-size: 0.9em;
}

.post-content .badge {
    height: 0.9em;
    vertical-align: middle;
    margin-left: 5px;
}

.post-content .flair {
    display: inline-block;
    padding: 2px 5px;
    margin-left: 5px;
    font-size: 0.7em;
    border-radius: 3px;
    vertical-align: middle;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.post-content p a {
    color: #50c878;
    text-decoration: none;
}

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

.no-posts {
    text-align: center;
    color: #bbbbbb;
    font-size: 0.9em;
    padding: 20px;
    background: #2a2a2a;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pagination {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pagination-btn {
    background: linear-gradient(90deg, #50c878, #3da660);
    color: #fff;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9em;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pagination-btn:hover {
    background: linear-gradient(90deg, #3da660, #2f8050);
    transform: translateY(-2px);
}

.pagination-btn.disabled {
    background: #3a3a3a;
    cursor: not-allowed;
}

.page-numbers {
    display: flex;
    gap: 5px;
}

.page-numbers a {
    padding: 5px 10px;
    color: #50c878;
    text-decoration: none;
    border-radius: 4px;
}

.page-numbers a.active {
    background: #50c878;
    color: #fff;
}

.page-numbers a:hover:not(.active) {
    background: #2a2a2a;
}

.page-numbers span {
    padding: 5px 10px;
    color: #cccccc;
}

/* Desktop layout */
@media (min-width: 769px) {
    .community-page {
        display: flex;
        flex-direction: row;
        align-items: flex-start; /* Align items at the top to prevent stretching */
    }

    .community-sidebar {
        flex: 0 0 auto; /* Do not grow or shrink, only as tall as content */
        min-width: 250px;
        margin-right: 20px;
    }

    .community-main {
        flex: 1; /* Take remaining space, but allow sidebar to dictate its own height */
    }

    .community-header {
        flex-direction: row;
        align-items: center;
        gap: 15px;
        margin-bottom: 10px;
    }

    h2 {
        font-size: 1.6em;
    }

    .community-header p {
        margin: 5px 0;
        font-size: 0.9em;
    }

    .community-actions {
        flex-direction: column; /* Stack buttons vertically on desktop */
        gap: 10px;
        align-items: center; /* Center buttons vertically */
    }

    .community-actions .btn-subscribe,
    .community-actions .btn-unsubscribe,
    .community-actions .mod-btn,
    .community-actions button.btn-subscribe,
    .community-actions button.btn-unsubscribe,
    .submit-post-action .btn {
        width: 150px; /* Match Create Post width */
        padding: 10px 20px;
        font-size: 0.9em;
        text-align: center; /* Center text inside buttons */
        display: block; /* Ensure block-level for alignment */
        text-decoration: none; /* Ensure no underline */
    }

    .search-bar input {
        padding: 10px;
        font-size: 0.9em;
    }

    .search-bar .search-btn img {
        width: 18px;
        height: 18px;
    }

    .post-item {
        padding: 25px;
    }

    .vote-arrow img {
        width: 30px;
        height: 30px;
    }

    .post-content h3 {
        font-size: 1.4em;
    }

    .post-content p {
        font-size: 0.95em;
    }
}

/* Mobile layout */
@media (max-width: 600px) {
    .community-page {
        padding: 10px;
    }

    .community-header {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        margin-bottom: 5px;
    }

    .community-image {
        width: 40px;
        height: 40px;
        margin-bottom: 0;
    }

    h2 {
        font-size: 1.4em;
    }

    .community-header p {
        margin: 3px 0;
        font-size: 0.85em;
    }

    .community-actions {
        flex-direction: column;
        gap: 8px;
        margin: 8px 0;
        align-items: flex-start; /* Left-align the button group on mobile */
    }

    .community-actions .btn-subscribe,
    .community-actions .btn-unsubscribe,
    .community-actions .mod-btn,
    .community-actions button.btn-subscribe,
    .community-actions button.btn-unsubscribe,
    .submit-post-action .btn {
        width: 100%;
        max-width: 130px; /* Reduced to match Create Post width */
        padding: 8px 15px;
        font-size: 0.85em;
        text-align: center; /* Center text inside buttons */
        display: block; /* Ensure block-level for alignment */
        text-decoration: none; /* Ensure no underline */
    }

    .post-actions-top {
        top: 5px;
        right: 5px;
        gap: 3px; /* Smaller gap on mobile */
    }

    .pin-btn img,
    .pinned-indicator img {
        width: 20px;
        height: 20px;
    }

    .submit-post-action {
        margin: 10px 0;
        text-align: left; /* Left-align the button */
    }

    .moderators h3 {
        font-size: 1em;
    }

    .moderators li {
        font-size: 0.8em;
        gap: 5px;
    }

    .search-bar input {
        padding: 8px;
        font-size: 0.85em;
    }

    .search-bar .search-btn img {
        width: 16px;
        height: 16px;
    }

    .sort-options a, .time-filters a {
        font-size: 0.85em;
        padding: 6px 10px;
    }

    .post-item {
        flex-direction: column;
        padding: 15px;
    }

    .vote-section {
        flex-direction: row;
        justify-content: space-between;
        margin-bottom: 10px;
        min-width: auto;
    }

    .vote-arrow img {
        width: 20px;
        height: 20px;
    }

    .post-content h3 {
        font-size: 1.2em;
    }

    .post-content p {
        font-size: 0.85em;
    }

    .pagination-btn {
        padding: 8px 15px;
        font-size: 0.85em;
    }

    .page-numbers a, .page-numbers span {
        padding: 3px 8px;
        font-size: 0.85em;
    }
}
