/**
 * Bootstrap 3 to Bootstrap 5 CSS Compatibility Layer
 * Provides backward compatibility for commonly used Bootstrap 3 classes
 */

/* Hidden classes - Bootstrap 3 used .hidden, Bootstrap 5 uses .d-none */
.hidden {
  display: none !important;
}

.hide {
  display: none !important;
}

/* Visible classes */
.visible-xs,
.visible-sm,
.visible-md,
.visible-lg {
  display: none !important;
}

/* Panel classes - Bootstrap 5 removed panels, map to cards */
.panel {
  position: relative;
  margin-bottom: 1rem;
  background-color: #fff;
  border: 1px solid rgba(0, 0, 0, 0.125);
  border-radius: 0.25rem;
}

.panel-default {
  position: relative;
  margin-bottom: 1rem;
  background-color: #fff;
  border: 1px solid rgba(0, 0, 0, 0.125);
  border-radius: 0.25rem;
}

.panel-heading {
  padding: 0.5rem 1rem;
  margin-bottom: 0;
  background-color: rgba(0, 0, 0, 0.03);
  border-bottom: 1px solid rgba(0, 0, 0, 0.125);
  border-radius: calc(0.25rem - 1px) calc(0.25rem - 1px) 0 0;
}

.panel-body {
  flex: 1 1 auto;
  padding: 1rem 1rem;
}

.panel-footer {
  padding: 0.5rem 1rem;
  background-color: rgba(0, 0, 0, 0.03);
  border-top: 1px solid rgba(0, 0, 0, 0.125);
  border-radius: 0 0 calc(0.25rem - 1px) calc(0.25rem - 1px);
}

/* Well class - removed in Bootstrap 5 */
.well {
  background-color: #f5f5f5;
  border: 1px solid #e3e3e3;
  border-radius: 4px;
  padding: 19px;
  margin-bottom: 20px;
}

.well-sm {
  padding: 9px;
  border-radius: 3px;
}

.well-lg {
  padding: 24px;
  border-radius: 6px;
}

/* Label class - renamed to badge in Bootstrap 5 */
.label {
  display: inline-block;
  padding: 0.25em 0.4em;
  font-size: 75%;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: 0.25rem;
}

.label-default {
  background-color: #6c757d;
  color: #fff;
}

.label-primary {
  background-color: #0d6efd;
  color: #fff;
}

.label-success {
  background-color: #198754;
  color: #fff;
}

.label-info {
  background-color: #0dcaf0;
  color: #000;
}

.label-warning {
  background-color: #ffc107;
  color: #000;
}

.label-danger {
  background-color: #dc3545;
  color: #fff;
}

/* Form control feedback - Bootstrap 3 compatibility */
.form-control-feedback {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  display: block;
  width: 34px;
  height: 34px;
  line-height: 34px;
  text-align: center;
  pointer-events: none;
}

/* Input group button - Bootstrap 5 changed structure */
.input-group-btn {
  position: relative;
  font-size: 0;
  white-space: nowrap;
}

.input-group-btn > .btn {
  position: relative;
}

.input-group-btn > .btn + .btn {
  margin-left: -1px;
}

