/* ── HQ DESIGN SYSTEM v2 ─────────────────────────────────────────────────────
   Shared by all Solutio HQ tool pages.
   Single source of truth — do not duplicate tokens in tool-specific stylesheets.
   ──────────────────────────────────────────────────────────────────────────── */

@import '/assets/fonts/inter/inter.css';
@import '/assets/fonts/mono/mono.css';

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg-base);
  color: var(--text-primary);
}

/* ── Tokens ────────────────────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-base:    #060606;
  --bg-surface: #0d0d0d;
  --bg-raised:  #141414;
  --bg-overlay: #1a1a1a;
  --bg-hover:   #1f1f1f;

  /* Borders */
  --border:      rgba(255,255,255,0.06);
  --border-soft: rgba(255,255,255,0.04);
  --border-med:  rgba(255,255,255,0.10);
  --border-bold: rgba(255,255,255,0.18);

  /* Text */
  --text-primary:   #f0f0f0;
  --text-secondary: #888;
  --text-muted:     #444;
  --text-disabled:  #2a2a2a;

  /* Brand */
  --red:      #E52825;
  --red-soft: rgba(229,40,37,0.12);
  --red-glow: rgba(229,40,37,0.06);

  /* Tool accents */
  --slash-color:    #f59e0b;
  --reach-color:    #10b981;
  --docs-color:     #6366f1;
  --bot-color:      #0ea5e9;
  --insights-color: #8b5cf6;
  --track-color:    #f97316;
  --invoice-color:  #ec4899;
  --edit-color:     #14b8a6;

  /* Spacing */
  --sidebar-w: 220px;
  --header-h:  56px;
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow:    0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.7);

  /* Motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --fast: 120ms;
  --med:  220ms;
}

/* ── Layout ────────────────────────────────────────────────────────────────── */
.hq-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg-base);
  color: var(--text-primary);
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.hq-sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-surface);
  z-index: 100;
  overflow-y: auto;
}

.hq-sidebar-logo {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-soft);
  gap: 10px;
  flex-shrink: 0;
}
.hq-sidebar-logo img { height: 22px; width: auto; }
.hq-sidebar-logo .logo-text {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text-primary);
  line-height: 1.2;
}
.hq-sidebar-logo .logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.hq-nav { padding: 10px 0; flex: 1; }
.hq-nav-section {
  padding: 14px 18px 6px;
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-disabled);
  font-weight: 600;
}

.hq-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 18px;
  margin: 1px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 450;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
  position: relative;
}
.hq-nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.hq-nav-item.active {
  background: var(--bg-overlay);
  color: var(--text-primary);
  font-weight: 500;
}
.hq-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px;
  background: var(--item-color, var(--red));
  border-radius: 0 2px 2px 0;
}
.hq-nav-item .nav-icon {
  width: 16px; height: 16px;
  opacity: 0.7;
  flex-shrink: 0;
  stroke-width: 1.8;
}
.hq-nav-item.active .nav-icon { opacity: 1; color: var(--item-color, var(--text-primary)); }
.hq-nav-item .nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
}

.hq-sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}
.hq-sidebar-footer .user-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.2;
}
.hq-sidebar-footer .user-role {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Main + Page Header ────────────────────────────────────────────────────── */
.hq-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.hq-page-header {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  background: rgba(6,6,6,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 50;
}
.hq-page-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}
.hq-page-title .tool-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--tool-color, var(--red));
}
.hq-content { padding: 28px; flex: 1; }

