/* ===========================================================================
   Nexus Dashboard — stylesheet
   Dark glassmorphism theme with animated gradient mesh background, neon status
   accents, staggered card entrances and glow-on-hover interactions.
   =========================================================================== */

:root {
  --bg: #05070d;
  --bg-soft: #0a0f1f;
  --panel: rgba(18, 26, 46, 0.55);
  --panel-strong: rgba(22, 32, 56, 0.75);
  --panel-border: rgba(120, 160, 255, 0.12);
  --panel-border-hot: rgba(120, 200, 255, 0.35);
  --text: #e8edff;
  --text-dim: #8a93b2;
  --text-faint: #5b6486;
  --accent: #34e0a1;
  --accent-2: #38bdf8;
  --accent-3: #a78bfa;
  --warn: #fbbf24;
  --danger: #fb7185;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.7);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Code",
    "Fira Code", Menlo, Consolas, monospace;
}

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

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

input {
  font-family: inherit;
  color: inherit;
}

::selection {
  background: rgba(52, 224, 161, 0.3);
  color: #fff;
}

/* ---- Scrollbar ----------------------------------------------------------- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(120, 160, 255, 0.18);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(120, 160, 255, 0.32);
  background-clip: padding-box;
}

/* ---- App root ------------------------------------------------------------ */
#app-root {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

/* ---- Animated background ------------------------------------------------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  background:
    radial-gradient(1200px 800px at 80% -10%, rgba(56, 189, 248, 0.08), transparent 60%),
    radial-gradient(900px 700px at 0% 110%, rgba(167, 139, 250, 0.08), transparent 60%),
    var(--bg);
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  mix-blend-mode: screen;
  will-change: transform;
}
.blob-1 {
  width: 520px;
  height: 520px;
  top: -120px;
  left: -80px;
  background: radial-gradient(circle at 30% 30%, #34e0a1, transparent 65%);
  animation: drift1 22s ease-in-out infinite;
}
.blob-2 {
  width: 640px;
  height: 640px;
  top: 30%;
  right: -160px;
  background: radial-gradient(circle at 60% 40%, #38bdf8, transparent 65%);
  animation: drift2 28s ease-in-out infinite;
}
.blob-3 {
  width: 480px;
  height: 480px;
  bottom: -160px;
  left: 30%;
  background: radial-gradient(circle at 50% 50%, #a78bfa, transparent 65%);
  animation: drift3 26s ease-in-out infinite;
}

@keyframes drift1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(120px, 80px) scale(1.15); }
}
@keyframes drift2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-100px, 120px) scale(0.9); }
}
@keyframes drift3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(80px, -90px) scale(1.1); }
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(120, 160, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 160, 255, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 30%, transparent 80%);
}

/* ---- Layout shell -------------------------------------------------------- */
.wrap {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 28px 48px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ---- Header -------------------------------------------------------------- */
.header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 24px;
  padding: 22px 26px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  font-size: 26px;
  color: #04130d;
  font-weight: 800;
  background: linear-gradient(135deg, #34e0a1, #38bdf8);
  box-shadow: 0 0 30px rgba(52, 224, 161, 0.45);
  animation: logo-pulse 4s ease-in-out infinite;
}
@keyframes logo-pulse {
  0%, 100% { box-shadow: 0 0 30px rgba(52, 224, 161, 0.4); }
  50% { box-shadow: 0 0 46px rgba(56, 189, 248, 0.55); }
}
.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, #e8edff 10%, #34e0a1 55%, #38bdf8 95%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.subtitle {
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 10px 18px;
  border-left: 1px solid var(--panel-border);
  border-right: 1px solid var(--panel-border);
}
.clock-time {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(52, 224, 161, 0.35);
}
.clock-date {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.08em;
}

.stats {
  display: flex;
  gap: 10px;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 66px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.stat:hover {
  transform: translateY(-2px);
}
.stat-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--mono);
  line-height: 1;
}
.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
}
.stat.total .stat-value { color: var(--text); }
.stat.online .stat-value { color: var(--accent); text-shadow: 0 0 16px rgba(52, 224, 161, 0.4); }
.stat.checking .stat-value { color: var(--warn); text-shadow: 0 0 16px rgba(251, 191, 36, 0.4); }
.stat.offline .stat-value { color: var(--danger); text-shadow: 0 0 16px rgba(251, 113, 133, 0.4); }
.stat.online { border-color: rgba(52, 224, 161, 0.25); }
.stat.checking { border-color: rgba(251, 191, 36, 0.25); }
.stat.offline { border-color: rgba(251, 113, 133, 0.25); }

