/* Bootstrap 5 utility shim
 * The theme ships CoreUI 3 (Bootstrap 4). Module list templates were authored
 * against Bootstrap 5. This file backfills the BS5 utilities those templates rely on.
 */

/* === Gap utilities === */
.gap-0 { gap: 0 !important; }
.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.gap-4 { gap: 1.5rem !important; }
.gap-5 { gap: 3rem !important; }

/* === Logical margin / padding (start/end → left/right in LTR) === */
.ms-0 { margin-left: 0 !important; }
.ms-1 { margin-left: 0.25rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.ms-3 { margin-left: 1rem !important; }
.ms-4 { margin-left: 1.5rem !important; }
.ms-5 { margin-left: 3rem !important; }
.ms-auto { margin-left: auto !important; }
.me-0 { margin-right: 0 !important; }
.me-1 { margin-right: 0.25rem !important; }
.me-2 { margin-right: 0.5rem !important; }
.me-3 { margin-right: 1rem !important; }
.me-4 { margin-right: 1.5rem !important; }
.me-5 { margin-right: 3rem !important; }
.me-auto { margin-right: auto !important; }
.ps-0 { padding-left: 0 !important; }
.ps-1 { padding-left: 0.25rem !important; }
.ps-2 { padding-left: 0.5rem !important; }
.ps-3 { padding-left: 1rem !important; }
.ps-4 { padding-left: 1.5rem !important; }
.ps-5 { padding-left: 3rem !important; }
.pe-0 { padding-right: 0 !important; }
.pe-1 { padding-right: 0.25rem !important; }
.pe-2 { padding-right: 0.5rem !important; }
.pe-3 { padding-right: 1rem !important; }
.pe-4 { padding-right: 1.5rem !important; }
.pe-5 { padding-right: 3rem !important; }

/* === Text alignment (BS5 logical) === */
.text-start { text-align: left !important; }
.text-end { text-align: right !important; }

/* === Position helpers === */
.start-0 { left: 0 !important; }
.start-50 { left: 50% !important; }
.start-100 { left: 100% !important; }
.end-0 { right: 0 !important; }
.end-50 { right: 50% !important; }
.end-100 { right: 100% !important; }
.top-0 { top: 0 !important; }
.top-50 { top: 50% !important; }
.top-100 { top: 100% !important; }
.bottom-0 { bottom: 0 !important; }
.bottom-50 { bottom: 50% !important; }
.bottom-100 { bottom: 100% !important; }
.translate-middle    { transform: translate(-50%, -50%) !important; }
.translate-middle-x  { transform: translateX(-50%) !important; }
.translate-middle-y  { transform: translateY(-50%) !important; }

/* === Form select (styled native select) === */
.form-select {
	display: block;
	width: 100%;
	padding: 0.375rem 2.25rem 0.375rem 0.75rem;
	font-size: 1rem;
	font-weight: 400;
	line-height: 1.5;
	color: #212529;
	background-color: #fff;
	background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
	background-repeat: no-repeat;
	background-position: right 0.75rem center;
	background-size: 16px 12px;
	border: 1px solid #ced4da;
	border-radius: 0.375rem;
	transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
}
.form-select:focus {
	border-color: #86b7fe;
	outline: 0;
	box-shadow: 0 0 0 0.25rem rgba(13,110,253,.25);
}

/* === Responsive flex direction / alignment / justify
       BS4 ships sm/md/lg/xl versions of flex-row, flex-column, etc., but newer
       BS5 templates also use *-sm-row / *-md-row variants. Re-declare for safety. === */
@media (min-width: 576px) {
	.flex-sm-row { flex-direction: row !important; }
	.flex-sm-column { flex-direction: column !important; }
	.align-items-sm-start   { align-items: flex-start !important; }
	.align-items-sm-center  { align-items: center !important; }
	.align-items-sm-end     { align-items: flex-end !important; }
	.align-items-sm-stretch { align-items: stretch !important; }
	.justify-content-sm-start   { justify-content: flex-start !important; }
	.justify-content-sm-center  { justify-content: center !important; }
	.justify-content-sm-end     { justify-content: flex-end !important; }
	.justify-content-sm-between { justify-content: space-between !important; }
	.justify-content-sm-around  { justify-content: space-around !important; }
}
@media (min-width: 768px) {
	.flex-md-row { flex-direction: row !important; }
	.flex-md-column { flex-direction: column !important; }
	.align-items-md-start   { align-items: flex-start !important; }
	.align-items-md-center  { align-items: center !important; }
	.align-items-md-end     { align-items: flex-end !important; }
	.align-items-md-stretch { align-items: stretch !important; }
	.justify-content-md-start   { justify-content: flex-start !important; }
	.justify-content-md-center  { justify-content: center !important; }
	.justify-content-md-end     { justify-content: flex-end !important; }
	.justify-content-md-between { justify-content: space-between !important; }
}
@media (min-width: 992px) {
	.flex-lg-row { flex-direction: row !important; }
	.flex-lg-column { flex-direction: column !important; }
	.align-items-lg-start   { align-items: flex-start !important; }
	.align-items-lg-center  { align-items: center !important; }
	.align-items-lg-end     { align-items: flex-end !important; }
	.align-items-lg-stretch { align-items: stretch !important; }
	.justify-content-lg-start   { justify-content: flex-start !important; }
	.justify-content-lg-center  { justify-content: center !important; }
	.justify-content-lg-end     { justify-content: flex-end !important; }
	.justify-content-lg-between { justify-content: space-between !important; }
}

/* === Button: outline-secondary (matches BS5 look) === */
.btn-outline-secondary {
	color: #6c757d;
	border-color: #ced4da;
	background-color: #fff;
}
.btn-outline-secondary:hover {
	color: #fff;
	background-color: #6c757d;
	border-color: #6c757d;
}

/* === Sort indicator inside table header — keep on the same line as the label === */
.table thead th .sort-indicator,
.table thead th .sortable-indicator,
.table thead th [class*="sort"] {
	display: inline-block;
	margin-left: 4px;
	vertical-align: middle;
}

/* === Pagination "Showing x to y of z resultsPage 1 of 1" — add a separator === */
[data-records-info] + [data-page-info]::before {
	content: '·';
	margin-right: 6px;
	color: #cbd5e1;
}

/* === Bootstrap Icons inside .form-control with leading icon === */
.position-relative .form-control.ps-5 { padding-left: 2.5rem !important; }

/* === Card shadow-sm === */
.card.shadow-sm {
	box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075) !important;
}

