/* -*- css-indent-offset: 2 -*- */

/*
 * GENERAL LOOKS - used in all parts of SUPR
 */

/* Declare colours at the top */
:root {
  --supr-bg-user: #ffffff;
  --supr-bg-highlight: #ffffe0;
  --supr-bg-highlight-darker: #f8f8d8;
  --supr-bg-links-header: #f0f0f0;
  --supr-bg-instancewarning: #f0d0d0;
  --supr-border-show: #e9ecef;
  --supr-border-listing: #a0a0a0;
  --supr-leftpanelheight: calc(100vh);
  --supr-leftpanelwidth: 15rem;
  --supr-contentwidth-nopanel: calc(100vw - 2.5rem);
  --supr-contentwidth-panel: calc(100vw - 2.5rem - var(--supr-leftpanelwidth));
  --supr-contentwidth: var(--supr-contentwidth-panel);
  --supr-contentheight: calc(100vh - var(--supr-headerheight));
  --supr-headerheight: 3.5rem;
  --supr-label-fontweight: 600;
  scroll-padding-top: var(--supr-headerheight);
}

/* Warning colour if turned on? */
body {
  background: var(--supr-bg-user);
  &.instancewarning {
    --supr-bg-user: var(--supr-bg-instancewarning) !important;
  }
}

/*
 * Override jquery-ui font settings
 */

.ui-widget {
  font-family: var(--bs-body-font-family) !important;
}

/*
 * Utility class
 */
.supr-label-fw {
  font-weight: var(--supr-label-fontweight);
}

/*
 * Text is hard to read if the column is too wide.
 * At the same time, we do not want to prohibit wide tables.
 * Instead of using <br> to introduce arbitrary line breaks,
 * place text in a div with a fixed max width.
 */

div.supr-nag-card,
div.supr-ua-card,
div.supr-doc-instructions-card {
  max-width: var(--supr-contentwidth);
  width: fit-content;
}

.narrow_text {
  max-width: min(var(--supr-contentwidth), 44rem) !important;
}

/* Turn off spinners on number fields
 *   http://stackoverflow.com/questions/3790935/can-i-hide-the-html5-number-input-s-spin-box
 */

input[type="number"] {
  -moz-appearance: textfield;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

/*
 * BOOTSTRAP-BASED TOP-LEVEL DESIGN
 */

/* LEFT COLUMN
 * Logos and menu
 */

#supr-page-row {
  grid-template-columns: var(--supr-leftpanelwidth) calc(
      100vw - var(--supr-leftpanelwidth) - 1rem
    );
  &.panel-hiding {
    grid-template-columns: 0 calc(100vw - 1rem) !important;
  }
  &.panel-showing {
    grid-template-columns: var(--supr-leftpanelwidth) calc(
        100vw - var(--supr-leftpanelwidth) - 1rem
      ) !important;
  }
}

div#supr-left-column {
  width: var(--supr-leftpanelwidth);
  min-width: var(--supr-leftpanelwidth);
  padding-bottom: 1rem;
  padding-top: 1rem;
  padding-left: 0rem;
  position: sticky;
  top: 0;
  left: 0;
  align-content: start;
  max-height: var(--supr-leftpanelheight);
  height: var(--supr-leftpanelheight);
  & > * {
    grid-column: 2/15;
  }
  & > #supr-menu {
    & a,
    div.supr-menu-alternative {
      grid-column: 2/13;
    }
  }
  & > #supr-menu > .supr-menu-subtitle {
    grid-column: 1/13;
  }
  &.panel-hiding {
    display: none !important;
  }
}

div#supr-menu {
  overflow: auto;
  scrollbar-gutter: stable;
  max-height: min(calc(var(--supr-leftpanelheight) - 15rem), 100%);
  min-height: 5rem;
}

body.user div#supr-left-column {
}

body.admin div#supr-left-column {
  background: var(--supr-bg-highlight);
}

/*
 *  Logotypes in their "normal" left-menu context
 */

