/* ═══════════════════════════════════════════════════════════════
   Nightwire — Dark Cyberpunk UI System
   A modern cyberpunk-inspired design system for any dark UI.
   Based on nerv-ui by TheGreatGildo.
   ═══════════════════════════════════════════════════════════════ */

/* ── Palette ─────────────────────────────────────────────────── */

:root {
  /* Surfaces */
  --void:             #000000;
  --void-warm:        #0a0a0a;
  --void-panel:       #111111;
  --void-raised:      #1a1a1a;

  /* Blue */
  --nw-primary:       #6699ff;
  --nw-primary-dim:   #4477cc;
  --nw-primary-hot:   #99bbff;
  --nw-primary-fill:  rgba(102, 153, 255, 0.08);

  /* Green */
  --nw-green:         #7aed7a;
  --nw-green-dim:     #5cb85c;
  --nw-green-faint:   rgba(122, 237, 122, 0.06);
  --nw-green-fill:    rgba(122, 237, 122, 0.1);

  /* Cyan */
  --nw-cyan:          #66ddff;
  --nw-cyan-dim:      #44aacc;
  --nw-cyan-glow:     rgba(102, 221, 255, 0.12);

  /* Red/Pink */
  --nw-red:           #ff6688;
  --nw-red-dim:       #cc4466;
  --nw-red-hot:       #ff99aa;
  --nw-red-fill:      rgba(255, 102, 136, 0.15);

  /* Accent */
  --nw-yellow:        #e8993a;
  --nw-yellow-dim:    #b8732a;
  --nw-yellow-fill:   rgba(232, 153, 58, 0.1);

  --nw-purple:        #b266e0;
  --nw-purple-dim:    #8844bb;
  --nw-purple-fill:   rgba(178, 102, 224, 0.1);

  /* Text */
  --nw-text:          #ffffff;
  --nw-text-dim:      #aaaaaa;
  --nw-text-faint:    rgba(255, 255, 255, 0.06);
  --nw-text-line:     rgba(255, 255, 255, 0.12);

  /* ── Semantic Roles ──────────────────────────────────────── */
  --nw-success:       var(--nw-green);
  --nw-info:          var(--nw-cyan);
  --nw-danger:        var(--nw-red);
  --nw-warning:       var(--nw-yellow);
  --nw-accent:        var(--nw-purple);

  /* ── Typography ──────────────────────────────────────────── */
  --font-title:       'Noto Serif Display', 'Times New Roman', serif;
  --font-sys:         'JetBrains Mono', 'Cascadia Mono', monospace;
  --font-stamp:       'Saira Extra Condensed', 'Impact', sans-serif;
  --font-mincho:      'Shippori Mincho B1', 'YuMincho', serif;

  /* Type Scale */
  --text-xs:          11px;
  --text-sm:          12px;
  --text-base:        14px;
  --text-lg:          16px;
  --text-xl:          20px;
  --text-2xl:         24px;
  --text-3xl:         32px;

  /* Letter Spacing */
  --ls-tight:         -0.01em;
  --ls-normal:        0;
  --ls-wide:          0.06em;
  --ls-ultra:         0.2em;

  /* ── Spacing (4px base) ──────────────────────────────────── */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* ── Border Radius ───────────────────────────────────────── */
  --radius-none: 0;
  --radius-sm:   2px;
  --radius-md:   4px;
  --radius-lg:   8px;
  --radius-full: 9999px;
}

/* ── Reset ───────────────────────────────────────────────────── */

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

html {
  background: var(--void);
  color: var(--nw-text);
}

body {
  font-family: var(--font-sys);
  font-size: var(--text-base);
  line-height: 1.5;
  background: var(--void);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--nw-primary);
  text-decoration: none;
}
a:hover { color: var(--nw-primary-hot); }

