/* Modern CSS Variables & Resets */
:root {
  --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-display: 'Outfit', system-ui, -apple-system, sans-serif;
  
  /* Color Palette - Premium HSL Dark Mode */
  --bg-main: #0B0E14;
  --bg-card: rgba(22, 28, 38, 0.65);
  --bg-card-hover: rgba(30, 38, 51, 0.8);
  --border-color: rgba(255, 255, 255, 0.08);
  
  --primary: #4F46E5;
  --primary-glow: rgba(79, 70, 229, 0.35);
  
  --success: #10B981;
  --success-glow: rgba(16, 185, 129, 0.25);
  --warning: #F59E0B;
  --warning-glow: rgba(245, 158, 11, 0.25);
  --danger: #EF4444;
  --danger-glow: rgba(239, 68, 68, 0.25);
  
  --text-primary: #F3F4F6;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px;
  background-image: 
    radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.08) 0px, transparent 50%);
  overflow-x: hidden;
}

/* App Layout */
.app-container {
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pulse-indicator-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 12px var(--success);
  transition: all 0.3s ease;
}

.pulse-active {
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.logo-area h1 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo-area h1 span {
  background: linear-gradient(135deg, #818CF8, #4F46E5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  text-transform: uppercase;
}

.badge-accent {
  background: rgba(79, 70, 229, 0.15);
  color: #818CF8;
  border-color: rgba(79, 70, 229, 0.3);
}

/* Control actions in header */
.control-actions {
  display: flex;
  gap: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-color);
  padding: 6px 12px;
  font-size: 12px;
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
}

/* Layout Grid */
.app-main {
  display: grid;
  grid-template-columns: 1.1fr 1.2fr;
  gap: 24px;
}

/* Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
}

/* Quality Hero Card (Top Left) */
.quality-hero-card {
  margin-bottom: 24px;
  background: linear-gradient(135deg, rgba(22, 28, 38, 0.8), rgba(16, 24, 38, 0.9));
  position: relative;
  overflow: hidden;
}

.quality-hero-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--success);
  transition: background-color 0.5s ease;
}

.quality-hero-card.warning::before {
  background: var(--warning);
}

.quality-hero-card.danger::before {
  background: var(--danger);
}

.quality-status-container {
  display: flex;
  align-items: center;
  gap: 32px;
}

/* Circular Gauge */
.gauge-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
}

.circular-chart {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.circle-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.05);
  stroke-width: 2.8;
}

.circle {
  fill: none;
  stroke-width: 2.8;
  stroke-linecap: round;
  transition: stroke-dasharray 0.5s ease, stroke 0.5s ease;
  stroke: var(--success);
}

.gauge-inner-val {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  display: flex;
  flex-direction: column;
}

#txt-health-score {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 800;
  line-height: 1;
}

.gauge-inner-val label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* Status Details */
.status-details {
  flex: 1;
}

.status-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.status-details h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  margin: 4px 0 8px 0;
  transition: color 0.5s ease;
}

.status-details p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}

.session-duration {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}

.session-duration #txt-duration-timer {
  color: var(--text-primary);
  font-weight: 600;
}

/* Metric Cards Grid */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.metric-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 130px;
}

.metric-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.metric-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

#card-latency.alert-warning .metric-icon,
#card-jitter.alert-warning .metric-icon,
#card-loss.alert-warning .metric-icon {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.3);
}

#card-latency.alert-danger .metric-icon,
#card-jitter.alert-danger .metric-icon,
#card-loss.alert-danger .metric-icon {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.metric-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.metric-body {
  margin-top: auto;
}

.metric-value-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.metric-number {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

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

.metric-caption {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.3;
}

/* Detail Section (Right Side) */
.detail-section {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Chart Card */
.chart-card {
  padding: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-header h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
}

.chart-legend {
  display: flex;
  gap: 16px;
}

.legend-item {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.color-latency {
  background-color: var(--primary);
  box-shadow: 0 0 6px var(--primary);
}

.color-jitter {
  background-color: #818CF8;
}

.chart-canvas-container {
  position: relative;
  width: 100%;
  height: 150px;
  border-bottom: 1px solid var(--border-color);
  border-left: 1px solid var(--border-color);
  padding-left: 4px;
}

#chart-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Simulator Card */
.simulator-card {
  background: linear-gradient(135deg, rgba(22, 28, 38, 0.4), rgba(30, 41, 59, 0.4));
}

.sim-intro {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.sim-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sim-slider-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sim-slider-group label {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

.sim-slider-group label span {
  font-weight: 600;
  color: var(--text-primary);
}

/* Styled Sliders */
.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  transition: background 0.3s;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 0 10px var(--primary-glow);
  transition: transform 0.1s;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

.sim-btn-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* Diagnostics Card */
.diagnostics-card {
  border-left: 4px solid var(--primary);
}

.diagnostics-body {
  font-size: 14px;
  line-height: 1.6;
}

.diag-default-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 0;
  color: var(--text-secondary);
}

.success-icon {
  color: var(--success);
  margin-bottom: 12px;
  padding: 8px;
  background: rgba(16, 185, 129, 0.08);
  border-radius: 50%;
  display: inline-flex;
}

.diag-default-state h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.diag-alert-state {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.diag-alert-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.diag-alert-icon {
  padding: 8px;
  border-radius: 50%;
  display: inline-flex;
}

.diag-alert-icon.warning {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
}

.diag-alert-icon.danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.diag-alert-title h4 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.diag-alert-title span {
  font-size: 12px;
  color: var(--text-muted);
}

.diag-alert-content {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  padding: 12px;
  border: 1px solid var(--border-color);
}

.diag-alert-content h5 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.diag-alert-content ul {
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Mini Widget View Style (Stay on top mockup) */
.mini-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 280px;
  background: linear-gradient(135deg, rgba(17, 24, 39, 0.95), rgba(31, 41, 55, 0.95));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.5);
  z-index: 9999;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: border-color 0.3s ease;
}

.mini-widget.warning {
  border-color: rgba(245, 158, 11, 0.5);
}

.mini-widget.danger {
  border-color: rgba(239, 68, 68, 0.5);
}

@keyframes slide-in {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.mini-widget.hidden {
  display: none !important;
}

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

.mini-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  transition: color 0.2s;
}

.btn-icon:hover {
  color: var(--text-primary);
}

.mini-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.mini-status-text h4 {
  font-size: 13px;
  font-weight: 600;
}

.mini-status-text p {
  font-size: 11px;
  color: var(--text-muted);
}

.mini-metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}

.mini-val-item {
  display: flex;
  flex-direction: column;
}

.mini-val {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
}

.mini-lbl {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 2px;
}

.mini-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
}

.mini-mute-indicator {
  color: var(--text-muted);
}

/* Helpers */
.hidden {
  display: none !important;
}

.text-warning {
  color: var(--warning) !important;
}

.text-danger {
  color: var(--danger) !important;
}

/* Footer */
.app-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 16px 0;
  border-top: 1px solid var(--border-color);
  margin-top: 24px;
}

/* Responsiveness */
@media (max-width: 900px) {
  body {
    padding: 12px;
  }
  .app-main {
    grid-template-columns: 1fr;
  }
  .metric-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }
  .app-header {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }
  .control-actions {
    width: 100%;
    justify-content: space-between;
  }
}
