/* Community stats popup (opened by clicking a مجموعة in the network legend) */

.community-stats-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.community-stats-modal {
    background: var(--color-surface, #fdfaf3);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    width: min(640px, 92vw);
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    direction: rtl;
}

.community-stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--color-border, #d8cfc0);
    flex-shrink: 0;
}

.community-stats-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
}

.community-swatch {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.community-stats-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--color-text-secondary, #6b5d4f);
    padding: 4px 8px;
    border-radius: 4px;
}

.community-stats-close:hover {
    background: rgba(0, 0, 0, 0.07);
}

.community-stats-summary {
    display: flex;
    gap: 28px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--color-border, #d8cfc0);
    flex-shrink: 0;
}

.community-stats-summary .summary-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.community-stats-summary .stat-value {
    font-weight: 700;
    font-size: 1.1rem;
}

.community-stats-summary .stat-label {
    font-size: 0.8rem;
    color: var(--color-text-secondary, #6b5d4f);
}

.community-stats-body {
    overflow-y: auto;
    padding: 14px 18px 18px;
    min-height: 0;
}

.community-stats-section {
    margin-bottom: 20px;
}

.community-stats-section h4 {
    margin: 0 0 10px;
    font-size: 1rem;
    border-bottom: 2px solid var(--color-accent, #b8946a);
    display: inline-block;
    padding-bottom: 2px;
}

/* --- Genre pie --------------------------------------------------------- */

.genre-pie-row {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.genre-pie {
    width: 170px;
    height: 170px;
    flex-shrink: 0;
}

.genre-pie-notes {
    flex: 1;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.genre-note {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.86rem;
}

.genre-note .note-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.genre-note .note-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.genre-note .note-count {
    color: var(--color-text-secondary, #6b5d4f);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* --- Tables ------------------------------------------------------------ */

.community-stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

.community-stats-table th {
    text-align: right;
    padding: 5px 8px;
    border-bottom: 2px solid var(--color-border, #d8cfc0);
    color: var(--color-text-secondary, #6b5d4f);
    font-weight: 600;
}

.community-stats-table td {
    padding: 5px 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
    font-variant-numeric: tabular-nums;
}

.community-stats-table .cell-name {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Clickable legend entries ------------------------------------------ */

.network-legend .legend-item.clickable {
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 4px;
    margin: -2px -4px;
}

.network-legend .legend-item.clickable:hover {
    background: rgba(0, 0, 0, 0.07);
}

/* --- Expandable community list in the legend ----------------------------- */

.legend-community-list.expanded {
    max-height: 260px;
    overflow-y: auto;
    padding-inline-end: 4px;
}

.legend-expand-toggle {
    cursor: pointer;
    color: var(--color-accent, #8a6d3b);
    font-size: 0.82rem;
    user-select: none;
}

.legend-expand-toggle:hover {
    text-decoration: underline;
}

/* --- Hadiths (isnad) panel ----------------------------------------------- */

.hadiths-panel .hadiths-count {
    padding: 8px 12px;
    font-size: 0.8rem;
    color: var(--color-text-secondary, #6b5d4f);
    border-bottom: 1px solid var(--color-border, #d8cfc0);
}

.hadith-link-row {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    cursor: pointer;
}

.hadith-link-row:hover {
    background: rgba(0, 0, 0, 0.05);
}

.hadith-tarf {
    font-family: "Amiri", "Noto Naskh Arabic", serif;
    font-size: 0.92rem;
    line-height: 1.7;
    direction: rtl;
}

.hadith-row-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 0.75rem;
}

.hadith-corpus {
    padding: 1px 7px;
    border-radius: 8px;
    color: #fff;
}

.hadith-corpus.shia { background: #2e8b6f; }
.hadith-corpus.sunni { background: #3b6ea5; }

.hadith-isnad-link {
    color: var(--color-accent, #8a6d3b);
    text-decoration: none;
    font-weight: 600;
}

.hadith-isnad-link:hover { text-decoration: underline; }

/* --- Isnad analyzer embed page ------------------------------------------- */

.isnad-tool-page {
    height: calc(100vh - var(--nav-height, 60px));
    display: flex;
}

.isnad-frame {
    flex: 1;
    width: 100%;
    border: none;
    background: var(--color-surface-primary, #FDF9F3);
}