code, pre {
  font-family: var(--font-sys);
  font-size: var(--text-sm);
}
pre {
  background: var(--void-panel);
  border: 1px solid var(--nw-text-faint);
  padding: var(--sp-3);
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* ── Accessibility ───────────────────────────────────────────── */

:focus-visible {
  outline: 2px solid var(--nw-primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ── Surface Classes ─────────────────────────────────────────── */

.surface-0 { background: var(--void); }
.surface-1 { background: var(--void-warm); }
.surface-2 { background: var(--void-panel); }
.surface-3 { background: var(--void-raised); }

/* ── Text Color ──────────────────────────────────────────────── */

.text-primary { color: var(--nw-primary); }
.text-success { color: var(--nw-success); }
.text-info    { color: var(--nw-info); }
.text-danger  { color: var(--nw-danger); }
.text-warning { color: var(--nw-warning); }
.text-accent  { color: var(--nw-accent); }
.text-dim     { color: var(--nw-text-dim); }

/* ── Glow ────────────────────────────────────────────────────── */

.glow-green  { text-shadow: 0 0 8px rgba(122,237,122,0.5), 0 0 16px rgba(122,237,122,0.2); }
.glow-blue   { text-shadow: 0 0 8px rgba(102,153,255,0.5), 0 0 16px rgba(102,153,255,0.2); }
.glow-cyan   { text-shadow: 0 0 8px rgba(102,221,255,0.5), 0 0 16px rgba(102,221,255,0.2); }
.glow-red    { text-shadow: 0 0 8px rgba(255,102,136,0.5), 0 0 16px rgba(255,102,136,0.3); }
.glow-yellow { text-shadow: 0 0 8px rgba(232,153,58,0.5),  0 0 16px rgba(232,153,58,0.2); }
.glow-purple { text-shadow: 0 0 8px rgba(178,102,224,0.5), 0 0 16px rgba(178,102,224,0.2); }

/* ── Border ──────────────────────────────────────────────────── */

.border         { border: 1px solid var(--nw-text-line); }
.border-primary { border: 1px solid var(--nw-primary-dim); }
.border-dim     { border: 1px solid var(--nw-text-faint); }

/* ── Grid & Layout ───────────────────────────────────────────── */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-2); }
.stack  { display: flex; flex-direction: column; gap: var(--sp-2); }

/* ── Compressed Title ────────────────────────────────────────── */

.compressed-title {
  font-family: var(--font-title);
  font-weight: 900;
  transform: scaleX(0.82);
  transform-origin: left center;
  letter-spacing: var(--ls-ultra);
  text-transform: uppercase;
}

/* ── Font Family Utilities ───────────────────────────────────── */

.font-sys    { font-family: var(--font-sys); }
.font-title  { font-family: var(--font-title); }
.font-stamp  { font-family: var(--font-stamp); }
.font-mincho { font-family: var(--font-mincho); }

/* ── Buttons ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  font-family: var(--font-sys);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--void);
  background: var(--nw-primary);
  border: 1px solid var(--nw-primary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover {
  background: var(--nw-primary-hot);
  border-color: var(--nw-primary-hot);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  font-family: var(--font-sys);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--nw-primary);
  background: transparent;
  border: 1px solid var(--nw-primary-dim);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-ghost:hover {
  background: var(--nw-primary-fill);
  border-color: var(--nw-primary);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  font-family: var(--font-sys);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--void);
  background: var(--nw-red);
  border: 1px solid var(--nw-red);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-danger:hover {
  background: var(--nw-red-hot);
  border-color: var(--nw-red-hot);
}

.btn-sm { padding: var(--sp-1) var(--sp-2); font-size: var(--text-xs); }

.btn:disabled,
.btn-ghost:disabled,
.btn-danger:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Form Inputs ─────────────────────────────────────────────── */

input, select, textarea {
  font-family: var(--font-sys);
  font-size: var(--text-base);
  color: var(--nw-text);
  background: var(--void-panel);
  border: 1px solid var(--nw-text-line);
  border-radius: var(--radius-md);
  padding: var(--sp-2) var(--sp-3);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--nw-primary);
  box-shadow: 0 0 0 3px var(--nw-primary-fill);
  outline: none;
}
input::placeholder, textarea::placeholder {
  color: var(--nw-text-dim);
  opacity: 0.6;
}

/* ── Badges ──────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  font-family: var(--font-stamp);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  padding: 1px var(--sp-2);
  border-radius: var(--radius-sm);
  color: var(--nw-primary);
  border: 1px solid var(--nw-primary-dim);
}
.badge-success { color: var(--nw-success); border-color: var(--nw-green-dim); }
.badge-danger  { color: var(--nw-danger);  border-color: var(--nw-red-dim); }
.badge-warning { color: var(--nw-warning); border-color: var(--nw-yellow); }

/* ── Status LED ──────────────────────────────────────────────── */