/* ---- Controls ------------------------------------------------------------ */
.controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.search {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 420px;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 16px;
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 11px 16px 11px 40px;
  font-size: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-input::placeholder {
  color: var(--text-faint);
}
.search-input:focus {
  border-color: var(--panel-border-hot);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12), 0 0 24px rgba(56, 189, 248, 0.18);
}

.pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.pill {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  transition: all 0.2s ease;
}
.pill:hover {
  color: var(--text);
  border-color: var(--panel-border-hot);
  transform: translateY(-1px);
}
.pill.active {
  color: #04130d;
  background: linear-gradient(135deg, #34e0a1, #38bdf8);
  border-color: transparent;
  box-shadow: 0 6px 22px -6px rgba(52, 224, 161, 0.55);
  font-weight: 600;
}

.refresh {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-strong);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}
.refresh:hover {
  border-color: var(--panel-border-hot);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.18);
  transform: translateY(-1px);
}
.refresh:active {
  transform: translateY(0);
}

/* ---- Grid + cards -------------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  /* Staggered entrance */
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  animation: card-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  transition: transform 0.25s ease, border-color 0.25s ease,
    box-shadow 0.25s ease;
}
@keyframes card-in {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--panel-border-hot);
  box-shadow: 0 30px 70px -24px rgba(0, 0, 0, 0.8),
    0 0 0 1px rgba(120, 200, 255, 0.1);
}
.card:hover .card-glow {
  opacity: 1;
}
.card-glow {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(420px 200px at var(--mx, 50%) var(--my, 0%),
    rgba(56, 189, 248, 0.18), transparent 60%);
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.card-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  font-size: 24px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
}
.card-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: 999px;
  border: 1px solid transparent;
}
.card-status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.card-status.online {
  color: var(--accent);
  background: rgba(52, 224, 161, 0.1);
  border-color: rgba(52, 224, 161, 0.25);
}
.card-status.online .dot {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  animation: pulse-green 2s ease-in-out infinite;
}
.card-status.checking {
  color: var(--warn);
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.25);
}
.card-status.checking .dot {
  background: var(--warn);
  box-shadow: 0 0 10px var(--warn);
  animation: pulse-amber 1.1s ease-in-out infinite;
}
.card-status.offline {
  color: var(--danger);
  background: rgba(251, 113, 133, 0.1);
  border-color: rgba(251, 113, 133, 0.25);
}
.card-status.offline .dot {
  background: var(--danger);
  box-shadow: 0 0 10px var(--danger);
}
@keyframes pulse-green {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}
@keyframes pulse-amber {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--panel-border);
}
.card-host {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-port {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent-2);
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.2);
  flex-shrink: 0;
}

/* Accent the left edge per status */
.card.online::before,
.card.checking::before,
.card.offline::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}
.card.online::before { background: linear-gradient(var(--accent), transparent); }
.card.checking::before { background: linear-gradient(var(--warn), transparent); }
.card.offline::before { background: linear-gradient(var(--danger), transparent); }

/* ---- Footer -------------------------------------------------------------- */
.footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 24px 0 8px;
  font-size: 12px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}
.refreshed {
  color: var(--text-dim);
  font-family: var(--mono);
}

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 860px) {
  .header {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .clock {
    border-left: none;
    border-right: none;
    border-top: 1px solid var(--panel-border);
    border-bottom: 1px solid var(--panel-border);
    padding: 12px 0;
    align-items: flex-start;
  }
  .stats {
    justify-content: space-between;
  }
  .stat {
    flex: 1;
    min-width: 0;
  }
  .refresh {
    margin-left: 0;
    width: 100%;
    justify-content: center;
  }
}
@media (max-width: 560px) {
  .wrap {
    padding: 20px 16px 36px;
    gap: 20px;
  }
  .title {
    font-size: 19px;
  }
  .grid {
    grid-template-columns: 1fr;
  }
}

/* ---- Reduced motion ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .blob,
  .logo,
  .card-status .dot {
    animation: none !important;
  }
  .card {
    animation: none;
    opacity: 1;
    transform: none;
  }
}
