/* ===== RESET & BASE ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Màu chính */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(23, 33, 54, 0.85);

  /* Màu accent */
  --cyan: #00d4ff;
  --cyan-dim: rgba(0, 212, 255, 0.15);
  --purple: #7c3aed;
  --purple-dim: rgba(124, 58, 237, 0.15);
  --emerald: #10b981;
  --emerald-dim: rgba(16, 185, 129, 0.15);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.15);
  --rose: #f43f5e;
  --rose-dim: rgba(244, 63, 94, 0.15);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.15);

  /* CPU */
  --cpu-from: #00d4ff;
  --cpu-to: #0ea5e9;
  /* RAM */
  --ram-from: #a855f7;
  --ram-to: #7c3aed;
  /* Disk */
  --disk-from: #f59e0b;
  --disk-to: #f97316;
  /* Network */
  --net-download: #10b981;
  --net-upload: #f43f5e;

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Border */
  --border-color: rgba(148, 163, 184, 0.1);
  --border-glow: rgba(0, 212, 255, 0.3);

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Shadow */
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3), 0 0 0 1px var(--border-color);
  --shadow-glow: 0 0 30px rgba(0, 212, 255, 0.1);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== HIỆU ỨNG NỀN ===== */
.bg-effects {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.4;
  animation: float 20s ease-in-out infinite;
}

.bg-orb-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--cyan) 0%, transparent 70%);
  top: -200px;
  right: -100px;
  animation-delay: 0s;
}

.bg-orb-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--purple) 0%, transparent 70%);
  bottom: -150px;
  left: -100px;
  animation-delay: -7s;
}

.bg-orb-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--emerald) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -14s;
  opacity: 0.2;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -40px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(40px, 30px) scale(1.02); }
}

/* ===== CONTAINER ===== */
.container {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== HEADER ===== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  margin-bottom: 24px;
  animation: slideDown 0.6s ease-out;
}

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

.header-left {
  display: flex;
  align-items: center;
}

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

.logo-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--cyan-dim), var(--purple-dim));
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 212, 255, 0.2);
}

.logo-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 1px;
}

.logo-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 500;
}

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

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--emerald-dim);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--emerald);
  transition: all 0.3s;
}

.status-badge.error {
  background: var(--rose-dim);
  border-color: rgba(244, 63, 94, 0.3);
  color: var(--rose);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  animation: pulse 2s ease-in-out infinite;
}

.status-badge.error .status-dot {
  background: var(--rose);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.header-info {
  display: flex;
  gap: 8px;
}

.info-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 100px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

.info-chip svg {
  opacity: 0.6;
}

/* ===== DASHBOARD GRID ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  flex: 1;
}

/* ===== CARD BASE ===== */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 24px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.6s ease-out backwards;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  opacity: 0.8;
}

.card-cpu::before { background: linear-gradient(90deg, var(--cpu-from), var(--cpu-to)); }
.card-ram::before { background: linear-gradient(90deg, var(--ram-from), var(--ram-to)); }
.card-disk::before { background: linear-gradient(90deg, var(--disk-from), var(--disk-to)); }
.card-network::before { background: linear-gradient(90deg, var(--net-download), var(--net-upload)); }

.card-cpu { animation-delay: 0.1s; }
.card-ram { animation-delay: 0.2s; }
.card-disk { animation-delay: 0.3s; }
.card-network { animation-delay: 0.4s; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow-card), var(--shadow-glow);
  border-color: rgba(148, 163, 184, 0.15);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.card-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: all 0.3s;
}

.cpu-icon { background: var(--cyan-dim); color: var(--cyan); border: 1px solid rgba(0, 212, 255, 0.2); }
.ram-icon { background: var(--purple-dim); color: var(--purple); border: 1px solid rgba(124, 58, 237, 0.2); }
.disk-icon { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(245, 158, 11, 0.2); }
.network-icon { background: var(--emerald-dim); color: var(--emerald); border: 1px solid rgba(16, 185, 129, 0.2); }

.card-title h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  display: block;
  margin-top: 2px;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== GAUGE ===== */
.gauge-container {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto 20px;
}

.gauge {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

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

.gauge-fill {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 534;
  stroke-dashoffset: 534;
  transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 0 8px currentColor);
}

