/* ============================================================
   Helm Design System — Enterprise Infrastructure Intelligence
   Sits on top of Bootstrap 5. Do NOT remove Bootstrap.
   ============================================================ */

/* Typography */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Brand colors */
  --helm-primary: #1B3A6B;
  --helm-primary-light: #2A4F8F;
  --helm-primary-dark: #0F2544;
  --helm-accent: #00BCD4;
  --helm-accent-warm: #FF6B35;
  --helm-success: #1a9641;
  --helm-warning: #fdae61;
  --helm-danger: #d73027;

  /* Surface colors */
  --helm-bg: #F5F6FA;
  --helm-surface: #FFFFFF;
  --helm-surface-elevated: #FFFFFF;
  --helm-surface-subtle: #F0F2F8;
  --helm-border: #E2E6EF;

  /* Text — high contrast, no gray */
  --helm-text: #1A1D26;
  --helm-text-secondary: #374151;
  --helm-text-muted: #4B5563;

  /* Shadows */
  --helm-shadow-sm: 0 1px 2px rgba(27, 58, 107, 0.06);
  --helm-shadow: 0 2px 8px rgba(27, 58, 107, 0.08);
  --helm-shadow-lg: 0 8px 24px rgba(27, 58, 107, 0.12);

  /* Typography */
  --helm-font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --helm-font-mono: 'JetBrains Mono', monospace;

  /* Spacing */
  --helm-page-padding: 1.5rem;

  /* Transitions */
  --helm-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Override Bootstrap's gray text utilities for better contrast */
.text-muted { color: var(--helm-text-muted) !important; }
.text-secondary { color: var(--helm-text-secondary) !important; }
.text-body-secondary { color: var(--helm-text-secondary) !important; }

body {
  font-family: var(--helm-font);
  background: var(--helm-bg);
  color: var(--helm-text);
  -webkit-font-smoothing: antialiased;
}

/* ---- Headings ---- */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: var(--helm-font);
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ---- Cards — elevated, clean ---- */
.card {
  border: 1px solid var(--helm-border);
  border-radius: 12px;
  box-shadow: var(--helm-shadow-sm);
  transition: box-shadow var(--helm-transition), transform var(--helm-transition);
}
.card:hover {
  box-shadow: var(--helm-shadow);
}
.card .card-header {
  border-radius: 12px 12px 0 0;
}

/* ---- Stat cards (KPI style) ---- */
.helm-stat-card {
  background: var(--helm-surface);
  border: 1px solid var(--helm-border);
  border-radius: 12px;
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--helm-transition), transform var(--helm-transition);
}
.helm-stat-card:hover {
  box-shadow: var(--helm-shadow);
  transform: translateY(-1px);
}
.helm-stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}
.helm-stat-card.accent-primary::before  { background: var(--helm-primary); }
.helm-stat-card.accent-success::before  { background: var(--helm-success); }
.helm-stat-card.accent-warning::before  { background: var(--helm-warning); }
.helm-stat-card.accent-danger::before   { background: var(--helm-danger); }
.helm-stat-card.accent-cyan::before     { background: var(--helm-accent); }

.helm-stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.helm-stat-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.helm-stat-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--helm-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}
.helm-stat-trend {
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
}
.helm-stat-trend.up   { color: var(--helm-success); background: rgba(26, 150, 65, 0.1); }
.helm-stat-trend.down { color: var(--helm-danger);  background: rgba(215, 48, 39, 0.1); }

/* ---- Section headers ---- */
.helm-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--helm-border);
}
.helm-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--helm-text);
  margin: 0;
}

/* ---- Score gauge (circular) ---- */
.helm-score-gauge {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  position: relative;
}
.helm-score-gauge::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.3);
}

/* ---- Activity timeline ---- */
.helm-timeline-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--helm-border);
}
.helm-timeline-item:last-child { border-bottom: none; }
.helm-timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--helm-accent);
  margin-top: 0.5rem;
  flex-shrink: 0;
}
.helm-timeline-content {
  font-size: 0.875rem;
}
.helm-timeline-time {
  font-size: 0.75rem;
  color: var(--helm-text-muted);
}

/* ---- Tables — cleaner ---- */
.table {
  font-size: 0.875rem;
}
.table thead th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--helm-text-secondary);
  border-bottom: 2px solid var(--helm-border);
  padding: 0.75rem;
}
.table tbody td {
  padding: 0.75rem;
  vertical-align: middle;
}

