/*
 * Inspinia v2.2 + Bootstrap 5 Conflict Resolution
 *
 * quividi-style.min.css (Inspinia) was written against Bootstrap 3.
 * This file fixes the conflicts that arise after swapping to BS5.
 *
 * Load AFTER quividi-style.min.css (which loads after bootstrap5.min.css).
 * Will be removed in Phase 3 when Inspinia is replaced by vidicenter-layout.
 */

/* ============================================================
   Links
   BS5 sets a { text-decoration: underline; color: #0d6efd }.
   BS3/Inspinia had no underline and color #337ab7.
   ============================================================ */
/* BS5 row adds vertical gutter spacing that doubles up with
   Inspinia's wrapper-content padding. Reduce to compensate. */
.wrapper-content {
  padding-top: 5px;
}

/* Body text color — BS5 uses #212529, BS3/Inspinia used #676a6c.
   Override the CSS variables that BS5 uses everywhere. */
:root {
  --bs-body-color: #676a6c;
  --bs-body-color-rgb: 103, 106, 108;
  --bs-emphasis-color: #676a6c;
  --bs-emphasis-color-rgb: 103, 106, 108;
}
body {
  color: #676a6c;
}

a {
  text-decoration: none;
  color: #337ab7;
}

/* BS5 sets color on table cells at specificity 0,1,3 via
   .table > :not(caption) > * > * — this overrides class-level colors.
   Re-declare affected classes at matching specificity. */
