/* ═══════════════════════════════════════════════════════════════════════════
   main.css — Global styles, layout, CSS variables
   Aesthetic: Dark Industrial / Terminal
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Google Fonts loaded in HTML ─────────────────────────────────────────── */

/* ── CSS Variables ─────────────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg: #07080f;
  --surface: #0d1220;
  --surface-2: #131c2e;
  --surface-3: #1a2540;

  /* Borders */
  --border: #1e2d4a;
  --border-accent: rgba(34, 211, 238, 0.2);
  --border-hover: rgba(34, 211, 238, 0.45);

  /* Accents */
  --accent: #22d3ee;
  --accent-dim: rgba(34, 211, 238, 0.1);
  --accent-glow: rgba(34, 211, 238, 0.35);
  --accent-2: #f59e0b;
  --accent-2-dim: rgba(245, 158, 11, 0.12);

  /* Status */
  --success: #10b981;
  --success-dim: rgba(16, 185, 129, 0.12);
  --error: #ef4444;
  --error-dim: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-dim: rgba(245, 158, 11, 0.12);

  /* Text */
  --text: #e2e8f0;
  --text-2: #94a3b8;
  --text-muted: #475569;

  /* Typography */
  --font-display: "Syne", sans-serif;
  --font-body: "Outfit", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  /* Layout */
  --sidebar-w: 256px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;

  /* Transitions */
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;

  /* Subtle grid texture */
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.018) 1px, transparent 1px);
  background-size: 48px 48px;
}

input,
select,
button,
textarea {
  font-family: inherit;
  font-size: inherit;
}

a {
  text-decoration: none;
  color: inherit;
}
button {
  cursor: pointer;
  border: none;
  background: none;
}

/* ── App Shell ───────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

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

/* Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.logo-mark svg {
  width: 36px;
  height: 36px;
  display: block;
  filter: drop-shadow(0 0 8px rgba(34, 211, 238, 0.4));
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.logo-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--text);
}

.logo-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--accent);
  margin-top: 3px;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  font-size: 14px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.nav-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition);
}

.nav-item:hover {
  background: var(--accent-dim);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.nav-item.active::before {
  transform: scaleX(1);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-width: 1.8;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.server-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.status-dot.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0);
  }
}

.version-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ── Main Content ────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100vh;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.main-content::-webkit-scrollbar {
  width: 6px;
}
.main-content::-webkit-scrollbar-track {
  background: transparent;
}
.main-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ── Pages ───────────────────────────────────────────────────────────────── */
.page {
  display: none;
  animation: fadeSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 100vh;
}

.page.active {
  display: block;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Page Header */
.page-header {
  background: linear-gradient(
    180deg,
    rgba(34, 211, 238, 0.04) 0%,
    transparent 100%
  );
  border-bottom: 1px solid var(--border);
  padding: 28px 32px 24px;
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(8px);
}

.page-header-inner {
  max-width: 1300px;
  margin: 0 auto;
}

.page-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 12px;
  letter-spacing: 0.02em;
}

.page-title-accent {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 400;
  color: var(--accent);
  letter-spacing: 0.08em;
  opacity: 0.7;
}

.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

/* Page Body */
.page-body {
  max-width: 1300px;
  margin: 0 auto;
  padding: 24px 32px 40px;
}

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}
.text-muted {
  color: var(--text-muted);
}
.text-accent {
  color: var(--accent);
}
.flex-grow {
  flex: 1;
}

/* ── Font fallback: ensure fonts load gracefully ─────────────────────────── */
@supports not (font-family: "Syne") {
  :root {
    --font-display: "Trebuchet MS", sans-serif;
    --font-body: "Segoe UI", sans-serif;
  }
}

/* ── Sidebar: subtle left-edge glow on active state ─────────────────────── */
.sidebar {
  box-shadow:
    1px 0 0 var(--border),
    4px 0 24px rgba(0, 0, 0, 0.3);
}

/* ── Page transition: slightly longer for smoothness ─────────────────────── */
.page {
  animation-duration: 0.28s;
}

/* ── Page header: stronger backdrop for readability ──────────────────────── */
.page-header {
  background: linear-gradient(
    180deg,
    rgba(13, 18, 32, 0.96) 0%,
    rgba(13, 18, 32, 0.82) 100%
  );
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

/* ── Focus-visible ring for keyboard navigation ──────────────────────────── */
:focus-visible {
  outline: 2px solid rgba(34, 211, 238, 0.6);
  outline-offset: 2px;
}
button:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(34, 211, 238, 0.6);
  outline-offset: 2px;
  border-radius: 3px;
}
