@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;600;700&display=swap');

:root {
  /* Default Light Theme */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.8);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --border-color: rgba(15, 23, 42, 0.08);
  --border-color-hover: rgba(15, 23, 42, 0.15);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-cyan: #0891b2;
  --accent-blue: #2563eb;
  --accent-teal: #0d9488;
  --accent-cyan-glow: rgba(8, 145, 178, 0.08);
  --accent-blue-glow: rgba(37, 99, 235, 0.08);
  --accent-teal-glow: rgba(13, 148, 136, 0.08);
  --title-gradient: linear-gradient(135deg, #0f172a 30%, #0891b2 100%);
  --indicator-bg: rgba(15, 23, 42, 0.04);
  --btn-hover-bg: rgba(15, 23, 42, 0.06);
  --btn-primary-text: #ffffff;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: 'Outfit', var(--font-sans);
}

body.dark-theme {
  /* Dark Theme overrides */
  --bg-primary: #090d16;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.9);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-hover: rgba(255, 255, 255, 0.15);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-teal: #14b8a6;
  --accent-cyan-glow: rgba(6, 182, 212, 0.15);
  --accent-blue-glow: rgba(59, 130, 246, 0.15);
  --accent-teal-glow: rgba(20, 184, 166, 0.15);
  --title-gradient: linear-gradient(135deg, #ffffff 30%, #a5f3fc 100%);
  --indicator-bg: rgba(255, 255, 255, 0.03);
  --btn-hover-bg: rgba(255, 255, 255, 0.05);
  --btn-primary-text: #090d16;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.dashboard-body {
  background-color: var(--bg-primary);
  background-image:
    radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.04) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(8, 145, 178, 0.03) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(13, 148, 136, 0.03) 0px, transparent 50%);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  padding: 24px;
  overflow-y: auto;
  transition: background-color 0.3s ease, color 0.3s ease, background-image 0.3s ease;
}

body.dashboard-body.dark-theme {
  background-image:
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(6, 182, 212, 0.08) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(20, 184, 166, 0.05) 0px, transparent 50%);
}

.dashboard-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Transition for theme swaps */
.dashboard-header,
.stat-card,
.chart-panel,
.controls-panel,
.btn,
.switch,
.slider {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header Styles */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

body.dark-theme .dashboard-header {
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

.header-branding {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-cyan-glow);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--accent-cyan);
}

.logo-icon svg {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 0 6px var(--accent-cyan-glow));
}

.header-titles h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: var(--title-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-titles p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 20px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--indicator-bg);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #6b7280;
  display: inline-block;
}

.status-dot.pulsing {
  background-color: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }

  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }

  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.status-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}

.latency-container {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.latency-label {
  color: var(--text-muted);
}

.latency-value {
  color: var(--accent-cyan);
  font-family: var(--font-display);
  font-weight: 600;
}

/* Stats Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.stat-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  overflow: hidden;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
}

body.dark-theme .stat-card {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-color-hover);
  background: var(--bg-card-hover);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

body.dark-theme .stat-card:hover {
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

.card-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 100% 0%, rgba(255, 255, 255, 0.03) 0%, transparent 70%);
  pointer-events: none;
}

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

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.temp1-icon {
  background: var(--accent-cyan-glow);
  color: var(--accent-cyan);
}

.temp2-icon {
  background: var(--accent-blue-glow);
  color: var(--accent-blue);
}

.delta-icon {
  background: var(--accent-teal-glow);
  color: var(--accent-teal);
}

.points-icon {
  background: var(--indicator-bg);
  color: var(--text-secondary);
}

.stat-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  z-index: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  margin-top: 4px;
  line-height: 1.2;
}

.text-cyan {
  color: var(--accent-cyan);
  text-shadow: 0 0 10px var(--accent-cyan-glow);
}

.text-blue {
  color: var(--accent-blue);
  text-shadow: 0 0 10px var(--accent-blue-glow);
}

.text-teal {
  color: var(--accent-teal);
  text-shadow: 0 0 10px var(--accent-teal-glow);
}

.text-slate {
  color: var(--text-primary);
}

.stat-subtext {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Chart Panel Styles */
.chart-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 24px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-grow: 1;
}

body.dark-theme .chart-panel {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.chart-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chart-panel-header h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--text-primary);
}

.chart-wrapper {
  position: relative;
  width: 100%;
  flex-grow: 1;
}

#chart-container {
  width: 100%;
  height: calc(100vh - 380px);
  min-height: 480px;
  border-radius: 12px;
}

/* Controls Panel Styles */
.controls-panel {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  backdrop-filter: blur(12px);
  gap: 16px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.control-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Switch Styles */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: var(--bg-secondary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

input:checked+.slider {
  background-color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan-glow);
}

input:checked+.slider:before {
  transform: translateX(22px);
}

.slider.round {
  border-radius: 22px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: var(--indicator-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.btn:hover {
  background-color: var(--btn-hover-bg);
  border-color: var(--border-color-hover);
}

.btn-icon {
  width: 14px;
  height: 14px;
}