.input-group-btn:not(:last-child) > .btn {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-group-btn:not(:first-child) > .btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* Navbar classes */
.navbar-default {
  background-color: #f8f9fa;
  border-color: #e7e7e7;
}

.navbar-inverse {
  background-color: #343a40;
  border-color: #343a40;
}

/* Thumbnail class */
.thumbnail {
  display: block;
  padding: 4px;
  margin-bottom: 20px;
  line-height: 1.42857143;
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  transition: border 0.2s ease-in-out;
}

.thumbnail > img {
  max-width: 100%;
  height: auto;
}

/* Button sizing compatibility */
.btn-xs {
  padding: 0.125rem 0.25rem;
  font-size: 0.75rem;
  line-height: 1.5;
  border-radius: 0.2rem;
}

/* Pull classes - Bootstrap 5 uses float utilities */
.pull-left {
  float: left !important;
}

.pull-right {
  float: right !important;
}

/* Bootstrap 3 col-push and col-pull classes - Bootstrap 5 uses order utilities */
.col-sm-push-8 {
  left: 66.66666667%;
  position: relative;
}

.col-sm-pull-4 {
  right: 33.33333333%;
  position: relative;
}

.col-md-push-7 {
  left: 58.33333333%;
  position: relative;
}

.col-md-pull-5 {
  right: 41.66666667%;
  position: relative;
}

.col-lg-pull-5 {
  right: 41.66666667%;
  position: relative;
}

/* Center block */
.center-block {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* Affix positioning */
.affix {
  position: fixed;
}

.affix-top {
  position: relative;
}

.affix-bottom {
  position: absolute;
}

/* Modal dialog sizing */
.modal-dialog.modal-sm {
  max-width: 300px;
}

.modal-dialog.modal-lg {
  max-width: 800px;
}

/* Glyphicon fallback - Bootstrap 5 removed glyphicons */
.glyphicon {
  position: relative;
  top: 1px;
  display: inline-block;
  font-family: 'Glyphicons Halflings';
  font-style: normal;
  font-weight: 400;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Caret */
.caret {
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 2px;
  vertical-align: middle;
  border-top: 4px dashed;
  border-top: 4px solid\9;
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
}

/* Close button compatibility */
.close {
  float: right;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: #000;
  text-shadow: 0 1px 0 #fff;
  opacity: 0.5;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.close:hover {
  color: #000;
  text-decoration: none;
  opacity: 0.75;
}

/* Responsive utilities */
@media (max-width: 575.98px) {
  .hidden-xs {
    display: none !important;
  }
  .visible-xs {
    display: block !important;
  }
}

@media (min-width: 576px) and (max-width: 767.98px) {
  .hidden-sm {
    display: none !important;
  }
  .visible-sm {
    display: block !important;
  }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  .hidden-md {
    display: none !important;
  }
  .visible-md {
    display: block !important;
  }
}

@media (min-width: 992px) {
  .hidden-lg {
    display: none !important;
  }
  .visible-lg {
    display: block !important;
  }
}

/* Container fluid padding fix for Bootstrap 5 - REMOVED as it breaks layouts */
/* Only apply if you have specific issues */

/* Row negative margin fix - REMOVED as it breaks grid system */
/* Bootstrap 5 handles this correctly */

/* Column padding - REMOVED as it breaks layouts */
/* Bootstrap 5 handles this correctly */

/* Form horizontal compatibility */
.form-horizontal .form-group {
  margin-right: -15px;
  margin-left: -15px;
}

.form-horizontal .control-label {
  padding-top: 7px;
  margin-bottom: 0;
  text-align: right;
}

/* Popover positioning fix for Bootstrap 5 */
.popover {
  z-index: 1060;
}

/* Tooltip z-index */
.tooltip {
  z-index: 1070;
}

/* Modal backdrop z-index */
.modal-backdrop {
  z-index: 1040;
}

/* Modal z-index */
.modal {
  z-index: 1050;
}

/* Dropdown compatibility fixes */
.dropdown-toggle {
  cursor: pointer !important;
}

/* Bootstrap 3 used .open, Bootstrap 5 uses .show - support both */
.dropdown.open > .dropdown-menu,
.dropdown.show > .dropdown-menu {
  display: block;
}

/* Ensure dropdown menu appears above other content */
.dropdown-menu {
  z-index: 1000;
  display: none;
}

.dropdown-menu.show {
  display: block;
}

/* Make entire dropdown toggle clickable, not just the caret */
.dropdown > a.dropdown-toggle,
.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

/* REMOVE Bootstrap 5 default caret/arrow from dropdown toggles */
.dropdown-toggle::after,
.dropdown-toggle-initialized::after,
a.dropdown-toggle::after {
  display: none !important;
  content: none !important;
}

/* Keep custom icons (like icon-down-open) visible */
.dropdown-toggle i,
.dropdown-toggle img {
  display: inline-block !important;
}

/* Dropdown menu positioning */
.dropdown {
  position: relative;
}

/* Fix dropdown menu alignment */
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.125rem;
}

/* Navbar dropdown fixes */
#Account .dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  left: auto;
  min-width: 300px;
  max-width: 500px;
  width: auto;
}

/* Make Account dropdown wider when sub-menu is present */
#Account .dropdown-menu:has(.sub-menu) {
  min-width: 370px;
}

/* Notification dropdown - position under the bell icon */
#Notification .dropdown-menu {
  position: absolute !important;
  top: 100% !important;
  left: 50% !important;
  right: auto !important;
  transform: translateX(-50%) !important;
  margin-top: 2px !important;
}

