/* =========================
   INFRAMETER DASHBOARD CSS
   Adapted from design reference
========================= */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
}

a {
  text-decoration: none;
  color: inherit;
}
ul {
  list-style: none;
}
button {
  cursor: pointer;
  font: inherit;
  color: inherit;
  background: none;
  border: none;
}
input,
select,
textarea {
  font: inherit;
  outline: none;
}

/* =========================
   DESIGN TOKENS — LIGHT
========================= */
:root {
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-height: 64px;

  --color-bg: #f6f6f7;
  --color-surface: #ffffff;
  --color-text: #1a1a1a;
  --color-text-secondary: #6b6b6b;
  --color-text-muted: #999999;
  --color-border: #e8e8e8;

  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-light: rgba(37, 99, 235, 0.1);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  --sidebar-bg: #1a1a1a;
  --sidebar-nav-active-bg: rgba(37, 99, 235, 0.15);
  --sidebar-nav-active-color: #fff;
  --sidebar-nav-accent: #2563eb;
}

/* DARK MODE */
.dark {
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-text: #f1f5f9;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;
  --color-border: #334155;
  --color-accent: #3b82f6;
  --color-accent-hover: #2563eb;
  --color-accent-light: rgba(59, 130, 246, 0.15);
  --sidebar-bg: #0f172a;
}

/* =========================
   SIDEBAR
========================= */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.sidebar--collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar--collapsed .nav-label,
.sidebar--collapsed .nav-item span,
.sidebar--collapsed .nav-badge,
.sidebar--collapsed .user-info,
.sidebar--collapsed .logo-full {
  display: none;
}

.sidebar--collapsed .logo-mini {
  display: flex;
}
.sidebar--collapsed .nav-item {
  justify-content: center;
  padding: 10px;
}
.sidebar--collapsed .sidebar-user {
  justify-content: center;
}
.sidebar--collapsed .sidebar-header {
  justify-content: center;
}

/* Header */
.sidebar-header {
  padding: 20px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--color-accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-icon svg {
  color: #fff;
}

.logo-full {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.logo-mini {
  display: none;
  font-size: 18px;
  font-weight: 700;
  color: var(--color-accent);
}

.sidebar-toggle {
  color: #666;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.sidebar-toggle:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: #555;
  letter-spacing: 1.2px;
  padding: 0 8px;
  margin-bottom: 8px;
  text-transform: uppercase;
  white-space: nowrap;
}

.nav-label--product {
  text-transform: none;
  letter-spacing: 0.04em;
  font-size: 11px;
  font-weight: 600;
  color: #8a8a8a;
  white-space: normal;
  line-height: 1.35;
}

.nav-label--product-sub {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: #666;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: #999;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
}

.nav-item svg {
  flex-shrink: 0;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
  color: #fff;
  background: var(--sidebar-nav-active-bg);
}

.nav-item.active svg {
  color: var(--sidebar-nav-accent);
}

.nav-badge {
  margin-left: auto;
  background: var(--color-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 1.4;
}

.nav-item--logout {
  color: #e53e3e !important;
}
.nav-item--logout:hover {
  background: rgba(229, 62, 62, 0.1) !important;
}

/* Footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  margin-bottom: 4px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(
    135deg,
    var(--color-accent),
    var(--color-accent-hover)
  );
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: #666;
  white-space: nowrap;
}

/* Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* =========================
   MAIN CONTENT
========================= */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.main--expanded {
  margin-left: var(--sidebar-collapsed);
}

/* =========================
   TOP BAR
========================= */
.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.mobile-menu-btn {
  display: none;
  color: var(--color-text);
  padding: 4px;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  transition: all var(--transition);
  position: relative;
}

.topbar-icon-btn:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: #e53e3e;
  border-radius: 50%;
  border: 2px solid var(--color-surface);
}

.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: linear-gradient(
    135deg,
    var(--color-accent),
    var(--color-accent-hover)
  );
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
}

/* =========================
   PAGE LAYOUT
========================= */
.page {
  padding: 28px 24px;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.3px;
}
.page-subtitle {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

.page-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.module-placeholder {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 8px;
}

.module-placeholder__card {
  max-width: 520px;
  width: 100%;
  padding: 28px 32px;
}

.module-placeholder__eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 0 0 12px;
}

.module-placeholder__title {
  margin: 0 0 8px;
}

.module-placeholder__text {
  margin: 0 0 16px;
  max-width: 48ch;
}

.module-placeholder__note {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin: 0 0 24px;
  line-height: 1.55;
}

.module-placeholder__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* =========================
   STATS GRID
========================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 22px;
  border: 1px solid var(--color-border);
  transition: all var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.stat-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon--blue {
  background: rgba(37, 99, 235, 0.12);
  color: #2563eb;
}
.stat-icon--green {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}
.stat-icon--violet {
  background: rgba(139, 92, 246, 0.12);
  color: #8b5cf6;
}
.stat-icon--amber {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.5px;
  line-height: 1;
}

.stat-change {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  margin-top: 10px;
  color: var(--color-text-muted);
}

/* =========================
   CARDS
========================= */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  overflow: hidden;
  margin-bottom: 24px;
}

