/* SAJ Custom Styles */

/* Logo adjustments in sidebar */
.logo-wrapper {
  padding: 20px 25px !important;
  border-bottom: 1px solid #e9ecef;
  margin-bottom: 15px;
  background-color: #fff;
  text-align: center;
}

.logo-wrapper .img-fluid {
  max-width: 120px !important;
  max-height: 120px !important;
  height: auto;
  display: block;
  margin: 0 auto;
  object-fit: contain;
}

.logo-wrapper a {
  display: block;
  text-decoration: none;
}

/* Logo icon wrapper for compact mode */
.logo-icon-wrapper {
  padding: 20px !important;
  text-align: center;
  border-bottom: 1px solid #e9ecef;
}

.logo-icon-wrapper .img-fluid {
  max-width: 40px !important;
  max-height: 40px !important;
  height: auto;
  display: block;
  margin: 0 auto;
  object-fit: contain;
}

/* Ensure proper spacing between logo and menu */
.sidebar-main {
  margin-top: 0;
}

.sidebar-main .sidebar-links {
  padding-top: 10px;
}

/* Back button logo in mobile */
.back-btn .img-fluid {
  max-width: 30px !important;
  max-height: 30px !important;
  object-fit: contain;
}

/* Additional SAJ specific styles can be added here */

/* Shared backend report form styles */
#report-create-form .cursor-pointer,
#report-edit-form .cursor-pointer {
  cursor: pointer;
}

#report-create-form .toggle-icon,
#report-edit-form .toggle-icon {
  transition: transform 0.3s ease;
}

#report-create-form [aria-expanded="true"] .toggle-icon,
#report-edit-form [aria-expanded="true"] .toggle-icon {
  transform: rotate(180deg);
}

#report-create-form .mb-3 label,
#report-edit-form .mb-3 label {
  font-weight: 500;
  margin-bottom: 0.4rem;
  font-size: 0.875rem;
  color: #495057;
}

/* Generated reports Select2 multiselect tweaks */
#generate-report-form .select2-container--default .select2-selection--multiple .select2-selection__choice {
  height: auto !important;
  line-height: 1.5 !important;
  padding: 3px 8px !important;
  margin: 3px 4px 3px 0 !important;
  font-size: 13px !important;
  background-color: #0d6efd !important;
  color: #fff !important;
  border: none !important;
  border-radius: 4px !important;
}

#generate-report-form .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
  color: #fff !important;
  margin-right: 4px !important;
  font-size: 14px !important;
}

#generate-report-form .select2-container--default .select2-selection--multiple {
  min-height: 38px !important;
  padding: 4px !important;
}

/* Mandate create validation normalization for optional fields */
#mandate-create-form.was-validated .form-control:not([required]):valid:placeholder-shown,
#mandate-create-form.was-validated .form-select:not([required]):valid:not(:has(option:checked[value=""])),
#mandate-create-form.was-validated .form-control:not([required]):valid[value=""],
#mandate-create-form.was-validated .form-control:not([required]):valid:not([value]) {
  background-image: none;
  border-color: #ced4da;
}

.organs-member-action-icon {
  width: 24px !important;
  height: 24px !important;
}

.post-attachments-meta {
  font-size: 0.85rem;
}

.post-attachment-item {
  max-width: 140px;
}

.post-attachment-icon {
  width: 12px !important;
  height: 12px !important;
}

.form-check-input[name="permissions[]"] {
  accent-color: var(--theme-default);
  border-color: var(--theme-default);
}

.form-check-input[name="permissions[]"]:checked {
  background-color: var(--theme-default);
  border-color: var(--theme-default);
}

.form-check-input[name="permissions[]"]:focus {
  border-color: var(--theme-default);
  box-shadow: 0 0 0 0.15rem rgba(43, 95, 96, 0.25);
}

.permissions-theme-border {
  border-color: var(--theme-default) !important;
}

