/* =============================================================================
   ArgusBoard — dashboard.css
   Dashboard layout: stat strip, alert groups, status lists
   ============================================================================= */

/* ── Page Shell ──────────────────────────────────────────────────── */
.dashboard-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.dashboard-main {
  flex: 1;
  padding: var(--space-8) var(--content-padding);
  max-width: var(--content-max-width);
  margin-inline: auto;
  width: 100%;
}

/* ── Page Header ─────────────────────────────────────────────────── */
.page-head {
  margin-bottom: var(--space-6);
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-sub {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ── Stat Strip ──────────────────────────────────────────────────── */
.stat-strip {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4) var(--space-6);
  margin-bottom: var(--space-8);
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.stat-num {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}

.stat-num.stat-ok { color: var(--color-success); }
.stat-num.stat-warn { color: var(--color-warning); }
.stat-num.stat-alert { color: var(--color-danger); }

.stat-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-sep {
  width: 1px;
  background: var(--color-border);
  margin: 0 var(--space-5);
  flex-shrink: 0;
}

/* ── Section ─────────────────────────────────────────────────────── */
.dashboard-section {
  margin-bottom: var(--space-8);
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
}

.section-badge {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-weight: 500;
}

/* ── Empty State ─────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  background: var(--color-success-bg);
  border: 1px solid var(--color-success-border);
  border-radius: var(--radius-lg);
  color: var(--color-success-ink);
}

.empty-state-icon {
  font-size: 1.25rem;
}

.empty-state h3 {
  font-size: var(--font-size-sm);
  font-weight: 600;
  margin-bottom: 2px;
}

.empty-state p {
  font-size: var(--font-size-xs);
  opacity: 0.85;
}

/* ── No Results Banner ───────────────────────────────────────────── */
#no-results-banner {
  display: none;
  padding: var(--space-4) var(--space-6);
  text-align: center;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-4);
}

#no-results-banner.is-visible {
  display: block;
}

/* ── Filter Bar ──────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}

.filter-select {
  height: 30px;
  padding: 0 var(--space-2);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast);
}

.filter-select:focus {
  border-color: var(--color-accent);
}

.filter-bar-spacer {
  margin-left: auto;
}

.filter-count {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* ── Customer Groups ─────────────────────────────────────────────── */
.customer-groups {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.customer-group {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition-base);
}

.customer-group:hover {
  border-color: #d1d5db;
}

.customer-group.is-hidden {
  display: none;
}

.customer-group-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast);
}

.customer-group-header:hover {
  background: var(--color-bg-tertiary);
}

.customer-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.customer-toggle-icon {
  display: inline-block;
  transition: transform var(--transition-base);
  font-style: normal;
  font-size: 0.625rem;
}

.customer-group.is-collapsed .customer-toggle-icon {
  transform: rotate(-90deg);
}

.customer-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-primary);
  flex-shrink: 0;
}

.customer-count {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  flex: 1;
}

.customer-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

.customer-content {
  overflow: hidden;
  transition: max-height var(--transition-base) ease,
              opacity var(--transition-base) ease;
  max-height: 99999px;
  opacity: 1;
}

.customer-group.is-collapsed .customer-content {
  max-height: 0;
  opacity: 0;
}

/* ── Device Rows ─────────────────────────────────────────────────── */
.device-list {
  display: flex;
  flex-direction: column;
}

.device-row {
  display: grid;
  /* Keep the hostname column from collapsing: a device with many alert pills
     would otherwise let the `auto` alerts track consume the row and the
     `min-width:0` info column shrink to 0px (hostname/serial disappear).
     Alerts stay sized to their content; info fills the remaining space. */
  grid-template-columns: 12px minmax(180px, 1fr) minmax(0, 2fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--color-border-light);
  transition: background var(--transition-fast);
}

.device-row:hover {
  background: var(--color-bg-tertiary);
}

.device-row.is-hidden {
  display: none;
}

.device-row.is-stale {
  background: rgba(239, 68, 68, 0.04);
}

.device-row.is-stale:hover {
  background: rgba(239, 68, 68, 0.08);
}

.device-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.device-hostname {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-primary);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-hostname:hover {
  color: var(--color-accent);
}

.device-meta {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-alerts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

.device-time {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── Status Dots ─────────────────────────────────────────────────── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--color-neutral);
}

.status-dot.dot-ok { background: var(--color-success); }
.status-dot.dot-danger { background: var(--color-danger); }
.status-dot.dot-critical { background: var(--color-critical); box-shadow: 0 0 6px var(--color-critical); }
.status-dot.dot-warning { background: var(--color-warning); }
.status-dot.dot-info { background: var(--color-info); }
.status-dot.dot-neutral { background: var(--color-neutral); }

/* ── Status List (System Status + PM2) ───────────────────────────── */
.status-list {
  display: flex;
  flex-direction: column;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.status-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border-light);
  transition: background var(--transition-fast);
}

.status-row:first-child {
  border-top: none;
}

.status-row:hover {
  background: var(--color-bg-tertiary);
}

.status-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-primary);
  flex: 1;
}

.status-meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.status-time {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}

.status-badge {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.status-badge.badge-ok {
  background: var(--color-success-bg);
  color: var(--color-success-ink);
}

.status-badge.badge-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger-ink);
}

.status-row-empty {
  padding: var(--space-6);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root {
    --content-padding: var(--space-5);
  }
}

@media (max-width: 768px) {
  :root {
    --content-padding: var(--space-4);
  }

  .dashboard-main {
    padding: var(--space-5) var(--content-padding);
  }

  .stat-strip {
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
  }

  .stat-sep {
    display: none;
  }

  .stat-item {
    flex: 1 1 40%;
  }

  .device-row {
    grid-template-columns: 12px 1fr;
    grid-template-rows: auto auto;
    gap: var(--space-1) var(--space-3);
    padding: var(--space-2) var(--space-3);
  }

  .device-alerts {
    grid-column: 2;
    justify-content: flex-start;
  }

  .device-time {
    grid-column: 2;
  }

  .customer-actions {
    display: none;
  }

  .filter-bar {
    gap: var(--space-2);
  }
}

@media (max-width: 600px) {
  .stat-item {
    flex: 1 1 100%;
  }

  .stat-strip {
    flex-direction: column;
    gap: var(--space-3);
  }
}