/* ==========================================================================
   Social CMS — Pages module
   ========================================================================== */

.pg-breadcrumb { font-size: .72rem; line-height: 1.2; color: var(--ink-soft); margin-bottom: .4rem; }
.pg-breadcrumb a { color: var(--indigo); text-decoration: none; }
.pg-breadcrumb a:hover { text-decoration: underline; }

/* ---------- Subnav (attached to the title card) --------------------- */
.pg-subnav {
    display: flex; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius, 5px); margin-bottom: 1.25rem; overflow-x: auto; overflow-y: hidden;
    flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.pg-subnav::-webkit-scrollbar { display: none; }
.pg-subnav a {
    flex-shrink: 0; text-align: center; padding: .5rem .7rem; text-decoration: none;
    color: var(--ink-soft); font-weight: 600; font-size: .78rem; position: relative;
    border-bottom: 2px solid transparent; white-space: nowrap; display: flex; align-items: center; justify-content: center; gap: .3rem;
}
.pg-subnav a.is-active { color: var(--indigo); border-bottom-color: var(--indigo); background: var(--indigo-soft, var(--paper)); }
.page-head-group .pg-subnav { margin-bottom: 0; border: none; border-radius: 0; }

.pg-search { display: flex; gap: .5rem; margin-bottom: 1rem; max-width: 420px; }
.pg-search input {
    flex: 1; padding: .55rem .75rem; border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); font-family: inherit; font-size: .9rem;
}

/* ---------- Panel ---------------------------------------------------- */
.pg-panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: .6rem .75rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.pg-section-head { font-weight: 800; font-size: .95rem; margin: .3rem 0 .5rem; }
.pg-back-link { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; color: var(--indigo); text-decoration: none; margin-bottom: .75rem; }
.pg-back-link:hover { text-decoration: underline; }

