/**
 * Main CSS stylesheet for application
 */

/* BEGIN: CSS custom properties (variables) */
:root {
  --cnsp-background-body: var(--bs-body-bg);
  --cnsp-body: var(--bs-body-color);
  --cnsp-border-color: var(--bs-border-color);
  --cnsp-border-radius: var(--bs-border-radius-lg); /* for containers such as cards & tables, and nav links */
  --cnsp-z-index: 1024; /* must be more than z-index of 1020 for .sticky-top applied to cards and tables */

  /* Override Bootstrap colors */
  --cnsp-primary: #282828;
  --cnsp-secondary: #EFEFEF;
  --cnsp-danger: var(--bs-danger);
  --cnsp-muted: var(--bs-gray); /* same as .text-muted in Bootstrap */

  /* Effects */
  --cnsp-checked-active: #4ADE80;
  --cnsp-hover-brightness: 85%;
}
/* CLOSE: CSS custom properties (variables) */


/* BEGIN: Containers */
html,
body {
  font-size: 16px; /* fix base font size for easier computation of rem units */
  margin: 0;
  padding: 0;
}

body {
  background: white;
  color: var(--cnsp-body);
}

.wild {
  height: 100vh;
}

.wild main {
  margin: 0;
}

.wild-left {
  align-items: center;
  background-color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.wild-right {
  background: url(/public/images/background-login.jpg);
  background-position: top left;
  background-repeat: no-repeat;
  background-size: cover;
  height: 100vh;
  padding: 0;
}
/* CLOSE: Containers */


/* BEGIN: Alerts (including modals, popovers and session messages) */
.alert {
  margin-bottom: 1rem;
  margin-top: 1rem;
}
.alert::before {
  display: inline-block;
  height: 1rem;
  position: relative;
  top: 0.15rem;
  width: 1rem;
}
.alert.alert-danger::before {
  /*
    Notes:
    - Do not depend solely on color to differentiate type of alert, hence prepend icon for accessibility
    - filter computed using https://github.com/angel-rs/css-color-filter-generator based on color for .alert-danger
    - background-color, color, fill will not work on the SVG here
    - See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content on setting of alternative text
  */
  content: url(/public/images/exclamation-triangle-fill.svg) / "Error";
  filter: brightness(0) saturate(100%) invert(17%) sepia(43%) saturate(3688%)
    hue-rotate(335deg) brightness(82%) contrast(93%);
}
.alert.alert-info::before {
  content: url(/public/images/info-circle-fill.svg) / "Info";
  filter: brightness(0) saturate(100%) invert(23%) sepia(9%) saturate(7153%)
    hue-rotate(153deg) brightness(98%) contrast(96%);
}
.alert.alert-success::before {
  content: url(/public/images/check-circle-fill.svg) / "Success";
  filter: brightness(0) saturate(100%) invert(23%) sepia(25%) saturate(1335%)
    hue-rotate(100deg) brightness(92%) contrast(90%);
}
.alert.alert-warning::before {
  content: url(/public/images/exclamation-diamond-fill.svg) / "Warning";
  filter: brightness(0) saturate(100%) invert(25%) sepia(97%) saturate(599%)
    hue-rotate(14deg) brightness(96%) contrast(98%);
}

#shared-modal .modal-description {
  color: var(--cnsp-muted);
}

#shared-modal .modal-error {
  color: var(--cnsp-danger);
}
/* CLOSE: Alerts */


/* BEGIN: Buttons */
.btn:focus-visible {
  outline: 2px solid black; /* show outline around button when user uses Tab key to select it */
}

.btn-icon { /* style <button> that uses Bootstrap Icons like a link */
  color: var(--cnsp-primary);
  padding: 0;
}

.btn-primary,
.btn-primary:focus,
.btn-primary:hover { /* override Bootstrap class */
  background-color: var(--cnsp-primary);
  border-color: var(--cnsp-primary);
  color: white;
}
.btn-primary:hover {
  filter: brightness(var(--cnsp-hover-brightness));
}
/* CLOSE: Buttons */


/* BEGIN: Forms */
fieldset {
  border: 1px solid var(--cnsp-border-color);
  border-radius: var(--cnsp-border-radius);
  padding: 1rem;
}

