/* =================================================================
   Community module
   ================================================================= */

/* ---------- Sub-nav (All / Joined / Top / My) — matches the Members module ---------- */
.cm-subnav {
    display: flex; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius, 5px); margin-bottom: .75rem; overflow: hidden;
}
.cm-subnav a {
    flex: 1; text-align: center; padding: .4rem .3rem; text-decoration: none;
    color: var(--ink-soft); font-weight: 600; font-size: .72rem; position: relative;
    border-bottom: 2px solid transparent; white-space: nowrap;
}
.cm-subnav a.is-active { color: var(--indigo); border-bottom-color: var(--indigo); background: var(--indigo-soft, var(--paper)); }
.cm-subnav-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 16px; height: 16px; padding: 0 .28rem; margin-left: .2rem;
    background: var(--success); color: #fff; border-radius: 999px; font-size: .64rem; font-weight: 700;
}
.cm-subnav-badge-neutral { background: var(--indigo); }

.cm-head-bar { display: flex !important; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; padding: .3rem .7rem !important; background: var(--surface) !important; border: 1px solid var(--border) !important; border-radius: var(--radius, 5px); }
.cm-head-bar h1 { margin: 0; font-size: .95rem; }

/* ---------- Back button (manage-community page) ------------------------ */
.cm-back-btn {
    display: inline-flex; align-items: center; gap: .4rem; margin-bottom: .75rem;
    padding: .4rem .9rem; border-radius: 999px; border: 1px solid var(--border);
    background: var(--surface); color: var(--indigo); font-size: .82rem; font-weight: 700;
    text-decoration: none; transition: background .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.cm-back-btn:hover { background: var(--indigo-soft, var(--paper)); border-color: var(--indigo); box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,.08)); }
.cm-back-btn .icon-ui { transition: transform .15s ease; }
.cm-back-btn:hover .icon-ui { transform: translateX(-3px); }
.page-add-btn {
    display: flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    background: var(--indigo); text-decoration: none; font-size: .82rem;
    box-shadow: 0 3px 10px -3px rgba(0,0,0,.3);
    transition: background .12s ease, transform .1s ease;
}
.page-add-btn:hover { background: var(--indigo-deep); }
.page-add-btn:active { transform: scale(.94); }
.cm-section-head { font-family: var(--font-display); font-weight: 800; font-size: 1rem; margin: 1.25rem 0 .6rem; }

.cm-breadcrumb {
    font-size: .68rem; line-height: 1.2; color: var(--ink-soft); margin-bottom: .4rem;
    padding: .35rem .6rem; background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius, 5px);
}
.cm-breadcrumb a { color: var(--ink-soft); text-decoration: none; }
.cm-breadcrumb a:hover { color: var(--indigo); }
.cm-breadcrumb span { color: var(--ink); font-weight: 700; }

/* ---------- Browse grid ------------------------------------------------ */
.cm-panel {
    background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius, 5px);
    padding: .6rem; margin-bottom: 1.5rem;
}
.cm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.cm-card {
    position: relative;
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: .35rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius, 5px);
    padding: 1rem .75rem; text-decoration: none; color: inherit;
    transition: transform .1s ease, box-shadow .15s ease;
}
.cm-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px -10px rgba(0,0,0,.2); }
.cm-card-logo {
    width: 56px; height: 56px; border-radius: 12px; overflow: hidden;
    background: var(--indigo); color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.3rem;
}
.cm-card-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cm-card-name { font-weight: 700; font-size: .88rem; color: var(--ink); }
.cm-card-meta { font-size: .74rem; color: var(--ink-soft); }
.cm-card-joined-badge {
    position: absolute; top: .5rem; right: .5rem; font-size: .62rem; font-weight: 800;
    padding: .1rem .4rem; border-radius: 999px; background: rgba(42,157,111,.15); color: var(--success);
}

/* ---------- Community hero (cover + logo) ------------------------------ */
.cm-hero { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius, 5px); overflow: hidden; margin-bottom: 1rem; }
.cm-hero-cover {
    height: 100px;
    background:
        repeating-linear-gradient(45deg, rgba(255,255,255,.07) 0 2px, transparent 2px 14px),
        linear-gradient(135deg, var(--marigold) 0%, var(--indigo) 100%);
    background-size: cover, cover; background-position: center; background-repeat: no-repeat;
    position: relative;
}
.cm-hero-cover-edit {
    position: absolute; top: .5rem; right: .5rem; display: flex; align-items: center; gap: .25rem;
    padding: .3rem .55rem; border-radius: 999px; background: rgba(0,0,0,.55); color: #fff;
    font-size: .68rem; font-weight: 700; text-decoration: none;
}
.cm-hero-cover-edit:hover { background: rgba(0,0,0,.7); }

