/*
 * Bootstrap 3 → 5 Compatibility Layer
 * ====================================
 * Scope: Module content areas ONLY (inside .app-content / #content)
 * NOT for layout chrome (sidebar, header, footer)
 *
 * Purpose: Allow existing module Blade files (612 files across 38 modules)
 * to render correctly with BS5 without immediate mass-migration.
 *
 * Remove after all modules migrated (Phase 9).
 */

/* ============================================
   Panels → Cards
   ============================================ */
.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  word-wrap: break-word;
  background-color: #fff;
  background-clip: border-box;
  border: 1px solid rgba(0, 0, 0, 0.125);
  border-radius: 0.375rem;
  margin-bottom: 1rem;
}
.panel-heading {
  padding: 0.75rem 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.375rem - 1px) calc(0.375rem - 1px) 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-body {
  flex: 1 1 auto;
  padding: 1rem;
}
.panel-footer {
  padding: 0.75rem 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.375rem - 1px) calc(0.375rem - 1px);
}
.panel-title {
  margin-bottom: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
}
.panel-title > a {
  text-decoration: none;
  color: inherit;
}

/* Panel color variants */
.panel-inverse .panel-heading {
  background-color: var(--app-component-header-bg, #1a2229);
  color: #fff;
  border-bottom-color: var(--app-component-header-bg, #1a2229);
}
.panel-inverse .panel-heading a,
.panel-inverse .panel-heading .panel-title {
  color: #fff;
}
.panel-default { border-color: #dee2e6; }
.panel-default > .panel-heading { background-color: #f8f9fa; border-bottom-color: #dee2e6; }
.panel-primary > .panel-heading { background-color: #0d6efd; color: #fff; border-bottom-color: #0d6efd; }
.panel-success > .panel-heading { background-color: #198754; color: #fff; border-bottom-color: #198754; }
.panel-info > .panel-heading { background-color: #0dcaf0; color: #212529; border-bottom-color: #0dcaf0; }
.panel-warning > .panel-heading { background-color: #ffc107; color: #212529; border-bottom-color: #ffc107; }
.panel-danger > .panel-heading { background-color: #dc3545; color: #fff; border-bottom-color: #dc3545; }

/* Panel toolbar buttons */
.panel-heading-btn {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-left: auto;
}
[dir="rtl"] .panel-heading-btn { margin-left: 0; margin-right: auto; }
.panel-heading-btn > a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  color: inherit;
  opacity: 0.6;
  text-decoration: none;
  font-size: 14px;
}
.panel-heading-btn > a:hover { opacity: 1; }

/* ============================================
   Grid: col-xs-* → col-*
   BS3 col-xs-* = no media query (applies at all sizes).
   BS5 equivalent is col-* (also no media query).
   BUT: col-xs-* must NOT override col-sm/md/lg/xl at their breakpoints.
   Solution: scope col-xs-* to xs only (< 576px).
   ============================================ */
@media (max-width: 575.98px) {
  .col-xs-1  { flex: 0 0 auto; width: 8.33333333%; }
  .col-xs-2  { flex: 0 0 auto; width: 16.66666667%; }
  .col-xs-3  { flex: 0 0 auto; width: 25%; }
  .col-xs-4  { flex: 0 0 auto; width: 33.33333333%; }
  .col-xs-5  { flex: 0 0 auto; width: 41.66666667%; }
  .col-xs-6  { flex: 0 0 auto; width: 50%; }
  .col-xs-7  { flex: 0 0 auto; width: 58.33333333%; }
  .col-xs-8  { flex: 0 0 auto; width: 66.66666667%; }
  .col-xs-9  { flex: 0 0 auto; width: 75%; }
  .col-xs-10 { flex: 0 0 auto; width: 83.33333333%; }
  .col-xs-11 { flex: 0 0 auto; width: 91.66666667%; }
  .col-xs-12 { flex: 0 0 auto; width: 100%; }

  .col-xs-offset-0  { margin-left: 0; }
  .col-xs-offset-1  { margin-left: 8.33333333%; }
  .col-xs-offset-2  { margin-left: 16.66666667%; }
  .col-xs-offset-3  { margin-left: 25%; }
  .col-xs-offset-4  { margin-left: 33.33333333%; }
  .col-xs-offset-5  { margin-left: 41.66666667%; }
  .col-xs-offset-6  { margin-left: 50%; }

  [dir="rtl"] .col-xs-offset-1  { margin-left: 0; margin-right: 8.33333333%; }
  [dir="rtl"] .col-xs-offset-2  { margin-left: 0; margin-right: 16.66666667%; }
  [dir="rtl"] .col-xs-offset-3  { margin-left: 0; margin-right: 25%; }
  [dir="rtl"] .col-xs-offset-4  { margin-left: 0; margin-right: 33.33333333%; }
  [dir="rtl"] .col-xs-offset-5  { margin-left: 0; margin-right: 41.66666667%; }
  [dir="rtl"] .col-xs-offset-6  { margin-left: 0; margin-right: 50%; }
}

/* ============================================
   Buttons
   ============================================ */
.btn-default {
  color: #212529;
  background-color: #f8f9fa;
  border-color: #dee2e6;
}
.btn-default:hover { color: #212529; background-color: #e2e6ea; border-color: #dae0e5; }
.btn-default:focus, .btn-default.focus { box-shadow: 0 0 0 0.25rem rgba(108, 117, 125, 0.5); }

/* ============================================
   Forms
   ============================================ */
.form-group { margin-bottom: 1rem; }
.control-label { display: inline-block; margin-bottom: 0.5rem; font-weight: 600; }
.help-block { display: block; margin-top: 0.25rem; font-size: 0.875em; color: #6c757d; }
.has-error .form-control,
.has-error .form-select { border-color: var(--bs-danger, #dc3545); }
.has-error .help-block,
.has-error .control-label { color: var(--bs-danger, #dc3545); }
.has-success .form-control { border-color: var(--bs-success, #198754); }
.has-warning .form-control { border-color: var(--bs-warning, #ffc107); }
.input-group-addon {
  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 #dee2e6;
  border-radius: 0.375rem;
}
.input-sm { min-height: calc(1.5em + 0.5rem + 2px); padding: 0.25rem 0.5rem; font-size: 0.875rem; border-radius: 0.25rem; }
.input-lg { min-height: calc(1.5em + 1rem + 2px); padding: 0.5rem 1rem; font-size: 1.25rem; border-radius: 0.5rem; }

/* ============================================
   Utilities
   ============================================ */
.pull-left  { float: left !important; }
.pull-right { float: right !important; }
[dir="rtl"] .pull-left  { float: right !important; }
[dir="rtl"] .pull-right { float: left !important; }

.text-left   { text-align: left !important; }
.text-right  { text-align: right !important; }
[dir="rtl"] .text-left  { text-align: right !important; }
[dir="rtl"] .text-right { text-align: left !important; }

.img-responsive { max-width: 100%; height: auto; display: block; }
.img-circle { border-radius: 50%; }
.img-rounded { border-radius: 0.375rem; }

/* Visibility */
.hidden { display: none !important; }
.show, .in { display: block !important; }

@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; } }

.fade.in { opacity: 1; }

/* ============================================
   Labels → Badges
   ============================================ */
span.label, a.label {
  display: inline-block;
  padding: 0.35em 0.65em;
  font-size: 0.75em;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: 0.375rem;
  text-decoration: none;
}
/* ============================================
   Color Admin v1.9 Custom Spacing
   ============================================ */
.m-b-0  { margin-bottom: 0 !important; }  .m-b-5  { margin-bottom: 5px !important; }
.m-b-10 { margin-bottom: 10px !important; } .m-b-15 { margin-bottom: 15px !important; }
.m-b-20 { margin-bottom: 20px !important; } .m-b-25 { margin-bottom: 25px !important; }
.m-b-30 { margin-bottom: 30px !important; }

.m-t-0  { margin-top: 0 !important; }  .m-t-5  { margin-top: 5px !important; }
.m-t-10 { margin-top: 10px !important; } .m-t-15 { margin-top: 15px !important; }
.m-t-20 { margin-top: 20px !important; } .m-t-25 { margin-top: 25px !important; }
.m-t-30 { margin-top: 30px !important; }

.m-r-0  { margin-right: 0 !important; } .m-r-5  { margin-right: 5px !important; }
.m-r-10 { margin-right: 10px !important; } .m-r-15 { margin-right: 15px !important; }
.m-r-20 { margin-right: 20px !important; }

.m-l-0  { margin-left: 0 !important; } .m-l-5  { margin-left: 5px !important; }
.m-l-10 { margin-left: 10px !important; } .m-l-15 { margin-left: 15px !important; }
.m-l-20 { margin-left: 20px !important; }

.p-t-0  { padding-top: 0 !important; }  .p-t-5  { padding-top: 5px !important; }
.p-t-10 { padding-top: 10px !important; } .p-t-15 { padding-top: 15px !important; }
.p-t-20 { padding-top: 20px !important; }

.p-b-0  { padding-bottom: 0 !important; }  .p-b-5  { padding-bottom: 5px !important; }
.p-b-10 { padding-bottom: 10px !important; } .p-b-15 { padding-bottom: 15px !important; }
.p-b-20 { padding-bottom: 20px !important; }

.p-l-0  { padding-left: 0 !important; }  .p-l-5  { padding-left: 5px !important; }
.p-l-10 { padding-left: 10px !important; } .p-l-15 { padding-left: 15px !important; }
.p-l-20 { padding-left: 20px !important; }

.p-r-0  { padding-right: 0 !important; }  .p-r-5  { padding-right: 5px !important; }
.p-r-10 { padding-right: 10px !important; } .p-r-15 { padding-right: 15px !important; }
.p-r-20 { padding-right: 20px !important; }

[dir="rtl"] .m-r-5  { margin-right: 0 !important; margin-left: 5px !important; }
[dir="rtl"] .m-r-10 { margin-right: 0 !important; margin-left: 10px !important; }
[dir="rtl"] .m-r-15 { margin-right: 0 !important; margin-left: 15px !important; }
[dir="rtl"] .m-r-20 { margin-right: 0 !important; margin-left: 20px !important; }
[dir="rtl"] .m-l-5  { margin-left: 0 !important; margin-right: 5px !important; }
[dir="rtl"] .m-l-10 { margin-left: 0 !important; margin-right: 10px !important; }
[dir="rtl"] .m-l-15 { margin-left: 0 !important; margin-right: 15px !important; }
[dir="rtl"] .m-l-20 { margin-left: 0 !important; margin-right: 20px !important; }

/* ============================================
   Breadcrumb compat
   ============================================ */
.breadcrumb > li { display: inline-block; }
.breadcrumb > li + li::before { content: "/"; padding: 0 0.5rem; color: #6c757d; }
[dir="rtl"] .breadcrumb > li + li::before { content: "\\"; }

/* ============================================
   Well → Card with bg-light
   ============================================ */
.well { min-height: 20px; padding: 19px; margin-bottom: 20px; background-color: #f8f9fa; border: 1px solid #dee2e6; border-radius: 0.375rem; }
.well-sm { padding: 9px; }
.well-lg { padding: 24px; }

/* ============================================
   Nav Tabs compat
   ============================================ */
.nav-tabs > li { margin-bottom: -1px; }
.nav-tabs > li > a {
  border: 1px solid transparent;
  border-radius: 0.375rem 0.375rem 0 0;
  display: block;
  padding: 0.5rem 1rem;
  color: #495057;
  text-decoration: none;
}
.nav-tabs > li > a:hover { border-color: #e9ecef #e9ecef #dee2e6; }
.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover { color: #495057; background-color: #fff; border-color: #dee2e6 #dee2e6 #fff; }

/* ============================================
   Pagination compat
   ============================================ */
.pagination > li > a,
.pagination > li > span {
  position: relative; display: block; padding: 0.375rem 0.75rem;
  color: #0d6efd; text-decoration: none; background-color: #fff; border: 1px solid #dee2e6;
}
.pagination > li.active > a { z-index: 3; color: #fff; background-color: #0d6efd; border-color: #0d6efd; }
.pagination > li.disabled > a { color: #6c757d; pointer-events: none; background-color: #fff; }

/* ============================================
   Thumbnail compat
   ============================================ */
.thumbnail { display: block; padding: 4px; margin-bottom: 1rem; background-color: #fff; border: 1px solid #dee2e6; border-radius: 0.375rem; }
.thumbnail > img { max-width: 100%; height: auto; }

/* ============================================
   Switchery → BS5 form-switch visual compat
   ============================================ */
input[data-render="switchery"] {
  appearance: none; -webkit-appearance: none;
  width: 44px; height: 22px; background-color: #dee2e6;
  border-radius: 11px; position: relative; cursor: pointer;
  transition: background-color 0.15s ease-in-out;
  outline: none; border: none; vertical-align: middle;
}
input[data-render="switchery"]::before {
  content: ''; position: absolute; width: 18px; height: 18px;
  border-radius: 50%; background-color: #fff; top: 2px; left: 2px;
  transition: transform 0.15s ease-in-out; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
input[data-render="switchery"]:checked { background-color: #198754; }
input[data-render="switchery"]:checked::before { transform: translateX(22px); }
[dir="rtl"] input[data-render="switchery"]::before { left: auto; right: 2px; }
[dir="rtl"] input[data-render="switchery"]:checked::before { transform: translateX(-22px); }

/* ============================================
   Color Admin v1.9 background color classes
   v5.5.2 uses numeric variants (bg-blue-700) but
   modules still reference v1.9 named variants.
   ============================================ */
.bg-silver-darker { background: #b4b6b7 !important; }
.bg-black-darker  { background: #242a30 !important; }
.bg-grey-darker   { background: #929ba1 !important; }
.bg-red-darker    { background: #cc4946 !important; }
.bg-orange-darker { background: #c47d15 !important; }
.bg-yellow-darker { background: #b6c832 !important; }
.bg-green-darker  { background: #008a8a !important; }
.bg-blue-darker   { background: #2a72b5 !important; }
.bg-aqua-darker   { background: #3a92ab !important; }
.bg-purple-darker { background: #5b6392 !important; }

.bg-silver-lighter { background: #f4f6f7 !important; }
.bg-black-lighter  { background: #575d63 !important; }
.bg-grey-lighter   { background: #c5c7cb !important; }
.bg-red-lighter    { background: #e1756f !important; }
.bg-orange-lighter { background: #f5b048 !important; }
.bg-yellow-lighter { background: #e1e572 !important; }
.bg-green-lighter  { background: #33bdbd !important; }
.bg-blue-lighter   { background: #5da5e2 !important; }
.bg-aqua-lighter   { background: #6dc5de !important; }
.bg-purple-lighter { background: #8e8ec1 !important; }

.bg-green  { background: #00acac !important; }
.bg-aqua   { background: #49b6d6 !important; }
.bg-purple { background: #727cb6 !important; }

/* ============================================
   Navbar: BS3 <li> → v5.5.2 .navbar-item
   Core partials still use <li class="dropdown"> inside .navbar-nav.
   v5.5.2 expects <div class="navbar-item dropdown">.
   ============================================ */
.app-header .navbar-nav > li {
  position: relative;
}
.app-header .navbar-nav > li > a {
  display: block;
  text-decoration: none;
  padding: 15px;
  line-height: 20px;
  color: rgba(255,255,255,.6);
}
.app-header .navbar-nav > li > a:hover,
.app-header .navbar-nav > li > a:focus {
  color: rgba(255,255,255,.9);
  opacity: .75;
}
.app-header .navbar-nav > li > a i {
  position: relative;
  font-size: 16px;
}
.app-header .navbar-nav > li.dropdown .dropdown-menu {
  margin: 0;
  top: 100% !important;
  position: absolute;
  min-width: 180px;
}
.app-header .navbar-nav > li .dropdown-menu a {
  color: var(--bs-body-color, #333);
  padding: 7px 15px;
  display: block;
  text-decoration: none;
}
.app-header .navbar-nav > li .dropdown-menu a:hover {
  background-color: var(--bs-tertiary-bg, #f0f0f0);
}
/* Flag icons in language menu */
.app-header .navbar-nav .flag-icon {
  margin-inline-end: 5px;
}
/* Caret in navbar dropdowns */
.app-header .navbar-nav .caret {
  display: inline-block;
  width: 0; height: 0;
  margin-left: 4px;
  vertical-align: middle;
  border-top: 4px solid;
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
}