.led {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 4px;
}
.led.green  { background: var(--nw-green);   box-shadow: 0 0 4px var(--nw-green); }
.led.blue   { background: var(--nw-primary); box-shadow: 0 0 4px var(--nw-primary); }
.led.red    { background: var(--nw-red);     box-shadow: 0 0 4px var(--nw-red); }
.led.yellow { background: var(--nw-yellow);  box-shadow: 0 0 4px var(--nw-yellow); }

/* ── Panel ───────────────────────────────────────────────────── */

.panel {
  background: var(--void-warm);
  border: 1px solid var(--nw-text-faint);
}

.panel-header {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--nw-primary);
  padding: var(--sp-2) var(--sp-3) 7px;
  border-bottom: 1px solid var(--nw-primary-dim);
  display: flex;
  justify-content: space-between;
}

.panel-body {
  padding: var(--sp-3);
}

/* ── Data Table ──────────────────────────────────────────────── */

.nw-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.nw-table th {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: left;
  padding: 6px 10px;
  color: var(--nw-primary);
  border-bottom: 1px solid var(--nw-primary-dim);
}

.nw-table td {
  padding: 5px 10px;
  color: var(--nw-green);
  border-bottom: 1px solid var(--nw-text-faint);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.nw-table tr:hover td { background: var(--nw-green-faint); }

/* ── Metrics Grid ────────────────────────────────────────────── */

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--nw-text-faint);
}

.metric-cell {
  background: var(--void-warm);
  padding: var(--sp-3) var(--sp-4);
}

.metric-cell .m-label {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--nw-primary);
  margin-bottom: 2px;
}

.metric-cell .m-value {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--nw-green);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 6px rgba(122,237,122,0.4), 0 0 12px rgba(122,237,122,0.15);
  line-height: 1.1;
}

.metric-cell .m-sub {
  font-size: 9px;
  color: var(--nw-text-dim);
  margin-top: 2px;
}

.metric-cell.highlight .m-value {
  color: var(--nw-primary);
  text-shadow: 0 0 6px rgba(102,153,255,0.4);
  font-size: var(--text-2xl);
}

/* ── Progress Bar ────────────────────────────────────────────── */

.nw-progress {
  height: 4px;
  background: var(--void-panel);
  border: 1px solid var(--nw-text-faint);
  overflow: hidden;
}

.nw-progress .fill {
  height: 100%;
  background: var(--nw-green);
  box-shadow: 0 0 4px rgba(122,237,122,0.3);
}

/* ── Toast / Notification ────────────────────────────────────── */

.toast {
  background: var(--void-panel);
  border-left: 3px solid var(--nw-primary);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm);
  color: var(--nw-text);
}
.toast-success { border-left-color: var(--nw-success); }
.toast-danger  { border-left-color: var(--nw-danger); }
.toast-warning { border-left-color: var(--nw-warning); }
.toast-info    { border-left-color: var(--nw-info); }

/* ── Card ────────────────────────────────────────────────────── */

.card {
  background: var(--void-warm);
  border: 1px solid var(--nw-text-faint);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--nw-primary);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--nw-text-faint);
}

.card-body {
  padding: var(--sp-4);
}

.card-footer {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--nw-text-faint);
}

/* ── Modal / Dialog ──────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--void-panel);
  border: 1px solid var(--nw-primary-dim);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--nw-primary);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--nw-primary-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: var(--sp-4);
  color: var(--nw-text);
  font-size: var(--text-base);
}

.modal-footer {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--nw-text-faint);
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
}

/* ── Tabs ────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--nw-text-faint);
  gap: 0;
}

.tab {
  font-family: var(--font-sys);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--nw-text-dim);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: var(--sp-2) var(--sp-4);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
  color: var(--nw-text);
}

.tab.active {
  color: var(--nw-primary);
  border-bottom-color: var(--nw-primary);
}

.tab-panel {
  padding: var(--sp-4) 0;
}

/* ── Sidebar Nav ─────────────────────────────────────────────── */

.sidebar {
  width: 240px;
  background: var(--void-warm);
  border-right: 1px solid var(--nw-text-faint);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sidebar-header {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--nw-primary);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--nw-primary-dim);
}