div#naiss-logotype a {
  color: black;
}

div#supr-logotype {
  margin-left: 1.2rem;
  margin-bottom: 0.8rem;
  margin-top: 0.6rem;
}

div#supr-logotype img {
  width: 11.5rem;
}

/* Admin User Switch */

.supr-admin-user-switch {
  width: 100%;
  max-height: 1.5rem;
}

.supr-admin-user-switch a,
.supr-admin-user-switch button {
  padding-top: 0.15rem;
  padding-bottom: 0.0625rem;

  width: 50%;
}

/* Quick Search box */

#id_quick_search {
  width: 100%;
  max-height: 2.2rem;
}

/* RIGHT COLUMN
 * Title and contents
 */

div#supr-right-column {
  grid-auto-rows: max-content;
  grid-auto-columns: auto;
  justify-items: start;
  overflow: auto;
  background: var(--supr-bg-user);
}
.supr-links-header {
  background: var(--supr-bg-links-header);
  padding: 0.4rem;
}
#supr-right-column .supr-show,
#supr-right-column .supr-edit,
#supr-right-column .supr-links-header,
#supr-right-column center,
.w-supr {
  width: var(--supr-contentwidth);
}
#supr-right-column .btn-toolbar,
#supr-right-column form,
.mw-supr {
  max-width: var(--supr-contentwidth);
}

.btn-lg img {
  max-width: 1.2rem;
  max-height: 1.2rem;
}

/*
 * Logotypes on top on small devices
 */

div#supr-small-top {
  width: 100%;
  position: sticky;
  height: var(--supr-headerheight);
  max-height: var(--supr-headerheight);
  top: 0;
  justify-content: left;
}

body.admin div#supr-small-top {
  background: var(--supr-bg-highlight);
}

body.user div#supr-small-top {
  background: var(--supr-bg-user);
}

span#supr-logotype-small img {
  width: 10rem;
}

button#show_menu_button {
  margin-top: 0;
  margin-left: 1rem;
  margin-right: 1rem;
  font-size: 200%;
  line-height: 0;
  height: 2.5rem;
  min-height: 2.5rem;
  width: 2.5rem;
  min-width: 2.5rem;
  --bs-btn-padding-x: 0;
  &:not(.active)::before {
    transform: rotate(90deg) translateY(0.1rem);
  }
}

/*
 * Breadcrumbs
 */

.supr-breadcrumbs {
  max-width: var(--supr-contentwidth);
  overflow-y: auto;
  max-height: 3.4rem;
}

.supr-breadcrumbs ol.breadcrumb {
  margin-top: 0.2rem;
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
  padding-left: 0.2rem;
  padding-right: 0.2rem;
  margin-bottom: 0.2rem;
}

.supr-breadcrumbs li.active {
  font-weight: var(--supr-label-fontweight);
  color: var(--bs-body-color);
}

/*
 * Title
 */

div#contenttitle {
  font-size: 200%;
  font-weight: var(--supr-label-fontweight);
  padding-bottom: 0.05rem;
  margin-bottom: 1rem;
}

div#contenttitle::after {
  content: " ";
  display: block;
  height: 0.05rem;
  background: var(--bs-body-color);
  width: var(--supr-contentwidth);
}

div#contenttitle:has(+ .supr-links-header) {
  margin-bottom: -0.5rem;
}

/*
 * Hide empty nag container to avoid gap
 */

#nag_boxes:not(:has(> div)) {
  display: none !important;
}

/*
 * Left side menu
 */

div.supr-menu-subtitle {
  padding-top: 0rem;
  font-weight: var(--supr-label-fontweight);
}

div.supr-menu-footer {
  font-size: calc(0.5rem * 4 / 3);
}

table.table-responsive {
  display: block;
  max-width: var(--supr-contentwidth);
}

table.table-responsive td {
  text-wrap: nowrap;
}

