:root {
    --community-bg: #0d0d1a;
    --community-card-bg: rgba(22, 33, 62, 0.7);
    --community-border: rgba(255, 255, 255, 0.1);
    --community-text: #cbd5e1;
    --community-text-muted: #94a3b8;
    --community-accent-1: #a78bfa;
    --community-accent-2: #f472b6;
}

.communities-page-wrapper {
    background-color: var(--community-bg);
    color: var(--community-text);
    min-height: calc(100vh - 70px);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--community-border);
}

.page-header-actions {
    display: flex;
    gap: 0.75rem;
}

.page-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
}

.page-header p {
    font-size: 1.1rem;
    color: var(--community-text-muted);
    margin-top: 0.5rem;
}

.btn-gradient-primary {
    background: linear-gradient(135deg, var(--community-accent-1) 0%, var(--community-accent-2) 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-gradient-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
    color: white;
}

.btn-gradient-secondary {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%); /* Example secondary gradient */
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-gradient-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
    color: white;
}

/* Styles for the new all_communities_list.html filter bar */
.popular-communities-section {
    margin-bottom: 3rem;
}

.section-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 1.5rem;
    text-align: center;
    background-image: linear-gradient(to right, var(--community-accent-1), var(--community-accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.popular-communities-carousel {
    display: flex;
    overflow-x: auto; /* Yatay kaydırmayı etkinleştir */
    -webkit-overflow-scrolling: touch; /* iOS için daha iyi kaydırma */
    scroll-snap-type: x mandatory; /* Kartların tam oturmasını sağlar */
    gap: 1rem; /* Kartlar arası boşluk */
    padding-top: 1rem;
    padding-bottom: 1rem; /* Kaydırma çubuğu için boşluk */
    scrollbar-width: auto; /* Firefox için kaydırma çubuğu stili (kalınlaştırıldı) */
    scrollbar-color: var(--community-accent-1) transparent; /* Firefox için kaydırma çubuğu rengi */
}

/* Webkit tabanlı tarayıcılar için kaydırma çubuğu stili */
.popular-communities-carousel::-webkit-scrollbar {
    height: 12px; /* Scrollbar kalınlığı artırıldı */
}

.popular-communities-carousel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.popular-communities-carousel::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--community-accent-1), var(--community-accent-2));
    border-radius: 10px;
}

.community-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); /* Kart genişliği küçültüldü */
    gap: 1rem; /* Kartlar arası boşluk azaltıldı */
}

.community-card {
    background-color: var(--community-card-bg);
    border: 1px solid var(--community-border);
    border-radius: 16px;
    overflow: hidden;
    text-decoration: none;
    color: var(--community-text);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.community-card.popular-card {
    flex: 0 0 auto; /* Kartların küçülmesini ve büyümesini engelle, sabit genişlikte kalmasını sağla */
    width: 220px; /* community-grid'deki minmax(220px, 1fr) ile aynı genişlik */
    scroll-snap-align: start; /* Kaydırmada kartların başlangıca hizalanmasını sağlar */
}

.community-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border-color: var(--community-accent-1);
}

.community-card-banner {
    height: 70px; /* Banner yüksekliği küçültüldü */
}

