/*
 * Expeditions Calculator - Bootstrap 5 Styles
 * Migrated from jQuery UI to Bootstrap 5.3.8
 * Shared pieces (.main-header, .subheader, .lined tables, warning banner)
 * follow the same conventions as the moon / graviton calculators. The tooltip
 * skin is not restated here - it lives once in css/common.css.
 */

#expeditions {
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
  position: relative;
  overflow-x: auto;
}

/* The results table is the widest content on the page, so the settings panel
   must not inflate #expeditions' max-content width: width:0 removes its
   contribution and min-width stretches it back. The m-1 utility adds 0.25rem
   margin per side, so subtract 0.5rem to keep the outer box within the parent. */
#settings-panel,
#api-accordion {
  width: 0;
  min-width: calc(100% - 0.5rem);
  box-sizing: border-box;
}

/* Stack both parameter tabs in the same grid cell so the widest and tallest one
   sizes the panel once and for all. Bootstrap hides inactive panes with
   display:none, which would drop them out of that intrinsic sizing and make the
   whole (max-content, centred) calculator jump on every tab switch, so they are
   hidden with visibility instead. */
#paramTabContent {
  display: grid;
}

#paramTabContent > .tab-pane {
  display: block;
  grid-area: 1 / 1;
}

/* Collapsed to zero height so only the active pane drives the panel height,
   while the grid column still sizes to the widest pane. */
#paramTabContent > .tab-pane:not(.active) {
  visibility: hidden;
  height: 0;
  overflow: hidden;
}

.main-header {
  width: auto;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 4px;
  margin: 2px;
}

.subheader {
  text-align: center;
  font-weight: 600;
  margin: 0 0 6px 0;
  padding: 2px 6px;
}

#reset {
  cursor: pointer;
  z-index: 10;
  width: 30px;
  height: 30px;
  border: 1px solid #dc3545;
  border-radius: 8px;
  margin-right: 0.2rem;
}

/* Layout tables: tighten the default cell padding and align vertically. */
#expeditions table td {
  padding: 2px 4px;
  vertical-align: middle;
}

/* Table styling (shared with the queue / costs / production calculators) */
.lined {
  border-collapse: collapse;
}

.lined th {
  background-color: var(--bs-tertiary-bg);
  font-weight: 600;
  padding: 2px 8px;
  border: 1px solid var(--bs-border-color);
  text-align: center;
}

.lined td {
  border: 1px solid var(--bs-border-color);
  padding: 2px 8px;
  white-space: nowrap;
}

/* Bootstrap scopes --bs-table-striped-bg to .table, so it resolves to nothing
   here; mix the stripe off the body colour instead, which flips with the theme. */
.lined tr.odd {
  background-color: color-mix(in srgb, var(--bs-body-color) 7%, transparent);
}

.lined tr.even {
  background-color: transparent;
}

/* The fleet table and the totals under it read as one table: the stack is as
   wide as the wider of the two (the fleet table), both fill it, and the
   totals drop their top border so the seam is a single line. On a phone the
   stack is held to the screen: the fleet table scrolls in its .pfg-scroll-x
   wrapper, and the totals - two columns of label and value - fit as they are,
   which is why they are a table of their own. */
.results-stack {
  width: max-content;
  max-width: 100%;
  margin-inline: auto;
}

#totals-table tr:first-child > td {
  border-top-width: 0;
}

/* Compact controls placed inside .lined tables */
.lined .form-control-sm {
  height: 1.5rem;
  min-height: unset;
  padding-top: 0;
  padding-bottom: 0;
}

/* Inputs */
.level-input {
  width: 60px;
  text-align: center;
}

.count-input {
  width: 80px;
  text-align: center;
}

/* Bootstrap's input-group overrides width utilities that are not id-scoped, so
   the percentage fields inside one get their own rule. */
.input-group > .form-control.percent-input {
  flex: 0 0 auto;
  width: 60px;
  text-align: center;
}

/* Clearing the fleet sits in the "number" column header. */
.clear-fleet-btn {
  padding: 0 4px;
  line-height: 1;
  vertical-align: middle;
}

/* The API table carries prose, so let it wrap instead of stretching the page. */
#api-table td {
  white-space: normal;
}

/* Warning banner (shared look with the moon / graviton calculators) */
#warning {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 10px 20px;
  text-align: center;
  background-color: var(--bs-warning-bg-subtle);
  border: 1px solid var(--bs-warning-border-subtle);
  border-radius: var(--bs-border-radius);
  color: var(--bs-body-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 300px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease-in-out;
}

#warning.visible {
  opacity: 1;
  pointer-events: auto;
  display: block;
}

/* Responsive */
@media (max-width: 992px) {
  #expeditions {
    max-width: 100%;
    padding: 0 10px;
  }

  /* Phone layout (docs/patterns.md): the cargo bonus table scrolls inside its
     .pfg-scroll-x wrapper, so the stacked panes' grid column must not grow to
     the table's width - an auto track would. */
  #paramTabContent {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Phone layout (docs/patterns.md). The results table scrolls sideways in
   its .pfg-scroll-x wrapper; its headers and the long labels of the total
   rows wrap and its cells tighten, so there is less of it to scroll. The
   ship names stay on one line - wrapped, they doubled the rows' height and
   the table still did not fit. The percent fields keep their "%" beside
   them: a squeezed input-group wraps it under the field. */
@media (max-width: 575.98px) {
  #data-table th,
  #totals-table td {
    white-space: normal;
  }

  #data-table th,
  #data-table td,
  #totals-table td {
    padding: 2px 4px;
  }

  /* A totals label is a single long word at worst ("Грузоподъёмность:"); with
     the numbers beside it, a wide font left it no room on a 360px screen. It
     may break inside the word, but only when it does not fit otherwise - not
     hyphens: auto, which hyphenated labels that would have wrapped at a space
     anyway. */
  #totals-table td:first-child {
    overflow-wrap: anywhere;
  }
}
