/* ===== Dashboard Design Tokens ===== */
:root {
  --ew-teal: #0d9488;
  --ew-teal-light: #ccfbf1;
  --ew-teal-dark: #115e59;
  --ew-indigo: #6366f1;
  --ew-coral: #f97316;
  --ew-rose: #e11d48;
  --ew-amber: #f59e0b;
  --ew-green: #22c55e;
  --ew-bg: #f8fafc;
  --ew-card: #ffffff;
  --ew-border: #e2e8f0;
  --ew-text: #0f172a;
  --ew-muted: #64748b;
  --ew-muted-light: #94a3b8;
  --ew-slate-light: #f1f5f9;
  --ew-slate-dark: #334155;
  --ew-chart-1: #0d9488;
  --ew-chart-2: #6366f1;
  --ew-chart-3: #f97316;
  --ew-chart-4: #e11d48;
  --ew-chart-5: #f59e0b;
  --ew-chart-6: #8b5cf6;
  --ew-indigo-light: #e0e7ff;
  --ew-amber-light: #fef3c7;
  --ew-green-light: #dcfce7;
  --ew-green-dark: #166534;
  --ew-amber-dark: #92400e;
  --ew-rose-light: #fecaca;
  --ew-rose-dark: #991b1b;
  --ew-slate-300: #cbd5e1;
  --ew-green-50: #f0fdf4;

  /* Dashboard card styling */
  --ew-card-radius: 16px;
  --ew-card-padding: 24px;
  --ew-card-border: 1px solid var(--ew-border);
  --ew-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
  --ew-card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08);

  /* Dashboard spacing */
  --ew-section-gap: 40px;
  --ew-card-gap: 16px;
}

/* ===== Dashboard Layout ===== */
.dashboard-section {
  margin-top: var(--ew-section-gap);
  margin-bottom: var(--ew-section-gap);
}

.dashboard-section > h2 {
  margin-bottom: 0.25rem;
}

.dashboard-section > .section-subtitle {
  color: var(--ew-muted-light);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--ew-card-gap);
}

.dashboard-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--ew-card-gap);
}

.grid-col-span-2 {
  grid-column: span 2;
}

/* ===== Dashboard Card (consistent for all dashboard cards) ===== */
.dashboard-card {
  background: var(--ew-card);
  border: var(--ew-card-border);
  border-radius: var(--ew-card-radius);
  padding: var(--ew-card-padding);
  box-shadow: var(--ew-card-shadow);
  transition: box-shadow 0.2s ease;
}

.dashboard-card:hover {
  box-shadow: var(--ew-card-shadow-hover);
}

/* ===== Card (dashboard-scoped overrides) ===== */
.dashboard-section .card {
  background: var(--ew-card);
  border: var(--ew-card-border);
  border-radius: var(--ew-card-radius);
  box-shadow: var(--ew-card-shadow);
  transition: box-shadow 0.2s ease;
}

.dashboard-section .card:hover {
  box-shadow: var(--ew-card-shadow-hover);
}

.dashboard-section .card-body {
  padding: var(--ew-card-padding);
}

/* ===== KPI Cards ===== */
.kpi-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--ew-card-gap);
  margin-bottom: 32px;
}

.kpi-card {
  background: var(--ew-card);
  border-radius: var(--ew-card-radius);
  padding: 20px 24px;
  border: 1px solid var(--ew-border);
  box-shadow: var(--ew-card-shadow);
  transition: box-shadow 0.2s ease;
}

.kpi-card:hover {
  box-shadow: var(--ew-card-shadow-hover);
}

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-icon-teal {
  background: var(--ew-teal-light);
  color: var(--ew-teal);
}

.kpi-icon-indigo {
  background: var(--ew-indigo-light);
  color: var(--ew-indigo);
}

.kpi-icon-amber {
  background: var(--ew-amber-light);
  color: var(--ew-amber);
}

.kpi-icon-green {
  background: var(--ew-green-light);
  color: var(--ew-green);
}

.kpi-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--ew-text);
  line-height: 1;
}

.kpi-label {
  font-size: 0.875rem;
  color: var(--ew-muted);
  margin-top: 0.25rem;
}

/* ===== Patient Avatar ===== */
.patient-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ew-card);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ===== Progress Bar ===== */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--ew-slate-light);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.3s ease;
}

/* ===== Risk Level Groups ===== */
.risk-level-group {
  margin-bottom: 12px;
}

.risk-level-group:last-child {
  margin-bottom: 0;
}

/* ===== Ring Gauge (SVG) ===== */
.ring-gauge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.adherence-ring {
  transform: rotate(-90deg);
}

.adherence-ring-label {
  position: absolute;
  text-align: center;
  font-weight: 700;
  color: var(--ew-text);
}