.community-card-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.community-card-content {
    padding: 1rem; /* İçerik dolgusu azaltıldı */
    padding-top: 0;
    text-align: center;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.community-card-image {
    width: 60px; /* Avatar boyutu küçültüldü */
    height: 60px; /* Avatar boyutu küçültüldü */
    border-radius: 50%;
    overflow: hidden;
    margin: -30px auto 0.5rem auto; /* Avatar konumu ve alt boşluk ayarlandı */
    border: 4px solid var(--community-card-bg);
    background-color: var(--community-card-bg);
    flex-shrink: 0;
}

.community-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.community-card-name {
    font-size: 1rem; /* İsim font boyutu küçültüldü */
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.4rem; /* İsim alt boşluğu azaltıldı */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.community-card-description {
    font-size: 0.8rem; /* Açıklama font boyutu küçültüldü */
    color: var(--community-text-muted);
    line-height: 1.5;
    margin-bottom: 0.75rem; /* Açıklama alt boşluğu azaltıldı */
    flex-grow: 1;
    overflow-wrap: break-word; /* Uzun kelimelerin satır atlamasını sağlar */
}

.community-card-meta {
    font-size: 0.75rem; /* Meta font boyutu küçültüldü */
    font-weight: 500;
    color: var(--community-text-muted);
    border-top: 1px solid var(--community-border);
    padding-top: 0.75rem; /* Meta üst dolgusu azaltıldı */
    margin-top: auto;
}

.filter-container {
    background-color: rgba(22, 33, 62, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.5rem;
}
.filter-bar {
    display: grid;
    grid-template-columns: 1fr auto; /* Only search and filter actions */
    gap: 1rem;
    align-items: flex-end;
}
.filter-bar .form-label {
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
    font-weight: 500;
    color: var(--community-text-muted);
}
.filter-actions {
    display: flex;
    align-items: end;
    gap: 0.5rem;
}
.form-control, .form-select, .btn-filter-dropdown {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 8px !important;
    padding: 0.5rem 0.75rem !important;
    font-size: 0.9rem !important;
    font-weight: 500;
    color: var(--community-text) !important; /* Changed to community-text */
}
.form-control:focus, .form-select:focus {
    box-shadow: 0 0 0 0.25rem rgba(139, 92, 246, 0.25) !important;
}
.form-control::placeholder {
    color: var(--community-text-muted) !important; /* Changed to community-text-muted */
    opacity: 0.7;
}
.btn-icon {
    display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.05); color: #cbd5e1; border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}
.btn-icon:hover { background-color: rgba(255, 255, 255, 0.1); }
.btn-icon.clear { background-color: rgba(239, 68, 68, 0.1); color: #fca5a5; border-color: rgba(239, 68, 68, 0.2); }
.btn-icon.clear:hover { background-color: rgba(239, 68, 68, 0.2); }
.btn-submit {
    padding: 0.5rem 1rem; border-radius: 8px; font-weight: 500; transition: all 0.3s ease; cursor: pointer;
    background-image: linear-gradient(to right, var(--community-accent-1), var(--community-accent-2)); color: #fff; border: none; text-decoration: none;
}
.btn-submit:hover { transform: scale(1.03); box-shadow: 0 2px 15px rgba(139, 92, 246, 0.3); }

.list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; margin-top: 2rem;}
.list-title { color: #fff; font-weight: 600; margin: 0; }
.btn-sort {
    background-color: rgba(255, 255, 255, 0.05); color: #cbd5e1; border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.375rem 0.75rem; font-size: 0.9rem; border-radius: 8px;
}
.dropdown-menu { background-color: #16213e; border-color: rgba(255, 255, 255, 0.1); padding: 0.5rem; z-index: 1050; }
.dropdown-item { color: #dcdcdc; }
.dropdown-item:hover, .dropdown-item.active { background-color: var(--community-accent-1); color: white; }

.community-post-list { display: flex; flex-direction: column; gap: 1.5rem; }
.community-post-card { display: flex; gap: 1rem; }
.post-author-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.post-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }
.post-author-name { font-weight: 600; color: #fff; text-decoration: none; }
.post-author-name:hover { text-decoration: underline; }
.post-date { font-size: 0.8rem; color: var(--community-text-muted); }
#community-post-list .post-main-content { flex: 1; min-width: 0; } /* Flex yapıda içeriğin taşmasını engeller */
#community-post-list .post-body {
    display: flex;
    flex-direction: column; /* Yazı ve resmi kesinlikle alt alta sıralar */
    gap: 0.5rem; /* Yazı ile resim arasına boşluk koyar */
}
#community-post-list .post-body p { 
    margin: 0; 
    line-height: 1.6; 
    overflow-wrap: break-word; /* Metni bozmadan sadece taşan kelimeleri kırar */
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
        margin-bottom: 2rem;
    }

    .page-header h1 {
        font-size: 2rem;
    }

    .page-header p {
        font-size: 1rem;
        margin-top: 0;
    }

    .page-header .btn-gradient-primary {
        order: 1; /* Butonu metinlerden sonra konumlandırır */
        width: 100%;
        max-width: 350px;
        justify-content: center;
    }

    .page-header-actions {
        order: 1; /* Butonları metinlerden sonra konumlandırır */
        flex-direction: column; /* Butonları alt alta sıralar */
        justify-content: center;
        width: 100%;
        max-width: 350px; /* Butonların maksimum genişliği */
    }

    .page-header-actions .btn-gradient-primary,
    .page-header-actions .btn-gradient-secondary {
        justify-content: center; /* Buton içeriğini ortalar */
    }

    .community-grid {
        grid-template-columns: repeat(2, 1fr); /* Mobil cihazlarda her satırda 2 kart */
    }

    .community-card-banner {
        height: 60px;
    }

    .community-card-image {
        width: 50px;
        height: 50px;
        margin-top: -25px;
        border-width: 3px;
    }

    .community-card-content {
        padding: 0.75rem;
        padding-top: 0;
    }

    .community-card-name {
        font-size: 0.9rem;
    }

    .community-card-description {
        display: -webkit-box; /* Mobilde açıklamayı göster ama kısalt */
        -webkit-line-clamp: 2; /* En fazla 2 satır göster */
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .section-title {
        font-size: 1.5rem;
    }
    .popular-communities-carousel {
        gap: 0.75rem;
    }
    .community-card.popular-card {
        width: 180px; /* Mobil için daha küçük kart genişliği */
    }
    .filter-bar {
        grid-template-columns: 1fr;
    }
    .filter-actions {
        grid-column: 1 / -1;
    }
    .list-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .btn-sort {
        width: 100%;
    }

    /* Yönetim seçenekleri butonunu mobil için sağ üste sabitle */
    .chat-header-options {
        position: fixed;
        top: 85px; /* Navbar yüksekliğine göre ayarlandı */
        right: 15px;
        z-index: 1040; /* Diğer elementlerin üzerinde kalması için */
        margin-left: 0 !important; /* Bootstrap'in ms-2 sınıfını geçersiz kıl */
    }

    /* Topluluk detay sayfasında mobil için başlık düzenlemesi */
    .profile-name {
        white-space: normal; /* Uzun isimlerin alt satıra inmesini sağlar */
        word-break: break-word; /* Çok uzun, tek kelimelik isimlerin taşmasını engeller */
    }
}

/* Styling for the management options button on community detail page */
.chat-header-options .btn-options {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; /* Slightly larger for better tap target */
    height: 40px;
    border-radius: 50%; /* Circular shape */
    background-color: rgba(255, 255, 255, 0.08); /* Subtle background */
    border: 1px solid rgba(255, 255, 255, 0.15); /* Light border */
    color: var(--community-text); /* Inherit theme text color */
    font-size: 1.2rem; /* Larger icon */
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); /* Subtle shadow */
}

.chat-header-options .btn-options:hover {
    background-color: rgba(255, 255, 255, 0.15); /* Slightly brighter background on hover */
    border-color: rgba(255, 255, 255, 0.25); /* Brighter border on hover */
    color: white; /* White icon on hover */
    transform: translateY(-2px); /* Slight lift effect */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); /* More prominent shadow on hover */
}

/* Ensure dropdown menu styling is consistent with the theme (already largely covered by existing .dropdown-menu styles) */
.dropdown-menu-dark .dropdown-item.text-danger:hover {
    background-color: transparent; /* Kırmızı hover efektini kaldırır */
    color: #f87171; /* Hover durumunda metin rengini biraz daha parlak yapar */
}

/* Gönderi detay sayfasındaki yorum kutusunun yeniden boyutlandırılmasını engelle */
#detail-comment-form .form-control {
    resize: none;
}

/* Üye kartı ve atma butonu stilleri */
.follow-card-wrapper {
    position: relative;
}

.btn-kick-member {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: rgba(220, 53, 69, 0.8); /* Kırmızı arka plan */
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0; /* Normalde görünmez */
}

/* Mobilde "At" butonunun her zaman görünür olmasını sağla */
@media (hover: none) and (pointer: coarse), (max-width: 768px) {
    .btn-kick-member {
        opacity: 1; /* Dokunmatik cihazlarda ve küçük ekranlarda her zaman görünür */
    }
}

.follow-card-wrapper:hover .btn-kick-member {
    opacity: 1; /* Üzerine gelince görünür */
}

.btn-kick-member:hover {
    background-color: rgba(220, 53, 69, 1);
    transform: scale(1.1);
}

/* Üye kartı içindeki isimlerin ortalanmasını sağla */
.follow-card {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#community-post-list .post-image {
    display: block; /* Resmin ayrı bir satırda durmasını garanti eder */
    width: 100%;
    height: 500px; /* Resimlerin dikeyde sabit ve uzun bir alan kaplamasını sağlar */
    object-fit: contain; /* Resmi kesmeden tamamını gösterir, yanlarda boşluk kalabilir */
    border-radius: 12px;
    background-color: rgba(0,0,0,0.2); /* Yüklenirken hafif bir arka plan rengi */
    margin-top: 0.75rem;
    border: 1px solid var(--explore-border);
}

.post-option-btn {
    background: none;
    border: none;
    color: var(--community-accent-1);
    font-size: 1.2rem;
    padding: 0.5rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}
.post-option-btn:hover {
    background-color: rgba(139, 92, 246, 0.1);
}

.post-card {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background-color: rgba(22, 33, 62, 0.9); /* backdrop-filter kaldırıldığı için opaklığı biraz artırıldı */
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    position: relative;
    overflow: hidden;
    z-index: 1;
    cursor: pointer;
}