/* =========================================================
   page-sales-analysis-bem.css
   Turn B 新增：BEM 命名（sa-*）規則集
   依賴：page-sales-analysis.css 之後載入
   ========================================================= */

/* ---------- Page head / tags ---------- */
.sa-page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin: 0.4rem 0 1.2rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed var(--momo-border-subtle);
}
.sa-page-head__lead {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}
.sa-page-head__title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--momo-text-strong);
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}
.sa-page-head__title i { color: var(--momo-page-accent); }

.sa-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--momo-border-strong);
  background: var(--momo-surface);
  color: var(--momo-text-muted);
}
.sa-tag--neutral {
  background: color-mix(in srgb, var(--momo-text-muted) 8%, var(--momo-surface));
}
.sa-tag--accent {
  background: color-mix(in srgb, var(--momo-page-accent) 10%, var(--momo-surface));
  border-color: color-mix(in srgb, var(--momo-page-accent) 30%, var(--momo-border-strong));
  color: color-mix(in srgb, var(--momo-page-accent) 60%, var(--momo-text-strong));
}
.sa-tag__sep { opacity: 0.5; margin: 0 0.15rem; }
.sa-alert { margin: 1rem 0; }

/* ---------- Filter card ---------- */
.sa-filter-card { margin-bottom: 1.4rem; }
.sa-filter-card--sticky {
  position: sticky;
  top: 0.6rem;
  z-index: 100;
}
.sa-filter-head {
  display: flex !important;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: center !important;
  justify-content: space-between;
  background: color-mix(in srgb, var(--momo-page-accent) 8%, var(--momo-surface)) !important;
  border-bottom: 1px solid var(--momo-border-subtle);
  padding: 0.9rem 1.2rem !important;
}
.sa-filter-head__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--momo-text-strong);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.sa-filter-head__title i { color: var(--momo-page-accent); }

.sa-metric-switch__btn {
  border: 1px solid var(--momo-border-strong);
  background: var(--momo-surface);
  color: var(--momo-text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.4rem 0.85rem;
}
.btn-check:checked + .sa-metric-switch__btn {
  background: var(--momo-page-accent) !important;
  border-color: var(--momo-page-accent) !important;
  color: var(--momo-on-accent, var(--momo-on-accent, #fff8ef)) !important;
}
.sa-metric-switch__btn:hover {
  background: color-mix(in srgb, var(--momo-page-accent) 10%, var(--momo-surface));
}

.sa-filter-body { padding: 1.1rem 1.2rem 1.3rem; }

.sa-filter-group {
  background: color-mix(in srgb, var(--momo-text-strong) 3%, var(--momo-surface));
  border: 1px solid var(--momo-border-subtle);
  border-radius: 8px;
  padding: 0.95rem 1rem 1.05rem;
}
.sa-filter-group + .sa-filter-group { margin-top: 0.4rem; }

.sa-filter-group__title {
  margin: 0 0 0.7rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--momo-text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* group-section colour cues (left bar) */
.sa-filter-group__icon { width: 1em; }
.sa-filter-group__icon--accent  { color: var(--momo-page-accent); }
.sa-filter-group__icon--info    { color: var(--momo-tag-walnut); }
.sa-filter-group__icon--warning { color: var(--momo-tag-honey); }
.sa-filter-group__icon--danger  { color: var(--momo-tag-mahogany); }
.sa-filter-group__icon--success { color: var(--momo-tag-olive); }

/* searchable dropdown */
.sa-dropdown-menu {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--momo-border-strong);
  border-radius: 8px;
  box-shadow: var(--momo-shadow-soft);
  padding: 0.4rem;
}
.sa-dropdown-menu .dropdown-item {
  border-radius: 5px;
  padding: 0.4rem 0.6rem;
  font-size: 0.88rem;
  color: var(--momo-text-strong);
}
.sa-dropdown-menu .dropdown-item:hover {
  background: color-mix(in srgb, var(--momo-page-accent) 12%, var(--momo-surface));
  color: var(--momo-text-strong);
}

/* ---------- Empty state ---------- */
.sa-empty {
  background: var(--momo-surface);
  border: 1px solid var(--momo-border-subtle);
  border-radius: 14px;
  padding: 3.2rem 1.5rem;
  text-align: center;
  margin: 1.5rem 0;
}
.sa-empty__inner { max-width: 760px; margin: 0 auto; }
.sa-empty__icon {
  width: 96px;
  height: 96px;
  margin: 0 auto 1.4rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--momo-page-accent) 14%, var(--momo-surface));
  color: var(--momo-page-accent);
  font-size: 2.4rem;
}
.sa-empty__title {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--momo-text-strong);
  margin-bottom: 0.6rem;
}
.sa-empty__lead {
  font-size: 1rem;
  color: var(--momo-text-muted);
  margin-bottom: 1.6rem;
}
.sa-empty__hints { margin: 0 0 1.4rem; }
.sa-empty__hint {
  text-align: left;
  background: var(--momo-surface);
  border: 1px solid var(--momo-border-strong);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 1rem 1.1rem;
  height: 100%;
}
.sa-empty__hint h5 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--momo-text-strong);
}
.sa-empty__hint p {
  font-size: 0.85rem;
  color: var(--momo-text-muted);
  margin-bottom: 0.3rem;
}
.sa-empty__hint--accent { border-left-color: var(--momo-page-accent); }
.sa-empty__hint--accent h5 i,
.sa-empty__hint--accent .sa-empty__hint-foot { color: var(--momo-page-accent); }
.sa-empty__hint--olive  { border-left-color: var(--momo-tag-olive); }
.sa-empty__hint--olive h5 i,
.sa-empty__hint--olive .sa-empty__hint-foot { color: var(--momo-tag-olive); }
.sa-empty__hint-foot {
  font-size: 0.75rem !important;
  font-weight: 700;
  margin-top: 0.4rem;
}
.sa-empty__tip {
  background: color-mix(in srgb, var(--momo-page-accent) 6%, var(--momo-surface)) !important;
  border: 1px solid color-mix(in srgb, var(--momo-page-accent) 25%, var(--momo-border-strong)) !important;
  color: var(--momo-text-strong) !important;
  font-size: 0.9rem;
  text-align: left;
  border-radius: 8px;
}

