.communities-page {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #333;
}

/* ── Intro ─────────────────────────────────────────────── */
.comm-intro { margin-bottom: 24px; }
.comm-intro h2 { font-size: 22px; font-weight: 700; color: #222; margin-bottom: 8px; letter-spacing: -0.02em; }
.comm-intro p  { color: #555; font-size: 15px; line-height: 1.7; margin-bottom: 6px; }
.comm-intro a  { color: #00568F; font-weight: 600; }

/* ── Stats cards ────────────────────────────────────────── */
.comm-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}
.comm-stat-card {
    background: #fff;
    border: 1px solid #e4e4e4;
    border-radius: 12px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: box-shadow 0.2s;
}
.comm-stat-card:hover { box-shadow: 0 4px 14px rgba(0,86,143,0.1); }
.comm-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 20px;
}
.comm-stat-icon.blue  { background: #eaf4ff; color: #00568F; }
.comm-stat-icon.green { background: #edfaf3; color: #1a8a4a; }
.comm-stat-icon.amber { background: #fff8ec; color: #d97706; }
.comm-stat-text strong {
    display: block;
    font-size: 26px;
    font-weight: 800;
    color: #111;
    line-height: 1.1;
    letter-spacing: -0.5px;
}
.comm-stat-text span {
    font-size: 12px;
    color: #888;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Filter / search bar ────────────────────────────────── */
.comm-filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.comm-search-wrap {
    flex: 1;
    min-width: 220px;
    position: relative;
}
.comm-search-wrap i {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 14px;
    pointer-events: none;
}
.comm-search-input {
    width: 100%;
    padding: 10px 14px 10px 36px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    color: #333;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    height: 42px;
}
.comm-search-input:focus {
    outline: none;
    border-color: #00568F;
    box-shadow: 0 0 0 3px rgba(0,86,143,0.1);
}
.comm-sort-select {
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    color: #333;
    background: #fff;
    min-width: 200px;
    height: 42px;
    transition: border-color 0.2s;
    cursor: pointer;
}
.comm-sort-select:focus { outline: none; border-color: #00568F; }
.comm-search-btn {
    padding: 0 20px;
    height: 42px;
    background: #00568F;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.comm-search-btn:hover { background: #004070; }
.comm-clear-btn {
    padding: 0 14px;
    height: 42px;
    background: #f5f5f5;
    color: #555;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background 0.2s;
    white-space: nowrap;
}
.comm-clear-btn:hover { background: #eee; color: #333; text-decoration: none; }

/* ── Results line ───────────────────────────────────────── */
.comm-results-line {
    font-size: 14px;
    color: #666;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.comm-results-line strong { color: #222; }

/* ── Grid ───────────────────────────────────────────────── */
.communities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 22px;
    margin-bottom: 30px;
}

/* ── Card ───────────────────────────────────────────────── */
.community-card {
    background: #fff;
    border: 1px solid #e4e4e4;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.25s ease;
}
.community-card:hover {
    box-shadow: 0 8px 24px rgba(0,86,143,0.13);
    transform: translateY(-3px);
    border-color: #b8d8f0;
}

/* ── Card thumbnail ─────────────────────────────────────── */
.comm-card-thumb {
    height: 130px;
    background: linear-gradient(135deg, #00568F 0%, #0080cc 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}
.comm-card-thumb::before,
.comm-card-thumb::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.07);
    pointer-events: none;
}
.comm-card-thumb::before { width: 110px; height: 110px; top: -30px; right: -25px; }
.comm-card-thumb::after  { width: 70px;  height: 70px;  bottom: -20px; left: -15px; }

/* ── Circular avatar ────────────────────────────────────── */
.comm-card-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.9);
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
    overflow: hidden;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}
.comm-card-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.comm-card-avatar-initials {
    font-size: 28px;
    font-weight: 800;
    color: #00568F;
    text-transform: uppercase;
    line-height: 1;
    user-select: none;
}

/* ── Card body ──────────────────────────────────────────── */
.comm-card-body { padding: 16px 18px 12px; flex: 1; display: flex; flex-direction: column; }
.comm-card-title {
    font-size: 17px;
    font-weight: 700;
    color: #00568F;
    margin: 0 0 10px 0;
    line-height: 1.4;
    text-decoration: none;
    display: block;
    transition: color 0.2s;
}
.comm-card-title:hover { color: #004070; text-decoration: underline; }
.comm-card-desc {
    color: #555;
    font-size: 14px;
    line-height: 1.65;
    margin-bottom: 14px;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Meta badges ────────────────────────────────────────── */
.comm-card-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.comm-meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.comm-meta-badge.opps    { background: #eaf4ff; color: #00568F; border: 1px solid #b8d8f0; }
.comm-meta-badge.orgs    { background: #f0f9eb; color: #3a7d44; border: 1px solid #b8dfc4; }
.comm-meta-badge.no-data { background: #f7f7f7; color: #999;    border: 1px solid #e5e5e5; }
.comm-meta-badge i { font-size: 11px; }

/* ── Card footer ────────────────────────────────────────── */
.comm-card-footer {
    padding: 12px 18px;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
}
.comm-view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    border-radius: 8px;
    background: #00568F;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}
.comm-view-btn:hover {
    background: #004070;
    color: #fff;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0,86,143,0.3);
}

/* ── Empty / no-results states ──────────────────────────── */
.comm-no-results {
    text-align: center;
    padding: 50px 20px;
    background: #fafafa;
    border: 1px dashed #ddd;
    border-radius: 12px;
}
.comm-no-results i  { font-size: 40px; color: #c8dff0; margin-bottom: 14px; display: block; }
.comm-no-results h4 { font-size: 18px; font-weight: 600; color: #444; margin-bottom: 8px; }
.comm-no-results p  { font-size: 14px; color: #777; }

.comm-empty-state { text-align: center; padding: 70px 20px; }
.comm-empty-state i  { font-size: 48px; color: #c8dff0; margin-bottom: 16px; display: block; }
.comm-empty-state h4 { font-size: 20px; font-weight: 600; color: #222; margin-bottom: 10px; }
.comm-empty-state p  { font-size: 15px; color: #777; }

/* ── View toggle buttons ────────────────────────────────── */
.comm-view-toggle {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}
.comm-view-btn-toggle {
    width: 34px;
    height: 34px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}
.comm-view-btn-toggle:hover { border-color: #00568F; color: #00568F; }
.comm-view-btn-toggle.active { background: #00568F; border-color: #00568F; color: #fff; }

/* ── List view layout ───────────────────────────────────── */
.communities-grid.list-view {
    grid-template-columns: 1fr;
    gap: 14px;
}
.communities-grid.list-view .community-card {
    flex-direction: row;
    align-items: stretch;
    border-radius: 12px;
}
.communities-grid.list-view .comm-card-thumb {
    width: 110px;
    height: auto;
    min-height: 100px;
    flex-shrink: 0;
    border-radius: 0;
}
.communities-grid.list-view .comm-card-avatar {
    width: 62px;
    height: 62px;
}
.communities-grid.list-view .comm-card-avatar-initials {
    font-size: 20px;
}
.communities-grid.list-view .comm-card-body {
    padding: 14px 16px;
    justify-content: center;
}
.communities-grid.list-view .comm-card-desc {
    -webkit-line-clamp: 2;
    margin-bottom: 8px;
}
.communities-grid.list-view .comm-card-footer {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-top: none;
    border-left: 1px solid #f0f0f0;
    min-width: 150px;
    flex-shrink: 0;
}
.communities-grid.list-view .comm-view-btn {
    white-space: nowrap;
    padding: 10px 16px;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 576px) {
    .comm-stats-row { grid-template-columns: 1fr; }
    .comm-filter-bar { flex-direction: column; align-items: stretch; }
    .comm-sort-select { min-width: unset; width: 100%; }
}
@media (max-width: 768px) {
    .communities-grid { grid-template-columns: 1fr; }
    /* Force grid view on mobile — list view toggle is hidden */
    .communities-grid.list-view {
        grid-template-columns: 1fr;
    }
    .communities-grid.list-view .community-card {
        flex-direction: column;
    }
    .communities-grid.list-view .comm-card-thumb {
        width: 100%;
        height: 130px;
    }
    .communities-grid.list-view .comm-card-footer {
        border-left: none;
        border-top: 1px solid #f0f0f0;
        min-width: unset;
    }
}
@media (min-width: 769px) and (max-width: 1024px) {
    .communities-grid { grid-template-columns: repeat(2, 1fr); }
}