/* ---------- Category browsing ---------------------------------------- */
.pg-category-row {
    display: flex; flex-wrap: nowrap; gap: .5rem; margin-bottom: .85rem;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.pg-category-row::-webkit-scrollbar { display: none; }
.touch-theme .pg-category-row {
    flex-wrap: wrap; overflow-x: visible; justify-content: flex-start;
}
.touch-theme .pg-category-card { width: calc(33.333% - .34rem); }
.pg-category-card {
    flex-shrink: 0; width: 88px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: .15rem;
    text-decoration: none; color: inherit; padding: .65rem .4rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    transition: transform .1s ease, box-shadow .15s ease;
}
.pg-category-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px -6px rgba(0,0,0,.15); }
.pg-category-icon { font-size: 1.25rem; }
.pg-category-name { font-weight: 700; font-size: .76rem; color: var(--ink); }
.pg-category-count { font-size: .64rem; color: var(--ink-soft); }
.pg-category-badge {
    display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; margin: .3rem 0;
    border-radius: 999px; background: var(--indigo-soft, var(--paper)); color: var(--indigo);
    font-size: .76rem; font-weight: 700; text-decoration: none;
}
.pg-category-badge:hover { background: var(--indigo); color: #fff; }

/* ---------- Row list (browse listing) --------------------------------- */
.pg-row-list { display: flex; flex-direction: column; }
.pg-row-list .pg-row:not(:last-child) { border-bottom: 1px solid var(--border); }
.pg-row {
    display: flex; align-items: center; gap: .75rem; padding: .5rem; border-radius: var(--radius, 5px);
    text-decoration: none; color: inherit; transition: background-color .12s ease;
}
.pg-row:hover { background: var(--paper); }
.pg-row-avatar {
    flex-shrink: 0; width: 52px; height: 52px; border-radius: 50%; overflow: hidden;
    background: linear-gradient(135deg, var(--indigo), var(--indigo-deep));
    display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.2rem;
}
.pg-row-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pg-row-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.pg-row-title { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-row-meta-list { display: flex; flex-wrap: wrap; gap: .25rem .75rem; }
.pg-row-meta { display: flex; align-items: center; gap: .3rem; font-size: .76rem; color: var(--ink-soft); white-space: nowrap; }
.pg-row-meta i { width: 14px; text-align: center; flex-shrink: 0; }
.pg-row-unpublished { display: flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 700; color: var(--danger); white-space: nowrap; }

/* ---------- Detail page ------------------------------------------------ */
.pg-detail {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: 1rem;
}
.pg-cover-area { position: relative; }
.pg-cover {
    width: 100%; aspect-ratio: 4/1; overflow: hidden; border-radius: var(--radius) var(--radius) 0 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(255,255,255,.12), transparent 55%),
        linear-gradient(135deg, var(--indigo), var(--indigo-deep));
    display: flex; align-items: center; justify-content: center;
}
.pg-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pg-cover-placeholder-icon { font-size: 1.7rem; color: rgba(255,255,255,.35); }

/* Kebab menu sits on the cover itself, top-right corner. */
.pg-menu.pg-cover-menu { position: absolute; top: .6rem; right: .6rem; z-index: 20; }
.pg-cover-menu .pg-menu-btn { background: rgba(0,0,0,.35); border-color: transparent; color: #fff; backdrop-filter: blur(2px); }
.pg-cover-menu .pg-menu-btn:hover, .pg-cover-menu.is-open .pg-menu-btn { background: rgba(0,0,0,.55); color: #fff; }

/* Small category chip, top-left of the cover — same semi-transparent
   treatment as the kebab menu so it stays legible over any photo. */
.pg-cover-category {
    position: absolute; top: .6rem; left: .6rem; z-index: 5;
    display: inline-flex; align-items: center; gap: .25rem;
    padding: .15rem .5rem; border-radius: 999px; background: rgba(0,0,0,.35);
    color: #fff; font-size: .68rem; font-weight: 700; text-decoration: none; backdrop-filter: blur(2px);
}
.pg-cover-category:hover { background: rgba(0,0,0,.55); }

/* Avatar is anchored to .pg-cover-area (which doesn't clip), not .pg-cover
   itself (which does, to crop the image to its box) — otherwise the half
   of the avatar meant to hang below the cover gets cut off by the same
   overflow:hidden that crops the photo. Its overlap amount is fixed here
   regardless of header content height, so the title below is never dragged
   up into the cover. */
.pg-profile {
    position: absolute; left: 1.1rem; bottom: -28px; z-index: 4;
    width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--surface);
    background: linear-gradient(135deg, var(--indigo), var(--indigo-deep));
    display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.4rem; overflow: hidden;
    box-shadow: 0 6px 16px -6px rgba(0,0,0,.35);
}
.pg-profile img { width: 100%; height: 100%; object-fit: cover; display: block; }

.pg-header-row { position: relative; z-index: 10; margin-top: -20px; padding: 0 1.1rem 0 calc(64px + 1.1rem + .75rem); min-height: 20px; }
.pg-header-info { min-width: 0; }
.pg-header-title-row { display: flex; align-items: flex-start; min-width: 0; }
.pg-title-highlight {
    display: inline-block; font-size: 1rem; font-weight: 800; margin: 0;
    padding: .1rem .55rem; border-radius: 5px; background: var(--indigo-soft, var(--paper)); color: var(--indigo);
    box-shadow: 0 3px 10px -3px rgba(0,0,0,.35);
    overflow-wrap: break-word; word-break: break-word;
}

.pg-header-sub-row { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; margin-top: .3rem; }
.pg-stat { font-size: .82rem; color: var(--ink-soft); }
.pg-stat strong { color: var(--ink); font-weight: 800; }

.pg-created-by { font-size: .78rem; margin: .1rem 0 0; }
.pg-description { font-size: .92rem; line-height: 1.6; margin: 0; padding: 0 1.1rem; white-space: pre-wrap; }
.pg-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .45rem 1.1rem 1.1rem; }
.pg-login-note { padding: 0 1.1rem 1.1rem; font-size: .85rem; color: var(--ink-soft); }
.pg-login-note a { color: var(--indigo); }

/* ---------- Kebab menu (Edit / Delete / Report) ------------------------ */
.pg-menu { position: relative; flex-shrink: 0; }
.pg-menu-btn {
    width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border);
    background: var(--surface); color: var(--ink-soft); font-size: 1rem; cursor: pointer;
    transition: background .12s ease;
}
.pg-menu-btn:hover, .pg-menu.is-open .pg-menu-btn { background: var(--paper); color: var(--ink); }
.pg-menu-dropdown {
    display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
    min-width: 150px; max-width: min(220px, calc(100vw - 2rem)); padding: .35rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 10px 28px -12px rgba(0,0,0,.35);
}
.pg-menu.is-open .pg-menu-dropdown { display: block; }
.pg-menu-dropdown a, .pg-menu-dropdown button, .pg-menu-dropdown form { display: block; width: 100%; }
.pg-menu-dropdown a, .pg-menu-dropdown button {
    padding: .5rem .6rem; border-radius: 5px; border: none; background: none;
    font-family: inherit; font-size: .86rem; font-weight: 600; text-align: left;
    color: var(--ink); text-decoration: none; cursor: pointer;
}
.pg-menu-dropdown a:hover, .pg-menu-dropdown button:hover { background: var(--paper); }
.pg-menu-danger { color: var(--danger) !important; }
.pg-menu-danger:hover { background: rgba(214,69,90,.1) !important; }