/* ---------- KPI variants (replaces Bootstrap bg-* classes) ---------- */
.sa-kpi { color: var(--momo-text-strong); }
.sa-kpi-row { row-gap: 1rem; }

/* Each variant defines its own left-stripe + icon tint */
.sa-kpi--revenue { border-left-color: var(--momo-page-accent); }
.sa-kpi--revenue .icon-bg,
.sa-kpi--revenue .kpi-value { color: var(--momo-page-accent); }

.sa-kpi--cost    { border-left-color: var(--momo-tag-mahogany); }
.sa-kpi--cost    .icon-bg { color: var(--momo-tag-mahogany); }

.sa-kpi--profit  { border-left-color: var(--momo-tag-olive); }
.sa-kpi--profit  .icon-bg,
.sa-kpi--profit  .kpi-value { color: var(--momo-tag-olive); }

.sa-kpi--rate    { border-left-color: var(--momo-tag-honey); }
.sa-kpi--rate    .icon-bg { color: var(--momo-tag-honey); }

.sa-kpi--qty     { border-left-color: var(--momo-tag-walnut); }
.sa-kpi--qty     .icon-bg { color: var(--momo-tag-walnut); }

.sa-kpi--sku     { border-left-color: var(--momo-tag-rust); }
.sa-kpi--sku     .icon-bg { color: var(--momo-tag-rust); }

/* ---------- Section panel + ABC ---------- */
.sa-panel__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--momo-text-strong);
  display: inline-flex;
  align-items: center;
}
.sa-panel--abc .card-body { padding: 1rem 1.2rem 1.3rem; }