/* === min-lh-100 (full content height for List views) === */
.min-lh-100 { min-height: calc(100vh - 200px); }

/* === Form views wrap content in `.container py-4 min-lh-100`, which constrains
       the form to BS4's max-width. The list template uses `container-fluid`, so
       lists already span the full width. Promote `.container.min-lh-100` to
       full-width so forms match the list's full-width layout. === */
.container.min-lh-100 {
	max-width: none;
	width: 100%;
}

/* === Inputs: ensure form-control rounding is consistent with form-select === */
.form-control { border-radius: 0.375rem; }
.form-control:focus { border-color: #86b7fe; box-shadow: 0 0 0 0.25rem rgba(13,110,253,.25); }

/* === Button: btn-primary using brand color === */
.btn-primary {
	background-color: #2563EB;
	border-color: #2563EB;
}
.btn-primary:hover, .btn-primary:focus {
	background-color: #1D4ED8;
	border-color: #1D4ED8;
}

/* === Search input with leading icon — the icon's positioned via top-50 start-0 translate-middle-y ms-3 === */
.position-relative > .bi.position-absolute.top-50 {
	pointer-events: none;
}

/* === Bootstrap 5 form-label === */
.form-label {
	display: inline-block;
	margin-bottom: 0.5rem;
	font-weight: 500;
	color: #1F2937;
	font-size: 0.875rem;
}
.form-label .text-danger { font-weight: 600; }

/* === Bootstrap 5 grid gutter utilities (.g-*) === */
.row.g-0 { --bs-gutter-x: 0; --bs-gutter-y: 0; margin: 0; }
.row.g-1 { --bs-gutter-x: 0.25rem; --bs-gutter-y: 0.25rem; margin: -0.125rem -0.125rem; }
.row.g-2 { --bs-gutter-x: 0.5rem;  --bs-gutter-y: 0.5rem;  margin: -0.25rem -0.25rem; }
.row.g-3 { --bs-gutter-x: 1rem;    --bs-gutter-y: 1rem;    margin: -0.5rem -0.5rem; }
.row.g-4 { --bs-gutter-x: 1.5rem;  --bs-gutter-y: 1.5rem;  margin: -0.75rem -0.75rem; }
.row.g-5 { --bs-gutter-x: 3rem;    --bs-gutter-y: 3rem;    margin: -1.5rem -1.5rem; }
.row.g-1 > [class*="col"] { padding: 0.125rem; }
.row.g-2 > [class*="col"] { padding: 0.25rem; }
.row.g-3 > [class*="col"] { padding: 0.5rem; }
.row.g-4 > [class*="col"] { padding: 0.75rem; }
.row.g-5 > [class*="col"] { padding: 1.5rem; }

/* === Bootstrap 5 rounding === */
.rounded-0 { border-radius: 0 !important; }
.rounded-1 { border-radius: 0.25rem !important; }
.rounded-2 { border-radius: 0.5rem !important; }
.rounded-3 { border-radius: 0.75rem !important; }
.rounded-4 { border-radius: 1rem !important; }
.rounded-5 { border-radius: 2rem !important; }

/* === Bootstrap 5 form-check / form-check-input === */
.form-check {
	display: block;
	min-height: 1.5rem;
	padding-left: 1.75rem;
	margin-bottom: 0.125rem;
}
.form-check-input {
	width: 1.1em; height: 1.1em;
	margin-top: 0.2em;
	margin-left: -1.75rem !important;
	background-color: #fff;
	border: 1px solid rgba(0,0,0,0.25);
	border-radius: 0.25em;
	appearance: none; -webkit-appearance: none;
}
.form-check-input:checked {
	background-color: #2563EB;
	border-color: #2563EB;
	background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3 6-6'/%3e%3c/svg%3e");
	background-repeat: no-repeat;
	background-position: center;
	background-size: 100% 100%;
}
.form-check-label { color: #1F2937; }

/* === Bootstrap 5 tabs: data-bs-toggle works like data-toggle ===
       The CoreUI bundle uses Bootstrap 4 selectors. We dual-bind so BS5 markup activates BS4's tab JS. */
[data-bs-toggle="tab"] { cursor: pointer; }

/* === Bootstrap 5 file input style ===
       Unified bordered control with the "Choose File" button styled inline. */
input[type="file"] {
	display: block;
	width: 100%;
	min-height: 38px;
	padding: 0.375rem 0.75rem;
	font-size: 1rem;
	font-weight: 400;
	line-height: 1.5;
	color: #212529;
	background-color: #fff;
	background-clip: padding-box;
	border: 1px solid #ced4da;
	border-radius: 0.375rem;
	transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
input[type="file"]:hover { border-color: #adb5bd; }
input[type="file"]:focus {
	outline: 0;
	border-color: #86b7fe;
	box-shadow: 0 0 0 0.25rem rgba(13,110,253,.25);
}
input[type="file"]:disabled, input[type="file"][readonly] {
	background-color: #F8FAFC;
	color: #64748B;
	cursor: not-allowed;
}
/* The browser-rendered button inside the file input — make it look like a BS5 inline button */
input[type="file"]::file-selector-button {
	padding: 0.375rem 0.75rem;
	margin: -0.375rem 0.75rem -0.375rem -0.75rem;
	color: #212529;
	background-color: #e9ecef;
	pointer-events: none;
	border: 0;
	border-inline-end: 1px solid #ced4da;
	border-radius: 0;
	transition: color 0.15s ease, background-color 0.15s ease;
	font-family: inherit;
	font-size: inherit;
}
input[type="file"]:hover::file-selector-button { background-color: #dde0e3; }
/* Legacy WebKit (older Safari / iOS) */
input[type="file"]::-webkit-file-upload-button {
	padding: 0.375rem 0.75rem;
	margin: -0.375rem 0.75rem -0.375rem -0.75rem;
	color: #212529;
	background-color: #e9ecef;
	pointer-events: none;
	border: 0;
	border-right: 1px solid #ced4da;
	border-radius: 0;
	font-family: inherit;
	font-size: inherit;
}
input[type="file"]:hover::-webkit-file-upload-button { background-color: #dde0e3; }

/* === Cards — match TF's soft rounded look === */
.card.shadow-sm, .card-body .card {
	border: 1px solid #E5E7EB;
}
.card-title.h3 {
	font-weight: 700;
	color: #0F172A;
	letter-spacing: -0.01em;
}

/* === Form-control consistent height with form-select === */
.form-control, .form-select {
	min-height: 38px;
}

/* === Tab buttons (form tabs) === */
[role="tablist"] [role="tab"].btn-light.active {
	background-color: #2563EB !important;
	color: #fff !important;
	border-color: #2563EB !important;
	box-shadow: 0 2px 4px -2px rgba(37,99,235,0.4);
}
[role="tablist"] [role="tab"].btn-light {
	background-color: transparent;
	color: #475569;
	border: 0;
	transition: background-color 180ms ease, color 180ms ease;
}
[role="tablist"] [role="tab"].btn-light:hover {
	background-color: #F1F5F9;
	color: #0F172A;
}

/* === Form spacing — give Bootstrap 4 .row.g-4 fallback enough breathing room === */
.card-body > .row.g-4 > [class*="col"] {
	margin-bottom: 0.5rem;
}

/* === Disabled field styling — subtle, not stark === */
.form-control:disabled, .form-control[readonly],
.form-select:disabled, .form-select[readonly] {
	background-color: #F8FAFC;
	color: #64748B;
	cursor: not-allowed;
}

/* === Selects that ended up with .form-control instead of .form-select still look right === */
select.form-control {
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
	background-repeat: no-repeat;
	background-position: right 0.75rem center;
	background-size: 16px 12px;
	padding-right: 2.25rem;
}