.fieldset-osp {
  border-color: #FFC107;
  background-color: #FBF6E6;
}

.fieldset-tsp {
  border-color: #20C997;
  background-color: #EDFFFA;
}

.fieldset-registry {
  background-color: #EEE;
}

textarea.form-control {
  height: 5rem;
  overflow-y: scroll;
}

label {
  /* Form fields nested in <label> for implicit accessible name instead of using "for" HTML attribute requiring "id". */
  /* See https://developer.mozilla.org/en-US/docs/Glossary/Accessible_name for more info. */
  display: block;
  font-weight: bold;
}

form .row {
  margin-bottom: 1rem;
}

.input-group {
  margin-bottom: 1rem;
}

.input-group > .btn {
  border-color: var(--cnsp-border-color);
}
.input-group > .btn:active {
  border-color: var(--cnsp-border-color);
}

.input-group:has(.input-group-text) input:first-child,
.input-group:has(.input-group-text) .input-group-text:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.form-label {
  margin-bottom: 1rem;
}
.form-label.required {
  font-weight: bold;
}
.form-label.required:after {
  content: " *" / "Required";
}

.form-check-label {
  font-weight: normal;
}

.form-select { /* override Bootstrap, ensure dropdown does not span entire page width nor exceed small screen width */
  cursor: pointer;
  max-width: 100%;
}

.form-control,
.form-select,
.input-group-text {
  border-color: var(--cnsp-border-color);
  color: var(--cnsp-body);
}

label:has(.form-control) .form-control,
label:has(.form-select) .form-select,
label:has(.input-group-text) .input-group-text {
  margin-top: 0.25rem;
}

/* Toggle switches */
.form-switch .form-check-input {
  border-color: var(--cnsp-border-color);
  cursor: pointer;
  height: 1.5rem;
  width: 3rem;
}
.form-switch .form-check-input:checked {
  background-color: var(--cnsp-checked-active);
  border-color: var(--cnsp-checked-active);
}
.form-switch .form-check-input[name="is_active"]::after {
  /* Change label of is_active switch based on its state, without use of JavaScript */
  content: "Inactive";
  margin-left: 4rem;
}
.form-switch .form-check-input[name="is_active"]:checked::after {
  content: "Active";
  margin-left: 4rem;
}

/* Clickable icons in fields such as Show Password icon for password fields */
.input-group-text.clickable {
  background: var(--cnsp-background-body);
}
.input-group-text.clickable:hover {
  background: var(--cnsp-primary);
  color: var(--cnsp-secondary);
}
/* CLOSE: Forms */


/* BEGIN: Navigation (includes links, breadcrumbs and tabs) */
a {
  color: var(--cnsp-primary);
}
a:hover {
  filter: brightness(var(--cnsp-hover-brightness));
}

.breadcrumb-item {
  font-size: 0.75rem;
  text-transform: capitalize;
}

.hover-underline:hover {
  text-decoration: underline;
}

.unclickable {
  color: var(--cnsp-muted);
  cursor: not-allowed;
  pointer-events: none;
  text-decoration: none;
}

/* Top menubar with dropdown menu */
nav.navbar-top {
  border-bottom: 1px solid var(--cnsp-border-color);
  margin-bottom: 1rem;
}

.navbar-top .navbar-logo {
  height: 2.5rem;
}

.navbar-top .dropdown-menu {
  padding: 1rem;
  z-index: var(--cnsp-z-index);
}

.navbar-top a.dropdown-item {
  padding: 0.5rem;
}
.navbar-top a.dropdown-item:hover {
  background: var(--cnsp-background-body);
}

.navbar-top .nav-link {
  border-radius: var(--cnsp-border-radius);
  color: var(--cnsp-body);
}
.navbar-top .nav-link:hover {
  color: var(--cnsp-primary);
}

.navbar-left .nav-link {
  border-radius: var(--cnsp-border-radius);
  color: var(--cnsp-body);
  padding: 0.5rem;
}
.navbar-left .nav-link:hover {
  background: var(--cnsp-background-body);
  color: var(--cnsp-primary);
}