/* ===== Adherence Ring Colors ===== */
.adherence-ring__track {
  fill: none;
  stroke: var(--ew-slate-light);
  stroke-width: 8;
}
.adherence-ring__fill {
  fill: none;
  stroke-width: 8;
}
.adherence-ring--high {
  stroke: var(--ew-green);
}
.adherence-ring--medium {
  stroke: var(--ew-amber);
}
.adherence-ring--low {
  stroke: var(--ew-rose);
}
.adherence-ring__text {
  fill: var(--ew-text);
}
/* ===== Adherence Cell ===== */
.adherence-cell {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.875rem;
  text-align: center;
}

.adherence-cell--high {
  background: var(--ew-green-light);
  color: var(--ew-green-dark);
}

.adherence-cell--medium {
  background: var(--ew-amber-light);
  color: var(--ew-amber-dark);
}

.adherence-cell--low {
  background: var(--ew-rose-light);
  color: var(--ew-rose-dark);
}

/* ===== Activity Toggle ===== */
.activity-toggle-btn {
  background: none;
  border: 1px solid var(--ew-border);
  border-radius: var(--radius-md, 0.5rem);
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--ew-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.activity-toggle-btn:hover {
  background: var(--ew-bg);
  color: var(--ew-text);
}

/* ===== Status Indicator ===== */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
}

.status-indicator::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* ===== Living Situation List ===== */
.living-situation-list {
  padding: 0;
  margin: 0;
}

.living-situation-list > div:last-child {
  border-bottom: none;
}

/* Living situation count badge */
.living-count-badge {
  background: var(--ew-slate-light);
  color: var(--ew-slate-dark);
  font-weight: 600;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 9999px;
}

/* ===== Chart Containers ===== */
.age-chart-container {
  min-height: 180px;
  max-height: 180px;
}

.type-chart-container {
  min-height: 200px;
}

/* Demographics combined card layout */
.demographics-split {
  display: flex;
  gap: 24px;
}

.demographics-split > div {
  min-width: 0;
}

/* ===== Utility Classes (Bootstrap-equivalent) ===== */
/* NOTE: .text-muted, .mb-1 through .mb-5, .text-sm already exist in application.css — NOT duplicated here */

.d-flex {
  display: flex;
}

.flex-column {
  flex-direction: column;
}

.flex-fill {
  flex: 1 1 auto;
}

.align-items-center {
  align-items: center;
}

.justify-content-center {
  justify-content: center;
}

.justify-content-between {
  justify-content: space-between;
}

.gap-1 {
  gap: 0.25rem;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-3 {
  gap: 1rem;
}

.gap-4 {
  gap: 1.5rem;
}

.fw-bold {
  font-weight: 700;
}

.fw-semibold {
  font-weight: 600;
}

.fw-medium {
  font-weight: 500;
}

.fw-black {
  font-weight: 900;
}

.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-dark {
  color: var(--ew-text);
}

.text-success {
  color: var(--ew-green);
}

.small {
  font-size: 0.875rem;
}

.display-5 {
  font-size: 2.5rem;
  font-weight: 700;
}

.display-6 {
  font-size: 2rem;
  font-weight: 700;
}

.shadow-sm {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.border-0 {
  border: none;
}

.border-top {
  border-top: 1px solid var(--ew-border);
}

.p-4 {
  padding: 1.5rem;
}

.py-3 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.py-4 {
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.mt-1 {
  margin-top: 0.25rem;
}

.mt-2 {
  margin-top: 0.5rem;
}

.mt-3 {
  margin-top: 1rem;
}

.mb-0 {
  margin-bottom: 0;
}

.mb-1 {
  margin-bottom: 0.25rem;
}

.mb-3 {
  margin-bottom: 1rem;
}

.h-100 {
  height: 100%;
}

.rounded-4 {
  border-radius: 1rem;
}

/* ===== Grid Layout (Bootstrap-equivalent) ===== */
.row {
  display: flex;
  flex-wrap: wrap;
  margin-left: -8px;
  margin-right: -8px;
}

.row > * {
  padding-left: 8px;
  padding-right: 8px;
  box-sizing: border-box;
}

.col-5 {
  flex: 0 0 auto;
  width: 41.6667%;
}

.col-7 {
  flex: 0 0 auto;
  width: 58.3333%;
}

.col-6 {
  flex: 0 0 auto;
  width: 50%;
}

.pe-4 {
  padding-right: 1.5rem;
}

.ps-4 {
  padding-left: 1.5rem;
}

.py-2 {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

/* ===== Responsive Breakpoints ===== */
@media (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-grid-3 {
    grid-template-columns: 1fr;
  }

  .grid-col-span-2 {
    grid-column: span 1;
  }

  .kpi-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .demographics-split {
    flex-direction: column;
  }

  .row {
    flex-direction: column;
  }

  .col-5,
  .col-7,
  .col-6 {
    width: 100%;
  }

  .pe-4 {
    padding-right: 0;
  }

  .ps-4 {
    padding-left: 0;
}