.post-cover-preview {
  max-height: 160px;
  object-fit: cover;
}

.lawyer-photo-preview {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
}

.mandate-lawyer-loading-indicator {
  display: none;
}

.mandate-refusals-col-index {
  width: 60px;
}

.mandate-refusals-col-date {
  width: 200px;
}

.mandate-refusals-view-col-date {
  width: 220px;
}

.backend-icon-14 {
  width: 14px !important;
  height: 14px !important;
}

.backend-icon-16 {
  width: 16px !important;
  height: 16px !important;
}

.backend-icon-24 {
  width: 24px !important;
  height: 24px !important;
}

.backend-icon-32 {
  width: 32px !important;
  height: 32px !important;
}

.backend-icon-28 {
  width: 28px !important;
  height: 28px !important;
}

.backend-icon-36 {
  width: 36px !important;
  height: 36px !important;
}

.backend-icon-48 {
  width: 48px !important;
  height: 48px !important;
}

.backend-icon-muted-50 {
  opacity: 0.5;
}

.backend-icon-muted-placeholder {
  color: #adb5bd;
}

.backend-width-50 {
  width: 50px;
}

.backend-width-60 {
  width: 60px;
}

.backend-width-80 {
  width: 80px;
}

.backend-width-100 {
  width: 100px;
}

.backend-width-150 {
  width: 150px;
}

.backend-width-160 {
  width: 160px;
}

.backend-width-200 {
  width: 200px;
}

.backend-width-220 {
  width: 220px;
}

.backend-width-250 {
  width: 250px;
}

.backend-width-280 {
  width: 280px;
}

.backend-max-width-150 {
  max-width: 150px;
}

.backend-max-width-200 {
  max-width: 200px;
}

.backend-max-width-280 {
  max-width: 280px;
}

.backend-flex-1 {
  flex: 1;
}

.backend-cover-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
}

.backend-cover-placeholder {
  width: 60px;
  height: 60px;
  border: 1px solid #dee2e6;
  border-radius: 4px;
}

.backend-avatar-40 {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
}

.backend-avatar-placeholder-40 {
  width: 40px;
  height: 40px;
  background: #eee;
  border-radius: 4px;
}

.backend-dashed-dropzone {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
  padding: 4px;
  border: 1px dashed #dee2e6;
  border-radius: 4px;
}

.backend-modal-body-70vh {
  height: 70vh;
}

.backend-preview-frame {
  width: 100%;
  height: 100%;
  border: 1px solid #e1e1e1;
  border-radius: 4px;
}

.card-options {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#filter-form button[type="submit"],
#filter-form button[type="submit"].btn,
#filter-form button[type="submit"].btn.btn-primary,
#filter-form button[type="submit"].btn.btn-primary.btn-sm {
  background-color: #2b5f60 !important;
  border-color: #2b5f60 !important;
  color: #fff !important;
}

#filter-form button[type="submit"]:hover,
#filter-form button[type="submit"]:focus,
#filter-form button[type="submit"]:active,
#filter-form button[type="submit"].btn:hover,
#filter-form button[type="submit"].btn:focus,
#filter-form button[type="submit"].btn:active,
#filter-form button[type="submit"].btn.btn-primary:hover,
#filter-form button[type="submit"].btn.btn-primary:focus,
#filter-form button[type="submit"].btn.btn-primary:active,
#filter-form button[type="submit"].btn.btn-primary.btn-sm:hover,
#filter-form button[type="submit"].btn.btn-primary.btn-sm:focus,
#filter-form button[type="submit"].btn.btn-primary.btn-sm:active {
  background-color: #234f50 !important;
  border-color: #234f50 !important;
  color: #fff !important;
}

.card-options>.btn.btn-sm,
.card-options>a.btn.btn-sm,
.card-options>button.btn.btn-sm,
#filter-form .btn.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 33px;
  padding: 0.3rem 0.6rem;
  line-height: 1.5;
}