td {
  & .supr-td-wrapper {
    text-wrap: wrap;
    max-height: 3rem;
    overflow-y: auto;
    display: inline-block;
    max-width: max(calc(0.5 * var(--supr-contentwidth)), auto);
    min-width: 12rem;
  }
  & .narrow-cell {
    max-width: max(calc(0.15 * var(--supr-contentwidth)), 12rem) !important;
    min-width: unset;
  }
  & .tall-cell {
    overflow-y: unset !important;
    max-height: unset !important;
  }
  & .narrow_text {
    max-width: min(calc(var(--supr-contentwidth) - 2rem), 44rem) !important;
  }
}

/*
 * Zebra striping for tables is provided by Bootstrap class table-striped.
 *
 * We override the background for some specific cases below.
 */

/* Yellow highlighting for active projects, enabled accounts etc. (Only listingtable) */

table.table-striped tr.activerow {
  background: var(--supr-bg-highlight) !important;
}

/* Emulate Bootstrap striping and our own for tables striped using tablesorter zebra instead */

table.tablesorter tr.ts-odd > * {
  --bs-table-accent-bg: var(--bs-table-striped-bg);
}
table.tablesorter tr.activerow {
  background: var(--supr-bg-highlight) !important;
}

/* Mimic this for general background use */

.bg-active {
  background: var(--supr-bg-highlight) !important;
}

/* Slightly darker for selected rows in the admin Review Sheet */

tr:nth-child(even).selectedrow {
  background: var(--supr-bg-highlight-darker) !important;
}
tr:nth-child(odd).selectedrow {
  background: var(--supr-bg-highlight-darker) !important;
}

/*
 * SHOWING OBJECTS - showing data for a single object with labels to the
 * left. Used in both admin and portal parts.
 * Still used with Bootstrap using the supr_show_* tags.
 */

div.supr-show > * {
  margin-left: 0;
  width: auto;
}
div.supr-show > *::before {
  content: " ";
  display: block;
  height: 0.05rem;
  background: var(--supr-border-show);
  width: var(--supr-contentwidth);
}
div.showvalue p {
  margin-top: 0;
  margin-bottom: 0 !important;
}
div.showlabel {
  font-weight: var(--supr-label-fontweight);
  max-width: 18rem;
  padding-top: 0.2rem;
  padding-left: 0;
}
div.showvalue {
  padding-top: 0.2rem !important;
  margin-bottom: 0.2rem !important;
  padding-left: 0;
}

/*
 * LISTINGTABLE - listing multiple objects with field labels on the top.
 * Used in both admin and portal parts. Invoked via table class "listingtable"
 * and the tr class "fieldname" on the row containing the field labels.
 */

tr.fieldname {
  font-weight: var(--supr-label-fontweight);
}
tr.fieldname td {
  border-bottom: var(--supr-border-listing) solid thin;
}
tr.total td {
  border-top: var(--supr-border-listing) solid thin;
  padding-top: calc(0.5rem * 2 / 3);
}

/* Overrides */

table.review_usage_list .showlabel {
  width: 7rem;
}

/*
 * EDITING OBJECTS - editing data for a single object with labels to
 * the left. In the portal, we mainly do this using the edit_fields_*
 * tags and in the admin mainly using the admin_editform.html
 * template.
 */

div.supr-edit .editlabel {
  font-weight: var(--supr-label-fontweight);
  max-width: 18rem;
}

div.supr-edit .editvalue {
  max-width: 35rem;
}

div.supr-edit .editvalue {
  & > input {
    font-size: 0.9rem;
  }
  & > textarea {
    font-size: 0.9rem;
  }
  & > select {
    font-size: 0.9rem;
  }
  & > small {
    font-size: 87.5%;
  }
}

div.supr-edit .editvalue.editvalue-wider {
  max-width: 53rem;
}

div.supr-edit .editheading {
  font-weight: var(--supr-label-fontweight);
  font-size: 120%;
}

div.supr-edit .edithelp {
  max-width: 53rem;
}

div.supr-edit div.supr-form-check-full-width input.form-check-input {
  margin-top: 0.1rem;
}