/* Tabs */
.nav-tabs .nav-link {
  border: none;
  border-radius: var(--cnsp-border-radius);
  color: var(--cnsp-primary);
}
.nav-tabs .nav-item.show .nav-link,
.nav-tabs .nav-link.active {
  background-color: var(--cnsp-secondary);
}
/* CLOSE: Navigation */


/* BEGIN: Pagination */
.pagination {
  /* override Bootstrap .pagination */
  font-size: 0.8rem;
  margin-bottom: 0;
}

.pagination-wrapper,
.pagination-wrapper label,
.pagination-wrapper .form-select {
  color: black;
  font-size: 0.85rem;
}

.page-item .page-link {
  border: none;
  border-color: transparent;
  border-radius: var(--cnsp-border-radius);
  margin: 0 0.125rem;
  color: var(--cnsp-body);
  padding: 0.25rem 0.5rem;
}
.disabled > .page-link,
.page-link.disabled {
  background: none;
}

.page-item.disabled .page-link {
  color: var(--cnsp-muted);
}

.page-item.active .page-link {
  /* override Bootstrap */
  background-color: var(--cnsp-primary);
  border-color: var(--cnsp-primary);
  border-radius: var(--cnsp-border-radius);
}

.page-item.curr-page {
  margin-right: 0.25rem;
}
.page-item.curr-page .input-page {
  padding: 0.25rem 0.25rem;
  width: 3rem;
  background: white;
  border: 1px solid var(--cnsp-border-color);
  border-radius: var(--bs-border-radius-sm);
  margin-right: 0.25rem;
  text-align: center;
}
/* CLOSE: Pagination */


/* BEGIN: Tables */
.table thead.sticky-top {
  background-color: white;
}

/* Search box */
.table-functions .search-field {
  margin-bottom: 0;
}
.table-functions .search-field .input-group-text {
  background: none;
  border-bottom-right-radius: 0;
  border-top-right-radius: 0;
}
.table-functions .search-field .form-control {
  border-left: none;
}

/* Filters */
.table-filters .btn-filter {
  border: 1px solid var(--cnsp-border-color);
}
.table-filters.btn-group > .btn.btn-filter { /* need this specificity to override Bootstrap */
  border-radius: var(--bs-border-radius);
}

.table-filters .dropdown-menu {
  list-style-type: none;
  margin: 0;
  padding: 1rem;
  width: 12.5rem;
  z-index: var(--cnsp-z-index);
}
.table-filters .dropdown-menu li ul {
  list-style-type: none;
  margin: 0;
  margin-top: 1rem;
  padding: 0;
}

.table-filters .filter-body .form-row {
  margin-bottom: 0.5rem;
}

.table-filters .btn-footer {
  padding: 1rem 0;
}

.table-with-pagination.card {
  border: none;
}

.table-with-pagination .card-header,
.table-with-pagination .card-footer {
  background-color: white;
  border: none;
  padding: 1rem;
}

.table-with-pagination .card-body {
  border: 1px solid rgba(0, 0, 0, 0.125);
  border-radius: var(--cnsp-border-radius);
  padding: 0.25rem 0;
}

.table.record-listing {
  border-color: var(--cnsp-border-color);
  margin-bottom: 0;
}

.table.record-listing thead th {
  color: var(--cnsp-muted);
  font-size: 0.75rem;
  padding-top: 0;
  text-transform: uppercase;
  vertical-align: text-top; /* text-top ensures text in columns with and without sort arrows are aligned vertically */
  white-space: nowrap; /* prevent sorting arrows from going onto next line from header text */
}

.table.record-listing tbody td {
  vertical-align: top;
}
.table.record-listing tbody td.actions {
  text-align: right;
}

/* Bulk select column (<th> and <td>) */
.table.record-listing .bulk-select-column {
  font-size: 1rem; /* reduce Bootstrap icon size */
  padding-left: 0;
  text-align: right;
}
.table.record-listing .bulk-select-column .form-check {
  display: inline-block; /* to allow bulk delete icon to be rendered side-by-side with select all checkbox in <th> */
  min-height: auto;
  margin-bottom: 0;
  padding-left: 0;
}
.table.record-listing .bulk-select-column .form-check .form-check-input {
  float: none;
  height: 1.25rem; /* normal size of 1rem is too small */
  margin-left: 0;
  margin-top: 0.1rem; /* in <th>, align bulk delete icon vertically with select all checkbox */
  width: 1.25rem;
}