.card-body {
  padding: 20px 22px;
}

.card--chart {
  min-height: 360px;
}
.card--no-mb {
  margin-bottom: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--color-border);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
}

.card-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-accent);
  transition: color var(--transition);
}

.card-link:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

/* =========================
   DASHBOARD GRID
========================= */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.dashboard-grid .card {
  margin-bottom: 0;
}

/* =========================
   BAR CHART
========================= */
.chart-area {
  padding: 24px 22px;
  height: 280px;
  display: flex;
  align-items: flex-end;
}

.chart-bars {
  display: flex;
  gap: 12px;
  width: 100%;
  height: 100%;
  align-items: flex-end;
}

.chart-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar {
  width: 100%;
  max-width: 48px;
  background: linear-gradient(180deg, #2563eb 0%, #60a5fa 100%);
  border-radius: 6px 6px 0 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  cursor: pointer;
  min-height: 4px;
}

.chart-bar:hover {
  background: linear-gradient(180deg, #1d4ed8 0%, #2563eb 100%);
}

.chart-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 10;
}

.chart-bar:hover .chart-tooltip {
  display: block;
}

.chart-label {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* =========================
   LOG LIST (sidebar card)
========================= */
.log-list {
  padding: 8px 0;
}

.log-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 22px;
  transition: background var(--transition);
  cursor: default;
}

.log-row:hover {
  background: var(--color-bg);
}

.log-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.log-source {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.log-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.log-time {
  font-size: 11px;
  color: var(--color-text-muted);
  font-family: "JetBrains Mono", monospace;
}

/* Status badges */
.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status--processed {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
}
.status--error {
  background: rgba(229, 62, 62, 0.1);
  color: #e53e3e;
}
.status--unmatched {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}
.status--pending {
  background: rgba(107, 114, 128, 0.1);
  color: #6b7280;
}

/* Medium badges */
.medium-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(37, 99, 235, 0.08);
  color: var(--color-accent);
}

/* =========================
   READINGS TABLE
========================= */
.readings-table-wrap {
  overflow-x: auto;
}

.readings-table {
  width: 100%;
  border-collapse: collapse;
}

.readings-table th {
  text-align: left;
  padding: 11px 22px;
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.readings-table td {
  padding: 13px 22px;
  font-size: 13px;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.readings-table tr:last-child td {
  border-bottom: none;
}

.readings-table tr:hover td {
  background: rgba(37, 99, 235, 0.02);
}

.mono {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
}

.val-cell {
  font-weight: 600;
}
.val-unit {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-left: 3px;
}

/* =========================
   ACTIVITY DOTS
========================= */
.activity-list {
  padding: 16px 22px;
}

.activity-item {
  display: flex;
  gap: 14px;
  padding: 10px 0;
}

.activity-item:not(:last-child) {
  border-bottom: 1px solid var(--color-border);
}

.activity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.dot--processed {
  background: #10b981;
}
.dot--error {
  background: #e53e3e;
}
.dot--unmatched {
  background: #f59e0b;
}
.dot--pending {
  background: #6b7280;
}

.activity-content {
  flex: 1;
}

.activity-text {
  font-size: 13px;
  color: var(--color-text);
  line-height: 1.5;
}

.activity-sep {
  margin: 0 4px;
  color: var(--color-text-muted);
  font-weight: 500;
}
.activity-time {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 2px;
  display: block;
}

/* =========================
   EMPTY STATE
========================= */
.empty-state {
  padding: 48px 22px;
  text-align: center;
  color: var(--color-text-muted);
}

.empty-state svg {
  margin: 0 auto 12px;
  opacity: 0.35;
}
.empty-state p {
  font-size: 14px;
}

/* =========================
   BUTTONS
========================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn--primary {
  background: var(--color-accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--color-accent-light);
}

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn--secondary:hover {
  background: var(--color-bg);
  border-color: #d1d1d1;
}

.btn--sm {
  padding: 7px 14px;
  font-size: 12px;
}

/* =========================
   FORM BASICS
========================= */
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  font-family: inherit;
  transition: all var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-light);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
  margin-top: 16px;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: var(--sidebar-width) !important;
  }

  .sidebar--open {
    transform: translateX(0);
  }
  .sidebar-overlay {
    display: block;
  }
  .main {
    margin-left: 0 !important;
  }
  .mobile-menu-btn {
    display: flex;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .page {
    padding: 20px 16px;
  }
}
