/**
 * PSM UI Components — Shared across backend pages
 * Designed to be used with Bootstrap 3 + Font Awesome
 *
 * Classes:
 *   .psm-page-hd          — Page header (title + count + actions)
 *   .psm-filter-bar        — Compact inline filter bar
 *   .psm-filter-bar.*      — Filter bar sub-elements
 *   .psm-report-hd         — Report header (title + meta columns)
 *   .psm-kpi-ib            — KPI info-box card (icon left + text right)
 *   .psm-chart-box         — Chart container box
 *   .psm-leader-*          — Leaderboard list row
 *   .psm-insights-box      — Insights / summary text box
 */

/* ── Page Header ─────────────────────────────────────────────────────────── */
.psm-page-hd {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding: 8px 0 10px;
    border-bottom: 2px solid #f0f0f0;
}
.psm-page-hd .ph-icon {
    width: 36px; height: 36px;
    background: #3c8dbc;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 16px; flex-shrink: 0;
}
.psm-page-hd .ph-info { flex: 1; }
.psm-page-hd .ph-title {
    margin: 0; font-size: 18px; font-weight: 700; color: #1a2d4f; line-height: 1.1;
}
.psm-page-hd .ph-count { font-size: 11px; color: #aaa; }
.psm-page-hd .ph-actions {
    margin-left: auto;
    display: flex; gap: 6px; align-items: center;
}

/* ── Compact Filter Bar ──────────────────────────────────────────────────── */
.psm-filter-bar {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    padding: 8px 14px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.psm-filter-bar .psm-fb-input {
    height: 28px !important;
    font-size: 12px !important;
    padding: 2px 8px !important;
    border-radius: 4px !important;
    border: 1px solid #ddd !important;
    display: inline-block;
    width: 180px;
}
.psm-filter-bar .psm-fb-select {
    height: 28px;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background: #fff;
    display: inline-block;
}
.psm-filter-bar .psm-fb-sep {
    width: 1px; height: 20px;
    background: #eee;
    margin: 0 2px;
    flex-shrink: 0;
}
.psm-filter-bar .btn-range {
    border-radius: 4px !important;
    font-size: 12px;
    padding: 3px 10px;
}
/* Chosen.js inside filter bar */
.psm-filter-bar .chosen-container { vertical-align: middle; }
.psm-filter-bar .chosen-container-multi .chosen-choices {
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    min-height: 28px !important;
    padding: 2px 4px !important;
    font-size: 12px;
    background: #fff !important;
    box-shadow: none !important;
}
.psm-filter-bar .chosen-container-multi .chosen-choices li.search-field input[type="text"] {
    height: 22px !important;
    font-size: 12px !important;
}
.psm-filter-bar .chosen-container-multi .chosen-choices li.search-choice {
    margin: 2px 3px 2px 0 !important;
    padding: 1px 18px 1px 5px !important;
    font-size: 11px !important;
    background: #e8f4fc !important;
    border: 1px solid #c8dff7 !important;
    border-radius: 3px !important;
    line-height: 16px !important;
    color: #1a5276;
}

/* ── Report Header ───────────────────────────────────────────────────────── */
.psm-report-hd {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    padding: 10px 18px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.psm-report-hd .rh-title { flex: 1; }
.psm-report-hd .rh-title h3 {
    margin: 0; font-size: 18px; font-weight: 800;
    color: #1a2d4f; letter-spacing: .3px; text-transform: uppercase;
}
.psm-report-hd .rh-title p {
    margin: 2px 0 0; font-size: 11px; font-weight: 700;
    color: #3c8dbc; letter-spacing: .5px; text-transform: uppercase;
}
.psm-report-hd .rh-meta { display: flex; gap: 0; border-left: 1px solid #eee; padding-left: 18px; }
.psm-report-hd .rh-meta-item {
    padding: 0 20px; border-right: 1px solid #eee; text-align: left;
}
.psm-report-hd .rh-meta-item:last-child { border-right: none; padding-right: 0; }
.psm-report-hd .rh-meta-label {
    font-size: 10px; color: #aaa; text-transform: uppercase;
    letter-spacing: .5px; font-weight: 600;
}
.psm-report-hd .rh-meta-val { font-size: 12px; font-weight: 700; color: #333; margin-top: 1px; }

/* ── KPI Info-box Cards ──────────────────────────────────────────────────── */
.psm-kpi-ib {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #eee;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    display: flex;
    align-items: stretch;
    overflow: hidden;
    height: 100%;
}
.psm-kpi-ib .ib-icon {
    width: 76px; min-width: 76px;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; color: #fff;
}
.psm-kpi-ib .ib-body { flex: 1; padding: 14px 16px 12px; }
.psm-kpi-ib .ib-label {
    font-size: 10px; color: #888; text-transform: uppercase;
    letter-spacing: .7px; font-weight: 600; margin-bottom: 3px;
}
.psm-kpi-ib .ib-val { font-size: 20px; font-weight: 800; line-height: 1.2; margin-bottom: 5px; }
.psm-kpi-ib .ib-sub {
    font-size: 11px; color: #999;
    border-top: 1px solid #f5f5f5; padding-top: 5px;
}
.psm-kpi-ib .ib-sub b { color: #555; }
.ib-up   { color: #27ae60; font-weight: 700; }
.ib-down { color: #e74c3c; font-weight: 700; }

/* ── Chart Box ───────────────────────────────────────────────────────────── */
.psm-chart-box {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #eee;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    margin-bottom: 16px;
}
.psm-chart-box .box-hd {
    padding: 14px 18px 0;
    border-bottom: 1px solid #f5f5f5;
    margin-bottom: 0;
    display: flex; align-items: baseline; gap: 8px;
}
.psm-chart-box .box-hd h4 {
    font-size: 14px; font-weight: 600; color: #333; margin: 0 0 10px;
}
.psm-chart-box .box-hd small { color: #aaa; font-size: 11px; }
.psm-chart-box .box-bd { padding: 14px 10px 10px; }

/* ── Leaderboard ─────────────────────────────────────────────────────────── */
.psm-leader-row {
    display: flex; align-items: center;
    padding: 7px 0; border-bottom: 1px solid #f8f8f8; gap: 10px;
}
.psm-leader-row:last-child { border-bottom: none; }
.psm-leader-rank { width: 22px; text-align: center; font-size: 13px; font-weight: 700; color: #bbb; flex-shrink: 0; }
.psm-leader-rank.top1 { color: #f5a623; }
.psm-leader-rank.top2 { color: #9b9b9b; }
.psm-leader-rank.top3 { color: #cd7f32; }
.psm-leader-name { flex: 1; font-size: 12px; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.psm-leader-bar  { width: 80px; height: 6px; border-radius: 3px; background: #eee; overflow: hidden; flex-shrink: 0; }
.psm-leader-bar-fill { height: 100%; border-radius: 3px; background: #3c8dbc; }
.psm-leader-val  { font-size: 12px; font-weight: 600; color: #555; width: 54px; text-align: right; flex-shrink: 0; }

/* ── Insights Box ────────────────────────────────────────────────────────── */
.psm-insights-box {
    display: flex; align-items: flex-start; gap: 14px;
    background: #f0f7ff; border: 1px solid #c8dff7;
    border-radius: 6px; padding: 12px 16px; margin: 0 0 16px;
}
.psm-insights-box .ins-icon { font-size: 22px; color: #3c8dbc; flex-shrink: 0; padding-top: 2px; }
.psm-insights-box .ins-main { flex: 1; font-size: 12px; color: #444; line-height: 1.7; }
.psm-insights-box .ins-main strong { color: #222; }
.psm-insights-box .ins-side { font-size: 12px; color: #555; min-width: 220px; }
.psm-insights-box .ins-side ul { margin: 0; padding-left: 16px; }
.psm-insights-box .ins-side li { line-height: 1.8; }
