/* /pl/niches + /pl/niche/{key} — style.
   Heatmap ch-heatmap-* / ch-cadence-* classes duplicated from pl/channel.php inline <style>. */

/* ===================== Cadence tiles (from channel.php) ===================== */
.ch-cadence-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.ch-cadence-tile { background: var(--bg, #0f1419); border-radius: 8px; padding: 12px; text-align: center; }
.ch-cadence-val  { font-size: 18px; font-weight: 700; }
.ch-cadence-label { font-size: 10px; color: var(--text-muted, #8b949e); text-transform: uppercase; margin-top: 3px; }

/* ===================== Heatmap (from channel.php) ===================== */
.ch-heatmap { overflow-x: auto; padding-bottom: 4px; }
.ch-heatmap-grid { display: flex; gap: 3px; align-items: flex-start; }
.ch-heatmap-col  { display: flex; flex-direction: column; gap: 3px; }
.ch-heatmap-cell {
    width: 13px; height: 13px; border-radius: 2px;
    background: rgba(255,255,255,0.06); flex-shrink: 0;
    cursor: default; transition: opacity 0.1s;
}
.ch-heatmap-cell:hover { opacity: 0.8; }

/* ===================== DoW × Hour heatmap (niche.php) ===================== */
.nd-dh-heatmap { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; }
.nd-dh-row {
    display: grid;
    grid-template-columns: 32px repeat(24, 1fr);
    gap: 3px;
    align-items: center;
}
.nd-dh-label {
    font-size: 11px; color: var(--text-muted, #8b949e);
    text-align: right; padding-right: 4px;
}
.nd-dh-cell {
    height: 22px; border-radius: 2px;
    background: rgba(255,255,255,0.04);
    cursor: default;
}
.nd-dh-cell:hover { outline: 1px solid rgba(255,255,255,0.3); }
.nd-dh-header .nd-dh-hlabel {
    font-size: 10px; color: var(--text-muted, #8b949e);
    text-align: center; height: 14px; line-height: 14px;
}

/* ===================== Scrollowana tabela (niche.php) ===================== */
.nd-table-scroll {
    max-height: 560px;
    overflow-y: auto;
    border: 1px solid var(--border, #2a3341);
    border-radius: 6px;
    margin-top: 10px;
}
.nd-table-scroll .nd-table { margin: 0; }
.nd-table-scroll thead {
    position: sticky; top: 0; z-index: 2;
    background: var(--bg-raised, #1a2028);
}

:root {
    --nv-gaming:        #e34c26;
    --nv-entertainment: #d946ef;
    --nv-sport:         #f59e0b;
    --nv-lifestyle:     #10b981;
    --nv-news:          #3b82f6;
    --nv-education:     #6366f1;
    --nv-inne:          #6b7280;
}

/* ===================== /pl/niches — overview ===================== */

.nv-section {
    background: var(--bg-raised, #1a2028);
    border: 1px solid var(--border, #2a3341);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    position: relative;
}
.nv-section h2 {
    font-size: 18px;
    font-weight: 500;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.nv-subtitle {
    color: var(--text-muted, #8b949e);
    font-weight: 400;
    font-size: 13px;
}
.nv-legend {
    display: flex; gap: 16px; flex-wrap: wrap;
    font-size: 12px; color: var(--text-muted, #8b949e); margin-bottom: 12px;
}
.nv-legend-item { display: flex; align-items: center; gap: 6px; }
.nv-legend-dot  { width: 12px; height: 12px; border-radius: 50%; }

#nv-bubble { width: 100%; height: 700px; display: block; }
#nv-tooltip {
    position: fixed;
    background: #0d1117;
    border: 1px solid var(--border, #2a3341);
    border-radius: 6px;
    padding: 8px 12px;
    pointer-events: none;
    opacity: 0;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    transition: opacity 0.15s;
    z-index: 100;
}
#nv-tooltip strong { font-size: 14px; display: block; margin-bottom: 4px; color: var(--text, #e6edf3); }
#nv-tooltip .t-row { display: flex; justify-content: space-between; gap: 16px; color: var(--text-muted, #8b949e); }
#nv-tooltip .t-row span:last-child { color: var(--text, #e6edf3); }

.nv-bubble-text {
    font-family: inherit;
    pointer-events: none;
    fill: #fff;
    text-anchor: middle;
    dominant-baseline: central;
    font-weight: 500;
}

/* Toggle */
.nv-toggle-group {
    display: inline-flex; gap: 2px;
    background: var(--bg, #0f1419);
    padding: 3px; border-radius: 8px;
    margin-left: auto;
}
.nv-toggle-btn {
    background: transparent; border: 0;
    color: var(--text-muted, #8b949e);
    font-family: inherit; font-size: 12px;
    padding: 6px 14px; border-radius: 6px;
    cursor: pointer; font-weight: 500;
}
.nv-toggle-btn.active { background: var(--accent, #58a6ff); color: #0a0e14; }
.nv-toggle-btn:hover:not(.active) { color: var(--text, #e6edf3); }

/* Horizontal bar rank */
#nv-bar-rank { display: flex; flex-direction: column; gap: 2px; }
.nv-bar-row {
    display: flex; align-items: center; gap: 12px;
    padding: 4px 0; cursor: pointer; transition: background 0.1s;
}
.nv-bar-row:hover { background: #0d1117; }
.nv-bar-label { flex: 0 0 180px; font-size: 13px; text-align: right; color: var(--text, #e6edf3); }
.nv-bar-category { flex: 0 0 110px; font-size: 11px; color: var(--text-muted, #8b949e); }
.nv-bar-container { flex: 1; position: relative; height: 22px; }
.nv-bar-center-line {
    position: absolute; left: 50%; top: 0; bottom: 0;
    width: 1px; background: var(--border, #2a3341);
}
.nv-bar-fill {
    height: 16px; border-radius: 3px;
    position: absolute; top: 3px;
    transition: all 0.2s;
}
.nv-bar-value { flex: 0 0 70px; font-size: 13px; font-weight: 500; text-align: right; }
.nv-bar-value.positive { color: #22c55e; }
.nv-bar-value.negative { color: #ef4444; }

/* ===================== /pl/niche/{key} — detail ===================== */

.nd-crumb { color: var(--text-muted, #8b949e); font-size: 13px; margin-bottom: 8px; }
.nd-crumb a { color: var(--text-muted, #8b949e); text-decoration: none; }
.nd-crumb a:hover { color: var(--text, #e6edf3); }

.nd-title {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin-bottom: 4px;
}
.nd-title h1 { font-size: 30px; font-weight: 700; margin: 0; }
.nd-badge {
    background: var(--bg-raised, #1a2028);
    border: 1px solid var(--border, #2a3341);
    color: var(--text-muted, #8b949e);
    font-size: 12px; padding: 4px 10px;
    border-radius: 999px; font-weight: 500;
}
.nd-badge-cat[data-cat="news"]          { color: var(--nv-news);          border-color: var(--nv-news); }
.nd-badge-cat[data-cat="education"]     { color: var(--nv-education);     border-color: var(--nv-education); }
.nd-badge-cat[data-cat="gaming"]        { color: var(--nv-gaming);        border-color: var(--nv-gaming); }
.nd-badge-cat[data-cat="entertainment"] { color: var(--nv-entertainment); border-color: var(--nv-entertainment); }
.nd-badge-cat[data-cat="sport"]         { color: var(--nv-sport);         border-color: var(--nv-sport); }
.nd-badge-cat[data-cat="lifestyle"]     { color: var(--nv-lifestyle);     border-color: var(--nv-lifestyle); }
.nd-badge-cat[data-cat="inne"]          { color: var(--nv-inne);          border-color: var(--nv-inne); }

.nd-subtitle { color: var(--text-muted, #8b949e); font-size: 14px; margin: 0 0 20px; }

/* KPIs */
.nd-kpis {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px; margin-bottom: 16px;
}
.nd-kpi {
    background: var(--bg-raised, #1a2028);
    border: 1px solid var(--border, #2a3341);
    border-radius: 12px; padding: 14px;
}
.nd-lbl {
    color: var(--text-muted, #8b949e);
    font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.08em; margin-bottom: 8px;
}
.nd-val { font-size: 22px; font-weight: 700; color: var(--text, #e6edf3); }
.nd-delta { font-size: 12px; margin-top: 6px; color: var(--text-muted, #8b949e); }
.nd-delta.up   { color: #22c55e; }
.nd-delta.down { color: #ef4444; }

/* Rows and panels */
.nd-row { display: grid; gap: 16px; margin-bottom: 16px; }
.nd-row-1-2 { grid-template-columns: 1fr 2fr; }
.nd-panel {
    background: var(--bg-raised, #1a2028);
    border: 1px solid var(--border, #2a3341);
    border-radius: 12px; padding: 16px;
}
.nd-panel h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; color: var(--text, #e6edf3); }
.nd-hint    { color: var(--text-muted, #8b949e); font-size: 12px; margin-bottom: 12px; }

/* Tabs */
.nd-tabs {
    display: flex; gap: 2px;
    background: var(--bg, #0f1419);
    padding: 3px; border-radius: 10px;
    width: fit-content; margin-bottom: 12px;
}
.nd-tab {
    background: transparent; border: 0;
    color: var(--text-muted, #8b949e);
    font-family: inherit; font-size: 13px;
    padding: 8px 16px; border-radius: 7px;
    cursor: pointer; font-weight: 500;
}
.nd-tab.active  { background: var(--accent, #58a6ff); color: #0b0d12; font-weight: 600; }
.nd-tab:hover:not(.active) { color: var(--text, #e6edf3); }

/* Filters */
.nd-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.nd-ctrl {
    background: var(--bg, #0f1419);
    border: 1px solid var(--border, #2a3341);
    color: var(--text, #e6edf3);
    font-size: 12px; padding: 6px 10px;
    border-radius: 8px; cursor: pointer; font-family: inherit;
}
select.nd-ctrl { appearance: none; padding-right: 22px; }

/* Charts */
.nd-chart { width: 100%; }
.nd-chart-tall { height: 480px; }
.nd-chart-sm   { height: 260px; }

/* Scatter helpers */
.nd-panel .axis text { fill: var(--text-muted, #8b949e); font-size: 11px; }
.nd-panel .axis path,
.nd-panel .axis line { stroke: var(--border, #2a3341); }
.nd-panel .grid line { stroke: var(--border, #2a3341); stroke-dasharray: 2,2; opacity: 0.45; }
.nd-panel .quad-label { fill: #5f6880; font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; }

/* Tooltip (shared with scatter) */
.nd-tooltip {
    position: absolute; pointer-events: none;
    background: #0b0d12ee;
    border: 1px solid var(--border, #2a3341);
    border-radius: 8px; padding: 8px 10px;
    font-size: 12px; color: var(--text, #e6edf3);
    max-width: 320px; line-height: 1.4;
    opacity: 0; transition: opacity 0.08s;
    z-index: 100;
}

/* Table */
.nd-table {
    width: 100%; border-collapse: collapse;
    margin-top: 16px; font-size: 13px;
}
.nd-table thead th {
    color: var(--text-muted, #8b949e); font-weight: 500;
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
    text-align: left; padding: 10px 12px;
    border-bottom: 1px solid var(--border, #2a3341);
}
.nd-table thead th.num { text-align: right; }
.nd-table thead th.sortable { cursor: pointer; user-select: none; position: relative; padding-right: 22px; }
.nd-table thead th.sortable:hover { color: var(--text, #e6edf3); }
.nd-table thead th.sortable::after {
    content: '↕'; position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    opacity: 0.35; font-size: 10px;
}
.nd-table thead th.sortable.sorted-desc::after { content: '▼'; opacity: 1; color: var(--accent, #58a6ff); }
.nd-table thead th.sortable.sorted-asc::after  { content: '▲'; opacity: 1; color: var(--accent, #58a6ff); }
.nd-table tbody tr {
    border-bottom: 1px solid var(--border, #2a3341);
    cursor: pointer; transition: background 0.1s;
}
.nd-table tbody tr:hover { background: var(--bg, #0f1419); }
.nd-table td { padding: 10px 12px; color: var(--text, #e6edf3); }
.nd-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.nd-table td.rank { color: var(--text-muted, #8b949e); width: 36px; }
.nd-table td.name { font-weight: 500; }
.nd-name-cell {
    display: flex; align-items: center; gap: 10px;
}
.nd-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--bg, #0f1419);
    border: 1px solid var(--border, #2a3341);
    object-fit: cover; flex-shrink: 0;
}
.nd-avatar-placeholder { display: inline-block; }
.nd-table td.metric { color: var(--accent, #58a6ff); font-weight: 600; }
.nd-table td.metric.bad  { color: #ef4444; }
.nd-table td.metric.good { color: #22c55e; }
.chip {
    display: inline-block;
    background: var(--bg, #0f1419);
    border: 1px solid var(--border, #2a3341);
    color: var(--text-muted, #8b949e);
    font-size: 11px; padding: 2px 8px;
    border-radius: 999px; font-weight: 500;
}

/* Audience demands list */
.nd-list { display: flex; flex-direction: column; gap: 10px; }
.nd-list-item { display: flex; flex-direction: column; gap: 6px; }
.nd-list-head {
    display: flex; justify-content: space-between;
    align-items: baseline; font-size: 13px; gap: 12px;
    color: var(--text, #e6edf3);
}
.nd-list-head strong { font-weight: 500; }
.nd-list-sub { color: var(--text-muted, #8b949e); font-size: 11px; white-space: nowrap; }
.nd-list-bar {
    height: 6px; background: var(--bg, #0f1419);
    border-radius: 4px; overflow: hidden;
}
.nd-list-bar > span {
    display: block; height: 100%;
    background: var(--accent, #58a6ff);
}

/* Responsive */
@media (max-width: 1200px) {
    .nd-kpis { grid-template-columns: repeat(3, 1fr); }
    .nd-row-1-2 { grid-template-columns: 1fr; }
}
