/* Dashboard cards: the manager dashboard (app/views/dashboard/index.html.erb)
   and the admin dashboard's offline section (dashboard/_offline_metrics).
   Every class is prefixed `dm-`: the stylesheets are concatenated into one
   global bundle. */

/* Kept from the previous version of this file: as part of the global bundle
   it applies to every page, not just this one. */
#page-content-wrapper {
  padding: 0px !important;
  align-content: center !important;
}

.dm-page {
  --dm-orange: #ff8b11;
  --dm-orange-soft: #fff3e6;
  --dm-ink: #11101d;
  --dm-muted: #6c757d;
  --dm-line: #e9ecef;
  --dm-ok: #2f9e44;
  --dm-ok-soft: #e6f6ea;
  --dm-warn: #b35c00;
  --dm-warn-soft: #fff1dc;
  --dm-bad: #c92a2a;
  --dm-bad-soft: #fdeaea;

  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 2rem 3rem;
  font-family: 'Poppins', sans-serif;
  color: var(--dm-ink);
}

.dm-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.dm-title {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0;
}

.dm-plan-badge {
  background: var(--dm-orange-soft);
  color: var(--dm-warn);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.9rem;
}

.dm-card {
  background: #fff;
  border: 1px solid var(--dm-line);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(17, 16, 29, 0.04), 0 4px 16px rgba(17, 16, 29, 0.05);
  padding: 1.25rem 1.5rem;
}

.dm-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.dm-kpi {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.dm-kpi-label {
  color: var(--dm-muted);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dm-kpi-value {
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.1;
}

.dm-kpi-value small {
  font-size: 1rem;
  font-weight: 400;
  color: var(--dm-muted);
}

.dm-kpi-value--ok { color: var(--dm-ok); }
.dm-kpi-value--muted { color: var(--dm-muted); }

.dm-kpi-hint {
  color: var(--dm-muted);
  font-size: 0.85rem;
}

.dm-progress {
  height: 8px;
  background: var(--dm-line);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.25rem;
}

.dm-progress-bar {
  height: 100%;
  background: var(--dm-orange);
  border-radius: 999px;
}

.dm-pill {
  align-self: flex-start;
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 500;
}

.dm-pill--ok { background: var(--dm-ok-soft); color: var(--dm-ok); }
.dm-pill--warning { background: var(--dm-warn-soft); color: var(--dm-warn); }
.dm-pill--expired { background: var(--dm-bad-soft); color: var(--dm-bad); }

.dm-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 1rem;
}

.dm-usage-body {
  display: flex;
  align-items: center;
  gap: 3rem;
}

.dm-donut {
  position: relative;
  width: 240px;
  height: 240px;
  flex-shrink: 0;
}

.dm-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.dm-donut-pct {
  font-size: 2.2rem;
  font-weight: 600;
  line-height: 1;
}

.dm-donut-caption {
  color: var(--dm-muted);
  font-size: 0.85rem;
}

.dm-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  max-width: 420px;
}

.dm-legend li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--dm-line);
}

.dm-legend li strong {
  margin-left: auto;
  font-weight: 600;
}

.dm-legend .dm-legend-total {
  border-bottom: 0;
  color: var(--dm-muted);
}

.dm-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dm-dot--used { background: var(--dm-orange); }
.dm-dot--available { background: #ced4da; }

.dm-kpi-value--warning { color: var(--dm-warn); }
.dm-kpi-value--expired { color: var(--dm-bad); }

/* Inside the admin dashboard, below its widgets. */
.dm-embedded {
  max-width: none;
  padding: 1.5rem 1rem 3rem;
}

.dm-embedded .dm-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dm-embedded .dm-kpis.dm-kpis--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.dm-section { margin-bottom: 1rem; }

.dm-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.dm-grid-2 .dm-section { margin-bottom: 0; }

.dm-chart-wrap {
  position: relative;
  height: 280px;
}

.dm-note {
  color: var(--dm-muted);
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}

.dm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.dm-table th {
  color: var(--dm-muted);
  font-weight: 500;
  text-align: left;
  padding: 0.5rem 0.5rem 0.5rem 0;
  border-bottom: 1px solid var(--dm-line);
}

.dm-table td {
  padding: 0.55rem 0.5rem 0.55rem 0;
  border-bottom: 1px solid var(--dm-line);
}

.dm-table tr:last-child td { border-bottom: 0; }
.dm-table td:not(:first-child),
.dm-table th:not(:first-child) { text-align: right; }
.dm-indent { padding-left: 1rem !important; color: var(--dm-muted); }

@media (max-width: 1100px) {
  .dm-kpis,
  .dm-embedded .dm-kpis,
  .dm-embedded .dm-kpis.dm-kpis--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dm-grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .dm-page { padding: 1.25rem 1rem 2rem; }
  .dm-kpis,
  .dm-embedded .dm-kpis,
  .dm-embedded .dm-kpis.dm-kpis--4 { grid-template-columns: 1fr; }
  .dm-usage-body { flex-direction: column; gap: 1.5rem; }
  .dm-donut { width: 200px; height: 200px; }
  .dm-legend { width: 100%; max-width: none; }
}

/* Separadores do dashboard do admin (Geral / Pagamentos / Modo offline), na
   barra do título: sublinhado laranja no ativo, sem caixas. */
.dm-tabs {
  display: inline-flex;
  align-self: stretch;
  gap: .25rem;
  margin-left: 2rem;
  font-family: 'Poppins', sans-serif;
}
.dm-tab {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: 0 .9rem;
  margin-bottom: -1px;
  font-size: 14px;
  font-weight: 500;
  color: #6c757d;
  border-bottom: 3px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}
.dm-tab i { font-size: 18px; }
.dm-tab:hover { color: #11101d; text-decoration: none; border-bottom-color: #e9ecef; }
/* scaffolds.scss pinta qualquer `a:hover` de preto com texto branco: aqui não. */
.dm-tab:hover, .dm-tab:focus, .dm-tab:visited,
.dm-segmented a:hover, .dm-segmented a:focus,
.dm-page a:hover, .dm-page a:focus { background-color: transparent; }
.dm-tab:visited:not(.is-active) { color: #6c757d; }
.dm-segmented a.is-active:hover { background-color: #fff; color: #ff8b11; }
.dm-page a:hover { color: var(--dm-orange); }
.dm-tab.is-active { color: #ff8b11; font-weight: 600; border-bottom-color: #ff8b11; }

/* Escolha do período (pagamentos): controlo segmentado. */
.dm-segmented {
  display: inline-flex;
  padding: 3px;
  background: #f1f3f5;
  border-radius: 999px;
}
.dm-segmented a {
  padding: .3rem .9rem;
  border-radius: 999px;
  font-size: 13px;
  color: #495057;
  white-space: nowrap;
  text-decoration: none;
}
.dm-segmented a:hover { color: #11101d; text-decoration: none; }
.dm-segmented a.is-active {
  background: #fff;
  color: #ff8b11;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
