/* Project Cockpit — Excel-/Acrobat-style tab bar.
 *
 * Two anchor tabs ("Übersicht", "Project Agent") on the left, then
 * one workspace tab per open Editor::AgentWorkspace. "+" at the end.
 * Active indicator: 2px brand-blue underline.
 *
 * The global html scrollbar/centring fix that previously lived in
 * this file moved to theme.css — it's not project-specific.
 */

.project-cockpit {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.project-tab-bar {
  display: flex;
  align-items: stretch;
  gap: 2px;
  border-bottom: 1px solid var(--tblr-border-color, #e6e7e9);
  /* overflow-x: auto implicitly upgrades overflow-y from visible to auto
     (CSS spec). With our 1px content/padding/border mismatch the browser
     would paint a vertical scrollbar at the right edge. clip prevents
     that without disabling horizontal scrolling. */
  overflow-x: auto;
  overflow-y: clip;
  scrollbar-width: thin;
  margin-top: 0.5rem;
}

.project-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.875rem;
  border: none;
  background: transparent;
  color: var(--tblr-secondary, #626976);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; /* overlaps the bar's bottom border so active underline aligns */
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.project-tab:hover {
  background-color: rgba(2, 108, 255, 0.06);
  color: var(--tblr-body-color, #1d273b);
}

.project-tab--active {
  color: #026CFF;
  border-bottom-color: #026CFF;
  background-color: rgba(2, 108, 255, 0.04);
}

.project-tab--anchor {
  font-weight: 600;
}

.project-tab__activator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: none;
  background: transparent;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  min-width: 0; /* let the label truncate inside flex */
}

.project-tab__label {
  display: inline-block;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.project-tab__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  margin-left: 0.25rem;
  border: none;
  background: transparent;
  border-radius: 4px;
  color: var(--tblr-secondary, #626976);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, background-color 0.12s ease;
}

.project-tab:hover .project-tab__close,
.project-tab--active .project-tab__close {
  opacity: 0.7;
}

.project-tab__close:hover {
  opacity: 1;
  background-color: rgba(220, 53, 69, 0.12);
  color: var(--tblr-danger, #d63939);
}

.project-tab__add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--tblr-secondary, #626976);
  text-decoration: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.project-tab__add:hover {
  background-color: rgba(2, 108, 255, 0.08);
  color: #026CFF;
}

.project-tab-panels {
  flex: 1 1 auto;
  min-height: 400px;
  padding-top: 0.5rem;
  /* The bottom padding gives tab content (esp. the last card on the
     Overview, which shows a drop-shadow) room to breathe — without it
     the shadow gets clipped by the panel container as the card grows. */
  padding-bottom: 1.5rem;
  /* Children may use Bootstrap rows whose negative margins peek beyond
     the container's content area; clip them so we don't paint a tiny
     horizontal scrollbar on the page body. */
  overflow-x: hidden;
}

/* turbo-frame defaults to display:inline which makes it shrink-to-fit
   and breaks width: 100% on flex children. Force block. */
.project-tab-panel {
  display: block;
  width: 100%;
}

.project-tab-panel[hidden] {
  display: none !important;
}

/* Turbo toggles aria-busy="true" on the frame while it fetches its
   src. Use that to paint a centred spinner so the tab doesn't sit
   empty while the panel content is loading. */
.project-tab-panel[aria-busy="true"] {
  position: relative;
  min-height: 240px;
}

.project-tab-panel[aria-busy="true"]::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  margin-top: -16px;
  margin-left: -16px;
  border: 3px solid var(--tblr-border-color, #e6e7e9);
  border-top-color: #026CFF;
  border-radius: 50%;
  animation: project-tab-spin 0.8s linear infinite;
}

@keyframes project-tab-spin {
  to { transform: rotate(360deg); }
}

.project-workspace-row {
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.project-workspace-row:hover {
  background-color: rgba(2, 108, 255, 0.04);
}

/* ==========================================================================
   Cockpit Focus Mode
   ==========================================================================
   On the project show page the sidebar gets out of the way so the
   cockpit can use the full width. A small hamburger button slides it
   back in as an overlay. Driven by `cockpit_focus_controller.js`. */

/* Hamburger inside the project tab bar — sits in the tab strip
   itself, so it stays visually quiet (no border/background) and
   borrows the tab-style hover. */
.project-tab__menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  padding: 0;
  margin-right: 0.25rem;
  border: none;
  background: transparent;
  color: var(--tblr-secondary, #626976);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.project-tab__menu:hover {
  background-color: rgba(2, 108, 255, 0.08);
  color: #026CFF;
}

/* Floating equivalent for project-scoped pages without a tab bar
   (memberships, settings). Same look so the hamburger feels like the
   same control. */
.cockpit-focus-trigger {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 1060;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--tblr-border-color, #e6e7e9);
  border-radius: 6px;
  background: #fff;
  color: var(--tblr-secondary, #626976);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.cockpit-focus-trigger:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
  color: #026CFF;
}

.cockpit-focus-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.32);
  z-index: 1040;
}

body.cockpit-focus .navbar-vertical {
  transform: translateX(-100%);
  transition: transform 200ms ease-out;
}

/* Keep specificity higher than theme.css's
   `body.sidebar-is-collapsed .page-wrapper` rule so the cockpit-focus
   override wins regardless of whether the user previously collapsed
   the sidebar from another page. */
body.cockpit-focus .page-wrapper,
body.cockpit-focus.sidebar-is-collapsed .page-wrapper {
  margin-left: 0 !important;
}

body.cockpit-focus.cockpit-focus--sidebar-shown .navbar-vertical {
  transform: translateX(0);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  z-index: 1050;
}

body.cockpit-focus--sidebar-shown .cockpit-focus-backdrop {
  display: block;
}
