/* ===================================================================
   NEXUS AGENTS — GOOGLE GEMINI WEB DESIGN SYSTEM & RESPONSIVE ENGINE
   =================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Pure Dark Black & Coral Aesthetic Tokens */
  --bg: #000000;
  --bg-subtle: #050505;
  --surface: #000000;
  --panel: #0A0A0C;
  --panel-raised: #121215;
  --surface-raised: #121215;
  --surface-hover: #1A1A1F;
  --surface-card: rgba(0, 0, 0, 0.95);

  --border: rgba(255, 255, 255, 0.08);
  --border-soft: rgba(255, 255, 255, 0.05);
  --border-subtle: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.2);
  --border-gemini: rgba(255, 109, 90, 0.35);

  --text: #F8FAFC;
  --text-muted: #A1A1AA;
  --text-dim: #A1A1AA;
  --text-faint: #71717A;

  /* n8n Signature Coral & Node Palette */
  --n8n-coral: #FF6D5A;
  --n8n-pink: #EA4B71;
  --n8n-purple: #7B42F6;
  --n8n-orange: #FF8038;
  --n8n-gradient: linear-gradient(135deg, #FF6D5A 0%, #EA4B71 100%);
  --n8n-glow: none;

  --gemini-blue: #FF6D5A;
  --gemini-purple: #7B42F6;
  --gemini-cyan: #FF8038;
  --gemini-pink: #EA4B71;
  --gemini-gradient: linear-gradient(135deg, #FF6D5A 0%, #EA4B71 100%);
  --gemini-glow: none;

  --accent: #FF6D5A;
  --accent-hover: #FF553E;
  --accent-soft: rgba(255, 109, 90, 0.14);
  --accent-border: rgba(255, 109, 90, 0.38);
  --accent-glow: none;

  --cyan: #FF8038;
  --cyan-soft: rgba(255, 128, 56, 0.14);
  --cyan-border: rgba(255, 128, 56, 0.35);

  --emerald: #10B981;
  --emerald-soft: rgba(16, 185, 129, 0.12);
  --emerald-border: rgba(16, 185, 129, 0.3);

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, Monaco, monospace;

  --sidebar-width: 275px;
  --topbar-height: 64px;
  --radius-sm: 0px;
  --radius: 0px;
  --radius-lg: 0px;
  --radius-pill: 0px;
  --shadow-sm: none;
  --shadow-md: none;
  --shadow-gemini: none;
  --touch-target-min: 44px;
}

[data-theme="light"] {
  --bg: #F8FAFC;
  --bg-subtle: #F1F5F9;
  --surface: #FFFFFF;
  --panel: #FFFFFF;
  --panel-raised: #F1F5F9;
  --surface-raised: #F1F5F9;
  --surface-hover: #E2E8F0;
  --surface-card: rgba(255, 255, 255, 0.95);

  --border: #E2E8F0;
  --border-soft: #F1F5F9;
  --border-subtle: #CBD5E1;
  --border-strong: #94A3B8;
  --border-gemini: rgba(255, 109, 90, 0.3);

  --text: #0F172A;
  --text-muted: #475569;
  --text-dim: #475569;
  --text-faint: #64748B;

  --accent: #FF6D5A;
  --accent-hover: #FF553E;
  --accent-soft: rgba(255, 109, 90, 0.1);
  --accent-border: rgba(255, 109, 90, 0.28);
  --accent-glow: none;

  --shadow-sm: none;
  --shadow-md: none;
  --shadow-gemini: none;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Custom Gemini Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 0px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Strict SVG sizing safety net */
svg {
  width: 1.2rem;
  height: 1.2rem;
  max-width: 100%;
  max-height: 100%;
  vertical-align: middle;
  flex-shrink: 0;
  display: inline-block;
}

*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-sans);
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

h1 {
  font-size: clamp(1.6rem, 3.5vw, 2.6rem);
}

h2 {
  font-size: clamp(1.3rem, 2.5vw, 2rem);
}

h3 {
  font-size: clamp(1.05rem, 1.8vw, 1.35rem);
}

h4 {
  font-size: clamp(0.95rem, 1.4vw, 1.1rem);
}

p {
  color: var(--text-muted);
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
}

ul,
ol {
  list-style: none;
}

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

/* Gemini Gradient Text Utility */
.gemini-text {
  background: var(--gemini-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

/* ===================================================================
   APP SHELL LAYOUT (DESKTOP + TABLET + MOBILE)
   =================================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
  background: var(--bg);
}

/* Sidebar Navigation — n8n Design Architecture with Fixed Footer & Hidden Scrollbar Track */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 100;
  overflow: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar::-webkit-scrollbar,
.sb-nav-body::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.sb-brand {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: var(--topbar-height);
  background: var(--surface);
  position: relative;
  z-index: 10;
}

.sb-brand .mark {
  width: 32px;
  height: 32px;
  background: #141416;
  border: 1px solid var(--n8n-coral);
  border-radius: 0px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  color: var(--n8n-coral);
  box-shadow: none;
  flex-shrink: 0;
}

.sb-brand .name {
  display: flex;
  flex-direction: column;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--text);
  line-height: 1.1;
}

.sb-brand .sub {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--n8n-coral);
  letter-spacing: 0.06em;
  margin-top: 1px;
}

.sb-nav-body {
  flex: 1 1 auto;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 16px;
}

.sb-section {
  padding: 8px 12px 0;
  flex-shrink: 0;
}

.sb-label {
  font-family: var(--font-sans);
  font-size: 0.73rem;
  font-weight: 800;
  color: #FFFFFF !important;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  padding: 12px 10px 6px;
  opacity: 1;
}

.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  min-height: 38px;
  border-radius: 0px;
  font-size: 0.85rem;
  line-height: 1.25;
  color: var(--text-muted);
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 2px solid transparent;
}