.table.record-listing .form-switch {
  padding-left: 2.5em;
}

.table.record-listing th .bi,
.table.record-listing td .bi {
  font-size: 1.25rem;
}
.table.record-listing td .bi {
  margin: 0 0.1rem;
}

/* Table borders */
.table > :not(:first-child) {
  /* Override Bootstrap, remove thick black bottom border of table header row */
  border-top: none;
}
.table.record-listing tbody td {
  border-color: var(--cnsp-border-color);
}
.table.record-listing tbody tr:last-child td {
  border: none;
}

/* Links in th/td */
th button,
td.actions button,
td.actions a,
td.actions [data-show-hidden-columns-target] .dropdown-toggle { /* only for header row and actions column */
  background: none;
  border: none;
  border-radius: 50%; /* follow Bootstrap .rounded-circle */
  color: var(--cnsp-body);
  margin-left: 0.25rem;
  padding: 0.125rem 0.375rem;
}
td.actions a {
  filter: none;
  padding: 0.375rem 0.375rem 0.25rem 0.375rem;;
  text-decoration: none;
}
th button:hover,
td.actions button:hover,
td.actions a:hover,
td.actions [data-show-hidden-columns-target] .dropdown-toggle:hover { /* only for header row and actions column */
  background: lightgray;
  color: var(--cnsp-primary);
}

th .bulk-delete,
td.actions .record-delete {
  background: none;
  border: none;
  border-radius: 50%; /* follow Bootstrap .rounded-circle */
  color: var(--cnsp-danger);
}
th .bulk-delete:hover,
td.actions .record-delete:hover {
  background: var(--cnsp-danger);
  color: white !important; /* !important needed to override Bootstrap for .text-danger */
}

/* Hidden columns in responsive tables */
[data-show-hidden-columns-target] .dropdown-toggle {
  background: none;
  border: none;
  padding-block: 0;
  padding-inline: 0;
}
[data-show-hidden-columns-target] .dropdown-toggle::before {
  display: none;
}
[data-show-hidden-columns-target] .dropdown-menu {
  padding: 0.5rem;
}
/* CLOSE: Tables */


/* BEGIN: Text, Badges, Icons, Images */
.logo {
  max-height: 10rem;
}

.title {
  font-size: 1.5rem;
  font-weight: bold;
  text-transform: capitalize;
}

.subtitle {
  font-size: 1.25rem;
}

.subtext {
  color: var(--cnsp-muted);
  font-size: 0.75rem;
}

.badge.category-registry {
  background-color: var(--cnsp-primary);
  color: white;
  text-transform: uppercase;
}

.badge.category-osp {
  background-color: #FFC107;
  color: black;
  text-transform: uppercase;
}

.badge.category-tsp {
  background-color: #20C997;
  color: white;
  text-transform: uppercase;
}

.text-warning {
  color: darkorange !important; /* override Bootstrap */
}

/* Animated ellipsis adapted from https://codepen.io/thetallweeks/pen/yybGra */
.loading:after { /* do not set font-size for .loading as it will change font size of adjacent text */
  animation: ellipsis steps(5, end) 1500ms infinite;
  bottom: -0.5rem;
  color: var(--cnsp-muted);
  content: "\2026" / "Loading"; /* ASCII code for the ellipsis character */
  display: inline-block;
  font-size: 3rem;
  margin-left: 0.25rem;
  margin-top: -3rem;
  overflow: hidden;
  position: relative;
  vertical-align: bottom;
  width: 0;
}
@keyframes ellipsis {
  to {
    width: 1.25em; /* must be 1.25em not rem to show all 3 dots in the ellipsis */
  }
}
/* CLOSE: Text, Badges, Icons, Images */


/* BEGIN: Uploads */
.dropzone {
  background: white;
  border: 0.2rem dashed var(--cnsp-body);
  border-radius: var(--cnsp-border-radius);
  font-size: 1.5rem;
  height: 12.5rem;
  padding: 1rem;
}
/* CLOSE: Upload */
