:root[data-bs-theme="light"] {
  --navbar-bg: #0d6efd; /* Blue background for light theme */
  --navbar-text-color: #ffffff; /* White text for contrast */
  --navbar-text-color-hover: #ffffff;
  
  --btn-responsive-bg: var(--navbar-bg);
  --btn-responsive-bg-hover: #0b5ed7; /* sligthly darker background for light theme (bootstrap's own btn-primary hover: 15% darker); used for buttons */
  /* The light theme hovers are darker, like bootstrap's own (15% darker where that keeps the text readable).
     All light theme button colours keep at least WCAG AA contrast (4.5:1) with their text, hovered or not.
     The hover text therefore stays white: dimmed (#ccc, as in the dark theme) it is only 3.6:1 on the hover blue */
  --btn-responsive-color: var(--navbar-text-color);
  --btn-responsive-color-hover: var(--navbar-text-color);
  
  /* one step darker than the striped table rows (#f2f2f2), so the button still stands out on them */
  --btn-responsive-grey-bg: var(--bs-gray-300);
  /* a bootstrap grey step darker; 15% darker (#bdc0c4) would leave its hover text (#495057) just under 4.5:1 */
  --btn-responsive-grey-bg-hover: var(--bs-gray-400);
  
  /* gray-500 with dark text: a lighter grey than bootstrap's btn-secondary (gray-600), which only white text allows
     (dark text on gray-600 is 3.3:1). Hovers 15% darker, like bootstrap's own */
  --btn-responsive-darkgrey-bg: var(--bs-gray-500);
  --btn-responsive-darkgrey-bg-hover: #939aa1;
  --btn-responsive-darkgrey-color: var(--bs-body-color);
  --btn-responsive-darkgrey-color-hover: black;
  
  /* its own lighter blue, not the (darker) button hover as in the dark theme: black row text on that is only 3.6:1 */
  --table-highlight-color: #007fff;
  --dropdown-submenu-1-bg: var(--bs-gray-100);
  --dropdown-submenu-2-bg: var(--bs-gray-200);

  --secondary-bg-color: var(--bs-light, #f8f9fa);
  --bg-color-hover: var(--bs-gray-200, #e9ecef);
  --highlight-color: var(--bs-gray-500, #adb5bd);
  --text-color: var(--bs-dark, #212529); 
  --border-color: var(--bs-gray-400, #ced4da); 
}

:root[data-bs-theme="dark"] {
  --navbar-bg: #024588; /* Darker blue background for dark theme */
  --navbar-text-color: var(--bs-body-color); /* Lighter text for dark theme */
  --navbar-text-color-hover: #ececec;
  
  --btn-responsive-bg: var(--navbar-bg);
  --btn-responsive-bg-hover: #024e9a; /* sligthly lighter background for dark theme; used for buttons */
  --btn-responsive-color: var(--navbar-text-color);
  --btn-responsive-color-hover: var(--bs-body-color);
  /* between gray-800 (#343a40) and gray-700: the previous tertiary-bg was the very colour of the striped table rows
     (#2c3034), so this is a step lighter, about as far from them as the light theme grey is */
  
  --btn-responsive-grey-bg: #383e44;
  --btn-responsive-grey-bg-hover: var(--bs-gray-700);
  
  /* bootstrap's btn-secondary colours swapped: its darker hover colour as base, hovering slightly lighter to gray-600
     (like the other dark theme buttons); still well apart from the grey button hover (gray-700) */
  --btn-responsive-darkgrey-bg: #5c636a;
  --btn-responsive-darkgrey-bg-hover: var(--bs-gray-600);
  --btn-responsive-darkgrey-color: var(--navbar-text-color);
  --btn-responsive-darkgrey-color-hover: var(--navbar-text-color-hover);

  --bs-primary: #66b2ff; /* Lighter blue for dark theme */
  --bs-primary-rgb: 102, 178, 255; 
  
  --table-highlight-color: var(--btn-responsive-bg-hover);
  --dropdown-submenu-1-bg: #363c42; /* one step above gray-800 (#343a40) */
  --dropdown-submenu-2-bg: #383f44; /* two steps above gray-800 */

  /* the following is aligned with the 3d_render repo */
  --secondary-bg-color: var(--bs-gray-800, #343a40);
  --bg-color-hover: var(--bs-gray-900, #212529);
  --highlight-color: var(--bs-dark-text-emphasis, #dee2e6);
  --text-color: var(--bs-light, #f8f9fa);
  --border-color: var(--bs-gray-700, #495057);
}


/* Apply these variables to the navbar */
.navbar {
  background-color: var(--navbar-bg) !important;
  color: var(--navbar-text-color);

  /* The nav-link colours, through bootstrap's own navbar variables rather than overriding its rules: those rules then
     use these in every state. A plain '.navbar .nav-link { color }' loses to e.g. '.navbar-nav .nav-link.show' (more
     specific), which turned an open dropdown's toggle black as soon as the mouse moved into its menu. */
  --bs-navbar-color: var(--navbar-text-color);
  --bs-navbar-hover-color: var(--navbar-text-color-hover); /* also on keyboard focus */
  --bs-navbar-active-color: var(--navbar-text-color); /* the current page, and a toggle while its dropdown is open */
}

.navbar-brand {
  padding: 2px 0;
}

/* NOTE an underline, not a colour: the '.navbar .nav-link' colour above is !important, so a hover colour never showed. */
/* One continuous line under the whole link: icon, the space after it, the text (and a dropdown arrow).
   A text-decoration underline cannot do that: it skips the icon (an inline-block) and the margin before the text.
   So it is a 1px background line along the bottom of the content box, a bit below the text.
   Subtle: thin and somewhat transparent (the currentColor line before is the fallback for browsers without color-mix).
   Only in the expanded navbar (navbar-expand-lg): in the collapsed menu a link spans the whole menu width, and the line
   with it; there the nav-item row highlight (below) marks the hover. */
@media (min-width: 992px) {
  .navbar .nav-link:hover {
    background-image: linear-gradient(currentColor, currentColor);
    background-image: linear-gradient(color-mix(in srgb, currentColor 40%, transparent),
                                      color-mix(in srgb, currentColor 40%, transparent));
    background-origin: content-box;
    background-position: 50% 110%;
    background-size: 90% 1px;
    background-repeat: no-repeat;
  }
}

@media (max-width: 991.98px) {
  .navbar .nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.25rem;
  }

  .nav-item {
    padding: 0 5px 0 5px;
    width: 270px;
  }
}

/* textual logo next to the image logo */
.navbar-brand-text {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 40px;
  z-index: 1;

  /* Align right edge of SVG to the left edge of .container */
  right: 100%; /* places it just outside the container */
}

.navbar-brand-text img {
  height: 100%;
}
.navbar-brand img {
  height: 50px;
  width: 50px;
  margin: 0;
  padding: 0;
}

.dropdown-toggle {
  cursor: pointer;
}

.navbar-toggler:focus {
  box-shadow: none;
  outline: none;
}

/* Show/hide logo based on [data-bs-theme] attribute */
[data-bs-theme="light"] .logo-dark {
  display: none;
}
[data-bs-theme="light"] .logo-light {
  display: inline;
}

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

/* Only show on large screens */
@media (max-width: 1650px) {
  .navbar-brand-text {
    display: none !important;
  }
}

.content {
  min-width: 25%;
}

h2 {
  margin-top: 0.25em;
}

h2.accordion-header {
  /* Offset the above for h2 */
  margin-top: 0;
}

h1 {
  margin-top: 0.5em;
}

hr.dashed {
  color: var(--highlight-color);
  border-top: var(--bs-border-width) dashed;
}

/* style boostrap buttons, because they are not responsive to light/dark */
.btn-responsive {
  background-color: var(--btn-responsive-bg) !important;
  color: var(--btn-responsive-color);
}

.btn-responsive:hover {
  background-color: var(--btn-responsive-bg-hover) !important;
  color: var(--btn-responsive-color-hover);
}

.btn-responsive-grey {
  background-color: var(--btn-responsive-grey-bg) !important;
  color: var(--bs-body-color);
}

.btn-responsive-grey:hover {
  background-color: var(--btn-responsive-grey-bg-hover) !important;
  color: var(--bs-light-text-emphasis);
}

/* a more prominent grey than btn-responsive-grey, e.g. for (un)marking reports as certified.
   Dark text in the light theme, white in the dark theme (see --btn-responsive-darkgrey-color), in both states:
   the dimmer navbar text colours would be too little contrast on these greys. */
.btn-responsive-darkgrey {
  background-color: var(--btn-responsive-darkgrey-bg) !important;
  color: var(--btn-responsive-darkgrey-color);
}

.btn-responsive-darkgrey:hover {
  background-color: var(--btn-responsive-darkgrey-bg-hover) !important;
  color: var(--btn-responsive-darkgrey-color-hover);
}

/* Delete buttons: grey like the other secondary buttons (btn btn-responsive-grey), only turning red
   (bootstrap's btn-danger) on hover, as a warning right before the click.
   The extra class makes it win over the (!important) .btn-responsive-grey:hover. */
.btn-responsive-grey.btn-responsive-delete:hover {
  background-color: var(--bs-danger) !important;
  color: #fff;
}


/* Style for nested dropdowns */
.dropdown-submenu {
  position: relative;
}

.dropdown-submenu > .dropdown-menu {
  position: absolute !important;
  top: 0;
  left: 100%;
  margin-top: -5px;
  margin-left: 0;
  background-color: var(--dropdown-submenu-1-bg);
}

.dropdown-submenu .dropdown-submenu > .dropdown-menu {
  background-color: var(--dropdown-submenu-2-bg);
}

/* On mobile, Bootstrap forces dropdown-menu to static inside the collapsed navbar,
   so we re-apply absolute positioning and prevent the parent from clipping the submenu */
@media (max-width: 991.98px) {
  .dropdown-submenu > .dropdown-menu {
    top: 0;
    left: 100%;
    margin-top: 0;
  }

    .dropdown-menu {
      overflow: visible !important;
  }
}

.dropdown-submenu > .dropdown-toggle::after {
  transition: transform 0.2s ease;
}

.dropdown-submenu > .dropdown-toggle[aria-expanded="true"]::after {
  transform: rotate(-90deg); /* submenu opens to the right, so caret points right when open */
}

iframe {
  width: 100%; 
  height: 80vh; 
  border: 1px solid #ccc; 
  border-radius: 5px;
}

.h2-icon {
  vertical-align: top;
  font-size: 0.4em;
  opacity: 0.8; 
}


.d-flex.flex-nowrap button {
  white-space: nowrap; /* Prevents text from wrapping */
  overflow: hidden; /* Ensures text doesn’t overflow */
  text-overflow: ellipsis; /* Adds "..." if text is too long */
}




.spinner-container {
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner-smaller {
  height: 1.8em;
  width: 1.8em;
  max-height: 100%; /* Ensure it doesn't overflow */
  max-width: 100%; /* Ensure it doesn't overflow */
}



/* Highlight <th> with colspan > 1 inside a table with class="table table-striped" */
table.table.table-striped th[colspan]:not([colspan="1"]) {
    background-color: var(--bs-table-striped-bg); 
    border-width: var(--bs-border-width);
    border-color: var(--bs-border-color);
}

/* Hide background and borders for <th> with colspan="1" */
table.table.table-striped th[colspan="1"] {
    background-color: transparent !important; /* Hide background */
    border: none !important; /* Hide all borders */
}


.bootstrap-table .fixed-table-container .table thead th .sortable {
    cursor: pointer;
    background-position: right;
    background-repeat: no-repeat;
    /* padding-right: 30px !important; */
}





/* Custom breakpoint for xxxl (e.g., >1920px) */
@media (min-width: 2000px) {
  .col-xxxl-1 { width: 8.333333%; }
  .col-xxxl-2 { width: 16.666667%; }
  .col-xxxl-3 { width: 25%; }
  .col-xxxl-4 { width: 33.333333%; }
  /* Add more as needed */
}


.bootstrap-table .table tbody tr.row-selected td {
    background-color: var(--table-highlight-color) !important;
}

/* Searchable select: a search input + dropdown list layered on top of a native <select>.
   The select itself stays in the form (and gets submitted), it is only hidden. See searchableSelect.js */
.searchable-select-native {
  display: none;
}

.searchable-select .searchable-select-menu {
  /* positioned by hand; this dropdown is not driven by the bootstrap dropdown plugin/popper */
  top: 100%;
  left: 0;
  /* --searchable-select-space is the room left under the search box, measured in searchableSelect.js.
     It keeps the list clear of the mobile keyboard, which vh units do not account for. */
  max-height: min(30rem, 80vh, var(--searchable-select-space, 100vh));
  overflow-y: auto;
}

.searchable-select .searchable-select-item {
  cursor: pointer;
  white-space: normal; /* long ship names wrap instead of being cut off */
}