.sb-item:hover {
  color: var(--text);
  background: var(--surface-raised);
  transform: translateX(2px);
}

.sb-item.active {
  color: var(--n8n-coral);
  background: rgba(255, 109, 90, 0.14);
  font-weight: 600;
  box-shadow: none;
  border-left: 2px solid var(--n8n-coral);
}

[data-theme="light"] .sb-item.active {
  color: var(--n8n-coral);
  background: rgba(255, 109, 90, 0.12);
}

.sb-item svg {
  width: 18px;
  height: 18px;
  color: var(--text-faint);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.sb-item:hover svg,
.sb-item.active svg {
  color: var(--n8n-coral);
  transform: scale(1.05);
}

.sb-item .badge {
  margin-left: auto;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 0px;
  background: var(--n8n-coral);
  color: #fff;
  font-weight: 700;
}

.sb-footer {
  margin-top: auto;
  padding: 14px 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  background: var(--bg-subtle);
  position: relative;
  z-index: 10;
}

.sb-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  min-height: 38px;
  background: var(--emerald-soft);
  border: 1px solid var(--emerald-border);
  color: var(--emerald);
  font-weight: 600;
  font-size: 0.8rem;
  border-radius: 0px;
  transition: all 0.2s ease;
}

.sb-cta:hover {
  background: var(--emerald);
  color: #FFFFFF;
  box-shadow: none;
}

.sb-cta svg {
  width: 16px;
  height: 16px;
}

.sb-close {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  margin-left: auto;
  border-radius: 0px;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.sb-close:hover {
  color: var(--n8n-coral);
  border-color: var(--n8n-coral);
  background: var(--surface-raised);
}

.sb-close svg {
  width: 18px;
  height: 18px;
}

.sb-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9990;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sb-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* Main Workspace Area */
.main {
  flex-grow: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-width));
}

/* Topbar Header */
.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 3vw, 32px);
  gap: 16px;
}

[data-theme="light"] .topbar {
  background: #FFFFFF;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sb-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 0px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.sb-toggle:hover {
  background: var(--surface-raised);
  color: var(--n8n-coral);
}

.sb-toggle svg {
  width: 22px;
  height: 22px;
}

.topbar-crumb {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--text-faint);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: clamp(140px, 45vw, 260px);
}

.topbar-crumb strong {
  color: var(--text);
  font-weight: 700;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
}

.topbar-search input {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 0px;
  padding: 8px 14px 8px 36px;
  font-size: 0.85rem;
  color: var(--text);
  width: clamp(180px, 22vw, 260px);
  min-height: 38px;
  transition: all 0.2s ease;
}