/* ---------- Like/Unlike button ------------------------------------------ */
.pg-like-btn {
    display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .7rem;
    border-radius: 5px; border: none; background: var(--indigo); color: #fff;
    font-size: .8rem; font-weight: 700; cursor: pointer;
    box-shadow: 0 3px 8px -3px rgba(0,0,0,.3);
    transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
}
.pg-like-btn:hover { background: var(--indigo-deep); box-shadow: 0 6px 16px -4px rgba(0,0,0,.35); }
.pg-like-btn:active { transform: scale(.97); }
.pg-like-btn.is-liked { background: var(--success); }
.pg-like-btn.is-liked:hover { background: #218a5c; }
.pg-like-btn:disabled { opacity: .6; cursor: default; }
.pg-count { font-size: .84rem; font-weight: 700; opacity: .9; }

/* Small overlapping avatar stack next to the Like button. */
.pg-liker-stack { display: flex; align-items: center; }
.pg-liker-stack-avatar {
    width: 24px; height: 24px; border-radius: 50%; overflow: hidden; margin-left: -8px;
    border: 2px solid var(--surface); background: linear-gradient(135deg, var(--indigo), var(--indigo-deep));
    display: flex; align-items: center; justify-content: center; color: #fff; font-size: .62rem; font-weight: 800;
}
.pg-liker-stack-avatar:first-child { margin-left: 0; }
.pg-liker-stack-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Full liker list + remove action, on the owner's settings page. */
.pg-liker-list { display: flex; flex-direction: column; }
.pg-liker-row { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.pg-liker-row:last-child { border-bottom: none; }
.pg-liker-avatar {
    width: 36px; height: 36px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
    background: linear-gradient(135deg, var(--indigo), var(--indigo-deep));
    display: flex; align-items: center; justify-content: center; color: #fff; font-size: .85rem; font-weight: 800;
}
.pg-liker-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pg-liker-name { flex: 1; min-width: 0; font-size: .88rem; font-weight: 700; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-liker-name:hover { text-decoration: underline; }
.pg-liker-time { font-size: .74rem; flex-shrink: 0; }
.pg-liker-remove {
    width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%; border: none; background: none;
    color: var(--ink-soft); cursor: pointer; font-size: .8rem;
}
.pg-liker-remove:hover { background: var(--paper); color: var(--danger); }

/* ---------- Insights dashboard ------------------------------------------- */
.pg-settings-form { display: flex; flex-direction: column; }
.pg-insights-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.pg-insights-kpi {
    display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: .9rem .6rem;
}
.pg-insights-kpi-icon { font-size: 1.1rem; color: var(--indigo); }
.pg-insights-kpi-value { font-size: 1.35rem; font-weight: 800; color: var(--ink); }
.pg-insights-kpi-label { font-size: .76rem; color: var(--ink-soft); font-weight: 600; }

.pg-insights-chart-wrap { position: relative; height: 220px; }

.pg-insights-top-posts { display: flex; flex-direction: column; }
.pg-insights-top-post {
    display: flex; align-items: center; gap: .7rem; padding: .6rem 0; border-bottom: 1px solid var(--border);
    text-decoration: none; color: inherit;
}
.pg-insights-top-post:last-child { border-bottom: none; }
.pg-insights-top-post-thumb { width: 48px; height: 48px; flex-shrink: 0; border-radius: 6px; overflow: hidden; }
.pg-insights-top-post-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pg-insights-top-post-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .25rem; }
.pg-insights-top-post-text { font-size: .86rem; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-insights-top-post-stats { display: flex; flex-wrap: wrap; gap: .7rem; font-size: .76rem; color: var(--ink-soft); }
.pg-insights-top-post-stats span { display: inline-flex; align-items: center; gap: .25rem; }
.pg-role-assign-form { display: flex; flex-direction: column; }
.pg-role-badge {
    flex-shrink: 0; padding: .2rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 800;
}
.pg-role-badge-admin { background: rgba(93,63,211,.12); color: var(--indigo); }
.pg-role-badge-editor { background: rgba(42,157,111,.12); color: var(--success); }
.pg-role-badge-moderator { background: rgba(244,163,0,.14); color: var(--marigold); }

/* ---------- Forms -------------------------------------------------------- */
.pg-form-hint { font-size: .8rem; color: var(--ink-soft); margin-top: .25rem; }

/* ---------- Post composer ------------------------------------------------ */
.pg-composer {
    display: flex; flex-direction: column; gap: .6rem; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: .85rem 1rem; margin-bottom: 1rem;
}
.pg-composer textarea {
    font-family: inherit; font-size: .9rem; padding: .6rem .7rem; border: 1px solid var(--border);
    border-radius: var(--radius, 5px); background: var(--paper); resize: vertical;
}
.pg-composer-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
/* Matches .feed-composer-attach exactly — label triggers the hidden input,
   file-preview.js (loaded site-wide) handles the actual preview into
   #pgComposerPreview automatically via data-preview-target. No custom JS
   or preview markup needed here anymore. */
.pg-composer-attach { display: flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--ink-soft); }
.pg-composer-attach label { cursor: pointer; display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; }
.pg-composer-attach input[type=file] { display: none; }

/* ---------- Timeline / wall ----------------------------------------------- */
/* Bookmark deliberately uses its default shared styling here — same small
   circular icon-only button, pushed to the far right — exactly as it
   appears on every feed post card. An earlier pass tried reshaping it to
   match Like/Dislike/Comment/Share, but that meant 5 buttons competing for
   flex space instead of feed's usual 4, which is what caused text to get
   cramped/truncated on touch theme in the first place. Leaving it alone
   is what actually makes this match feed posts. */
/* Like/Dislike/Share are <button> elements while Comment is an <a> tag —
   buttons can carry small browser-default margins anchors don't, which
   shows up as uneven spacing between them. Reset scoped to page posts
   only, without touching the shared feed.css file. */
.pg-post .feed-react-btn, .pg-timeline .feed-react-btn { margin: 0; }
.pg-timeline { display: flex; flex-direction: column; gap: .75rem; margin-bottom: .5rem; }
.pg-post {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: .85rem 1rem; cursor: pointer; transition: box-shadow .12s ease;
}
.pg-post:hover { box-shadow: 0 6px 18px -10px rgba(0,0,0,.25); }
.pg-post-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.pg-post-avatar {
    width: 36px; height: 36px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
    background: linear-gradient(135deg, var(--indigo), var(--indigo-deep));
    display: flex; align-items: center; justify-content: center; color: #fff; font-size: .9rem;
}
.pg-post-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pg-post-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .05rem; font-size: .78rem; }
.pg-post-meta strong { font-size: .86rem; }
.pg-post-body {
    font-size: .9rem; line-height: 1.55; white-space: pre-wrap; margin: 0 0 .35rem;
    display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden;
}
.pg-post-body.is-expanded { display: block; -webkit-line-clamp: unset; overflow: visible; }
.pg-post-see-more {
    display: block; border: none; background: none; color: var(--indigo); font-weight: 700;
    font-size: .82rem; padding: 0; margin: 0 0 .5rem; cursor: pointer;
}
.pg-post-see-more:hover { text-decoration: underline; }
.pg-post-image {
    width: 100% !important; max-height: 420px !important; height: auto !important;
    object-fit: contain !important; border-radius: 8px; display: block;
    background: var(--paper);
}
.pg-post-edit-form {
    display: flex; flex-direction: column; gap: .5rem; margin-top: .5rem;
    padding-top: .6rem; border-top: 1px solid var(--border);
}
.pg-post-edit-form textarea {
    font-family: inherit; font-size: .88rem; padding: .55rem .65rem; border: 1px solid var(--border);
    border-radius: var(--radius, 5px); background: var(--paper); resize: vertical;
}

@media (max-width: 640px) {
    .pg-profile { width: 54px; height: 54px; font-size: 1.2rem; bottom: -24px; left: .85rem; }
    .pg-header-row { position: relative; z-index: 10; margin-top: -16px; padding: 0 .85rem 0 calc(54px + .85rem + .6rem); min-height: 16px; }
    .pg-title-highlight { font-size: .92rem; padding: .08rem .45rem; }
    .pg-header-sub-row { gap: .45rem; }
    .pg-description { padding: .7rem .85rem 0; }
    .pg-actions { padding: .75rem .85rem .9rem; }
}
