/* ===== CSS Variables & Design Tokens ===== */
:root {
  /* Colors - Dark Theme (Hostinger-inspired) */
  --bg-primary: #0f0f13;
  --bg-secondary: #17171c;
  --bg-card: #1e1e26;
  --bg-card-hover: #252530;

  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #6b6b7b;

  --accent-primary: #7c3aed;
  --accent-secondary: #a855f7;
  --accent-gradient: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);

  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;

  --chart-line-1: #7c3aed;
  --chart-line-2: #f97316;
  --chart-line-3: #22c55e;
  --chart-fill-1: rgba(124, 58, 237, 0.15);
  --chart-fill-2: rgba(249, 115, 22, 0.15);
  --chart-fill-3: rgba(34, 197, 94, 0.15);
  --chart-track: rgba(255, 255, 255, 0.1);

  --border-color: rgba(255, 255, 255, 0.08);
  --border-radius: 16px;
  --border-radius-sm: 8px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== Light Theme Overrides ===== */
:root[data-theme='light'] {
  --bg-primary: #f6f7fb;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f2f8;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  --border-color: rgba(15, 23, 42, 0.12);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 8px 32px rgba(15, 23, 42, 0.16);

  --chart-track: rgba(15, 23, 42, 0.12);
}

/* ===== Reset & Base Styles ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* ===== Dashboard Container ===== */
.dashboard {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ===== Header ===== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}

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

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

.logo-icon {
  width: 40px;
  height: 40px;
  color: var(--accent-primary);
}

.logo-text {
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  height: 44px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

.theme-toggle:active {
  transform: scale(0.98);
}

.theme-toggle .theme-icon {
  width: 18px;
  height: 18px;
}

.theme-toggle .theme-label {
  font-size: 0.875rem;
  font-weight: 600;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 24px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--success);
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(1.2);
  }
}

.refresh-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.refresh-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

.refresh-btn:active {
  transform: scale(0.95);
}

.refresh-btn svg {
  width: 20px;
  height: 20px;
}

.refresh-btn.spinning svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* ===== System Info Bar ===== */
.system-info-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  padding: 20px 24px;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
}

.system-info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.system-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.system-value {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ===== Metrics Grid ===== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* ===== Metric Cards ===== */
.metric-card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  padding: 24px;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.metric-card:hover {
  border-color: rgba(124, 58, 237, 0.3);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-card:hover::before {
  opacity: 1;
}

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

.metric-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.metric-icon {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
}

.metric-icon.incoming {
  color: var(--success);
}

.metric-icon.outgoing {
  color: var(--chart-line-2);
}

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

.metric-value span:first-child {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}

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

.metric-chart {
  width: 100%;
  height: 60px;
}

.metric-chart canvas {
  width: 100%;
  height: 100%;
}

.metric-detail {
  margin-top: 12px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ===== Disk Card (Circular Chart) ===== */
.disk-card .disk-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.disk-chart-container {
  position: relative;
  width: 120px;
  height: 120px;
}

.disk-chart-container canvas {
  width: 100%;
  height: 100%;
}

.disk-percentage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.disk-percentage span:first-child {
  font-size: 1.75rem;
  font-weight: 700;
}

.disk-info {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ===== Bandwidth Card ===== */
.bandwidth-card .bandwidth-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bandwidth-chart-container {
  position: relative;
  width: 120px;
  height: 120px;
}

.bandwidth-value-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bandwidth-value-overlay span:first-child {
  font-size: 1.5rem;
  font-weight: 700;
}

.bandwidth-unit {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ===== Details Section ===== */
.details-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.details-card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  padding: 24px;
}

.details-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-value {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ===== Footer ===== */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ===== Responsive Design ===== */
@media (max-width: 1200px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .dashboard {
    padding: 16px;
    gap: 16px;
  }

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

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .system-info-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .metric-value span:first-child {
    font-size: 2rem;
  }

  .footer {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .system-info-bar {
    grid-template-columns: 1fr;
  }

  .logo-text {
    font-size: 1.25rem;
  }
}

/* ===== Loading State ===== */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* ===== Error State ===== */
.error {
  color: var(--error);
}

.error-message {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--border-radius-sm);
  padding: 12px 16px;
  color: var(--error);
  font-size: 0.875rem;
}

/* ===== Clickable Card ===== */
.metric-card.clickable {
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.metric-card.clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(124, 58, 237, 0.2);
  border-color: var(--accent-primary);
}

.click-hint {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.metric-card.clickable:hover .click-hint {
  opacity: 1;
}

/* ===== Modal Overlay ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

/* ===== Modal ===== */
.modal {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 700px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.75rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: color 0.2s ease;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

/* ===== Memory Breakdown ===== */
.memory-breakdown h3,
.processes-section h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 16px 0;
}

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.breakdown-item {
  background: var(--bg-secondary);
  border-radius: var(--border-radius-sm);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.breakdown-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.breakdown-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ===== Processes Table ===== */
.processes-table-container {
  overflow-x: auto;
}

.processes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.processes-table th,
.processes-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.processes-table th {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--bg-secondary);
}

.processes-table td {
  color: var(--text-primary);
}

.processes-table tr:hover td {
  background: rgba(124, 58, 237, 0.05);
}

.processes-table td:nth-child(2),
.processes-table td:nth-child(4) {
  color: var(--text-secondary);
  font-family: monospace;
}

.processes-table td:nth-child(3) {
  font-weight: 500;
}

@media (max-width: 600px) {
  .modal {
    max-height: 90vh;
  }

  .breakdown-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .processes-table {
    font-size: 0.8rem;
  }

  .processes-table th,
  .processes-table td {
    padding: 8px;
  }
}