/* ==========================================================================
   WipCloud-AI — Mobile-Perfect Console Theme v4.5
   Ultra Anti-Numbur, Full-Fluid Responsive, Touch-Locked, Zero Emoji
   ========================================================================== */

:root {
  --font-display: "Space Grotesk", "Inter", sans-serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, Menlo, monospace;

  /* ---- Light Theme: Daylight Ops ---- */
  --bg-void: #eef1f8;
  --bg-page: #eef1f8;
  --bg-glass: rgba(255, 255, 255, 0.92);
  --bg-surface-subtle: rgba(255, 255, 255, 0.65);
  --bg-surface-solid: #ffffff;
  --border-glass: rgba(30, 41, 82, 0.12);
  --border-glass-hover: rgba(13, 148, 136, 0.6);
  --grid-line: rgba(30, 41, 82, 0.05);

  --text-main: #0b1220;
  --text-muted: #4b5563;
  --text-dim: #6b7280;

  --accent-primary: #0d9488;
  --accent-hover: #0f766e;
  --accent-secondary: #7c3aed;
  --accent-glow: rgba(13, 148, 136, 0.22);
  --accent-light: #e3f6f3;
  --accent-contrast: #ffffff;

  --status-active: #0d9488;
  --status-active-bg: rgba(13, 148, 136, 0.12);
  --status-danger: #dc2626;
  --status-danger-bg: rgba(220, 38, 38, 0.10);
  --status-warn: #b45309;
  --status-warn-bg: rgba(217, 119, 6, 0.12);

  --code-bg: #0a0f1c;
  --code-text: #5eead4;
  --card-shadow: 0 1px 2px rgba(16, 24, 48, 0.04), 0 12px 28px -12px rgba(16, 24, 48, 0.12);
  --card-shadow-hover: 0 1px 2px rgba(16, 24, 48, 0.05), 0 20px 40px -14px rgba(13, 148, 136, 0.22);
  --inset-hairline: inset 0 1px 0 rgba(255, 255, 255, 0.6);

  --sidebar-w: 260px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

[data-theme="dark"] {
  /* ---- Dark Theme: Deep Node ---- */
  --bg-void: #05070d;
  --bg-page: #05070d;
  --bg-glass: rgba(13, 17, 30, 0.88);
  --bg-surface-subtle: rgba(255, 255, 255, 0.05);
  --bg-surface-solid: #0c1120;
  --border-glass: rgba(148, 178, 255, 0.14);
  --border-glass-hover: rgba(45, 212, 191, 0.55);
  --grid-line: rgba(148, 178, 255, 0.055);

  --text-main: #eef2ff;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --accent-primary: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-secondary: #a78bfa;
  --accent-glow: rgba(45, 212, 191, 0.3);
  --accent-light: rgba(45, 212, 191, 0.14);
  --accent-contrast: #04120f;

  --status-active: #34d399;
  --status-active-bg: rgba(52, 211, 153, 0.15);
  --status-danger: #fb7185;
  --status-danger-bg: rgba(251, 113, 133, 0.15);
  --status-warn: #fbbf24;
  --status-warn-bg: rgba(251, 191, 36, 0.15);

  --code-bg: #030509;
  --code-text: #5eead4;
  --card-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 20px 44px -16px rgba(0, 0, 0, 0.65);
  --card-shadow-hover: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 24px 56px -14px rgba(45, 212, 191, 0.22);
  --inset-hairline: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-sans);
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  touch-action: pan-y;
}

body {
  background-color: var(--bg-page);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 36px 36px;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: background-color 0.25s ease, color 0.25s ease;
  overflow-wrap: anywhere;
  word-break: normal;
}

#bgNetworkCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

.ambient-glow {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-glow) 0%, rgba(2, 132, 199, 0) 68%);
  top: -180px;
  right: -180px;
  pointer-events: none;
  z-index: 0;
  filter: blur(12px);
  animation: pulseGlow 14s ease-in-out infinite alternate;
}

@keyframes pulseGlow {
  0% { transform: translate(0, 0) scale(1); opacity: 0.45; }
  100% { transform: translate(-50px, 70px) scale(1.15); opacity: 0.8; }
}

/* HEADER & NAVBAR - ALWAYS ACCESSIBLE BUTTONS */
header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  width: 100%;
}

