/* ============================================================
   BUSINESS MANAGER DASHBOARD - page-scoped styles
   Source of truth: the approved dashboard design (BM/dashboard.css).

   EVERY rule is scoped under .bm-dashboard on purpose. The source
   stylesheet carried global overrides (body, .page-content .row,
   .table, .btn, .small, .badge, and a font-family !important rule)
   that would have restyled every other page in this app. The shell
   (sidebar, topbar, app-layout) already matches the design and is
   owned by app.css - nothing here touches it.
   ============================================================ */

.bm-dashboard {
  --bg-body: #f4f6f9;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #f1f5f9;
  --primary-color: #4f46e5;
  --primary-soft: #eef2ff;
  --success-color: #10b981;
  --success-soft: #ecfdf5;
  --warning-color: #f59e0b;
  --warning-soft: #fffbeb;
  --danger-color: #ef4444;
  --danger-soft: #fef2f2;
  --radius-8: 8px;
  --radius-10: 10px;
  --radius-12: 12px;
  --radius-14: 14px;
  --radius-16: 16px;
  --radius-20: 20px;
  --radius-50: 50%;

  color: var(--text-main);
}

/* ─── Grid gutters and spacing (design parity, scoped) ────────── */
.bm-dashboard .row { --bs-gutter-x: 1.5rem !important; --bs-gutter-y: 0 !important; }
.bm-dashboard .row.g-1, .bm-dashboard .g-1 { --bs-gutter-x: 0.25rem !important; --bs-gutter-y: 0.25rem !important; }
.bm-dashboard .row.g-2, .bm-dashboard .g-2 { --bs-gutter-x: 0.5rem !important; --bs-gutter-y: 0.5rem !important; }
.bm-dashboard .row.g-3, .bm-dashboard .g-3 { --bs-gutter-x: 1rem !important; --bs-gutter-y: 1rem !important; }
.bm-dashboard .row.g-4, .bm-dashboard .g-4 { --bs-gutter-x: 1.5rem !important; --bs-gutter-y: 1.5rem !important; }
.bm-dashboard .mb-1 { margin-bottom: 0.25rem !important; }
.bm-dashboard .mb-2 { margin-bottom: 0.5rem !important; }
.bm-dashboard .mb-3 { margin-bottom: 1rem !important; }
.bm-dashboard .mb-4, .bm-dashboard .my-4 { margin-bottom: 1.5rem !important; }

/* ─── Typography and control primitives ──────────────────────── */
.bm-dashboard .small, .bm-dashboard small { font-size: 0.875rem; }
.bm-dashboard .btn,
.bm-dashboard .btn-outline-primary,
.bm-dashboard .btn-outline-secondary,
.bm-dashboard .btn-outline-danger,
.bm-dashboard .btn-outline-success { border-radius: var(--bs-border-radius); }
.bm-dashboard .btn-sm {
  min-height: 0;
  padding: var(--bs-btn-padding-y) var(--bs-btn-padding-x) !important;
  font-size: var(--bs-btn-font-size) !important;
}
.bm-dashboard .entity-sub,
.bm-dashboard .text-muted,
.bm-dashboard .form-text { font-size: inherit; color: var(--bs-secondary-color) !important; }
.bm-dashboard .bg-light { background-color: rgba(var(--bs-light-rgb), var(--bs-bg-opacity)) !important; }

/* ─── Tables ─────────────────────────────────────────────────── */
.bm-dashboard .table { font-size: 0.875rem; }
.bm-dashboard .table.table-borderless thead th,
.bm-dashboard .table.table-borderless tbody td { border-bottom: none !important; padding: 0.5rem !important; }
.bm-dashboard .table.table-borderless thead th {
  background-color: var(--bs-table-bg);
  font-size: 0.875rem;
  letter-spacing: unset;
  color: rgba(0, 0, 0, 0.5);
}
.bm-dashboard .table.table-borderless tbody td {
  background-color: transparent;
  font-size: initial;
  color: var(--bs-table-color-state, var(--bs-table-color-type, var(--bs-table-color)));
}
.bm-dashboard .table.table-borderless thead .small th { font-size: 10px; }
.bm-dashboard .table.table-borderless tbody td:not(:first-child),
.bm-dashboard .table.table-borderless thead .small th:not(:first-child) { text-align: center; }

