/* ═════════════════════════════════════════════════════════════════════════════
   Analytics-Style Company / Role Pages
   ═════════════════════════════════════════════════════════════════════════════ */

.q-analytics-page {
    /* Light tweaks for the analytics layout — uses main site design tokens */
}

/* Hero — replaces the standard .questions-hero */
.q-analytics-hero {
    padding: 130px 0 32px;
    background: linear-gradient(180deg, #f5f3ff 0%, var(--bg, #fff) 100%);
    border-bottom: 1px solid var(--border, #e5e7eb);
}
.q-analytics-hero h1 {
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--text-heading, #0f172a);
    margin: 8px 0 10px;
    letter-spacing: -0.5px;
}
.q-analytics-hero-eyebrow {
    display: inline-block;
    background: rgba(139, 30, 63, 0.08);
    color: var(--primary, #8B1E3F);
    padding: 4px 14px;
    border-radius: 100px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.q-analytics-hero-sub {
    font-size: 1.05rem;
    color: var(--text-muted, #64748b);
    margin: 0 0 18px;
    line-height: 1.55;
    max-width: 760px;
}
.q-analytics-hero-meta {
    display: flex;
    gap: 22px;
    flex-wrap: wrap;
    font-size: 0.88rem;
    color: var(--text-muted, #64748b);
}
.q-analytics-hero-meta strong {
    color: var(--text-heading, #0f172a);
    font-weight: 600;
}

/* Section padding */
.q-analytics-section {
    padding: 36px 0 80px;
    background: var(--bg, #fff);
    min-height: 60vh;
}

/* ── Stat tiles (4-up KPI grid) ──────────────────────────────────────────── */
.q-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}
.q-stat-tile {
    background: var(--bg-card-solid, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.q-stat-tile-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-heading, #0f172a);
    line-height: 1.1;
    letter-spacing: -0.02em;
}
.q-stat-tile-label {
    font-size: 0.78rem;
    color: var(--text-muted, #64748b);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Charts grid (donut / bars / heatmap) ────────────────────────────────── */
.q-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1.4fr 1.4fr;
    gap: 18px;
    margin-bottom: 28px;
}
.q-chart-card {
    background: var(--bg-card-solid, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
}
.q-chart-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-heading, #0f172a);
    margin: 0 0 2px;
}
.q-chart-sub {
    font-size: 0.8rem;
    color: var(--text-muted, #64748b);
    margin: 0 0 18px;
}

/* Donut */
.q-donut-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: center;
}
.q-donut {
    width: 140px;
    height: 140px;
    flex-shrink: 0;
    color: var(--text-heading, #0f172a);
}
.q-donut-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text, #1e293b);
    min-width: 130px;
}
.q-donut-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.q-donut-legend-item strong {
    font-weight: 700;
    color: var(--text-heading, #0f172a);
}
.q-donut-legend-item em {
    font-style: normal;
    opacity: 0.7;
    font-size: 0.78rem;
}
.q-donut-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* Bar chart — fixed width, not stretched */
.q-bars {
    width: 360px;
    height: auto;
    max-width: 100%;
    color: var(--text, #1e293b);
}

/* Heatmap — inline SVG with explicit width, no stretching */
.q-heatmap {
    display: block;
    width: 200px;
    height: auto;
    max-width: 100%;
    color: var(--text, #1e293b);
}

/* ── Generic block (topics, levels, recent) ───────────────────────────────── */
.q-block {
    background: var(--bg-card-solid, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    padding: 22px 24px;
    margin-bottom: 22px;
}
.q-block-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-heading, #0f172a);
    margin: 0 0 2px;
}
.q-block-sub {
    font-size: 0.82rem;
    color: var(--text-muted, #64748b);
    margin: 0 0 16px;
}

/* Top topics — horizontal bars */
.q-topics-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.q-topic-bar {
    display: grid;
    grid-template-columns: 140px 1fr 40px;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
}
.q-topic-bar-label {
    color: var(--text, #1e293b);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.q-topic-bar-track {
    height: 8px;
    background: rgba(128,128,128,0.12);
    border-radius: 4px;
    overflow: hidden;
}
.q-topic-bar-fill {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #8B1E3F, #d4537a);
    border-radius: 4px;
    transition: width 0.4s ease;
}
.q-topic-bar-count {
    color: var(--text-muted, #64748b);
    font-weight: 600;
    font-size: 0.82rem;
    text-align: right;
}

/* Pills (experience levels) */
.q-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.q-pill {
    background: var(--bg-input, #f8fafc);
    color: var(--text, #1e293b);
    padding: 6px 12px;
    border-radius: 100px;
    font-size: 0.82rem;
    font-weight: 500;
    border: 1px solid var(--border, #e5e7eb);
}
.q-pill strong {
    color: var(--primary, #8B1E3F);
    font-weight: 700;
    margin-left: 4px;
}

/* Recent questions grid */
.q-recent-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.q-recent-card {
    display: block;
    padding: 14px 16px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, transform 0.15s;
}
.q-recent-card:hover {
    border-color: var(--primary, #8B1E3F);
    transform: translateY(-1px);
}
.q-recent-card .q-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.q-recent-card .q-diff {
    font-size: 0.78rem;
    font-weight: 600;
}
.q-recent-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-heading, #0f172a);
    margin: 0 0 8px;
    line-height: 1.4;
}
.q-recent-card .q-tags {
    margin-bottom: 8px;
}
.q-recent-card .q-tag {
    font-size: 0.72rem;
}
.q-recent-meta {
    font-size: 0.78rem;
    color: var(--text-muted, #64748b);
}

/* CTA tweak */
.q-analytics-cta {
    margin-top: 28px;
}

/* ── Hub grid (companies / roles directory) ───────────────────────────────── */
.q-hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.q-hub-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 18px 16px;
    min-height: 92px;
    background: var(--bg-card-solid, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.q-hub-tile:hover {
    border-color: var(--primary, #8B1E3F);
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(139,30,63,0.08);
}
.q-hub-tile-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    margin-bottom: 10px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(139,30,63,0.08) 0%, rgba(59,130,246,0.08) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary, #8B1E3F);
    /* Company logo fallback — if the background-image fails to load */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
/* Fallback for emoji icons (roles, unknown) */
.q-hub-tile-icon:not([style*="background-image"]) {
    background: linear-gradient(135deg, rgba(139,30,63,0.08) 0%, rgba(59,130,246,0.08) 100%);
}
/* Company logo wrapper — contains the <img> for Google Favicon */
.q-hub-tile-logo {
    padding: 0;
    overflow: hidden;
}
.q-hub-tile-logo-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
    background: #fff;
    padding: 2px;
}
.q-hub-tile-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-heading, #0f172a);
    line-height: 1.3;
    text-align: center;
}
.q-hub-tile-count {
    font-size: 0.78rem;
    color: var(--primary, #8B1E3F);
    font-weight: 600;
    margin-top: 10px;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 980px) {
    .q-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .q-charts-grid { grid-template-columns: 1fr; }
    .q-recent-grid { grid-template-columns: 1fr; }
    .q-topic-bar { grid-template-columns: 110px 1fr 36px; }
}
@media (max-width: 640px) {
    .q-analytics-hero h1 { font-size: 1.7rem; }
    .q-stat-tile-value { font-size: 1.4rem; }
    .q-analytics-hero-meta { gap: 12px; font-size: 0.82rem; }
    .q-donut-wrap { flex-direction: column; align-items: stretch; }
    .q-donut { margin: 0 auto; }
}