/* ---- Score bar (inline in tables) ---- */
.helm-score-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.helm-score-bar-track {
  flex: 1;
  height: 6px;
  background: var(--helm-surface-subtle);
  border-radius: 3px;
  overflow: hidden;
}
.helm-score-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width var(--helm-transition);
}
.helm-score-bar-value {
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--helm-font-mono);
  min-width: 2.5rem;
  text-align: right;
}

/* ---- Badges ---- */
.badge {
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ---- Buttons ---- */
.btn {
  font-weight: 500;
  border-radius: 8px;
  transition: all var(--helm-transition);
}

/* ---- Sidebar enhancements ---- */
.sidebar .nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  margin-bottom: 2px;
  padding: 0.5rem 0.75rem;
}
.sidebar .nav-link:hover {
  background: var(--helm-surface-subtle);
}
.sidebar .nav-link.active {
  background: rgba(27, 58, 107, 0.08);
  color: var(--helm-primary);
  font-weight: 600;
}

/* ---- Page wrapper ---- */
.helm-page {
  padding: var(--helm-page-padding);
}
.helm-page-header {
  margin-bottom: 1.5rem;
}
.helm-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}
.helm-page-subtitle {
  font-size: 0.875rem;
  color: var(--helm-text-secondary);
  margin-top: 0.25rem;
}

/* ---- Empty states ---- */
.helm-empty-state {
  text-align: center;
  padding: 3rem 2rem;
}
.helm-empty-state-icon {
  font-size: 3rem;
  color: var(--helm-text-muted);
  margin-bottom: 1rem;
}
.helm-empty-state-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--helm-text);
  margin-bottom: 0.5rem;
}
.helm-empty-state-text {
  color: var(--helm-text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* ---- Skeleton loading ---- */
.helm-skeleton {
  background: linear-gradient(90deg, var(--helm-surface-subtle) 25%, var(--helm-bg) 50%, var(--helm-surface-subtle) 75%);
  background-size: 200% 100%;
  animation: helm-shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes helm-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Navbar refinement ---- */
.navbar {
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* ---- Data source status dots ---- */
.helm-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.helm-status-dot.fresh   { background: var(--helm-success); box-shadow: 0 0 0 2px rgba(26,150,65,0.2); }
.helm-status-dot.stale   { background: var(--helm-warning); box-shadow: 0 0 0 2px rgba(253,174,97,0.2); }
.helm-status-dot.error   { background: var(--helm-danger);  box-shadow: 0 0 0 2px rgba(215,48,39,0.2); }
.helm-status-dot.unknown { background: var(--helm-text-muted); }

/* ---- Quick-action cards ---- */
.helm-action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.25rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--helm-border);
  background: var(--helm-surface);
  color: var(--helm-text);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--helm-transition);
  text-align: center;
}
.helm-action-card:hover {
  border-color: var(--helm-primary);
  box-shadow: var(--helm-shadow);
  color: var(--helm-primary);
  transform: translateY(-2px);
}
.helm-action-card .helm-action-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

/* ---- Condition bar chart (horizontal stacked) ---- */
.helm-condition-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
}
.helm-condition-label {
  min-width: 70px;
  font-size: 0.8rem;
  font-weight: 600;
}
.helm-condition-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--helm-surface-subtle);
  border-radius: 4px;
  overflow: hidden;
}
.helm-condition-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}
.helm-condition-count {
  min-width: 40px;
  text-align: right;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--helm-font-mono);
}

/* ---- Data source grid ---- */
.helm-fetcher-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
}
.helm-fetcher-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--helm-surface-subtle);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
}

/* ---- Map preview container ---- */
.helm-map-preview {
  height: 280px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--helm-border);
}
.helm-map-preview .leaflet-container {
  height: 100%;
  width: 100%;
}

/* ---- Role badge ---- */
.helm-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.helm-role-badge.role-platform_admin { background: rgba(215,48,39,0.1);  color: var(--helm-danger); }
.helm-role-badge.role-firm_admin     { background: rgba(27,58,107,0.1);  color: var(--helm-primary); }
.helm-role-badge.role-project_manager{ background: rgba(0,188,212,0.1);  color: #0097A7; }
.helm-role-badge.role-inspector      { background: rgba(26,150,65,0.1);  color: var(--helm-success); }
.helm-role-badge.role-viewer         { background: rgba(107,114,128,0.1);color: var(--helm-text-secondary); }
