﻿/* ===================================================================
   Apenest Lab VPS Dashboard — style.css v2
   Themes: dark (default, really dark) + light
   =================================================================== */

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

/* ─── Design tokens ─────────────────────────────────────────────── */
:root {
  /* accent palette — same in both themes */
  --cyan:   #00d4ff;
  --green:  #00ff87;
  --purple: #a78bfa;
  --amber:  #fbbf24;
  --red:    #f87171;

  /* ring circumference for r=38: 2π×38 ≈ 238.76 */
  --ring-circ: 238.76px;

  --radius-sm:  8px;
  --radius-md:  14px;
  --radius-lg:  20px;
  --transition: 0.2s ease;
}

/* ─── DARK theme (default — really dark) ───────────────────────── */
[data-theme="dark"] {
  --bg:            #06060a;
  --bg2:           #0c0c14;
  --surface:       rgba(255,255,255,0.028);
  --surface-hover: rgba(255,255,255,0.055);
  --border:        rgba(255,255,255,0.07);
  --border-hover:  rgba(255,255,255,0.18);
  --text:          #e2e8f0;
  --text-muted:    #64748b;
  --text-sub:      #3d4f66;
  --shadow-card:   0 4px 32px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.04) inset;
  --shadow-top:    0 1px 0 rgba(255,255,255,0.06);
  --chart-grid:    rgba(255,255,255,0.04);
  --ring-track:    rgba(255,255,255,0.07);
  --input-bg:      rgba(0,0,0,0.45);
  --pre-bg:        #03030599;
  --pre-border:    rgba(255,255,255,0.06);
  --pre-text:      #7fa9c8;
  --badge-bg:      rgba(255,255,255,0.07);
  --top-bar-bg:    rgba(6,6,10,0.85);
  --login-card-bg: rgba(255,255,255,0.035);
}

/* ─── LIGHT theme ───────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:            #eef2f8;
  --bg2:           #e4eaf3;
  --surface:       rgba(255,255,255,0.88);
  --surface-hover: rgba(255,255,255,0.98);
  --border:        rgba(0,0,0,0.07);
  --border-hover:  rgba(0,0,0,0.18);
  --text:          #0f172a;
  --text-muted:    #64748b;
  --text-sub:      #94a3b8;
  --shadow-card:   0 1px 3px rgba(0,0,0,0.04), 0 8px 28px rgba(0,0,0,0.08);
  --shadow-top:    0 1px 0 rgba(0,0,0,0.06);
  --chart-grid:    rgba(0,0,0,0.05);
  --ring-track:    rgba(0,0,0,0.09);
  --input-bg:      rgba(255,255,255,0.95);
  --pre-bg:        #f8fafc;
  --pre-border:    rgba(0,0,0,0.07);
  --pre-text:      #4a6785;
  --badge-bg:      rgba(0,0,0,0.05);
  --top-bar-bg:    rgba(238,242,248,0.88);
  --login-card-bg: rgba(255,255,255,0.85);
}

/* ─── Theme icon visibility ─────────────────────────────────────── */
[data-theme="dark"]  .icon-moon { display: none; }
[data-theme="light"] .icon-sun  { display: none; }

/* ─── Base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

/* ─── Typography helpers ─────────────────────────────────────────── */
.eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

h1 { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1rem;    font-weight: 600; line-height: 1.3; }

/* ─── Buttons ────────────────────────────────────────────────────── */
button { font-family: inherit; cursor: pointer; border: none; outline: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 0.8125rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.btn-ghost:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  color: var(--text);
}
.btn-sm { padding: 6px 11px; font-size: 0.8rem; }

/* ─── Theme toggle button ───────────────────────────────────────── */
.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  color: var(--text);
}
.theme-toggle--floating {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  width: 40px;
  height: 40px;
  box-shadow: var(--shadow-card);
}