/* ── Components ────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  transition: border-color var(--fast);
}
.card:hover { border-color: var(--border-med); }
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 10px;
}
.card-title { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.card-sub   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  border-left: 2px solid var(--accent, var(--red));
}
.stat-label {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.stat-delta {
  font-size: 11px;
  margin-top: 6px;
  color: var(--text-muted);
}
.stat-delta.up   { color: #22c55e; }
.stat-delta.down { color: var(--red); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background var(--fast) var(--ease), transform var(--fast) var(--ease), color var(--fast), border-color var(--fast);
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}
.btn-primary   { background: var(--red); color: #fff; }
.btn-primary:hover { background: #cc2422; transform: translateY(-1px); }
.btn-secondary { background: var(--bg-overlay); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-med); }
.btn-ghost     { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-hover); }
.btn-sm        { padding: 5px 10px; font-size: 11px; }
.btn-icon      { padding: 7px; width: 32px; height: 32px; justify-content: center; }
.btn:disabled  { opacity: 0.5; cursor: not-allowed; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
}
.badge-green  { background: rgba(34,197,94,0.10);  color: #22c55e; }
.badge-red    { background: rgba(229,40,37,0.10);  color: var(--red); }
.badge-amber  { background: rgba(245,158,11,0.10); color: #f59e0b; }
.badge-blue   { background: rgba(14,165,233,0.10); color: #0ea5e9; }
.badge-purple { background: rgba(139,92,246,0.10); color: #8b5cf6; }
.badge-indigo { background: rgba(99,102,241,0.10); color: #6366f1; }
.badge-pink   { background: rgba(236,72,153,0.10); color: #ec4899; }
.badge-teal   { background: rgba(20,184,166,0.10); color: #14b8a6; }
.badge-orange { background: rgba(249,115,22,0.10); color: #f97316; }
.badge-muted  { background: var(--bg-overlay);     color: var(--text-muted); }

/* Status dot */
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.status-dot.online  { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.6); animation: pulse-dot 2s infinite; }
.status-dot.offline { background: #444; }
.status-dot.warning { background: #f59e0b; }
.status-dot.error   { background: var(--red); }

/* Tables */
.hq-table { width: 100%; border-collapse: collapse; }
.hq-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 10px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
.hq-table td {
  padding: 11px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-soft);
}
.hq-table tr:hover td { background: var(--bg-hover); color: var(--text-primary); }

/* Inputs */
.hq-input {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary);
  width: 100%;
  font-family: inherit;
  transition: border-color var(--fast);
  outline: none;
}
.hq-input:focus { border-color: var(--border-bold); }
.hq-input::placeholder { color: var(--text-muted); }
.hq-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23444'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.hq-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* Progress bar */
.progress-bar { height: 4px; background: var(--bg-overlay); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 2px; background: var(--accent, var(--red)); transition: width 0.8s var(--ease); }

/* Tabs */
.hq-tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.hq-tab {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 450;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--fast), border-bottom-color var(--fast);
  font-family: inherit;
}
.hq-tab:hover { color: var(--text-secondary); }
.hq-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--tool-color, var(--red));
  font-weight: 500;
}

/* Empty state */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
}
.empty-state svg { opacity: 0.2; width: 32px; height: 32px; }
.empty-state p { font-size: 13px; max-width: 260px; line-height: 1.5; }

/* Grids */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-raised) 25%, var(--bg-overlay) 50%, var(--bg-raised) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}

/* ── Command palette (FIX: opacity + pointer-events, not display:none) ─────── */
.hq-palette {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--fast) var(--ease);
}
.hq-palette.open {
  opacity: 1;
  pointer-events: auto;
}
.hq-palette-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-med);
  border-radius: var(--radius-xl);
  width: 520px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(-8px);
  transition: transform var(--med) var(--ease);
}
.hq-palette.open .hq-palette-panel { transform: translateY(0); }
.hq-palette-search {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.hq-palette-search input {
  border: none; background: none; padding: 0;
  font-size: 14px; color: var(--text-primary); font-family: inherit;
  flex: 1; outline: none;
}
.hq-palette-search input::placeholder { color: var(--text-muted); }
.hq-palette-results {
  max-height: 320px;
  overflow-y: auto;
}
.hq-palette-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  color: var(--text-secondary);
  font-size: 13px;
  text-decoration: none;
  transition: background var(--fast);
  cursor: pointer;
}
.hq-palette-item:hover, .hq-palette-item.selected {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.hq-palette-empty {
  padding: 24px; color: var(--text-muted);
  font-size: 12px; text-align: center;
}
kbd.hq-kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  background: var(--bg-overlay);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ── Animations ────────────────────────────────────────────────────────────── */
@keyframes shimmer  { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes pulse-dot{ 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes fade-up  { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }

.fade-up   { animation: fade-up 0.4s var(--ease) both; }
.fade-up-1 { animation-delay: 0.05s; }
.fade-up-2 { animation-delay: 0.10s; }
.fade-up-3 { animation-delay: 0.15s; }
.fade-up-4 { animation-delay: 0.20s; }

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1f1f1f; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #2a2a2a; }

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .hq-sidebar { transform: translateX(-100%); transition: transform var(--med) var(--ease); }
  .hq-sidebar.open { transform: translateX(0); }
  .hq-main { margin-left: 0; }
  .grid-4, .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
}

/* ── TOOL OFFSET v2 ──────────────────────────────────────────────────────────
   Push every tool's React root past the fixed HQ sidebar (Session E follow-up).
   Works for all tools where React mounts into #root — uniform behavior. */
@media (min-width: 769px) {
  /* The HQ sidebar floats at left:0 with width var(--sidebar-w).
     Offset the React mount target so content starts past the sidebar. */
  body > #root,
  body > #app {
    margin-left: var(--sidebar-w);
    width: calc(100vw - var(--sidebar-w));
  }
  /* If the tool's React tree renders its own .layout (Slash post-restore),
     the inherited margin from #root is enough — don't add another. */
  #root > .layout,
  #root > .app-shell { margin-left: 0; }
}
@media (max-width: 768px) {
  body > #root, body > #app { margin-left: 0; width: 100%; }
}