.sa-abc { row-gap: 0.6rem; }
.sa-abc__cell {
  cursor: pointer;
  border-radius: 10px;
  padding: 1rem 1.1rem;
  border: 1px solid var(--momo-border-strong);
  background: var(--momo-surface);
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}
.sa-abc__cell:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--momo-text-strong) 12%, transparent);
}
.sa-abc__heading {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--momo-text-strong);
}
.sa-abc__metric {
  font-size: 1.4rem;
  font-weight: 800;
  font-family: var(--momo-font-mono, ui-monospace, monospace);
  letter-spacing: 0;
}
.sa-abc__sku {
  font-size: 0.82rem;
  color: var(--momo-text-muted);
  margin-bottom: 0.6rem;
}
.sa-abc__bar {
  height: 6px;
  background: color-mix(in srgb, var(--momo-text-strong) 8%, transparent);
  border-radius: 3px;
  overflow: hidden;
}
.sa-abc__bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 480ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ABC tier (P0/P1/P2) */
.sa-abc__cell--p0 { border-left: 4px solid var(--momo-priority-p0, var(--momo-tag-mahogany)); }
.sa-abc__cell--p0 .sa-abc__metric,
.sa-abc__cell--p0 .sa-abc__heading { color: var(--momo-priority-p0, var(--momo-tag-mahogany)); }
.sa-abc__cell--p0 .sa-abc__bar-fill { background: var(--momo-priority-p0, var(--momo-tag-mahogany)); }

.sa-abc__cell--p1 { border-left: 4px solid var(--momo-priority-p1, var(--momo-tag-honey)); }
.sa-abc__cell--p1 .sa-abc__metric,
.sa-abc__cell--p1 .sa-abc__heading { color: var(--momo-priority-p1, var(--momo-tag-honey)); }
.sa-abc__cell--p1 .sa-abc__bar-fill { background: var(--momo-priority-p1, var(--momo-tag-honey)); }

.sa-abc__cell--p2 { border-left: 4px solid var(--momo-priority-p2, var(--momo-tag-olive)); }
.sa-abc__cell--p2 .sa-abc__metric,
.sa-abc__cell--p2 .sa-abc__heading { color: var(--momo-priority-p2, var(--momo-tag-olive)); }
.sa-abc__cell--p2 .sa-abc__bar-fill { background: var(--momo-priority-p2, var(--momo-tag-olive)); }