/* ─── Spinner ───────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 17px;
  height: 17px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-left-color: currentColor;
  border-radius: 50%;
  animation: spin 0.55s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Panel base ────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

/* ─── LOGIN PAGE ────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  padding: 24px;
}

.login-bg-gradient {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

[data-theme="dark"] .login-bg-gradient {
  background:
    radial-gradient(ellipse 60% 50% at 20% 10%, rgba(0,212,255,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 60% at 80% 90%, rgba(167,139,250,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(0,255,135,0.03) 0%, transparent 70%);
}

[data-theme="light"] .login-bg-gradient {
  background:
    radial-gradient(ellipse 60% 50% at 20% 10%, rgba(0,212,255,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 50% 60% at 80% 90%, rgba(167,139,250,0.09) 0%, transparent 60%);
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  background: var(--login-card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-card);
  transition: background var(--transition);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(0,212,255,0.25);
}

.brand-text h1 { font-size: 1.35rem; }
.login-hint { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 22px; line-height: 1.5; }

/* login form */
.login-card form { display: grid; gap: 10px; }

.input-group {
  position: relative;
  display: flex;
}

.input-group input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.925rem;
  padding: 13px 44px 13px 14px;
  transition: border-color var(--transition), background var(--transition);
}
.input-group input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0,212,255,0.12);
}
.input-group input::placeholder { color: var(--text-sub); }

.show-key-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color var(--transition);
}
.show-key-btn:hover { color: var(--text); }

#login-btn {
  background: linear-gradient(135deg, var(--cyan), #0099cc);
  color: #001a2e;
  font-size: 0.925rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  padding: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter var(--transition), opacity var(--transition);
}
#login-btn:hover:not(:disabled) { filter: brightness(1.1); }
#login-btn:disabled { opacity: 0.65; cursor: not-allowed; }

.login-error {
  color: var(--red);
  font-size: 0.85rem;
  min-height: 1.2em;
  text-align: center;
}

/* shake on bad key */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  18%      { transform: translateX(-9px); }
  36%      { transform: translateX( 9px); }
  54%      { transform: translateX(-6px); }
  72%      { transform: translateX( 6px); }
}
.shake { animation: shake 0.4s ease; }

/* ─── TOP BAR ───────────────────────────────────────────────────── */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--top-bar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: background var(--transition), border-color var(--transition);
}

.top-bar-left  { display: flex; align-items: center; gap: 12px; }
.top-bar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* pulsing status dot */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(0,255,135,0.4);
  animation: pulse-dot 2.2s ease-out infinite;
}
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 rgba(0,255,135,0.5); }
  70%  { box-shadow: 0 0 0 7px rgba(0,255,135,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,255,135,0); }
}

.server-name  { font-size: 0.95rem; font-weight: 600; line-height: 1.2; }
.server-uptime { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

.updated-badge {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ─── DASHBOARD LAYOUT ──────────────────────────────────────────── */
.dashboard {
  max-width: 1320px;
  margin: 0 auto;
  padding: 22px 20px 56px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ─── METRIC CARDS ──────────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.metric-card {
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.metric-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-card), 0 0 0 1px var(--border-hover);
}

/* SVG ring */
.ring-wrap {
  position: relative;
  width: 88px;
  height: 88px;
  flex-shrink: 0;
}

.ring {
  width: 88px;
  height: 88px;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--ring-track);
  stroke-width: 7;
}

.ring-fill {
  fill: none;
  stroke: var(--ring-color, var(--cyan));
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: var(--ring-circ);
  stroke-dashoffset: var(--ring-circ); /* 0% by default */
  transition: stroke-dashoffset 0.7s cubic-bezier(0.4,0,0.2,1), stroke 0.4s ease;
  filter: drop-shadow(0 0 5px var(--ring-color, var(--cyan)));
}

.ring-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}
.ring-value--small {
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  white-space: pre-line;
  line-height: 1.4;
  letter-spacing: 0;
}

.metric-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.metric-label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.metric-sub   { font-size: 0.78rem; color: var(--text-muted); }

/* ─── NETWORK CHART ─────────────────────────────────────────────── */
.network-panel {}
.chart-legend { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.legend-item  { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-muted); }
.legend-dot   { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.chart-wrap {
  position: relative;
  height: 200px;
}
.chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* ─── MID GRID ──────────────────────────────────────────────────── */
.mid-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ─── JOBS LIST ─────────────────────────────────────────────────── */
.jobs-list { display: flex; flex-direction: column; gap: 7px; }

.job-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--badge-bg);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--cyan);
  transition: background var(--transition);
}
.job-row:hover { background: var(--surface-hover); }

