@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap");

/* ─── Design Tokens ─────────────────────────────────────────────── */
:root {
  --bg: #0c1119;
  --surface-1: #141b28;
  --surface-2: #1a2434;
  --surface-3: #233044;
  --surface-4: #2a3952;
  --border: #2f3f58;
  --border-light: #3a4d69;

  --text-primary: #e8eef8;
  --text-secondary: #b8c5da;
  --text-muted: #8e9cb5;

  --accent: #4c9cff;
  --accent-hover: #3d8be9;
  --accent-dim: rgba(76, 156, 255, 0.16);

  --success: #35c38b;
  --success-bg: rgba(53, 195, 139, 0.16);
  --warning: #ffb75e;
  --warning-bg: rgba(255, 183, 94, 0.16);
  --error: #ff6d80;
  --error-bg: rgba(255, 109, 128, 0.16);
  --purple: #9ca8ff;
  --purple-bg: rgba(156, 168, 255, 0.15);

  --font: "Space Grotesk", "Segoe UI", "Helvetica Neue", sans-serif;
  --mono: "JetBrains Mono", "Fira Code", "Courier New", monospace;

  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 24px 56px rgba(0, 0, 0, 0.45);
}

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

html,
body {
  height: 100%;
}

button {
  cursor: pointer;
}

input,
textarea,
select,
button {
  font-family: var(--font);
  font-size: 14px;
}

/* ─── Base ───────────────────────────────────────────────────────── */
body {
  font-family: var(--font);
  background: radial-gradient(circle at 18% 0%, #1a2b47 0%, rgba(26, 43, 71, 0) 32%),
    radial-gradient(circle at 88% 12%, #1f3046 0%, rgba(31, 48, 70, 0) 32%),
    var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ─── App Shell ──────────────────────────────────────────────────── */
#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.nav-logo {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-tab {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  border-radius: 10px;
  padding: 6px 12px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  transition: 0.2s ease;
}

.nav-tab:hover {
  border-color: var(--border-light);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.nav-tab.active {
  background: linear-gradient(140deg, rgba(76, 156, 255, 0.26), rgba(53, 195, 139, 0.14));
  border-color: rgba(76, 156, 255, 0.52);
  color: #eaf4ff;
}

/* ─── Offline Banner ─────────────────────────────────────────────── */
#offline-banner {
  display: none;
  background: linear-gradient(90deg, rgba(255, 109, 128, 0.18), rgba(255, 183, 94, 0.18));
  border-bottom: 1px solid rgba(255, 109, 128, 0.5);
  color: #ffdce2;
  text-align: center;
  padding: 8px 16px;
  font-size: 12px;
  letter-spacing: 0.02em;
}

#offline-banner.visible {
  display: block;
}

/* ─── Top Nav ────────────────────────────────────────────────────── */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 17, 25, 0.8);
  backdrop-filter: blur(12px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  flex-shrink: 0;
  overflow: hidden;
}

#refresh-dot,
.refresh-dot-mini {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--success);
  opacity: 0;
  transition: opacity 0.3s;
}

#refresh-dot.pulse {
  animation: dot-pulse 0.75s ease-out;
}

@keyframes dot-pulse {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* ─── Views ──────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  position: relative;
  padding: 20px;
}

.view {
  display: none;
  padding: 0;
  animation: view-fade 0.28s ease;
}

.view.active {
  display: block;
}

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

#view-dashboard.view.active {
  display: grid;
  gap: 20px;
}

/* ─── Editor is a full-viewport block with its own layout ───────── */
#view-editor {
  display: none;
  position: relative;
  height: calc(100dvh - 64px);
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0));
  box-shadow: var(--shadow);
}

#view-editor.active {
  display: flex;
}

/* ─── Section titles ─────────────────────────────────────────────── */
.section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.section-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

/* ─── Divider ────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent);
  margin: 6px 0;
}

/* ─── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(184, 197, 218, 0.22);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(184, 197, 218, 0.36);
}

/* ─── Utility ────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

.flex {
  display: flex;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.gap-8 {
  gap: 8px;
}

.gap-12 {
  gap: 12px;
}

.flex-wrap {
  flex-wrap: wrap;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.flex-1 {
  flex: 1;
}

.text-sm {
  font-size: 12px;
}

.text-muted {
  color: var(--text-secondary);
}

.text-error {
  color: var(--error);
}

.text-success {
  color: var(--success);
}

.mono {
  font-family: var(--mono);
}

.mt-4 {
  margin-top: 4px;
}

.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 920px) {
  .top-nav {
    padding: 0 12px;
  }

  .topbar-left {
    gap: 8px;
  }

  .nav-tabs {
    gap: 6px;
  }

  .nav-tab {
    padding: 6px 10px;
  }

  #view-editor {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  #view-editor .editor-content {
    overflow: visible;
    min-height: 0;
  }
}

@media (max-width: 680px) {
  .main-content {
    padding: 12px;
  }

  .top-nav {
    padding: 0 10px;
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .nav-logo {
    font-size: 14px;
  }

  .topbar-left {
    width: 100%;
    flex-wrap: wrap;
    overflow: visible;
  }

  .nav-tabs {
    width: 100%;
    order: 3;
  }
}