/* ---------- YoY ---------- */
.sa-yoy-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}
.sa-yoy-controls {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}
.sa-yoy-controls .form-select-sm {
  width: auto;
  font-size: 0.85rem;
}
.sa-yoy-controls__sep {
  font-weight: 700;
  color: var(--momo-text-muted);
  padding: 0 0.2rem;
}
.sa-yoy-summary { row-gap: 0.6rem; margin-bottom: 0.6rem; }
.sa-yoy-card {
  border: 1px solid var(--momo-border-subtle);
  margin-bottom: 0;
}
.sa-yoy-card small {
  color: var(--momo-text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.sa-yoy-card__value {
  margin: 0.3rem 0 0;
  font-family: var(--momo-font-mono, ui-monospace, monospace);
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: 0;
}
.sa-yoy-card__value--neutral { color: var(--momo-text-muted); }
.sa-yoy-card__value--accent  { color: var(--momo-page-accent); }
.sa-yoy-card--growth {
  background: color-mix(in srgb, var(--momo-tag-olive) 10%, var(--momo-surface));
  border-color: color-mix(in srgb, var(--momo-tag-olive) 28%, var(--momo-border-strong));
}
.sa-yoy-card--growth .sa-yoy-card__value { color: var(--momo-tag-olive); }
.sa-yoy-card--growth.is-decline {
  background: color-mix(in srgb, var(--momo-tag-mahogany) 10%, var(--momo-surface));
  border-color: color-mix(in srgb, var(--momo-tag-mahogany) 28%, var(--momo-border-strong));
}
.sa-yoy-card--growth.is-decline .sa-yoy-card__value { color: var(--momo-tag-mahogany); }

/* ---------- Chart shell ---------- */
.sa-chart-shell {
  position: relative;
  width: 100%;
}

/* ---------- Vendor table ---------- */
.sa-vendor-table { max-height: 560px; overflow-y: auto; }
.sa-vendor-table__profit {
  font-weight: 700;
  color: var(--momo-tag-olive);
}
.sa-vendor-link {
  color: var(--momo-text-strong);
  text-decoration: none;
  transition: color 160ms ease;
}
.sa-vendor-link:hover {
  color: var(--momo-page-accent);
  text-decoration: underline;
}
.sa-vendor-link__icon {
  font-size: 0.7rem;
  opacity: 0;
  transition: opacity 160ms ease;
  color: var(--momo-page-accent);
}
.sa-vendor-link:hover .sa-vendor-link__icon { opacity: 1; }

.sa-margin-badge {
  display: inline-block;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}
.sa-margin-badge--p0 {
  background: color-mix(in srgb, var(--momo-priority-p0, var(--momo-tag-mahogany)) 15%, var(--momo-surface));
  border-color: color-mix(in srgb, var(--momo-priority-p0, var(--momo-tag-mahogany)) 32%, transparent);
  color: var(--momo-priority-p0, var(--momo-tag-mahogany));
}
.sa-margin-badge--p1 {
  background: color-mix(in srgb, var(--momo-priority-p1, var(--momo-tag-honey)) 18%, var(--momo-surface));
  border-color: color-mix(in srgb, var(--momo-priority-p1, var(--momo-tag-honey)) 32%, transparent);
  color: color-mix(in srgb, var(--momo-priority-p1, var(--momo-tag-honey)) 70%, var(--momo-text-strong));
}
.sa-margin-badge--p2 {
  background: color-mix(in srgb, var(--momo-priority-p2, var(--momo-tag-olive)) 14%, var(--momo-surface));
  border-color: color-mix(in srgb, var(--momo-priority-p2, var(--momo-tag-olive)) 32%, transparent);
  color: var(--momo-priority-p2, var(--momo-tag-olive));
}

/* ---------- Insights ---------- */
.sa-insights__head {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.sa-insights__row { row-gap: 1rem; }
.sa-insights__col {
  border-right: 1px dashed var(--momo-border-subtle);
  padding: 0.6rem 1rem;
}
.sa-insights__col--last { border-right: none; }
.sa-insights__col--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--momo-text-muted);
  font-size: 0.92rem;
  background: color-mix(in srgb, var(--momo-text-muted) 4%, var(--momo-surface));
  border-radius: 8px;
}
.sa-insights__col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}
.sa-insights__col-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
}
.sa-insights__col-title--accent   { color: var(--momo-page-accent); }
.sa-insights__col-title--olive    { color: var(--momo-tag-olive); }
.sa-insights__col-title--mahogany { color: var(--momo-tag-mahogany); }

.sa-insights__sub {
  display: block;
  margin: 0.6rem 0 0.2rem;
  color: var(--momo-text-muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.sa-insights__list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
}
.sa-insights__list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.28rem 0;
  border-bottom: 1px dotted color-mix(in srgb, var(--momo-text-strong) 6%, transparent);
  color: var(--momo-text-strong);
}
.sa-insights__list li:last-child { border-bottom: none; }
.sa-insights__rank {
  display: inline-grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 800;
  font-family: var(--momo-font-mono, ui-monospace, monospace);
  flex-shrink: 0;
  color: var(--momo-on-accent, var(--momo-on-accent, #fff8ef));
}
.sa-insights__rank--accent   { background: var(--momo-page-accent); }
.sa-insights__rank--olive    { background: var(--momo-tag-olive); }
.sa-insights__rank--mahogany { background: var(--momo-tag-mahogany); }
.sa-insights__value {
  margin-left: auto;
  font-family: var(--momo-font-mono, ui-monospace, monospace);
  font-weight: 700;
  color: var(--momo-text-muted);
  font-size: 0.82rem;
}

/* ---------- Marketing chart titles ---------- */
.sa-mkt-title {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 0.6rem;
}
.sa-mkt-title--accent { color: var(--momo-page-accent); }
.sa-mkt-title--olive  { color: var(--momo-tag-olive); }

/* ---------- Responsive trims ---------- */
@media (max-width: 991.98px) {
  .sa-insights__col { border-right: none; border-bottom: 1px dashed var(--momo-border-subtle); }
  .sa-insights__col:last-child { border-bottom: none; }
  .sa-filter-card--sticky { position: static; }
}