div.supr-edit div.supr-form-check-full-width {
  margin-bottom: 0.5rem;
}

span.reqfield {
  color: #d00000;
  font-size: 80%;
}

/* We only generate content with "invalid-feedback" when there are
   errors, so always showing it make things less complicated. */

div.supr-edit div.invalid-feedback {
  display: block;
  font-size: 90%;
}

/* ajax_select tweaks */

div.results_on_deck {
  padding-bottom: 0;
}

div.results_on_deck div {
  margin-bottom: 0;
}

.ui-menu .ui-menu-item {
  font-size: 90%;
}

/* Legacy handling for mergetable (was based on edittable before */

td.supr-merge-label {
  font-weight: var(--supr-label-fontweight);
  width: 18rem;
}

/* Similar for table used by federated UA approval */

td.supr-federated-ua-label {
  font-weight: var(--supr-label-fontweight);
  width: 10rem;
}

/*
 * OBJECT HELP TEXT - in admin_*_help.html
 */

div.objecthelp {
  max-width: 48rem;
}

div.objecthelp h2 {
  font-size: 144%;
}

/*
 * ROUND DRILLDOWN
 */

div.round-drilldown div.card {
  min-width: 20rem;
  max-width: 20rem;
}

/*
 * NAG CARDS
 */

div.supr-nag-card {
  background: var(--supr-bg-highlight);
}

/*
 * ICON TWEAKS
 */

i.bi-box-arrow-up-right {
  position: relative;
  top: -0.09em;
}

/*
 * PRE
 * Set scrollbar-gutter to be wstable to avoid changing page width
 */

div.showvalue pre {
  overflow: clip;
  margin-bottom: 0;
}

/*
 * TWEAKS FOR PRINTING
 */

@media print {
  /* Based on https://github.com/twbs/bootstrap/issues/23489 */
  #supr-page-row {
    display: block;
  }

  /* From https://daneveland.com/content/printing-bootstrap */
  [class*="col-sm-"] {
    float: left;
  }
  [class*="col-xs-"] {
    float: left;
  }
  .col-sm-12,
  .col-xs-12 {
    width: 100% !important;
  }

  .col-sm-11,
  .col-xs-11 {
    width: 91.66666667% !important;
  }

  .col-sm-10,
  .col-xs-10 {
    width: 83.33333333% !important;
  }

  .col-sm-9,
  .col-xs-9 {
    width: 75% !important;
  }

  .col-sm-8,
  .col-xs-8 {
    width: 66.66666667% !important;
  }

  .col-sm-7,
  .col-xs-7 {
    width: 58.33333333% !important;
  }

  .col-sm-6,
  .col-xs-6 {
    width: 50% !important;
  }

  .col-sm-5,
  .col-xs-5 {
    width: 41.66666667% !important;
  }

  .col-sm-4,
  .col-xs-4 {
    width: 33.33333333% !important;
  }

  .col-sm-3,
  .col-xs-3 {
    width: 25% !important;
  }

  .col-sm-2,
  .col-xs-2 {
    width: 16.66666667% !important;
  }

  .col-sm-1,
  .col-xs-1 {
    width: 8.33333333% !important;
  }

  .col-sm-1,
  .col-sm-2,
  .col-sm-3,
  .col-sm-4,
  .col-sm-5,
  .col-sm-6,
  .col-sm-7,
  .col-sm-8,
  .col-sm-9,
  .col-sm-10,
  .col-sm-11,
  .col-sm-12,
  .col-xs-1,
  .col-xs-2,
  .col-xs-3,
  .col-xs-4,
  .col-xs-5,
  .col-xs-6,
  .col-xs-7,
  .col-xs-8,
  .col-xs-9,
  .col-xs-10,
  .col-xs-11,
  .col-xs-12 {
    float: left !important;
  }
  body {
    margin: 0;
    padding-left: 3rem !important;
    padding-right: 3rem !important;
    min-width: 768px;
    font-size: 10px;
  }
  .container {
    width: auto;
    min-width: 750px;
  }
}