.cm-hero-bottom { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .55rem; padding: .4rem .75rem .6rem; }
.cm-hero-logo-wrap { flex-shrink: 0; margin-top: -34px; }
.cm-hero-logo {
    width: 70px; height: 70px; border-radius: 5px; border: 3px solid var(--surface);
    background: var(--indigo); color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.3rem; object-fit: cover; display: block;
    box-shadow: 0 0 0 1px var(--border);
}
.cm-hero-logo-initial { display: flex; align-items: center; justify-content: center; }
.cm-hero-identity { flex: 1; min-width: 160px; padding-top: .2rem; }
.cm-hero-identity h1 { margin: 0 0 .1rem; font-size: .98rem; }
.cm-hero-identity .muted { font-size: .72rem; }
.cm-hero-identity a { color: inherit; font-weight: 600; }
.cm-hero-stat-line { margin: 0; display: flex; align-items: center; gap: .35rem; }
.cm-hero-stat-line + .cm-hero-stat-line { margin-top: .15rem; }
.cm-hero-stat-line .icon-ui { width: 12px; text-align: center; flex-shrink: 0; }
.cm-hero-actions { display: flex; gap: .4rem; align-items: flex-end; flex-wrap: wrap; padding-bottom: .05rem; }
.cm-hero-description { margin: 0; padding: 0 .75rem .6rem; font-size: .82rem; color: var(--ink); line-height: 1.45; }

/* ---------- Forms (create / edit) --------------------------------------- */
.cm-form { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; padding: 1.1rem; }
.cm-form h3 { margin-bottom: .35rem; }
.cm-form form { display: flex; flex-direction: column; gap: .35rem; }
.cm-form label { font-size: .82rem; font-weight: 600; margin-top: .55rem; }
.cm-form input[type=text], .cm-form input[type=file], .cm-form textarea {
    display: block; width: 100%; box-sizing: border-box;
    padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 5px;
    background: var(--paper); font-family: inherit; font-size: .9rem; resize: vertical;
}
.cm-form button[type=submit] { align-self: flex-start; }
.cm-form-hint { font-size: .76rem; color: var(--ink-soft); margin: .2rem 0 0; }
.cm-edit-preview-cover { width: 100%; max-height: 160px; object-fit: cover; border-radius: 8px; margin-bottom: .6rem; }
.cm-edit-preview-logo { width: 76px; height: 76px; object-fit: cover; border-radius: 12px; margin-bottom: .6rem; }

/* ---------- Member list -------------------------------------------------- */
.cm-add-member-form { display: flex; gap: .5rem; margin-bottom: 1rem; }
.cm-add-member-form input {
    flex: 1; padding: .55rem .75rem; border: 1px solid var(--border); border-radius: 5px;
    background: var(--surface); font-family: inherit; font-size: .88rem; color: var(--ink);
}
.cm-member-list {
    display: flex; flex-direction: column; margin-bottom: 1rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius, 5px);
    overflow: hidden; box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,.05));
}
.cm-member-row { display: flex; align-items: center; gap: .65rem; padding: .65rem .9rem; border-top: 1px solid var(--border); }
.cm-member-list .cm-member-row:first-child { border-top: none; }
.cm-member-avatar {
    flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; overflow: hidden;
    background: var(--indigo); color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem; text-decoration: none;
}
.cm-member-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cm-member-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: .4rem; }
.cm-member-name { font-weight: 600; font-size: .88rem; color: var(--ink); text-decoration: none; }
.cm-member-name:hover { color: var(--indigo); }
.cm-member-badge {
    font-size: .64rem; font-weight: 800; padding: .1rem .45rem; border-radius: 999px;
    background: var(--indigo-soft, var(--paper)); color: var(--indigo);
}
.cm-member-remove-btn {
    display: flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 50%; border: none; background: none;
    color: var(--ink-soft); cursor: pointer; transition: background .12s ease, color .12s ease;
}
.cm-member-remove-btn:hover { background: rgba(214,69,90,.1); color: var(--danger); }

/* ---------- Pending join requests (creator-only) --------------------- */
.cm-requests-panel { margin-bottom: 1rem; padding: 1.1rem; }
.cm-requests-panel h3 { margin: 0 0 .6rem; font-size: .92rem; }
.cm-requests-panel .cm-member-list { border: 1px solid var(--border); }
.cm-request-actions { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }
.cm-request-approve-btn, .cm-request-reject-btn {
    display: flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border); background: none;
    cursor: pointer; transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.cm-request-approve-btn { color: var(--success); }
.cm-request-approve-btn:hover { background: rgba(42,157,111,.1); border-color: var(--success); }
.cm-request-reject-btn { color: var(--ink-soft); }
.cm-request-reject-btn:hover { background: rgba(214,69,90,.1); border-color: var(--danger); color: var(--danger); }
.cm-pending-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 16px; height: 16px; padding: 0 .3rem; margin-left: .3rem; border-radius: 999px;
    background: var(--danger); color: #fff; font-size: .68rem; font-weight: 800;
}

@media (max-width: 640px) {
    .cm-hero-cover { height: 80px; }
    .cm-hero-logo { width: 58px; height: 58px; }
    .cm-hero-logo-wrap { margin-top: -26px; }
}