.table > :not(caption) > * > *.homepage-danger  { color: #c91212; font-weight: bold; }
.table > :not(caption) > * > *.homepage-warning { color: #edb100; font-weight: bold; }
.table > :not(caption) > * > *.homepage-primary { color: green; font-weight: bold; }
.table > :not(caption) > * > *.text-danger  { color: #dc3545; }
.table > :not(caption) > * > *.text-warning { color: #ffc107; }
.table > :not(caption) > * > *.text-success { color: #198754; }
.table > :not(caption) > * > *.text-primary { color: #337ab7; }
.table > :not(caption) > * > *.text-muted   { color: #676a6c; }
.table > :not(caption) > * > *.text-info    { color: #5bc0de; }
a:hover,
a:focus {
  text-decoration: underline;
  color: #23527c;
}

/* DataTables pagination — BS5 page links are larger than BS3. */
.pagination {
  --bs-pagination-padding-x: 0.5rem;
  --bs-pagination-padding-y: 0.15rem;
  --bs-pagination-font-size: 12px;
}

/* Masonry overview grid — restore BS3 column padding.
   BS3 col-* always had padding-left/right: 15px regardless of parent.
   BS5 col-* only gets the 12px padding (--bs-gutter-x/2) when inside a .row.
   .grid-content is NOT a .row, so cards would be flush with no gutters.
   Restore the 15px side padding explicitly. */
.grid-item {
  padding-left: 15px;
  padding-right: 15px;
}

/* BS5 table cell padding (.5rem) is larger than BS3 (5px 8px). */
.table > :not(caption) > * > * {
  padding: 5px 8px !important;
}
/* .form-group inside tables shouldn't add bottom margin. */
.table .form-group {
  margin-bottom: 0 !important;
}

/* Bootstrap-select: the plugin copies classes from the native <select> to
   the wrapper div, including .form-select. BS5's .form-select adds a
   background SVG chevron — hide it on the wrapper since the button's
   .dropdown-toggle::after already provides a clickable caret. */
.bootstrap-select.form-select {
  background-image: none;
  padding: 0;
  border: none;
  height: auto;
}
.bootstrap-select .dropdown-toggle {
  padding-right: 20px;
}

/* Info icon (fa-info-circle) in datatable column headers — blue in BS3. */
.fa-info-circle {
  color: #3b7ccc;
}

/* BS3 .btn-block was removed in BS5. Restore full-width block button. */
.btn-block {
  display: block;
  width: 100%;
}

/* BS5 .btn is larger than BS3 (padding + font-size). Match BS3.
   Force inline-block and consistent vertical-align so mixed <a>/<button>
   elements sit on the same line. */
.btn {
  display: inline-block;
  padding: 6px 12px;
  font-size: 14px;
  line-height: 1.42857143;
  vertical-align: middle;  /* BS3 used middle, not baseline */
}

/* BS3 .btn without a color variant had a default grey look.
   BS5 .btn alone is unstyled. Restore the default appearance.
   Exclude actual color variants but include size-only variants like btn-xs. */
.btn:not(.btn-primary):not(.btn-secondary):not(.btn-success):not(.btn-info):not(.btn-warning):not(.btn-danger):not(.btn-default):not(.btn-link):not(.btn-white):not(.btn-download):not(.btn-outline-primary):not(.btn-outline-secondary):not(.btn-outline-success):not(.btn-outline-danger):not(.btn-outline-warning):not(.btn-outline-info) {
  background-color: #e7eaec;
  border-color: #e7eaec;
  color: #676a6c;
}
.btn:not(.btn-primary):not(.btn-secondary):not(.btn-success):not(.btn-info):not(.btn-warning):not(.btn-danger):not(.btn-default):not(.btn-link):not(.btn-white):not(.btn-download):not(.btn-outline-primary):not(.btn-outline-secondary):not(.btn-outline-success):not(.btn-outline-danger):not(.btn-outline-warning):not(.btn-outline-info):hover {
  background-color: #d2d6d9;
  border-color: #d2d6d9;
  color: #676a6c;
}

/* ============================================================
   Dropdowns
   BS5 uses Popper for positioning. Inspinia set display:none via
   CSS and expected BS3 JS to toggle .open on the parent.
   BS5 uses .show on the .dropdown-menu itself — ensure this works.
   ============================================================ */
.dropdown-menu.show { display: block; }

/* Inspinia's dropdown-menu has no border-radius on top — restore it
   since BS5 shows dropdowns below the toggle by default */
.dropdown-menu {
  border-radius: 0.375rem;
}

/* ============================================================
   Navbar / sidebar
   The sidebar nav uses .navbar-default.navbar-static-side which
   Inspinia styles completely. BS5's .navbar resets some things we
   need to restore.
   ============================================================ */
nav.navbar-default.navbar-static-side {
  border: none;
  border-radius: 0;
}

/* BS5 .navbar sets display:flex by default. The sidebar nav is a
   vertical side panel — override back to block. */
nav.navbar-default.navbar-static-side {
  display: block;
  overflow: visible;
}
/* Mini-navbar sidebar should not show scrollbar */
.mini-navbar .sidebar-collapse {
  overflow: visible !important;
}
/* BS5 .nav adds padding/margin that expands the mini-navbar icons.
   Restore BS3/Inspinia compact spacing. */
.mini-navbar #side-menu > li > a {
  padding: 14px 20px 14px 25px;
  text-align: center;
}
.mini-navbar .nav-header {
  padding: 0;
}
/* In mini-navbar the .logo-element dropdown-menu is positioned absolute
   in BS3 but BS5 may add spacing. Ensure it's hidden properly. */
.logo-element .dropdown-menu:not(.show) {
  display: none;
}
/* BS5 adds margin/padding to .dropdown that expands the logo area */
.logo-element .dropdown-menu {
  position: absolute;
}
/* Sidebar li in BS5 gets extra list styling. Reset. */
#side-menu > li {
  list-style: none;
}

/* Sidebar search — BS5 input-group strips border-radius on the right
   side of the input when adjacent to an addon. Restore full rounding. */
.input-group > .input-group-addon:last-child {
  border-top-right-radius: var(--bs-border-radius, 0.375rem) !important;
  border-bottom-right-radius: var(--bs-border-radius, 0.375rem) !important;
}
.input-group > .form-control:first-child {
  border-top-left-radius: var(--bs-border-radius, 0.375rem) !important;
  border-bottom-left-radius: var(--bs-border-radius, 0.375rem) !important;
}

/* BS5 .nav uses display:flex — the sidebar expects display:block
   so that float:right works on .arrow carets.
   Only override the top-level list; submenus are managed by metisMenu. */
#side-menu {
  display: block !important;
}

/* Inspinia nav links — BS5 sets a { text-decoration: underline } globally.
   Remove underlines from sidebar nav and all .nav links. */
.nav > li > a,
#side-menu a {
  position: relative;
  display: block;
  text-decoration: none;
}

/* ============================================================
   Forms
   BS5 .form-control changed min-height behaviour and font-size.
   Inspinia used 14px form controls; BS5 defaults to 1rem (16px).
   ============================================================ */
.form-control {
  height: auto;
  font-size: 14px;
}

select.form-control {
  /* BS5 select uses .form-select; keep .form-control working for selects */
  appearance: auto;
  -webkit-appearance: auto;
}

/* help-block — crispy-bootstrap3 renders field help text as .help-block.
   BS3 styled it small and grey; BS5 has no .help-block rule. */
.help-block {
  display: block;
  margin-top: 5px;
  margin-bottom: 10px;
  color: #737373;
  font-size: 12px;
}

/* ============================================================
   select2-bootstrap-5-theme sizing
   BS3's select2-bootstrap theme was 14px / 34px tall.
   The bootstrap-5 theme defaults to 1rem (16px) / ~38px tall.
   Override to match BS3 compact sizing.
   ============================================================ */
.select2-container--bootstrap-5 .select2-selection {
  font-size: 14px;
  min-height: 34px;
}
/* Single-select: tighten vertical padding */
.select2-container--bootstrap-5 .select2-selection--single {
  padding-top: 5px;
  padding-bottom: 5px;
}
/* Multi-select tags: BS3 used font-size 12px, small padding */
.select2-container--bootstrap-5 .select2-selection--multiple
    .select2-selection__rendered
    .select2-selection__choice {
  font-size: 14px !important;
  padding: 1px 6px !important;
  margin-right: 3px;
  margin-bottom: 3px;
}
/* select2 v4.0.x renders the remove button as an inline <span>×</span>.
   The BS5 theme's SVG + text-indent trick targets select2 v4.1+ <button>.
   Flex layout blockifies the span, making the SVG show but at wrong size.
   Revert to the compact BS3-style text × used by the old bootstrap theme. */
.select2-container--bootstrap-5 .select2-selection--multiple
    .select2-selection__rendered
    .select2-selection__choice
    .select2-selection__choice__remove {
  width: auto !important;
  height: auto !important;
  padding: 0 !important;
  overflow: visible !important;
  text-indent: 0 !important;
  white-space: normal !important;
  background: none !important;
  border: 0 !important;
  color: #999 !important;
  font-weight: bold;
  margin-right: 3px;
}
.select2-container--bootstrap-5 .select2-selection--multiple
    .select2-selection__rendered
    .select2-selection__choice
    .select2-selection__choice__remove:hover {
  color: #333 !important;
  background: none !important;
}
/* Dropdown options: match BS3 compact sizing */
.select2-container--bootstrap-5 .select2-dropdown
    .select2-results__options
    .select2-results__option {
  font-size: 14px;
  padding: 4px 10px;
}
.select2-container--bootstrap-5 .select2-dropdown
    .select2-search
    .select2-search__field {
  font-size: 14px;
  padding: 4px 10px;
}

/* ============================================================
   Input groups
   BS5 changed border-radius cascade for adjacent .form-control
   and .input-group-text. Fix rounded corners when .input-group-addon
   (BS3 name) sits next to .form-control.
   ============================================================ */
.input-group > .input-group-addon + .form-control,
.input-group > .input-group-addon + select {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.input-group > .form-control + .input-group-addon,
.input-group > select + .input-group-addon {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

/* ============================================================
   Modals
   BS5 changed z-index hierarchy: backdrop 1050, modal 1055.
   Inspinia sidebar is z-index 2020, page-wrapper 100.
   No changes needed — BS5 z-indices don't conflict with Inspinia's.

   BS5 adds padding-right to body when modal opens (scrollbar
   compensation). The sidebar is fixed-width so this is fine.
   ============================================================ */

/* modal-header has .close (BS3) — float it correctly */
.modal-header .close {
  float: right;
  margin-top: -2px;
}
/* Hide the BS5 .btn-close that crispy-forms may add, if .close is also present */
.modal-header:has(.close) .btn-close { display: none; }

/* ============================================================
   Alerts
   BS5 dismissible alerts use .btn-close. Old templates use .close.
   Both should work. Ensure .close is right-aligned in .alert.
   ============================================================ */
.alert .close {
  float: right;
  margin-top: -0.1rem;
  color: inherit;
  opacity: 0.5;
}
.alert .close:hover { opacity: 0.75; }

/* BS3 modals put the close button before the title, with float:right.
   BS5 .modal-header uses flexbox. Reorder so close goes to the end. */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header .modal-title {
  flex: 1;
}
.inmodal .modal-header .modal-title {
  text-align: center;
}
.modal-header .close {
  order: 1;
  background: none;
  border: 0;
  font-size: 1.5rem;
  opacity: 0.5;
  padding: 0.5rem;
  cursor: pointer;
  flex-shrink: 0;
}
.modal-header .close:hover { opacity: 0.75; }

/* Inspinia's .btn-large-dim sets font-size:42px but .btn's font-size:14px
   overrides it at the same specificity. Use a two-class selector to win. */
.btn.btn-large-dim {
  font-size: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* BS3 .panel-group .panel+.panel had margin-top. BS5 cards have none.
   Also restore bold font on accordion headers (panel-title links). */
.panel-group .card + .card {
  margin-top: 5px;
}
.panel-group .card {
  overflow: hidden;
}
.panel-title a {
  font-weight: 600;
  text-decoration: none;
}

/* ============================================================
   Buttons
   BS5 changed box-shadow on :focus for buttons. Inspinia has its
   own button focus styles. Let BS5 win on focus ring.
   ============================================================ */
.btn:focus-visible { outline: 0; }

/* Hide BS5 auto-caret on breadcrumb dropdown toggles (icon-only links) */
.breadcrumb .dropdown-toggle::after {
  display: none;
}

/* BS5 removed .btn-xs — provide it (Inspinia uses it occasionally) */
.btn-xs {
  padding: 1px 5px;
  font-size: 12px;
  line-height: 1.5;
  border-radius: 3px;
}

/* Our base .btn rule (above) cancels BS5's .btn-sm/.btn-lg because it loads
   later in the cascade. Re-declare them here to restore BS3 sizes. */
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  line-height: 1.5;
  border-radius: 3px;
}
.btn-lg {
  padding: 10px 16px;
  font-size: 18px;
  line-height: 1.33333;
  border-radius: 6px;
}

/* ============================================================
   Breadcrumb
   BS5's breadcrumb expects .breadcrumb-item on each <li>.
   The shim CSS handles plain <li> children.
   Restore the separator colour that Inspinia may override.
   ============================================================ */
.breadcrumb > li + li::before,
.breadcrumb-item + .breadcrumb-item::before {
  color: #6c757d;
}

/* ============================================================
   select2 theme name change
   Old: select2-container--bootstrap (BS3 theme)
   New: select2-container--bootstrap-5
   The JS in base.html is updated to use "bootstrap-5" theme.
   Ensure the old class doesn't ghost-style anything.
   ============================================================ */
.select2-container--bootstrap .select2-selection { display: none; }

/* ============================================================
   DataTables
   dataTables.bootstrap5.min.css adds BS5 pagination/table styles.
   Ensure it overrides any lingering BS3 DT styles cleanly.
   ============================================================ */
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  color: #fff !important;
  background: #0d6efd !important;
  border-color: #0d6efd !important;
  border-radius: 0.375rem;
}

/* ============================================================
   Badge colours
   BS5 .bg-success/danger/etc. use standard Bootstrap colours.
   Inspinia overrode .label-success etc. with Quividi branding.
   Match the Inspinia palette for badges.
   ============================================================ */
.badge.bg-success { background-color: #6C6DFF !important; color: #fff !important; }
.badge.bg-danger  { background-color: #FF2346 !important; color: #fff !important; }
.badge.bg-warning { background-color: #FBD54a !important; }  /* light bg keeps default dark text */
.badge.bg-info    { background-color: #615D91 !important; color: #fff !important; }
.badge.bg-primary { background-color: #2C2760 !important; color: #fff !important; }

/* Pace.js loading bar may appear behind BS5 modal backdrop (z: 1050) */

/* ============================================================
   Headings inside ibox-title
   Inspinia sets .ibox-title h5 at specificity (0,1,1) but BS5's
   reboot overrides line-height (1.2 vs BS3's 1.1) and font-weight
   at the same specificity.  Re-declare ALL Inspinia h5 properties
   so they stick regardless of cascade order.
   ============================================================ */
.ibox-title h5 {
  display: inline-block;
  font-size: 14px;
  line-height: 1.1;           /* BS3 heading default; BS5 uses 1.2 */
  margin: 0 0 7px;
  padding: 0;
  text-overflow: ellipsis;
  float: left;
}

/* ============================================================
   Cards / Panels
   BS5 .card-header uses rgba(0,0,0,.03) — nearly invisible.
   BS3 .panel-heading used #f5f5f5 — a visible light grey.
   Restore the BS3 look for accordion/card headers.
   ============================================================ */
.card-header {
  background-color: #f5f5f5;
}

/* ============================================================
   BS5 Accordion — look like BS3 panels
   crispy-bootstrap5 renders accordion-button with a ::after
   chevron.  Our forms already use manual <i class="fa fa-chevron-*">
   icons in the accordion title, so hide the BS5 auto-chevron.
   Also neutralise the blue highlight on expanded headers.
   ============================================================ */
.accordion-button::after {
  display: none;
}
.accordion-button {
  background-color: #f5f5f5;
  color: #333;
  padding: 10px 15px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: none;
}
.accordion-button:not(.collapsed) {
  background-color: #f5f5f5;
  color: #333;
  box-shadow: none;
}
.accordion-button:focus {
  box-shadow: none;
  border-color: #ddd;
}
.accordion-body {
  background-color: #fff;
  border-top: 1px solid #ddd;
}
/* BS5 reboot sets label/legend font-weight heavier than BS3.
   Restore normal weight for form labels inside accordion bodies. */
.accordion-body label,
.accordion-body legend,
.accordion-body .form-label,
.accordion-body .form-check-label {
  font-weight: normal;
}
/* Remove gap between accordion-item border and the button background */
.accordion-header {
  padding: 0;
}
/* Make each accordion-item look like a separate BS3 panel:
   full border, individual border-radius, vertical spacing.
   BS5 default collapses borders between adjacent items — undo that. */
.accordion-item {
  border: 1px solid #ddd !important;
  border-radius: 4px !important;
  margin-bottom: 15px;
  background-color: #f5f5f5;
}
.accordion-item:first-of-type {
  border-top-left-radius: 4px !important;
  border-top-right-radius: 4px !important;
}
.accordion-item:last-of-type {
  border-bottom-left-radius: 4px !important;
  border-bottom-right-radius: 4px !important;
}
/* BS5 removes top radius from non-first buttons — restore it */
.accordion-item .accordion-button {
  border-radius: 0;
}
.accordion-item:first-of-type .accordion-button,
.accordion-item:last-of-type .accordion-button.collapsed,
.accordion-item .accordion-button.collapsed {
  border-radius: inherit;
}
/* Remove <br/> between accordion groups — margin-bottom handles spacing */
.accordion > br {
  display: none;
}

/* ============================================================
   Crispy-bootstrap5 form action buttons (Submit / Delete)
   The inputs.html template wraps buttons in <div class="mb-3">
   with floats.  Ensure the container clears floats and has
   spacing from the accordion above.
   ============================================================ */
fieldset + .mb-3:last-child {
  margin-top: 15px;
  overflow: hidden;  /* clearfix for floated buttons */
}

/* BS3 .col-xs-* always had 15px side padding (float-based grid).
   BS5 .col-* only gets gutter padding inside a .row.  Chart widgets
   use .col-12 without a .row parent — restore the BS3 padding. */
.chart > [class*="col-"] {
  padding-left: 15px;
  padding-right: 15px;
}

/* ============================================================
   List groups inside cards — match BS3 flush look
   BS3 auto-hid side borders on list-group-items inside panels.
   BS5 shows full borders by default.
   ============================================================ */
.card > .list-group .list-group-item {
  border-left: 0;
  border-right: 0;
  border-radius: 0;
}
.card > .list-group .list-group-item:last-child {
  border-bottom: 0;
}

.pace .pace-progress { z-index: 2000; }
.pace-overlay { z-index: 1999; }

/* Driver.js z-index override — ensures tour popovers appear above
   Bootstrap modals when touring elements inside a modal dialog.
   The JS lifts the modal to 100002; the popover must sit above that. */
.driver-popover { z-index: 100003 !important; }

/* ============================================================
   Page-wrapper footer clearance
   Inspinia's .footer is position:absolute;bottom:0 inside the
   relatively-positioned #page-wrapper.  BS5's taller form
   elements push the submit button into the footer zone.
   Add bottom padding so content never hides behind the footer.
   ============================================================ */
#page-wrapper {
  padding-bottom: 50px;
}