button#filter-toggle.btn.btn-sm i[data-feather],
button#filter-toggle.btn.btn-sm svg,
.card-options>.btn.btn-sm i[data-feather],
.card-options>.btn.btn-sm svg,
.card-options>a.btn.btn-sm i[data-feather],
.card-options>a.btn.btn-sm svg,
#filter-form .btn.btn-sm i[data-feather],
#filter-form .btn.btn-sm svg {
  width: 15px !important;
  height: 15px !important;
  margin: 0 !important;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Consistent spacing under nav tabs */
.nav-tabs {
  margin-bottom: 1rem
}

/* Normalize form group spacing where .mb-3 not used */
.form-group {
  margin-bottom: 1rem
}

/* Map Bootstrap primary to theme default */
:root {
  --bs-primary: var(--theme-default, #2b5f60);
  --bs-primary-rgb: 43, 95, 96;
}

/* Inputs/selects focus styling aligned to theme */
.form-select:focus,
.form-control:focus {
  border-color: var(--theme-default, #2b5f60);
  box-shadow: 0 0 0 0.15rem rgba(43, 95, 96, 0.25);
}

/* Radio accent as well */
.form-check-input[type="radio"],
input[type="radio"].form-check-input,
input[type="radio"] {
  accent-color: var(--theme-default, #2b5f60);
}

/* Select2 base styling aligned to Bootstrap 5 */
.select2-container .select2-selection--single,
.select2-container .select2-selection--multiple {
  min-height: calc(2.25rem + 2px);
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  background-color: #fff;
  transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

/* Select2 global fixes for Bootstrap 5 alignment in filter forms */
.select2-container {
  display: block !important;
  /* Fixes inline-block baseline gap */
  width: 100% !important;
  line-height: 0 !important;
  /* Eliminates the invisible line box space */
  padding: 0 !important;
  margin: 0 !important;
}

/* Hide the culprit: the extra wrapper that triggers line-height spacing */
.select2-container .dropdown-wrapper {
  display: none !important;
}

.select2-container--default .select2-selection--single {
  height: 38px !important;
  border: 1px solid #ced4da !important;
  border-radius: 0.375rem !important;
  background-color: #fff !important;
  position: relative !important;
  display: block !important;
  padding: 0 !important;
  line-height: normal !important;
  /* Reset line-height for internal elements */
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 36px !important;
  padding-left: 12px !important;
  padding-right: 48px !important;
  /* Prevents text from overlapping clear (x) and arrow */
  color: #212529 !important;
  display: block !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
  color: #6c757d !important;
  line-height: 36px !important;
}

.select2-results__option {
  padding: 8px 15px !important;
  line-height: normal !important;
}

.select2-results {
  line-height: normal !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 36px !important;
  width: 24px !important;
  top: 1px !important;
  right: 1px !important;
  position: absolute !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Fix for the clear button (x) position and alignment */
.select2-container--default .select2-selection--single .select2-selection__clear {
  position: absolute !important;
  right: 25px !important;
  top: 0 !important;
  height: 36px !important;
  line-height: 36px !important;
  margin-right: 0 !important;
  padding: 0 5px !important;
  cursor: pointer !important;
  font-weight: bold !important;
  color: #999 !important;
}

.select2-container--default .select2-selection--single .select2-selection__clear:hover {
  color: #333 !important;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--multiple {
  border-color: var(--theme-default, #2b5f60) !important;
  box-shadow: 0 0 0 0.15rem rgba(43, 95, 96, 0.25) !important;
}

.select2-container--default .select2-selection--multiple {
  padding: 0.15rem 0.25rem;
}

.select2-dropdown .select2-results__option--highlighted[aria-selected] {
  background-color: var(--theme-default, #2b5f60);
  color: #fff;
}

.select2-container--default .select2-results__option--selected {
  background-color: var(--theme-default, #2b5f60);
  color: #fff;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
  background-color: var(--theme-default, #2b5f60);
  border-color: var(--theme-default, #2b5f60);
  color: #fff;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
  color: #fff;
  opacity: 0.85;
}

.select2-dropdown {
  border: 1px solid #ced4da;
  box-shadow: 0 .75rem 1.5rem rgba(58, 70, 93, 0.15);
}

.select2-search--dropdown {
  padding: 0.15rem 0.5rem 0.25rem;
}

.select2-search--dropdown .select2-search__field {
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  padding: 0.2rem 0.4rem;
}

/* Select2 dropdown sizing: reduce gap and add scroll for long lists */
/* Ensure dropdown sticks exactly to the input bottom without gaps */
.select2-container--open .select2-dropdown--below {
  margin-top: -1px !important;
  border-top: none !important;
  border-radius: 0 0 4px 4px !important;
}

.select2-container--open .select2-dropdown--above {
  margin-bottom: -1px !important;
  border-bottom: none !important;
  border-radius: 4px 4px 0 0 !important;
}

.select2-container--open .select2-dropdown {
  margin-top: 0;
}

.select2-results__options {
  max-height: 300px;
  overflow-y: auto;
  line-height: normal !important;
}

/* List components */
.list-group-item.active,
.list-group-item.active:hover,
.list-group-item.active:focus {
  background-color: var(--theme-default, #2b5f60);
  border-color: var(--theme-default, #2b5f60);
}

/* Pagination active */
.page-item.active .page-link {
  background-color: var(--theme-default, #2b5f60);
  border-color: var(--theme-default, #2b5f60);
}

.page-link:focus {
  box-shadow: 0 0 0 0.15rem rgba(43, 95, 96, 0.25);
  border-color: var(--theme-default, #2b5f60);
}


/* Global checkbox theming */
/* Apply to all checkboxes; form-check-input kept for specificity */
.form-check-input[type="checkbox"],
input[type="checkbox"].form-check-input,
input[type="checkbox"] {
  accent-color: var(--theme-default, #2b5f60);
  border-color: var(--theme-default, #2b5f60);
}

.form-check-input[type="checkbox"]:checked,
input[type="checkbox"].form-check-input:checked,
input[type="checkbox"]:checked {
  background-color: var(--theme-default, #2b5f60);
  border-color: var(--theme-default, #2b5f60);
}

.form-check-input[type="checkbox"]:focus,
input[type="checkbox"].form-check-input:focus,
input[type="checkbox"]:focus {
  border-color: var(--theme-default, #2b5f60);
  box-shadow: 0 0 0 0.15rem rgba(43, 95, 96, 0.25);
}


/* Select2 Bootstrap 5 tweaks for multi-select width + badges */
.select2-container {
  width: 100% !important;
}

.select2-container--bootstrap-5 .select2-selection--multiple {
  min-height: 38px;
  padding: .125rem .25rem
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice {
  background: #e7f1ff;
  color: #0d6efd;
  border: 1px solid #cfe2ff;
  border-radius: 50rem;
  padding: .15rem .5rem;
  margin-top: .15rem
}

/* Ensure inline flatpickr calendar is visible when appended */
#excluded-dates-calendar .flatpickr-calendar.inline,
#excluded-dates-calendar .flatpickr-calendar.open {
  display: block !important;
  position: static !important;
}

.select2-container--open .select2-dropdown--below {
  margin-top: 0;
}

.select2-container--default .select2-selection--multiple {
  border: 1px solid #ced4da !important;
  border-radius: 0.375rem !important;
  min-height: 38px !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
  background-color: var(--theme-default, #2b5f60) !important;
  border: none !important;
  color: #fff !important;
  border-radius: 4px !important;
  padding: 2px 8px !important;
  margin-top: 6px !important;
  font-size: 12px !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
  color: #fff !important;
  margin-right: 5px !important;
  border: none !important;
}