.job-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cyan);
  background: rgba(0,212,255,0.1);
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
  margin-top: 1px;
}
.job-label { font-size: 0.82rem; color: var(--text-muted); word-break: break-all; }
.placeholder-row { color: var(--text-muted); font-size: 0.85rem; padding: 8px 0; }
.job-empty { color: var(--text-muted); font-size: 0.85rem; padding: 8px 0; }

/* ─── ACTION BUTTONS ─────────────────────────────────────────────── */
.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 12px;
  background: var(--badge-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  cursor: pointer;
  white-space: nowrap;
}
.action-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}
.action-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.action-btn--warning {
  color: var(--amber);
  border-color: rgba(251,191,36,0.25);
  background: rgba(251,191,36,0.06);
}
.action-btn--warning:hover:not(:disabled) {
  background: rgba(251,191,36,0.12);
  border-color: rgba(251,191,36,0.5);
}

.action-btn--danger {
  color: var(--red);
  border-color: rgba(248,113,113,0.25);
  background: rgba(248,113,113,0.06);
}
.action-btn--danger:hover:not(:disabled) {
  background: rgba(248,113,113,0.12);
  border-color: rgba(248,113,113,0.5);
}

.action-output {
  background: var(--pre-bg);
  border: 1px solid var(--pre-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--pre-text);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 180px;
  overflow-y: auto;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.action-output.running { color: var(--amber); }

/* ─── AUDIT LOG ─────────────────────────────────────────────────── */
.audit-panel {}
.audit-list { display: flex; flex-direction: column; gap: 0; }

.audit-row {
  display: flex;
  gap: 14px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  border-radius: 4px;
}
.audit-row:last-child { border-bottom: none; }
.audit-row:hover { background: var(--surface-hover); }

.audit-dot-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  padding-top: 3px;
}
.audit-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.audit-dot--ok  { background: var(--green);  box-shadow: 0 0 6px rgba(0,255,135,0.4); }
.audit-dot--err { background: var(--red);    box-shadow: 0 0 6px rgba(248,113,113,0.4); }
.audit-dot--neutral { background: var(--cyan); box-shadow: 0 0 6px rgba(0,212,255,0.4); }

.audit-vline {
  flex: 1;
  width: 1px;
  background: var(--border);
  margin-top: 4px;
}

.audit-content { flex: 1; min-width: 0; }
.audit-action  { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }

.audit-code {
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--cyan);
  background: rgba(0,212,255,0.08);
  border-radius: 4px;
  padding: 2px 7px;
}
.audit-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
  cursor: default;
}
.audit-result { font-size: 0.8rem; color: var(--text-muted); word-break: break-word; }
.audit-empty  { color: var(--text-muted); font-size: 0.85rem; padding: 8px 0; }

/* ─── ANIMATIONS ────────────────────────────────────────────────── */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.metric-card  { animation: fade-in-up 0.35s ease both; }
.metric-card:nth-child(1) { animation-delay: 0.04s; }
.metric-card:nth-child(2) { animation-delay: 0.09s; }
.metric-card:nth-child(3) { animation-delay: 0.14s; }
.metric-card:nth-child(4) { animation-delay: 0.19s; }

/* ─── SCROLLBAR (dark) ──────────────────────────────────────────── */
[data-theme="dark"] ::-webkit-scrollbar { width: 6px; height: 6px; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: transparent; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ─── RESPONSIVE ────────────────────────────────────────────────── */

/* tablet */
@media (max-width: 960px) {
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .mid-grid { grid-template-columns: 1fr; }
}

/* mobile */
@media (max-width: 600px) {
  .top-bar { padding: 10px 14px; gap: 10px; }
  .server-uptime { display: none; }
  .updated-badge { display: none; }
  .dashboard { padding: 14px 12px 48px; gap: 12px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { padding: 14px 12px; gap: 11px; }
  .ring-wrap, .ring { width: 72px; height: 72px; }
  .ring-value { font-size: 1.05rem; }
  .ring-value--small { font-size: 0.65rem; }
  .panel { padding: 16px 14px; }
  .panel-header { margin-bottom: 14px; }
  .actions-grid { grid-template-columns: 1fr; }
  .login-card { padding: 30px 22px; }
  .chart-wrap { height: 160px; }
  .theme-toggle--floating { bottom: 16px; right: 16px; }
}

@media (max-width: 380px) {
  .metrics-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
}
