/* ============================================
   Bot Families — Tree Layout
   Dark theme, category trees with branches
   ============================================ */

/* ---------- Reset & base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0a0a1a;
  color: #e2e8f0;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ---------- Header ---------- */
.fam-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: rgba(15, 15, 35, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.fam-back {
  color: #94a3b8;
  font-size: 0.875rem;
  white-space: nowrap;
  transition: color 0.2s;
}

.fam-back:hover {
  color: #e2e8f0;
}

.fam-header-center {
  flex: 1;
  text-align: center;
}

.fam-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #f1f5f9;
}

.fam-subtitle {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 0.15rem;
}

.fam-header-right {
  white-space: nowrap;
}

.header-login-btn {
  font-size: 0.8rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: #cbd5e1;
  transition: background 0.2s, color 0.2s;
}

.header-login-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
}

/* ---------- Stats bar ---------- */
.fam-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  padding: 0.75rem 1rem;
  background: rgba(15, 15, 35, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.8rem;
  color: #94a3b8;
  flex-wrap: wrap;
}

.fam-stat {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.fam-stat-value {
  font-weight: 700;
  color: #f1f5f9;
}

.fam-stat-label {
  color: #64748b;
}

/* ---------- Layout ---------- */
.fam-layout {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
  gap: 1rem;
}

/* ---------- Sidebar / quick-jump ---------- */
.fam-sidebar {
  width: 200px;
  flex-shrink: 0;
  position: sticky;
  top: 80px;
  align-self: flex-start;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 0.5rem;
}

.fam-sidebar::-webkit-scrollbar {
  width: 4px;
}

.fam-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.fam-jump-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.78rem;
  color: #94a3b8;
  transition: background 0.2s, color 0.2s;
  cursor: pointer;
}

.fam-jump-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

.fam-jump-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.fam-jump-count {
  margin-left: auto;
  font-size: 0.7rem;
  color: #475569;
}

/* ---------- Tree container ---------- */
.fam-trees {
  flex: 1;
  min-width: 0;
}

/* ---------- Family section ---------- */
.fam-section {
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  background: rgba(15, 15, 35, 0.5);
  overflow: hidden;
}

/* --- Category header (tree root) --- */
.fam-cat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.fam-cat-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.fam-cat-color {
  width: 4px;
  height: 28px;
  border-radius: 2px;
  flex-shrink: 0;
}

.fam-cat-name {
  font-size: 1rem;
  font-weight: 600;
  color: #f1f5f9;
  flex: 1;
}

.fam-cat-count {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  color: #e2e8f0;
}

.fam-cat-toggle {
  font-size: 0.75rem;
  color: #64748b;
  transition: transform 0.3s;
}

.fam-section.collapsed .fam-cat-toggle {
  transform: rotate(-90deg);
}

.fam-cat-cart-btn {
  font-size: 0.7rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  color: #94a3b8;
  background: transparent;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.fam-cat-cart-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
}

/* --- Tree body (branch list) --- */
.fam-tree-body {
  padding: 0 1rem 0.75rem 1rem;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.35s ease, opacity 0.25s ease;
  max-height: 2000px;
  opacity: 1;
}

.fam-section.collapsed .fam-tree-body {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

/* --- Tree structure --- */
.fam-branch-list {
  list-style: none;
  position: relative;
  padding-left: 20px;
}

/* Vertical trunk line */
.fam-branch-list::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 12px;
  width: 2px;
  border-radius: 1px;
}

/* Individual branch item */
.fam-branch {
  position: relative;
  padding: 0.35rem 0 0.35rem 20px;
}

/* Horizontal branch connector */
.fam-branch::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  width: 18px;
  height: 2px;
}

/* Bot node */
.fam-bot-node {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  transition: background 0.2s;
  cursor: pointer;
  position: relative;
}

.fam-bot-node:hover {
  background: rgba(255, 255, 255, 0.06);
}

.fam-bot-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  object-fit: cover;
  flex-shrink: 0;
}

.fam-bot-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: #e2e8f0;
}

.fam-bot-slug {
  font-size: 0.7rem;
  color: #64748b;
  margin-left: auto;
}

/* --- Tooltip on hover --- */
.fam-bot-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e1e3a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: #cbd5e1;
  white-space: nowrap;
  z-index: 50;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  margin-bottom: 6px;
}

.fam-bot-node:hover .fam-bot-tooltip {
  display: block;
}

.fam-tooltip-strengths {
  color: #94a3b8;
  margin-top: 0.2rem;
}

.fam-tooltip-strength {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  margin: 0.1rem 0.1rem 0 0;
  font-size: 0.68rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .fam-sidebar {
    display: none;
  }

  .fam-layout {
    padding: 0.5rem;
  }

  .fam-header {
    padding: 0.5rem 1rem;
  }

  .fam-subtitle {
    display: none;
  }

  .fam-stats {
    gap: 1rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
  }

  /* Simpler indented list on mobile — no tree lines */
  .fam-branch-list {
    padding-left: 0.5rem;
  }

  .fam-branch-list::before {
    display: none;
  }

  .fam-branch::before {
    display: none;
  }

  .fam-branch {
    padding-left: 0.25rem;
  }

  .fam-bot-slug {
    display: none;
  }

  .fam-bot-tooltip {
    display: none !important;
  }

  .fam-cat-cart-btn {
    display: none;
  }
}

@media (max-width: 480px) {
  .fam-title {
    font-size: 1rem;
  }

  .fam-bot-avatar {
    width: 26px;
    height: 26px;
  }

  .fam-bot-name {
    font-size: 0.8rem;
  }
}

/* ---------- Scroll anchor offset ---------- */
.fam-section[id] {
  scroll-margin-top: 90px;
}

/* ---------- Animations ---------- */
@media (prefers-reduced-motion: reduce) {
  .fam-tree-body,
  .fam-cat-toggle {
    transition: none;
  }
}
