/* ============================================================
   VPS Dashboard – Global Styles
   Dark theme inspired by GitHub dark / VS Code
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg-base:      #0d1117;
  --bg-sidebar:   #161b22;
  --bg-card:      #1c2128;
  --bg-card-alt:  #21262d;
  --bg-input:     #0d1117;
  --bg-hover:     #262c36;

  --border:       #30363d;
  --border-light: #21262d;

  --text-primary: #e6edf3;
  --text-muted:   #8b949e;
  --text-faint:   #484f58;

  --accent:       #58a6ff;
  --accent-dim:   #1f6feb;
  --accent-hover: #79c0ff;

  --green:        #3fb950;
  --yellow:       #d29922;
  --red:          #f85149;
  --orange:       #e3b341;
  --purple:       #bc8cff;
  --cyan:         #39d353;

  --radius:       8px;
  --radius-sm:    4px;
  --sidebar-w:    220px;
  --header-h:     56px;
  --transition:   0.15s ease;

  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
ul { list-style: none; }

/* ── Scrollbars ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ══════════════════════════════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(88, 166, 255, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(63, 185, 80, 0.04) 0%, transparent 60%);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.4);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.login-header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.login-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color var(--transition);
  outline: none;
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.12);
}

.form-group input::placeholder { color: var(--text-faint); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-dim);
  border-color: rgba(88, 166, 255, 0.35);
  color: #fff;
  width: 100%;
  justify-content: center;
  font-size: 14px;
  padding: 11px;
}
.btn-primary:hover { background: var(--accent); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: rgba(248, 81, 73, 0.15);
  border-color: rgba(248, 81, 73, 0.4);
  color: var(--red);
}
.btn-danger:hover { background: rgba(248, 81, 73, 0.25); }

.btn-success {
  background: rgba(63, 185, 80, 0.15);
  border-color: rgba(63, 185, 80, 0.4);
  color: var(--green);
}
.btn-success:hover { background: rgba(63, 185, 80, 0.25); }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.alert.error { background: rgba(248,81,73,0.1); border: 1px solid rgba(248,81,73,0.3); color: var(--red); }
.alert.success { background: rgba(63,185,80,0.1); border: 1px solid rgba(63,185,80,0.3); color: var(--green); }
.alert.show { display: block; }

/* ══════════════════════════════════════════════════════════════
   APP LAYOUT
   ══════════════════════════════════════════════════════════════ */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sidebar-logo {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo .logo-icon { font-size: 22px; }

.sidebar-logo-text { overflow: hidden; }

.sidebar-logo-text h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logo-text small {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 10px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 2px;
  user-select: none;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(88, 166, 255, 0.15);
  color: var(--accent);
}

.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.nav-badge.green { background: rgba(63,185,80,0.15); color: var(--green); border-color: rgba(63,185,80,0.3); }
.nav-badge.red   { background: rgba(248,81,73,0.15);  color: var(--red);   border-color: rgba(248,81,73,0.3);  }
.nav-badge.yellow{ background: rgba(210,153,34,0.15); color: var(--yellow);border-color: rgba(210,153,34,0.3); }

/* Sidebar footer – hostname, uptime, connection status */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-footer .host-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.conn-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
  display: inline-block;
  animation: pulse-red 2s infinite;
}
.conn-dot.connected {
  background: var(--green);
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0%,100% { box-shadow: 0 0 0 0 rgba(63,185,80,0.5); }
  50%      { box-shadow: 0 0 0 4px rgba(63,185,80,0); }
}
@keyframes pulse-red {
  0%,100% { box-shadow: 0 0 0 0 rgba(248,81,73,0.5); }
  50%      { box-shadow: 0 0 0 4px rgba(248,81,73,0); }
}

.sidebar-footer .uptime-val {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-size: 11px;
}

.sidebar-footer .logout-btn {
  margin-top: 8px;
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  transition: all var(--transition);
}
.sidebar-footer .logout-btn:hover { background: var(--bg-hover); color: var(--red); border-color: rgba(248,81,73,0.4); }

/* ── Main content ──────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-base);
}

.tab-panel {
  display: none;
  padding: 24px;
  min-height: 100%;
}
.tab-panel.active { display: block; }

/* ── Page header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.page-header .page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Stat cards (top row) ───────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0.6;
}
.stat-card.green::before  { background: var(--green); }
.stat-card.yellow::before { background: var(--yellow); }
.stat-card.red::before    { background: var(--red); }
.stat-card.purple::before { background: var(--purple); }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-value .unit {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
}

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Progress bars ─────────────────────────────────────────── */
.progress-wrap {
  margin-top: 8px;
}

.progress-bar-bg {
  height: 4px;
  background: var(--bg-card-alt);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.6s ease;
}
.progress-bar-fill.green  { background: var(--green); }
.progress-bar-fill.yellow { background: var(--yellow); }
.progress-bar-fill.red    { background: var(--red); }

