/* TrnkeyAI Insight Hub — chrome (topbar / nav / drawer layout).
   Source of truth: DESIGN.MD §5 (Insight Hub row), §7 component recipes.
   Consumes tokens.css + components.css; every color here is var(--token) —
   no hardcoded hex, per R18. Author: A0.12. Do not import from any other
   template's chrome.css. */

/* ==========================================================================
   1. Topbar shell — sticky 64px, glass-over-gradient (DESIGN §4.1/§5)
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 64px;
  background: var(--card);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1400px;
  height: 100%;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ---- left cluster: logo + company switcher + refresh ---- */

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.topbar-logo-link {
  display: inline-flex;
  align-items: center;
}

.topbar-logo {
  height: 36px;
  width: auto;
}

.company-switcher {
  max-width: 11rem;
  padding: 0.375rem 0.5rem;
  font-size: var(--text-xs);
}

/* ---- center cluster: pill nav ---- */

.topbar-nav {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
}

.pill-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  max-width: 100%;
  background: var(--secondary);
  border-radius: 999px;
  padding: 0.25rem;
  overflow-x: auto;
}

.pill-nav-item {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.875rem;
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--foreground);
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.pill-nav-item:hover {
  background: color-mix(in srgb, var(--card-solid) 40%, transparent);
}

.pill-nav-item.is-active,
.pill-nav-item[aria-current="page"] {
  background: var(--primary);
  color: var(--primary-foreground);
}

/* ---- right cluster: admin gear, chat, export, alerts, avatar ---- */

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

.topbar-icon-btn {
  position: relative;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 8px;
  font-size: 1rem;
  line-height: 1;
}

/* ==========================================================================
   2. Dropdown menus — admin gear, avatar (click-toggled via chrome script)
   ========================================================================== */

.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 55;
  min-width: 12rem;
  padding: 0.375rem;
  display: none;
}

.dropdown.is-open .dropdown-menu {
  display: block;
}

.dropdown-menu a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: var(--text-sm);
  color: var(--foreground);
  text-decoration: none;
}

.dropdown-menu a:hover {
  background: var(--secondary);
}

.dropdown-menu a.is-active,
.dropdown-menu a[aria-current="page"] {
  /* text darkened toward --foreground to clear 4.5:1 on the tinted background,
     same fix as the sidebar/rail active-nav pattern in the other three templates,
     without touching the --primary brand token itself. */
  color: color-mix(in srgb, var(--primary) 75%, var(--foreground) 25%);
  font-weight: 600;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.theme-icon-dark {
  display: none;
}

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

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

.avatar-trigger {
  all: unset;
  cursor: pointer;
}

.avatar-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: var(--text-xs);
  font-weight: 600;
}

/* ==========================================================================
   3. Alerts hovercard preview (CSS-only open via .hovercard, DESIGN §7.8)
   ========================================================================== */

.alerts-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--destructive);
  color: var(--primary-foreground);
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 1;
}

.alerts-hovercard {
  width: 20rem;
}

.hovercard-title {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 0.625rem;
}

.alerts-preview-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.alerts-preview-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: var(--text-xs);
}

.alerts-preview-message {
  color: var(--foreground);
}

.alerts-preview-item:not(.is-unread) .alerts-preview-message {
  color: var(--muted);
}

.alerts-preview-empty {
  color: var(--muted);
  font-size: var(--text-xs);
}

/* ==========================================================================
   4. Content wrapper
   ========================================================================== */

.page-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ==========================================================================
   5. Mobile <640px — pill nav becomes a horizontal scroll strip
   ========================================================================== */

@media (max-width: 640px) {
  .topbar {
    height: auto;
  }

  .topbar-inner {
    flex-wrap: wrap;
    padding: 0.5rem 1rem;
    row-gap: 0.5rem;
  }

  .topbar-brand {
    order: 1;
  }

  .topbar-actions {
    order: 2;
    margin-left: auto;
  }

  .company-switcher {
    max-width: 7rem;
  }

  .topbar-nav {
    order: 3;
    width: 100%;
    justify-content: flex-start;
  }

  .pill-nav {
    width: 100%;
    justify-content: flex-start;
  }

  .page-main {
    padding: 1rem;
  }
}

/* ==========================================================================
   9. Chat drawer — header actions + full-screen toggle (R42)
   Base .drawer/.drawer-header live in components.css (shared, do not
   edit); this file only adds the header action cluster and the
   full-screen presentation, both scoped to the chat drawer.
   ========================================================================== */

.drawer-header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

#chat-drawer.is-fullscreen {
  inset: 0;
  width: auto;
  max-width: none;
  border-left: none;
  transition: transform 0.25s ease, inset 0.2s ease;
}