.cpu-gauge { stroke: url(#cpuGradient); }
.ram-gauge { stroke: url(#ramGradient); }
.disk-gauge { stroke: url(#diskGradient); }

/* Fallback colors */
.cpu-gauge { stroke: var(--cyan); }
.ram-gauge { stroke: var(--purple); }
.disk-gauge { stroke: var(--amber); }

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gauge-value {
  font-size: 2.8rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gauge-unit {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: -2px;
}

.gauge-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 4px;
}

/* ===== CARD STATS ===== */
.card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.stat {
  text-align: center;
  padding: 10px 8px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  transition: all 0.3s;
}

.stat:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(148, 163, 184, 0.2);
}

.stat-label {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.stat-value {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}

.highlight-green {
  color: var(--emerald) !important;
}

/* ===== CPU CORES GRID ===== */
.cores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 6px;
  margin-top: 16px;
}

.core-bar {
  height: 30px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
  transition: all 0.3s;
}

.core-bar-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, var(--cpu-from), var(--cpu-to));
  border-radius: 3px;
  transition: height 1s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0.7;
}

.core-bar-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  z-index: 1;
}

/* ===== MEMORY BAR ===== */
.memory-bar-container {
  margin-top: 16px;
}

.memory-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 10px;
}

.memory-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 100px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.memory-bar-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
}

.ram-bar-fill {
  background: linear-gradient(90deg, var(--ram-from), var(--ram-to));
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
}

.swap-bar-fill {
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

/* ===== FILESYSTEM LIST ===== */
.filesystem-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.filesystem-list::-webkit-scrollbar {
  width: 4px;
}

.filesystem-list::-webkit-scrollbar-track {
  background: transparent;
}

.filesystem-list::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 100px;
}

.fs-item {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: all 0.3s;
}

.fs-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.fs-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.fs-mount {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

.fs-percent {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--amber);
  font-family: 'JetBrains Mono', monospace;
}

.fs-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 4px;
}

.fs-bar-fill {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--disk-from), var(--disk-to));
  transition: width 1s ease;
}

.fs-details {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* ===== NETWORK ===== */
.network-speed-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
}

.speed-item {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  justify-content: center;
}

.speed-arrow {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s;
}

.download .speed-arrow {
  background: var(--emerald-dim);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.upload .speed-arrow {
  background: var(--rose-dim);
  color: var(--rose);
  border: 1px solid rgba(244, 63, 94, 0.25);
}

.speed-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: block;
  margin-bottom: 4px;
}

.speed-value-wrap {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.speed-value {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1;
}

.download .speed-value { color: var(--emerald); }
.upload .speed-value { color: var(--rose); }

.speed-unit {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.speed-divider {
  width: 1px;
  height: 60px;
  background: var(--border-color);
}

.network-chart-container {
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

#networkChart {
  width: 100% !important;
  height: 120px !important;
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: 20px;
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 0.75rem;
  animation: fadeInUp 0.6s ease-out 0.5s backwards;
}

.footer-update {
  margin-top: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.7;
}

/* ===== RESPONSIVE ===== */

/* Tablet */
@media (max-width: 1024px) {
  .container {
    padding: 16px;
  }

  .dashboard-grid {
    gap: 16px;
  }

  .header {
    flex-direction: column;
    gap: 12px;
    padding: 16px;
  }

  .header-right {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .gauge-container {
    width: 150px;
    height: 150px;
  }

  .gauge-value {
    font-size: 2.2rem;
  }
}

/* Tablet nhỏ */
@media (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 12px;
  }

  .header {
    border-radius: var(--radius-lg);
  }

  .card {
    border-radius: var(--radius-lg);
    padding: 20px;
  }

  .network-speed-display {
    padding: 16px;
    gap: 16px;
  }

  .speed-value {
    font-size: 1.3rem;
  }

  .card-stats {
    gap: 8px;
  }
}

/* Điện thoại */
@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  .container {
    padding: 8px;
  }

  .header {
    padding: 12px;
    margin-bottom: 12px;
  }

  .logo-text h1 {
    font-size: 1.1rem;
  }

  .header-info {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }

  .info-chip {
    font-size: 0.65rem;
    padding: 4px 8px;
  }

  .dashboard-grid {
    gap: 12px;
  }

  .card {
    padding: 16px;
    border-radius: var(--radius-md);
  }

  .gauge-container {
    width: 140px;
    height: 140px;
  }

  .gauge-value {
    font-size: 2rem;
  }

  .card-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .stat {
    padding: 8px 4px;
  }

  .stat-value {
    font-size: 0.8rem;
  }

  .network-speed-display {
    flex-direction: column;
    gap: 12px;
    padding: 14px;
  }

  .speed-divider {
    width: 80%;
    height: 1px;
  }

  .speed-item {
    width: 100%;
    justify-content: flex-start;
    padding-left: 20px;
  }

  .cores-grid {
    grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
  }

  .footer {
    padding: 12px;
  }
}

/* ===== HIỆU ỨNG LOADING ===== */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.loading {
  background: linear-gradient(90deg, transparent 25%, rgba(255,255,255,0.05) 50%, transparent 75%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

/* ===== SCROLLBAR CHUNG ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ===== ANIMATION UTILITY ===== */
.data-updated {
  animation: dataFlash 0.3s ease;
}

@keyframes dataFlash {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}