/* Ensure each dropdown in notification list is positioned relative to its parent */
#Notification .noti_list > li {
  position: relative;
}

#Notification .noti_list .dropdown {
  position: relative;
  display: inline-block;
}

/* Development plan dropdown positioning */
#Notification .noti_list > li > .dropdown > .dropdown-menu {
  position: absolute !important;
  top: 100% !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
}

/* Fix for nested dropdowns */
.dropdown-menu .dropdown-menu {
  top: 0;
  left: 100%;
  margin-top: -1px;
}

/* Remove outline on dropdown toggle focus */
.dropdown-toggle:focus {
  outline: 0;
}

/* Dropdown item hover state */
.dropdown-item:hover,
.dropdown-item:focus {
  background-color: #f8f9fa;
  color: #16181b;
  text-decoration: none;
}

/* Sub-menu compatibility (for nested menus) */
.sub-menu {
  position: relative;
}

.sub-menu-content {
  display: none;
  position: absolute;
  top: 0;
  left: 100%;
  min-width: 220px;
  max-width: 280px;
  margin-left: 5px;
  z-index: 1002;
  background-color: #fff;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 0.25rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.175);
  padding: 0;
}

.sub-menu:hover .sub-menu-content,
.sub-menu:focus-within .sub-menu-content {
  display: block;
}

/* Ensure sub-menu items are styled properly */
.sub-menu-content li {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sub-menu-content a {
  display: block;
  padding: 0.5rem 1rem;
  color: #212529;
  text-decoration: none;
  white-space: nowrap;
}

.sub-menu-content a:hover,
.sub-menu-content a:focus {
  background-color: #f8f9fa;
  color: #16181b;
}

/* Prevent sub-menu from causing page overflow */
#Account .dropdown-menu {
  overflow: visible;
}

/* Staff Detail Page - Date input width fix */
#Information input[type="date"].form-control {
  width: 17rem;
  max-width: 100%;
}

/* Staff Detail Page - Date inputs in tables should be smaller */
#Information table input[type="date"].form-control,
#Information .table-responsive input[type="date"].form-control {
  width: 10rem;
  max-width: 100%;
}

/* Staff Detail Page - Search box layout fixes */
#Information .input-group {
  display: table;
  width: 100%;
  border-collapse: separate;
}

#Information .input-group .form-control {
  display: table-cell;
  width: 100%;
  position: relative;
  z-index: 2;
  float: left;
  margin-bottom: 0;
}

#Information .input-group-btn {
  display: table-cell;
  width: 1%;
  white-space: nowrap;
  vertical-align: middle;
  position: relative;
  font-size: 0;
}

#Information .input-group-btn > .btn {
  position: relative;
  white-space: nowrap;
  margin-left: -1px;
}

#Information .input-group-btn:last-child > .btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

#Information .input-group .form-control:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

/* Date input height standardization */
input[type="date"].form-control {
  height: 36px !important;
  line-height: 1.42857143;
  padding: 6px 12px;
}