/* ─── Widget card container ──────────────────────────────────── */
.bm-dashboard .widget-box {
  background: var(--card-bg);
  border-radius: var(--radius-16);
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(226, 232, 240, 0.8);
  margin-bottom: 24px;
  transition: all 0.3s ease;
  overflow: hidden;
}
.bm-dashboard .widget-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: #ffffff;
  cursor: pointer;
  user-select: none;
}
.bm-dashboard .widget-footer {
  padding: 16px 20px;
  display: flex;
  gap: 0.5rem;
  border-top: 1px solid var(--border-color);
}
.bm-dashboard .widget-title {
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.025rem;
  color: var(--text-main);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.bm-dashboard .widget-controls { display: flex; align-items: center; gap: 0.5rem; }
.bm-dashboard .widget-controls .btn-toggle {
  background: #f8fafc;
  color: var(--text-muted);
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-8);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.bm-dashboard .widget-controls .btn-toggle:hover { background: #e2e8f0; color: var(--text-main); }
.bm-dashboard .widget-body {
  padding: 20px;
  transition: max-height 0.3s ease-out, opacity 0.2s ease-out, padding 0.3s ease-out;
  overflow: hidden;
  max-height: 4000px;
  opacity: 1;
}
.bm-dashboard .widget-body.collapsed {
  max-height: 0 !important;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

/* ─── Metric cards ───────────────────────────────────────────── */
.bm-dashboard .metric-card {
  background: #ffffff;
  border: 1px solid #f1f5f9;
  border-radius: var(--radius-16);
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}
.bm-dashboard .metric-title { font-size: 1rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.5rem; }
.bm-dashboard .metric-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.05rem;
  line-height: 1.2;
}
.bm-dashboard .badge {
  min-height: 0;
  padding: var(--bs-badge-padding-y) var(--bs-badge-padding-x);
  font-size: 0.78125rem;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
}
.bm-dashboard .badge-trend-up,
.bm-dashboard .badge-trend-down {
  font-weight: 700;
  font-size: 0.875rem;
  line-height: 1;
  letter-spacing: -0.03rem;
  padding: 4px 10px;
  border-radius: var(--radius-20);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.bm-dashboard .badge-trend-up { background-color: var(--success-soft); color: var(--success-color); }
.bm-dashboard .badge-trend-down { background-color: var(--danger-soft); color: var(--danger-color); }
.bm-dashboard .badge-trend-flat { background-color: #f1f5f9; color: var(--text-muted); }
.bm-dashboard .sparkline-container { width: 110px; height: 45px; }

/* ─── Quick action buttons ───────────────────────────────────── */
.bm-dashboard .quick-action-btn {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-12);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-main);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
}
.bm-dashboard .quick-action-btn:hover {
  color: var(--primary-color);
  border-color: var(--primary-color);
  box-shadow: 0 0.5rem 15px rgba(79, 70, 229, 0.08);
  transform: translateY(-2px);
}
.bm-dashboard .action-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-10);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ─── Event card ─────────────────────────────────────────────── */
.bm-dashboard .event-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-14);
  padding: 16px;
}
.bm-dashboard .event-card + .event-card { margin-top: 12px; }

/* ─── Activity feed ──────────────────────────────────────────── */
.bm-dashboard .activity-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}
.bm-dashboard .activity-item:last-child { border-bottom: none; }
.bm-dashboard .activity-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-50);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ─── Alerts / attention items ───────────────────────────────── */
.bm-dashboard .alert {
  font-size: 0.875rem;
  border: var(--bs-alert-border);
  border-radius: var(--bs-alert-border-radius) !important;
}
.bm-dashboard .alert-item {
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius-10);
  padding: 12px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.bm-dashboard .alert-item:last-child { margin-bottom: 0; }

/* ─── Listing health gauge ───────────────────────────────────── */
.bm-dashboard .health-bar-container {
  background-color: #e2e8f0;
  height: 10px;
  border-radius: var(--radius-10);
  overflow: hidden;
}
.bm-dashboard .health-bar-fill {
  background: linear-gradient(90deg, #4f46e5, #10b981);
  height: 100%;
  border-radius: var(--radius-10);
}

/* ─── Chart canvas sizing ────────────────────────────────────── */
.bm-dashboard .chart-container { position: relative; width: 100%; min-height: 220px; }
