/* ============================================================================
   SWIMMING LANE DIAGRAM VIEWER
   ----------------------------------------------------------------------------
   1) Reset & base layout
   2) Sticky page header
   3) Main flex container
   4) Fixed‐size, scrolling diagram pane
   5) Attempt to sticky‐freeze the SVG actor‐header <g>
   6) Download/Edit controls
   7) Footer
   ============================================================================ */

/* ----------------------------------------------------------------------------
   1) GLOBAL RESET & BASE LAYOUT
   ----------------------------------------------------------------------------
   - Remove default margins/padding
   - Body = full viewport, column flex so header/main/footer stack
   ---------------------------------------------------------------------------- */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: Arial, sans-serif;
  background-color: #f4f4f9;
  color: #333;
}
body {
  display: flex;
  flex-direction: column;
}

/* ----------------------------------------------------------------------------
   2) HEADER
   ----------------------------------------------------------------------------
   - Sticky to top of viewport
   - Full width
   ---------------------------------------------------------------------------- */
header {
  background-color: #007acc;
  height:60px;
  color: white;
  padding: 0.5rem 0;   /* smaller header height */
  text-align: center;
  position: sticky;    /* remain visible */
  top: 0;
  z-index: 10;         /* above everything else */
}

/* --------------------------------------------------------------
   SELECTION BAR
   -------------------------------------------------------------- */
.selection-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #e9eef3;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid #c0c0c0;
  position: sticky;     
  top: 3rem;            
  z-index: 9;
}
.selection-bar select,
.selection-bar button {
  padding: 0.3rem 0.5rem;
}

/* Collapsible menu inside the selection bar */
.menu-wrapper {
  position: relative;
}
.menu-toggle {
  padding: 0.3rem 0.6rem;
  color: #ffffff;
  background-color: #005fa3;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
}
.menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: #e9eef3;
  border: 1px solid #c0c0c0;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 100;
}
.menu.collapsed {
  display: none;
}
.menu button {
  width: 150px;
  padding: 0.4rem 0.8rem;
  color: #ffffff;
  background-color: #005fa3;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  text-align: left;
}
.menu button:hover {
  background-color: #003f73;
}

/* ----------------------------------------------------------------------------
   3) MAIN VIEWER REGION
   ----------------------------------------------------------------------------
   - Row‐flex: sidebar + diagram + controls
   - Children stretch full height
   - Allow children’s scrollbars to appear
   ---------------------------------------------------------------------------- */
main.diagram-container {
  flex: 1;                   /* fill space between header & footer */
  display: flex;
  flex-direction: row;
  align-items: stretch;      /* children fill height */
  height: calc(100vh - 200px); /* keep container within viewport */
  overflow: visible;         /* don’t clip child scrollbars */
  padding: 1rem 2rem;
  gap: 1rem;
}

/* ----------------------------------------------------------------------------
   4) SIDEBAR (project/flow selects & meta info)
   ----------------------------------------------------------------------------
   - Fixed width + height
   - Scrollbars when content overflows
   ---------------------------------------------------------------------------- */
.meta-box {
  width: 400px;                                 /* default width */
  height: calc(100vh - 200px);                  /* full viewport minus header/footer/selects */
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  transition: width 0.3s ease;

  overflow-x: auto;                             /* horizontal scroll if needed */
  overflow-y: auto;                             /* vertical   scroll if needed */
}
.meta-box.collapsed {
  width: 0;
  padding: 0;
  overflow: hidden;
  border: none;
}

/* ----------------------------------------------------------------------------
   5) DIAGRAM PANE (.flow-diagram-wrapper)
   ----------------------------------------------------------------------------
   - Fixed size
   - Internal scrollbars (both axes)
   ---------------------------------------------------------------------------- */


.flow-diagram-wrapper {
  flex: 1;                                      /* take remaining space */
  height: calc(100vh - 200px);                  /* match sidebar height */
  overflow: auto;                               /* scrollbars inside wrapper */

  position: relative;                           /* for sticky children */
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* ----------------------------------------------------------------------------
   5a) SVG ITSELF
   ----------------------------------------------------------------------------
   - Let it size to its natural dimensions so it can overflow
   ---------------------------------------------------------------------------- */
#svgDiagram {
  display: block;      /* remove inline whitespace */
  width: max-content;  /* intrinsic width */
  height: max-content; /* intrinsic height */
}

/* ----------------------------------------------------------------------------
   5b) ATTEMPT STICKY HEADER FOR YOUR SVG <g> GROUP
   ----------------------------------------------------------------------------
   We assume the first <g> in your SVG is the actor header row.
   If your renderer adds a class to that <g>, replace `:nth-child(1)` with
   `.<your-class>` for more precision.
   ---------------------------------------------------------------------------- */
.flow-diagram-wrapper #svgDiagram > g:nth-child(1) {
  position: sticky;    /* try to pin this group inside the scroll box */
  top: 0;              /* distance from top of .flow-diagram-wrapper */
  z-index: 5;          /* float above other SVG elements */
  /* you can also force a background rect inside this <g> to cover what scrolls under */
}

/* ----------------------------------------------------------------------------
   6) DOWNLOAD / EDIT BUTTONS
   ---------------------------------------------------------------------------- */
.download-controls {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.download-controls button {
  width: 150px;
  padding: 0.4rem 0.8rem;
  color: #ffffff;
  background-color: #005fa3;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  text-align: center;
}
.download-controls button:hover {
  background-color: #003f73;
}


/* ----------------------------------------------------------------------------
   7) FOOTER
   ----------------------------------------------------------------------------
   - Sticky to bottom if content is short
   ---------------------------------------------------------------------------- */
footer {
  background-color: #333;
  height:50px;
  color: white;
  text-align: center;
  padding: 1rem 0;
  position: sticky;    /* pin to bottom */
  bottom: 0;
  z-index: 10;
}

/* ----------------------------------------------------------------------------
   8) NAV‐LINK UTILITY
   ---------------------------------------------------------------------------- */
.nav-link {
  color: #ffffff;
  text-decoration: none;
  background-color: #005fa3;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-weight: bold;
  display: inline-block;
  margin-right: 1rem;
}
.nav-link:hover {
  background-color: #003f73;
}