/* ── Chart containers ──────────────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.chart-card canvas {
  max-height: 180px;
}

/* ── Per-core bars ─────────────────────────────────────────── */
.core-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.core-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-family: var(--font-mono);
}

.core-label { color: var(--text-muted); width: 32px; flex-shrink: 0; }
.core-bg {
  flex: 1;
  height: 8px;
  background: var(--bg-card-alt);
  border-radius: 99px;
  overflow: hidden;
}
.core-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.5s ease;
}
.core-pct { width: 32px; text-align: right; color: var(--text-muted); }

/* ── Disk bars ─────────────────────────────────────────────── */
.disk-list { display: flex; flex-direction: column; gap: 12px; }

.disk-item {}

.disk-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  font-size: 12px;
}

.disk-mount { font-family: var(--font-mono); color: var(--text-primary); }
.disk-detail { color: var(--text-muted); }

/* ── Tables ────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--bg-card-alt);
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th:hover { color: var(--text-primary); }

tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }

tbody td {
  padding: 7px 12px;
  color: var(--text-primary);
  vertical-align: middle;
}

.td-mono { font-family: var(--font-mono); }
.td-muted { color: var(--text-muted); }
.td-truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge::before { content: '●'; font-size: 8px; }

.badge-green  { background: rgba(63,185,80,0.15);  color: var(--green);  border: 1px solid rgba(63,185,80,0.3);  }
.badge-red    { background: rgba(248,81,73,0.15);   color: var(--red);    border: 1px solid rgba(248,81,73,0.3);  }
.badge-yellow { background: rgba(210,153,34,0.15);  color: var(--yellow); border: 1px solid rgba(210,153,34,0.3); }
.badge-blue   { background: rgba(88,166,255,0.15);  color: var(--accent); border: 1px solid rgba(88,166,255,0.3); }
.badge-gray   { background: rgba(139,148,158,0.15); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Filters / toolbar ─────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar input, .toolbar select {
  padding: 7px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}
.toolbar input:focus, .toolbar select:focus {
  border-color: var(--accent);
}
.toolbar input::placeholder { color: var(--text-faint); }

/* ── File browser ───────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--bg-card-alt);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.breadcrumb-sep { color: var(--text-faint); }

.breadcrumb a {
  color: var(--accent);
  cursor: pointer;
}
.breadcrumb a:hover { color: var(--accent-hover); }

.file-list { display: flex; flex-direction: column; gap: 0; }

.file-row {
  display: grid;
  grid-template-columns: 20px 1fr auto auto;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  transition: background var(--transition);
  font-size: 13px;
}
.file-row:hover { background: var(--bg-hover); }
.file-row.dir  { color: var(--accent); }
.file-row.file { color: var(--text-primary); }
.file-row .file-icon { font-size: 14px; text-align: center; }
.file-row .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); }
.file-row .file-size { color: var(--text-muted); font-size: 11px; font-family: var(--font-mono); text-align: right; }
.file-row .file-date { color: var(--text-faint); font-size: 11px; text-align: right; }

/* ── Log viewer ─────────────────────────────────────────────── */
.log-output {
  background: #0a0e14;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  max-height: calc(100vh - 260px);
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
}

.log-line {
  display: flex;
  gap: 8px;
  padding: 1px 0;
  border-radius: 2px;
  transition: background var(--transition);
}
.log-line:hover { background: rgba(255,255,255,0.04); }

.log-ts   { color: var(--text-faint); flex-shrink: 0; width: 160px; }
.log-unit { color: var(--cyan); flex-shrink: 0; width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-msg  { color: var(--text-primary); word-break: break-word; }
.log-msg.err   { color: var(--red); }
.log-msg.warn  { color: var(--yellow); }
.log-msg.plain { color: var(--text-primary); white-space: pre-wrap; }

/* ── Toast notifications ────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  max-width: 380px;
  animation: slide-in 0.2s ease;
}
.toast.ok    { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info  { border-left: 3px solid var(--accent); }

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

/* ── Loading spinner ────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-muted);
}

/* ── Section grid ───────────────────────────────────────────── */
.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

/* ── Section spacing ────────────────────────────────────────── */
.section { margin-bottom: 20px; }

/* ── Network interface pills ────────────────────────────────── */
.iface-list { display: flex; flex-wrap: wrap; gap: 8px; }

.iface-card {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
}

.iface-name { font-weight: 600; color: var(--text-primary); font-family: var(--font-mono); }
.iface-ip   { color: var(--text-muted); font-family: var(--font-mono); }
.iface-status { float: right; }

/* ── Empty states ───────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 56px; min-width: 56px; }
  .sidebar-logo-text,
  .nav-item span,
  .nav-badge,
  .sidebar-footer .host-row + *,
  .sidebar-footer .logout-btn { display: none; }
  .sidebar-logo { justify-content: center; padding: 14px 8px; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-item .nav-icon { width: auto; }
  .tab-panel { padding: 16px; }
  .stat-grid  { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
}