.topbar-search input:focus {
  border-color: var(--n8n-coral);
  box-shadow: none;
  outline: none;
}

.topbar-search svg {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-faint);
  pointer-events: none;
}

.topbar-icon-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.topbar-icon-btn:hover {
  color: var(--n8n-coral);
  background: var(--surface-raised);
  border-color: var(--accent-border);
}

.topbar-icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Theme toggle icons */
.sun-icon {
  display: block;
}

.moon-icon {
  display: none;
}

[data-theme="dark"] .sun-icon {
  display: none;
}

[data-theme="dark"] .moon-icon {
  display: block;
}

/* Content Area */
.content {
  padding: clamp(20px, 4vw, 36px);
  flex-grow: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Panels & Cards System — Boxy n8n Aesthetic */
.panel {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 0px;
  transition: border-color 0.2s ease;
  box-shadow: none;
}

.panel:hover {
  border-color: var(--border-strong);
  box-shadow: none;
}

.panel-pad {
  padding: clamp(20px, 3vw, 32px);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.section-head p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 0px;
  font-size: 0.74rem;
  font-weight: 600;
  font-family: var(--font-mono);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}

.pill.live {
  background: var(--emerald-soft);
  border-color: var(--emerald-border);
  color: var(--emerald);
}

.pill.live .dot {
  width: 6px;
  height: 6px;
  border-radius: 0px;
  background: var(--emerald);
  box-shadow: none;
}

.pill.beta {
  background: var(--cyan-soft);
  border-color: var(--cyan-border);
  color: var(--cyan);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 0px;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-mono);
  text-transform: uppercase;
}

.badge-emerald {
  background: var(--emerald-soft);
  color: var(--emerald);
  border: 1px solid var(--emerald-border);
}

.badge-amber,
.badge-cyan {
  background: var(--cyan-soft);
  color: var(--cyan);
  border: 1px solid var(--cyan-border);
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

/* Buttons System — Crisp Boxy n8n Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  min-height: 42px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 0px;
  transition: all 0.2s ease;
  white-space: nowrap;
  line-height: 1;
}

.btn-primary {
  background: var(--n8n-coral);
  color: #FFFFFF;
  border: 1px solid var(--n8n-coral);
  box-shadow: none;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: none;
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-raised);
  border-color: var(--border-strong);
  color: var(--n8n-coral);
}

.btn-sm {
  padding: 8px 16px;
  min-height: 36px;
  font-size: 0.82rem;
}

.btn-block {
  width: 100%;
  text-align: center;
}

/* Grid System */
.grid {
  display: grid;
  gap: clamp(16px, 2.5vw, 24px);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* Mobile Bottom Navigation Bar (< 768px) */
.mobile-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 990;
  align-items: center;
  justify-content: space-around;
  padding: 0 6px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.mbb-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  position: relative;
  flex-grow: 1;
  height: 100%;
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.2s ease;
}

.mbb-item svg {
  width: 22px;
  height: 22px;
}

.mbb-item.active,
.mbb-item:hover {
  color: var(--n8n-coral) !important;
}

.mbb-badge {
  position: absolute;
  top: 4px;
  right: 18%;
  font-size: 0.52rem;
  font-weight: 800;
  background: var(--n8n-coral);
  color: #FFFFFF;
  padding: 1px 4px;
  border-radius: 2px;
  line-height: 1;
}

/* Animations */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Strict Horizontal Containment */
pre,
code,
table,
.table-container {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Responsive Overrides */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    width: min(300px, 85vw);
    z-index: 10000;
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.5);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sb-close {
    display: flex;
  }

  .main {
    margin-left: 0;
    width: 100%;
  }

  .sb-toggle {
    display: flex;
  }

  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .mobile-bottom-bar {
    display: flex;
  }

  .main,
  .content {
    padding-bottom: 80px;
  }

  .home-main {
    padding: 0 !important;
    padding-bottom: 0 !important;
    height: 100vh !important;
    max-height: 100vh !important;
    overflow: hidden !important;
  }

  .topbar-search {
    display: none;
  }

  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .topbar-crumb {
    font-size: 0.8rem;
  }

  .content {
    padding: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  ::before,
  ::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}