.sidebar-section {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--nw-text-dim);
  padding: var(--sp-3) var(--sp-4) var(--sp-1);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--nw-text-dim);
  padding: var(--sp-2) var(--sp-4);
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  text-decoration: none;
}

.sidebar-item:hover {
  color: var(--nw-text);
  background: var(--nw-text-faint);
}

.sidebar-item.active {
  color: var(--nw-primary);
  border-left-color: var(--nw-primary);
  background: var(--nw-primary-fill);
}

/* ── Dropdown ────────────────────────────────────────────────── */

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  min-width: 180px;
  background: var(--void-raised);
  border: 1px solid var(--nw-text-line);
  border-radius: var(--radius-md);
  padding: var(--sp-1) 0;
  margin-top: var(--sp-1);
}

.dropdown-item {
  display: block;
  width: 100%;
  font-family: var(--font-sys);
  font-size: var(--text-sm);
  color: var(--nw-text-dim);
  background: transparent;
  border: none;
  padding: var(--sp-2) var(--sp-3);
  text-align: left;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.dropdown-item:hover {
  color: var(--nw-text);
  background: var(--nw-primary-fill);
}

.dropdown-item.danger { color: var(--nw-red); }
.dropdown-item.danger:hover { background: var(--nw-red-fill); }

.dropdown-divider {
  height: 1px;
  background: var(--nw-text-faint);
  margin: var(--sp-1) 0;
}

/* ── Breadcrumbs ─────────────────────────────────────────────── */

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--nw-text-dim);
}

.breadcrumbs a {
  color: var(--nw-text-dim);
  transition: color 0.15s;
}

.breadcrumbs a:hover { color: var(--nw-primary); }

.breadcrumbs .separator {
  color: var(--nw-text-faint);
  font-size: var(--text-xs);
}

.breadcrumbs .current {
  color: var(--nw-text);
}

/* ── Tooltip ─────────────────────────────────────────────────── */

.tooltip {
  position: relative;
}

.tooltip-content {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--void-raised);
  border: 1px solid var(--nw-text-line);
  border-radius: var(--radius-md);
  padding: var(--sp-1) var(--sp-2);
  font-size: var(--text-xs);
  color: var(--nw-text);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.tooltip:hover .tooltip-content {
  opacity: 1;
}

/* ── Skeleton Loader ─────────────────────────────────────────── */

.skeleton {
  background: var(--void-panel);
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--nw-text-faint);
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(102, 153, 255, 0.08) 40%,
    rgba(102, 221, 255, 0.12) 50%,
    rgba(102, 153, 255, 0.08) 60%,
    transparent 100%
  );
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--sp-2);
}

.skeleton-heading {
  height: 24px;
  width: 60%;
  margin-bottom: var(--sp-3);
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
}

.skeleton-block {
  height: 80px;
}

/* ── Key-Value Row ───────────────────────────────────────────── */

.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--sp-1) 0;
  border-bottom: 1px solid var(--nw-text-faint);
  font-size: var(--text-sm);
}

.kv-row .kv-label {
  color: var(--nw-primary-dim);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  font-size: 10px;
}

.kv-row .kv-value {
  color: var(--nw-green);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ── Avatar ──────────────────────────────────────────────────── */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--nw-primary-fill);
  border: 1px solid var(--nw-primary-dim);
  color: var(--nw-primary);
  font-size: var(--text-sm);
  font-weight: 700;
}

.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 48px; height: 48px; font-size: var(--text-lg); }

/* ── Divider ─────────────────────────────────────────────────── */

.divider {
  height: 1px;
  background: var(--nw-text-faint);
  margin: var(--sp-4) 0;
}

.divider-primary {
  background: var(--nw-primary-dim);
}

/* ── Tag ─────────────────────────────────────────────────────── */

.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-family: var(--font-stamp);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  padding: 0 var(--sp-2);
  border-radius: var(--radius-full);
  color: var(--nw-primary);
  background: var(--nw-primary-fill);
}

.tag-success { color: var(--nw-success); background: var(--nw-green-faint); }
.tag-danger  { color: var(--nw-danger);  background: var(--nw-red-fill); }
.tag-warning { color: var(--nw-warning); background: rgba(232, 153, 58, 0.1); }
.tag-info    { color: var(--nw-info);    background: var(--nw-cyan-glow); }