.nav-container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.12rem;
  background: linear-gradient(135deg, var(--text-main) 30%, var(--accent-primary) 130%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.brand-badge {
  background: var(--accent-light);
  color: var(--accent-primary);
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  border: 1px solid var(--border-glass);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  -webkit-text-fill-color: initial;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Nav links - on mobile, links like 'quickstart' can hide if crowded, BUT LOGIN BUTTON NEVER HIDES */
.nav-link-item {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.18s ease;
}

.nav-link-item:hover {
  color: var(--accent-primary);
  background: var(--bg-surface-subtle);
}

.btn-theme, .btn-drawer-toggle {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn-theme:hover, .btn-drawer-toggle:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.btn-drawer-toggle { display: none; font-weight: 700; }

.banner-alert {
  background: linear-gradient(90deg, var(--accent-light), transparent 140%);
  border-bottom: 1px solid var(--border-glass);
  color: var(--accent-primary);
  text-align: center;
  padding: 0.6rem 1rem;
  font-size: 0.83rem;
  font-weight: 600;
  position: relative;
  z-index: 10;
  word-break: break-word;
}

/* APP SHELL (Sidebar + Main Content Layout) */
.app-shell {
  display: flex;
  flex: 1;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  z-index: 10;
}

/* SIDEBAR DRAWER */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.9rem;
  gap: 0.35rem;
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.6rem 0.75rem 0.25rem;
  font-family: var(--font-mono);
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.68rem 0.85rem;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  border-left: 2px solid transparent;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.sidebar-btn:hover {
  background: var(--bg-surface-subtle);
  color: var(--text-main);
}

.sidebar-btn.active {
  background: var(--accent-light);
  color: var(--accent-primary);
  border-left: 2px solid var(--accent-primary);
  font-weight: 700;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 5, 10, 0.55);
  backdrop-filter: blur(4px);
  z-index: 70;
}

/* MAIN CONTENT AREA - FLUID & NO OVERFLOW */
.content-area {
  flex: 1;
  padding: 1.5rem 1.25rem;
  min-width: 0;
  max-width: 100%;
}

/* TERMINAL / TELEMETRY WINDOW */
.terminal-window {
  background: var(--code-bg);
  border: 1px solid rgba(45, 212, 191, 0.22);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  margin-bottom: 1.5rem;
  width: 100%;
}

.terminal-header {
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 0.65rem 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mac-dots { display: flex; align-items: center; gap: 6px; }
.mac-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.mac-dot.red { background: #ff5f56; }
.mac-dot.yellow { background: #ffbd2e; }
.mac-dot.green { background: #27c93f; }

.terminal-title {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-dim);
  font-weight: 500;
}

.terminal-body {
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.81rem;
  color: var(--code-text);
  line-height: 1.55;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.telemetry-pill {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  min-width: 0;
}

.telemetry-pill .label {
  font-size: 0.66rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.telemetry-pill .val {
  font-size: 0.94rem;
  font-weight: 700;
  color: #fff;
  margin-top: 3px;
  word-break: break-word;
}

/* CARDS */
.card {
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  margin-bottom: 1.4rem;
  box-shadow: var(--card-shadow), var(--inset-hairline);
  width: 100%;
  transition: border-color 0.2s ease;
}

.card:hover {
  border-color: var(--border-glass-hover);
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--text-main);
  letter-spacing: -0.01em;
  word-break: break-word;
}

.card-desc {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 1.25rem;
  line-height: 1.55;
  word-break: break-word;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.15rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.4rem;
}

.stat-box {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.stat-box::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, var(--accent-primary), var(--accent-secondary));
}

.stat-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.38rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
  word-break: break-word;
}

/* FORMS */
.form-group { margin-bottom: 1rem; }

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.7rem 0.88rem;
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.88rem;
  outline: none;
  transition: all 0.18s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background-color: var(--bg-surface-solid);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.68rem 1.3rem;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
  color: var(--accent-contrast);
  box-shadow: 0 3px 14px -3px var(--accent-glow);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-secondary {
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
}

.btn-secondary:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.btn-danger {
  background-color: var(--status-danger);
  color: #ffffff;
}

/* TABLE CONTAINER - SCROLLABLE & PREVENTS PAGE STRETCH */
.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  position: relative;
}

table {
  width: 100%;
  min-width: 580px;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.84rem;
}

th {
  background-color: var(--bg-surface-subtle);
  color: var(--text-dim);
  padding: 0.75rem 0.9rem;
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-glass);
  white-space: nowrap;
}

td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border-glass);
  color: var(--text-muted);
}

td code {
  font-family: var(--font-mono);
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-glass);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--accent-primary);
}

td strong { color: var(--text-main); font-weight: 600; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-active { background: var(--status-active-bg); color: var(--status-active); }
.badge-inactive { background: var(--status-danger-bg); color: var(--status-danger); }
.badge-locked { background: var(--status-warn-bg); color: var(--status-warn); }

pre {
  background-color: var(--code-bg);
  color: var(--code-text);
  padding: 0.95rem 1.05rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.81rem;
  overflow-x: auto;
  line-height: 1.55;
  border: 1px solid rgba(45, 212, 191, 0.15);
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

footer {
  background: var(--bg-glass);
  border-top: 1px solid var(--border-glass);
  padding: 1.35rem 1rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  position: relative;
  z-index: 10;
  word-break: break-word;
}

/* ==========================================================================
   MOBILE FIRST RESPONSIVENESS (ABSOLUTE ANTI-NUMBUR & VISIBLE LOGIN)
   ========================================================================== */
@media (max-width: 900px) {
  .btn-drawer-toggle { display: inline-block; }

  /* In mobile, regular nav links hide so header never overflows, BUT LOGIN BUTTON REMAINS */
  .nav-link-item { display: none !important; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 80;
    transform: translateX(-100%);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.6);
  }

  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.active { display: block; }

  .content-area { padding: 1.1rem 0.85rem; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 0.65rem; }
  .grid-2 { grid-template-columns: 1fr; gap: 0.9rem; }
  .card { padding: 1.15rem; border-radius: var(--radius-md); }
}

@media (max-width: 480px) {
  .nav-container { padding: 0.65rem 0.75rem; }
  .brand-link { font-size: 1rem; }
  .brand-badge { display: none; } /* Hide tiny badge on smallest phone so Login button has max room */

  .grid-4 { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.22rem; }
  h1 { font-size: 1.55rem !important; line-height: 1.25 !important; }

  .btn { width: 100%; }
  .nav-actions .btn { width: auto; padding: 5px 10px; font-size: 0.78rem; }
  .nav-actions .btn-theme { padding: 5px 8px; }
}
