/**
 * Bootstrap 5 Compatibility Styles
 * =================================
 * This file provides compatibility styles for Bootstrap 4 to 5 migration
 * Includes utility classes that were removed or renamed in Bootstrap 5
 */

/* ================================
   SPACING UTILITIES (Bootstrap 4 style)
   Bootstrap 5 changed ml/mr/pl/pr to ms/me/ps/pe
   ================================ */

/* Margin Left/Right (ml-*, mr-*) */
.ml-0 { margin-left: 0 !important; }
.ml-1 { margin-left: 0.25rem !important; }
.ml-2 { margin-left: 0.5rem !important; }
.ml-3 { margin-left: 1rem !important; }
.ml-4 { margin-left: 1.5rem !important; }
.ml-5 { margin-left: 3rem !important; }
.ml-auto { margin-left: auto !important; }

.mr-0 { margin-right: 0 !important; }
.mr-1 { margin-right: 0.25rem !important; }
.mr-2 { margin-right: 0.5rem !important; }
.mr-3 { margin-right: 1rem !important; }
.mr-4 { margin-right: 1.5rem !important; }
.mr-5 { margin-right: 3rem !important; }
.mr-auto { margin-right: auto !important; }

/* Padding Left/Right (pl-*, pr-*) */
.pl-0 { padding-left: 0 !important; }
.pl-1 { padding-left: 0.25rem !important; }
.pl-2 { padding-left: 0.5rem !important; }
.pl-3 { padding-left: 1rem !important; }
.pl-4 { padding-left: 1.5rem !important; }
.pl-5 { padding-left: 3rem !important; }

.pr-0 { padding-right: 0 !important; }
.pr-1 { padding-right: 0.25rem !important; }
.pr-2 { padding-right: 0.5rem !important; }
.pr-3 { padding-right: 1rem !important; }
.pr-4 { padding-right: 1.5rem !important; }
.pr-5 { padding-right: 3rem !important; }

/* Responsive spacing utilities */
@media (min-width: 576px) {
  .ml-sm-0 { margin-left: 0 !important; }
  .ml-sm-2 { margin-left: 0.5rem !important; }
  .ml-sm-4 { margin-left: 1.5rem !important; }
  .mr-sm-0 { margin-right: 0 !important; }
  .mr-sm-2 { margin-right: 0.5rem !important; }
  .mr-sm-4 { margin-right: 1.5rem !important; }
  .pl-sm-2 { padding-left: 0.5rem !important; }
  .pr-sm-2 { padding-right: 0.5rem !important; }
}

@media (min-width: 992px) {
  .ml-lg-0 { margin-left: 0 !important; }
  .ml-lg-4 { margin-left: 1.5rem !important; }
  .mr-lg-0 { margin-right: 0 !important; }
  .mr-lg-4 { margin-right: 1.5rem !important; }
}

/* ================================
   TEXT ALIGNMENT UTILITIES
   Bootstrap 5 changed text-left/right to text-start/end
   ================================ */
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

/* Responsive text alignment */
@media (min-width: 576px) {
  .text-sm-left { text-align: left !important; }
  .text-sm-right { text-align: right !important; }
}

@media (min-width: 768px) {
  .text-md-left { text-align: left !important; }
  .text-md-right { text-align: right !important; }
}

@media (min-width: 992px) {
  .text-lg-left { text-align: left !important; }
  .text-lg-right { text-align: right !important; }
}

/* ================================
   FLOAT UTILITIES
   Bootstrap 5 changed float-left/right to float-start/end
   ================================ */
.float-left { float: left !important; }
.float-right { float: right !important; }
.pull-left { float: left !important; }
.pull-right { float: right !important; }

/* ================================
   FORM COMPONENTS
   ================================ */

/* Form Groups - Bootstrap 5 removed .form-group */
.form-group {
  margin-bottom: 1rem;
}

/* Form Row - Bootstrap 5 removed .form-row, use .row instead */
.form-row {
  display: flex;
  flex-wrap: wrap;
  margin-right: -5px;
  margin-left: -5px;
}

.form-row > .col,
.form-row > [class*="col-"] {
  padding-right: 5px;
  padding-left: 5px;
}

/* Custom Controls - Bootstrap 5 changed to .form-check */
.custom-control {
  position: relative;
  z-index: 1;
  display: block;
  min-height: 1.5rem;
  padding-left: 1.5rem;
  color-adjust: exact;
}

.custom-control-inline {
  display: inline-flex;
  margin-right: 1rem;
}

.custom-control-input {
  position: absolute;
  left: 0;
  z-index: -1;
  width: 1rem;
  height: 1.25rem;
  opacity: 0;
}

.custom-control-label {
  position: relative;
  margin-bottom: 0;
  vertical-align: top;
  cursor: pointer;
}

/* Custom Radio */
.custom-radio .custom-control-label::before {
  border-radius: 50%;
}

.custom-radio .custom-control-input:checked ~ .custom-control-label::after {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
}

/* Custom Checkbox */
.custom-checkbox .custom-control-label::before {
  border-radius: 0.25rem;
}

