/* ── تحلیل هوشمند کسب‌وکار (/insights) ── */

/* ستون‌های کنار هم در نمودار ماهانه (MonthlyTrendChart) */
.monthly-chart .trend-group {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    width: 100%;
    max-width: 44px;
    height: 100%;
    margin-inline: auto;
}
.monthly-chart .trend-group > span {
    flex: 1;
    min-width: 4px;
    min-height: 2px;
    border-radius: 3px 3px 0 0;
    animation: vv-rise-bar 0.6s var(--ease-out) backwards;
    transform-origin: bottom;
}
.monthly-chart .trend-group > span.is-zero { opacity: 0.25; }
.monthly-chart .trend-cols { gap: 6px; }
.monthly-axis { gap: 6px; }
.monthly-axis span { white-space: normal; line-height: 1.2; font-size: 10px; }

/* سربرگ: انتخاب بازه و دکمه‌ی تحلیل */
.insight-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.insight-toolbar .meta { color: var(--muted); font-size: var(--text-sm); }

/* کارت KPI با درصد تغییر نسبت به بازه‌ی قبل */
.kpi .delta { display: inline-block; margin-inline-start: 6px; padding: 1px 7px; border-radius: var(--r-pill); font-size: 11px; font-weight: 700; vertical-align: middle; }
.kpi .delta.up { background: var(--t-emerald-soft); color: var(--t-emerald); }
.kpi .delta.down { background: var(--danger-soft, #fde8e8); color: var(--q-bad, #c62828); }
.kpi .delta.flat { background: var(--surface-sunken); color: var(--muted); }

/* نمره‌ی سلامت و جمع‌بندی */
.insight-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--s-4);
    align-items: center;
    padding: var(--s-4);
    margin-bottom: var(--s-4);
    border-radius: var(--r-panel);
    background: linear-gradient(135deg, var(--t-violet-soft), var(--t-blue-soft));
    border: 1px solid var(--line);
}
.insight-hero h2 { margin: 0 0 6px; font-size: var(--text-lg); font-weight: 800; }
.insight-hero p { margin: 0; line-height: 1.9; color: var(--ink-2); }
.insight-hero .meta { display: block; margin-top: 8px; color: var(--muted); font-size: var(--text-xs); }
.health-ring {
    --p: 0;
    position: relative;
    width: 118px;
    height: 118px;
    border-radius: 50%;
    background: conic-gradient(var(--tone, var(--t-violet)) calc(var(--p) * 1%), var(--surface-sunken) 0);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.health-ring::before { content: ""; position: absolute; inset: 11px; border-radius: 50%; background: var(--surface, #fff); }
.health-ring > div { position: relative; text-align: center; line-height: 1.1; }
.health-ring strong { display: block; font-size: 1.7rem; font-weight: 800; }
.health-ring span { color: var(--muted); font-size: var(--text-xs); }
.health-ring.good { --tone: var(--t-emerald); }
.health-ring.warn { --tone: var(--t-amber); }
.health-ring.bad { --tone: var(--t-pink); }
@media (max-width: 720px) { .insight-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; } }

/* ستون‌های قوت / ضعف */
.insight-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: var(--s-4); margin-bottom: var(--s-4); }
.insight-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.insight-list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; line-height: 1.8; font-size: var(--text-sm); }
.insight-list li > i { margin-top: 4px; flex-shrink: 0; }
.insight-list.strengths li { background: var(--t-emerald-soft); }
.insight-list.strengths li > i { color: var(--t-emerald); }
.insight-list.weaknesses li { background: var(--t-pink-soft); }
.insight-list.weaknesses li > i { color: var(--t-pink); }

/* راهکارها */
.reco-list { display: grid; gap: var(--s-3); }
.reco {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-inline-start: 4px solid var(--tone, var(--t-blue));
    border-radius: 12px;
    background: var(--surface, #fff);
}
.reco .reco-num { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--tone-soft, var(--t-blue-soft)); color: var(--tone, var(--t-blue)); font-weight: 800; }
.reco h4 { margin: 0 0 4px; font-size: var(--text-md, 1rem); font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.reco p { margin: 0; color: var(--ink-2); line-height: 1.9; font-size: var(--text-sm); }
.reco .badge-priority { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: var(--r-pill); }
.reco.p-high { --tone: var(--t-pink); --tone-soft: var(--t-pink-soft); }
.reco.p-medium { --tone: var(--t-amber); --tone-soft: var(--t-amber-soft); }
.reco.p-low { --tone: var(--t-teal); --tone-soft: var(--t-teal-soft); }
.reco.p-high .badge-priority { background: var(--t-pink-soft); color: var(--t-pink); }
.reco.p-medium .badge-priority { background: var(--t-amber-soft); color: var(--t-amber); }
.reco.p-low .badge-priority { background: var(--t-teal-soft); color: var(--t-teal); }
.reco .area { color: var(--muted); font-size: var(--text-xs); font-weight: 500; }

/* فهرست‌های برچسب/شمارش (منبع لید، محصول، دسته‌ی تیکت) */
.bar-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.bar-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; font-size: var(--text-sm); }
.bar-list li .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-list li .mini-bar { grid-column: 1 / -1; }

/* جدول عملکرد تیم */
.insight-agents td, .insight-agents th { white-space: nowrap; }

/* کارت‌های جزئیات هر حوزه */
.insight-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.insight-fact { padding: 10px 12px; border-radius: 10px; background: var(--surface-sunken); }
.insight-fact strong { display: block; font-size: 1.1rem; font-weight: 800; }
.insight-fact span { color: var(--muted); font-size: var(--text-xs); }

/* کارت هوش مصنوعی فقط‌خواندنی در «اتصال‌ها» */
.ai-managed dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; font-size: var(--text-sm); }
.ai-managed dt { color: var(--muted); font-weight: 500; }
.ai-managed dd { margin: 0; }
