/* ═══════════════════════════════════════════════════════════════
   Intel HQ — 3-Column Layout System
   Transforms the default single-column Intel HQ into a polished
   3-column dashboard: Competitors | Content | Stats+Actions
   ═══════════════════════════════════════════════════════════════ */

/* ── Override .hq-wrap to 3-column grid ── */
.hq-wrap.three-col {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  grid-template-rows: auto 1fr;
  gap: 0 22px;
  max-width: 1440px;
  padding: 24px 28px 80px;
  align-items: start;
}

/* Header spans full width */
.hq-wrap.three-col .hq-header {
  grid-column: 1 / -1;
  margin-bottom: 20px;
}

/* ── Left Sidebar: Competitors ── */
.hq-sidebar-left {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.hq-sidebar-left::-webkit-scrollbar { width: 3px; }
.hq-sidebar-left::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

.sidebar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.sidebar-card-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Competitor list items */
.comp-sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: default;
  transition: all 0.15s;
  margin-bottom: 3px;
}
.comp-sidebar-item:hover {
  background: var(--bg-card2);
}
.comp-sidebar-item.active {
  background: var(--accent-glow);
  border: 1px solid rgba(57,255,20,0.2);
}
.comp-sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(74,125,255,0.15), rgba(139,92,246,0.15));
  border: 1px solid rgba(74,125,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #7aadff;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
}
.comp-sidebar-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.comp-sidebar-signals {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  margin-left: auto;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

/* Quick nav in left sidebar */
.sidebar-quick-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}
.sidebar-nav-link:hover {
  background: var(--bg-card2);
  color: var(--text-primary);
}
.sidebar-nav-link.active {
  background: var(--accent-glow);
  color: var(--accent);
}
.sidebar-nav-link .nav-emoji {
  font-size: 13px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-nav-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: auto;
}

/* ── Center Column ── */
.hq-center {
  min-width: 0;
}

/* Upgraded tabs for 3-col layout */
.hq-wrap.three-col .hq-tabs {
  margin-bottom: 20px;
  background: rgba(13,17,32,0.7);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}

/* Remove old stats row when in 3-col mode */
.hq-wrap.three-col .stats-row {
  display: none;
}

/* ── Right Sidebar: Stats + Actions ── */
.hq-sidebar-right {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.hq-sidebar-right::-webkit-scrollbar { width: 3px; }
.hq-sidebar-right::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

/* Stats grid in right sidebar */
.sidebar-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.sidebar-stat-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 8px;
  text-align: center;
}
.sidebar-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.sidebar-stat-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

/* The Play card — highlighted recommended action */
.sidebar-the-play {
  background: linear-gradient(135deg, rgba(57,255,20,0.06) 0%, rgba(57,255,20,0.02) 100%);
  border: 1px solid rgba(57,255,20,0.3);
  border-radius: 10px;
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.sidebar-the-play::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
}
.sidebar-the-play-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sidebar-the-play-text {
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.65;
}
.sidebar-the-play-save {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

/* Recent Activity feed */
.sidebar-activity-item {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 11px;
  color: var(--text-secondary);
  align-items: flex-start;
  line-height: 1.45;
}
.sidebar-activity-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 4px;
}
.sidebar-activity-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 2px;
  display: block;
}

/* ── Brief Content Enhancements ── */
/* When inside 3-col page layout, brief overlay takes full center */
.hq-wrap.three-col .brief-overlay {
  margin-bottom: 0;
}
.hq-wrap.three-col .brief-overlay-header {
  margin-bottom: 16px;
  padding-bottom: 14px;
}

/* Override brief-3col inside 3-col page to be single column (sidebars are page-level) */
.hq-wrap.three-col .brief-3col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.hq-wrap.three-col .brief-nav-sidebar {
  display: none; /* Handled by page-level left sidebar */
}
.hq-wrap.three-col .brief-stats-sidebar {
  display: none; /* Handled by page-level right sidebar */
}

/* Enhanced signal cards in brief */
.brief-item {
  border-radius: 8px;
  transition: all 0.2s;
}
.brief-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ── Responsive ── */
@media (max-width: 1200px) {
  .hq-wrap.three-col {
    grid-template-columns: 240px 1fr 260px;
    gap: 0 18px;
    padding: 20px 20px 80px;
  }
}

@media (max-width: 1100px) {
  .hq-wrap.three-col {
    grid-template-columns: 210px 1fr 230px;
    gap: 0 14px;
    padding: 20px 16px 80px;
  }
}

@media (max-width: 960px) {
  .hq-wrap.three-col {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 16px 16px 80px;
  }
  .hq-wrap.three-col .hq-header {
    grid-column: 1;
  }

  /* Left sidebar: horizontal compact strip */
  .hq-sidebar-left {
    position: static;
    max-height: none;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    overflow: visible;
  }
  .hq-sidebar-left .sidebar-card {
    flex: 1;
    min-width: 200px;
  }
  .sidebar-quick-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }
  .sidebar-nav-link {
    white-space: nowrap;
  }

  /* Right sidebar: horizontal strip below content */
  .hq-sidebar-right {
    position: static;
    max-height: none;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
    order: 3;
    overflow: visible;
  }
  .hq-sidebar-right .sidebar-card,
  .hq-sidebar-right .sidebar-the-play {
    flex: 1;
    min-width: 200px;
  }

  /* Show brief overlay sidebars on mobile (since page sidebars collapse) */
  .hq-wrap.three-col .brief-3col {
    display: grid;
    grid-template-columns: 1fr;
  }
  .hq-wrap.three-col .brief-nav-sidebar {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    padding: 10px 12px;
    position: static;
  }
  .hq-wrap.three-col .brief-nav-sidebar .brief-nav-title { display: none; }
  .hq-wrap.three-col .brief-nav-sidebar .brief-nav-item { display: inline-flex; white-space: nowrap; margin-bottom: 0; }
  .hq-wrap.three-col .brief-stats-sidebar {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    position: static;
  }
  .hq-wrap.three-col .brief-stats-sidebar > * {
    flex: 1;
    min-width: 180px;
  }

  /* Restore stats row on mobile */
  .hq-wrap.three-col .stats-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 500px) {
  .hq-sidebar-left .sidebar-card,
  .hq-sidebar-right .sidebar-card,
  .hq-sidebar-right .sidebar-the-play {
    min-width: 100%;
  }
}