.custom-checkbox .custom-control-input:checked ~ .custom-control-label::after {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3e%3cpath fill='%23fff' d='M6.564.75l-3.59 3.612-1.538-1.55L0 4.26l2.974 2.99L8 2.193z'/%3e%3c/svg%3e");
}

/* Custom Control Styles */
.custom-control-label::before {
  position: absolute;
  top: 0.25rem;
  left: -1.5rem;
  display: block;
  width: 1rem;
  height: 1rem;
  pointer-events: none;
  content: "";
  background-color: #fff;
  border: 1px solid #adb5bd;
}

.custom-control-label::after {
  position: absolute;
  top: 0.25rem;
  left: -1.5rem;
  display: block;
  width: 1rem;
  height: 1rem;
  content: "";
  background: 50% / 50% 50% no-repeat;
}

.custom-control-input:checked ~ .custom-control-label::before {
  color: #fff;
  border-color: #0d6efd;
  background-color: #0d6efd;
}

.custom-control-input:focus ~ .custom-control-label::before {
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.custom-control-input:focus:not(:checked) ~ .custom-control-label::before {
  border-color: #86b7fe;
}

.custom-control-input:not(:disabled):active ~ .custom-control-label::before {
  color: #fff;
  background-color: #b6d4fe;
  border-color: #b6d4fe;
}

.custom-control-input:disabled ~ .custom-control-label,
.custom-control-input[disabled] ~ .custom-control-label {
  color: #6c757d;
}

.custom-control-input:disabled ~ .custom-control-label::before,
.custom-control-input[disabled] ~ .custom-control-label::before {
  background-color: #e9ecef;
}

/* Custom Select - Bootstrap 5 removed .custom-select */
.custom-select {
  display: inline-block;
  width: 100%;
  height: calc(1.5em + 0.75rem + 2px);
  padding: 0.375rem 1.75rem 0.375rem 0.75rem;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: #212529;
  vertical-align: middle;
  background: #fff url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='4' height='5' viewBox='0 0 4 5'%3e%3cpath fill='%23343a40' d='M2 0L0 2h4zm0 5L0 3h4z'/%3e%3c/svg%3e") right 0.75rem center/8px 10px no-repeat;
  border: 1px solid #ced4da;
  border-radius: 0.25rem;
  appearance: none;
}

.custom-select:focus {
  border-color: #86b7fe;
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.custom-select:disabled {
  color: #6c757d;
  background-color: #e9ecef;
}

/* ================================
   CLOSE BUTTON
   Bootstrap 5 renamed .close to .btn-close
   ================================ */
.close {
  float: right;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: #000;
  text-shadow: 0 1px 0 #fff;
  opacity: .5;
  background-color: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.close:hover,
.close:focus {
  color: #000;
  text-decoration: none;
  opacity: .75;
}

button.close {
  padding: 0;
  background-color: transparent;
  border: 0;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* ================================
   BADGE UTILITIES
   Bootstrap 5 changed badge-* to bg-*
   ================================ */
.badge-primary { background-color: #0d6efd !important; }
.badge-secondary { background-color: #6c757d !important; }
.badge-success { background-color: #198754 !important; }
.badge-danger { background-color: #dc3545 !important; }
.badge-warning { background-color: #ffc107 !important; color: #212529 !important; }
.badge-info { background-color: #0dcaf0 !important; color: #212529 !important; }
.badge-light { background-color: #f8f9fa !important; color: #212529 !important; }
.badge-dark { background-color: #212529 !important; }

/* ================================
   FONT WEIGHT UTILITIES
   Bootstrap 5 changed font-weight-* to fw-*
   ================================ */
.font-weight-bold { font-weight: 700 !important; }
.font-weight-bolder { font-weight: bolder !important; }
.font-weight-normal { font-weight: 400 !important; }
.font-weight-light { font-weight: 300 !important; }
.font-weight-lighter { font-weight: lighter !important; }

/* ================================
   UTILITY CLASSES
   ================================ */

/* Screen Reader Only - Bootstrap 5 changed to .visually-hidden */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.sr-only-focusable:active,
.sr-only-focusable:focus {
  position: static !important;
  width: auto !important;
  height: auto !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
}

/* No Gutters - Bootstrap 5 changed to .g-0 */
.no-gutters {
  margin-right: 0;
  margin-left: 0;
}

.no-gutters > .col,
.no-gutters > [class*="col-"] {
  padding-right: 0;
  padding-left: 0;
}

/* Media Object - Removed in Bootstrap 5 */
.media {
  display: flex;
  align-items: flex-start;
}

.media-body {
  flex: 1;
}

/* ================================
   INPUT GROUP
   Bootstrap 5 changed append/prepend structure
   ================================ */
.input-group-append,
.input-group-prepend {
  display: flex;
}

.input-group-append {
  margin-left: -1px;
}

.input-group-prepend {
  margin-right: -1px;
}

.input-group-text {
  display: flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: #212529;
  text-align: center;
  white-space: nowrap;
  background-color: #e9ecef;
  border: 1px solid #ced4da;
  border-radius: 0.25rem;
}

/* Form Control File - Removed in Bootstrap 5 */
.form-control-file {
  display: block;
  width: 100%;
}