/**
 * Selection Bar & Universal Multi-Select Component Styles
 * RSA E-Learning System
 * 
 * Modular component CSS covering:
 * 1. Table row & mobile card universal selection (border indicator, highlight, 0px shift)
 * 2. Responsive morphing: Floating center dock (Desktop) <-> Docked bottom bar (Mobile)
 * 3. 1:1 square badge counters
 * 4. Dropdown & Dropup action menus
 * 5. Button text normalization
 * 6. Mobile checklist avatar transformations
 */

/* ── 1. Universal Table Row & Card Selection ── */
tr > td:first-child,
tr > th:first-child,
table.table thead tr > th:first-child,
table.table tbody tr > td:first-child,
.selectable-row > td:first-child {
  border-left: 3.5px solid transparent !important;
  transition: border-color 0.15s ease, background-color 0.15s ease !important;
}

tr.non-selectable,
tr[data-selectable="false"],
.card.non-selectable,
.card[data-selectable="false"] {
  user-select: auto !important;
  -webkit-user-select: auto !important;
}

/* Global Standard Checkbox Column Perfect Center Alignment across ALL Tables */
.col-checkbox-cell,
.table th.col-checkbox-cell,
.table td.col-checkbox-cell,
.table thead th:first-child:has(.form-check-input),
.table tbody td:first-child:has(.form-check-input),
table th.col-checkbox-cell,
table td.col-checkbox-cell {
  width: 48px !important;
  min-width: 48px !important;
  max-width: 48px !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  text-align: center !important;
  vertical-align: middle !important;
}

.col-checkbox-cell .form-check-input,
.table th.col-checkbox-cell .form-check-input,
.table td.col-checkbox-cell .form-check-input,
.table thead th:first-child:has(.form-check-input) .form-check-input,
.table tbody td:first-child:has(.form-check-input) .form-check-input {
  margin: 0 auto !important;
  display: block !important;
  float: none !important;
  position: static !important;
  vertical-align: middle !important;
}

.card.selectable-card,
.selectable-card {
  transition: border-left-color 0.15s ease, box-shadow 0.15s ease, border-radius 0.15s ease, background-color 0.15s ease !important;
}

/* Background Highlight when Selected (Soft & Dim Tint) */
tr.selected,
tr.user-row-selected,
tr.table-active,
table.table tbody tr.selected,
table.table tbody tr.user-row-selected,
.selectable-row.selected,
.selectable-row.user-row-selected,
.export-participant-row.selected,
.export-class-row.selected,
.export-material-row.selected,
.recovery-user-row.selected,
.recovery-class-row.selected,
.recovery-session-row.selected,
.recovery-material-row.selected {
  background-color: rgba(var(--bs-primary-rgb), 0.035) !important;
  --bs-table-accent-bg: rgba(var(--bs-primary-rgb), 0.035) !important;
  --bs-table-bg-state: rgba(var(--bs-primary-rgb), 0.035) !important;
  --bs-table-hover-bg: rgba(var(--bs-primary-rgb), 0.055) !important;
}

tr.selected > td,
tr.user-row-selected > td,
tr.table-active > td,
table.table tbody tr.selected > td,
table.table tbody tr.user-row-selected > td,
.selectable-row.selected > td,
.selectable-row.user-row-selected > td,
.export-participant-row.selected > td,
.export-class-row.selected > td,
.export-material-row.selected > td,
.recovery-user-row.selected > td,
.recovery-class-row.selected > td,
.recovery-session-row.selected > td,
.recovery-material-row.selected > td {
  background-color: rgba(var(--bs-primary-rgb), 0.035) !important;
  --bs-table-accent-bg: rgba(var(--bs-primary-rgb), 0.035) !important;
  --bs-table-bg-state: rgba(var(--bs-primary-rgb), 0.035) !important;
  --bs-table-hover-bg: rgba(var(--bs-primary-rgb), 0.055) !important;
  box-shadow: none !important;
}

/* Orange Left Border Indicator on Selected Rows (Desktop & Modals: Single line at first column) */
tr.selected > td:first-child,
tr.user-row-selected > td:first-child,
tr.table-active > td:first-child,
table.table tbody tr.selected > td:first-child,
table.table tbody tr.user-row-selected > td:first-child,
.selectable-row.selected > td:first-child,
.selectable-row.user-row-selected > td:first-child,
.modal table tbody tr.selected > td:first-child,
.modal table tbody tr.user-row-selected > td:first-child,
.export-participant-row.selected > td:first-child,
.export-class-row.selected > td:first-child,
.export-material-row.selected > td:first-child,
.recovery-user-row.selected > td:first-child,
.recovery-class-row.selected > td:first-child,
.recovery-session-row.selected > td:first-child,
.recovery-material-row.selected > td:first-child {
  border-left: 3.5px solid var(--bs-primary) !important;
}

/* Mobile Screen: When first checkbox td is hidden (d-none), ONLY the visible name/data column gets the left border */
@media (max-width: 767.98px) {
  tr > td.col-checkbox-cell + td,
  tr > td:first-child.d-none + td,
  table.table tbody tr > td.col-checkbox-cell + td,
  table.table tbody tr > td:first-child.d-none + td,
  .modal table tbody tr > td:first-child.d-none + td {
    border-left: 3.5px solid transparent !important;
    transition: border-color 0.15s ease, background-color 0.15s ease !important;
  }

  tr.selected > td.col-checkbox-cell + td,
  tr.user-row-selected > td.col-checkbox-cell + td,
  tr.selected > td:first-child.d-none + td,
  tr.user-row-selected > td:first-child.d-none + td,
  tr.selected > td.d-none:first-child + td,
  table.table tbody tr.selected > td.col-checkbox-cell + td,
  table.table tbody tr.user-row-selected > td.col-checkbox-cell + td,
  table.table tbody tr.selected > td:first-child.d-none + td,
  table.table tbody tr.user-row-selected > td:first-child.d-none + td,
  .selectable-row.selected > td:first-child.d-none + td,
  .selectable-row.selected > td.d-none:first-child + td,
  .user-row-clickable.user-row-selected > td.col-checkbox-cell + td,
  .user-row-clickable.selected > td.col-checkbox-cell + td,
  .modal table tbody tr.selected > td:first-child.d-none + td,
  .modal table tbody tr.user-row-selected > td:first-child.d-none + td,
  .modal table tbody tr.selected > td.d-none:first-child + td,
  .modal table tbody tr.user-row-selected > td.d-none:first-child + td {
    border-left: 3.5px solid var(--bs-primary) !important;
  }
}

/* Mobile Selected Cards (Zero Content Shift: 1px border + 2.5px inset shadow = 3.5px total bar) */
.card.selected,
.card.user-row-selected,
.selectable-card.selected,
.selectable-card.user-row-selected {
  border-left: 1px solid var(--bs-primary) !important;
  box-shadow: inset 2.5px 0 0 0 var(--bs-primary) !important;
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
  background-color: rgba(var(--bs-primary-rgb), 0.035) !important;
}

/* ── 2. Unified Responsive Selection Bar Component ── */
.selection-bar {
  position: fixed !important;
  z-index: 1045 !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Mobile: Docked Bottom Bar (Above Bottom Navigation) */
@media (max-width: 767.98px) {
  .selection-bar,
  #userMobileSelectionBar {
    position: fixed !important;
    bottom: calc(70px + env(safe-area-inset-bottom, 0px)) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 70px !important;
    min-height: 70px !important;
    z-index: 1035 !important;
    transform: translateY(100%) !important;
    pointer-events: none !important;
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease !important;
  }

  .selection-bar.active,
  #userMobileSelectionBar.active {
    transform: translateY(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .selection-bar-inner {
    background-color: var(--bs-card-bg) !important;
    border-top: 1px solid var(--bs-border-color) !important;
    border-top-left-radius: 12px !important;
    border-top-right-radius: 12px !important;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35) !important;
    height: 100% !important;
    width: 100% !important;
    padding: 12px 16px !important;
    gap: 12px !important;
  }

  .selection-floating-bar,
  .selection-floating-bar.active {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
}

/* Desktop: Floating Center Bottom Rounded Dock */
@media (min-width: 768px) {
  .selection-bar,
  .selection-floating-bar {
    position: fixed !important;
    bottom: 28px !important;
    left: 50%;
    width: auto !important;
    min-width: 540px !important;
    max-width: 90vw !important;
    transform: translate(-50%, 80px) !important;
    z-index: 1045 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease, visibility 0.22s ease !important;
  }

  .selection-bar.active,
  .selection-floating-bar.active {
    transform: translate(-50%, 0) !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .selection-bar-inner,
  .selection-floating-inner {
    background: var(--bs-card-bg) !important;
    border: 1px solid var(--bs-border-color) !important;
    border-radius: 14px !important;
    box-shadow: var(--bs-box-shadow-lg) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    width: 100% !important;
    min-width: 540px !important;
    white-space: nowrap !important;
    padding: 15px !important;
    gap: 24px !important;
  }

  .selection-actions-wrapper,
  .selection-bar .selection-actions-wrapper,
  .selection-bar-inner .selection-actions-wrapper {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }

  .selection-bar .btn,
  .selection-bar-inner .btn,
  .selection-floating-inner .btn {
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    padding: 0 14px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.8125rem !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    border-radius: 8px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    box-sizing: border-box !important;
    gap: 6px !important;
  }

  .selection-bar .btn-cancel-selection,
  .selection-bar .btn-icon,
  .selection-bar-inner .btn-cancel-selection,
  .selection-bar-inner .btn-icon {
    width: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    box-sizing: border-box !important;
  }

  .selection-bar .btn i,
  .selection-bar-inner .btn i {
    font-size: 1.125rem !important;
    line-height: 1 !important;
  }

  .selection-bar .dropdown-item,
  .selection-bar .dropdown-item * {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    text-transform: none !important;
  }

  #userMobileSelectionBar {
    display: none !important;
  }
}

/* ── 3. 1:1 Square Badge Counters ── */
.selection-bar-inner .badge,
.selection-floating-inner .badge,
.selection-count-badge,
#floatingSelectedCountBadge,
#mobileSelectedCountBadge {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 26px !important;
  height: 26px !important;
  border-radius: 6px !important;
  padding: 0 6px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  font-size: 0.8125rem !important;
}

/* ── 4. Dropdown & Dropup Menus in Selection Bar ── */
.selection-bar .dropdown-menu {
  margin-bottom: 8px !important;
  box-shadow: var(--bs-box-shadow-lg) !important;
  border-radius: 10px !important;
  border: 1px solid var(--bs-border-color) !important;
  background-color: var(--bs-card-bg) !important;
  z-index: 1060 !important;
}

.selection-bar .dropdown-menu .dropdown-item {
  font-weight: 500;
  padding: 0.5rem 1rem;
}

/* ── 5. Button Text Case Normalization (Never Uppercase) ── */
.selection-bar .btn,
.selection-bar .btn-bulk-action,
.selection-bar .dropdown button,
.selection-bar .dropdown-toggle,
.selection-bar .select-all-text,
.selection-bar .selection-count-label {
  text-transform: none !important;
  letter-spacing: normal !important;
}

/* ── 6. Universal Avatar Checklist Transformation (Mobile & Desktop) ── */
tr.selected .avatar,
tr.user-row-selected .avatar,
.selected .avatar,
.user-row-selected .avatar,
.user-row-clickable.selected .avatar,
.user-row-clickable.user-row-selected .avatar,
.participant-row.selected .avatar,
.participant-row.user-row-selected .avatar,
.participant-row-clickable.selected .avatar,
.participant-row-clickable.user-row-selected .avatar,
.export-participant-row.selected .avatar,
.export-participant-row.user-row-selected .avatar,
.recovery-user-row.selected .avatar,
.selectable-card.selected .avatar {
  position: relative !important;
}

tr.selected .avatar img,
tr.selected .avatar .avatar-initial,
tr.selected .avatar .avatar-initials,
tr.selected .avatar span,
tr.user-row-selected .avatar img,
tr.user-row-selected .avatar .avatar-initial,
tr.user-row-selected .avatar .avatar-initials,
tr.user-row-selected .avatar span,
.selected .avatar img,
.selected .avatar .avatar-initial,
.selected .avatar .avatar-initials,
.selected .avatar span,
.user-row-selected .avatar img,
.user-row-selected .avatar .avatar-initial,
.user-row-selected .avatar .avatar-initials,
.user-row-selected .avatar span,
.user-row-clickable.selected .avatar img,
.user-row-clickable.selected .avatar .avatar-initial,
.user-row-clickable.selected .avatar .avatar-initials,
.user-row-clickable.selected .avatar span,
.user-row-clickable.user-row-selected .avatar img,
.user-row-clickable.user-row-selected .avatar .avatar-initial,
.user-row-clickable.user-row-selected .avatar .avatar-initials,
.user-row-clickable.user-row-selected .avatar span,
.participant-row.selected .avatar img,
.participant-row.selected .avatar .avatar-initial,
.participant-row.selected .avatar .avatar-initials,
.participant-row.selected .avatar span,
.participant-row.user-row-selected .avatar img,
.participant-row.user-row-selected .avatar .avatar-initial,
.participant-row.user-row-selected .avatar .avatar-initials,
.participant-row.user-row-selected .avatar span,
.participant-row-clickable.selected .avatar img,
.participant-row-clickable.selected .avatar .avatar-initial,
.participant-row-clickable.selected .avatar .avatar-initials,
.participant-row-clickable.selected .avatar span,
.participant-row-clickable.user-row-selected .avatar img,
.participant-row-clickable.user-row-selected .avatar .avatar-initial,
.participant-row-clickable.user-row-selected .avatar .avatar-initials,
.participant-row-clickable.user-row-selected .avatar span,
.export-participant-row.selected .avatar img,
.export-participant-row.selected .avatar .avatar-initial,
.export-participant-row.selected .avatar .avatar-initials,
.export-participant-row.selected .avatar span,
.export-participant-row.user-row-selected .avatar img,
.export-participant-row.user-row-selected .avatar .avatar-initial,
.export-participant-row.user-row-selected .avatar .avatar-initials,
.export-participant-row.user-row-selected .avatar span,
.selectable-card.selected .avatar img,
.selectable-card.selected .avatar .avatar-initial,
.selectable-card.selected .avatar .avatar-initials,
.selectable-card.selected .avatar span {
  opacity: 0 !important;
  visibility: hidden !important;
}

tr.selected .avatar::before,
tr.user-row-selected .avatar::before,
.selected .avatar::before,
.user-row-selected .avatar::before,
.user-row-clickable.selected .avatar::before,
.user-row-clickable.user-row-selected .avatar::before,
.participant-row.selected .avatar::before,
.participant-row.user-row-selected .avatar::before,
.participant-row-clickable.selected .avatar::before,
.participant-row-clickable.user-row-selected .avatar::before,
.export-participant-row.selected .avatar::before,
.export-participant-row.user-row-selected .avatar::before,
.recovery-user-row.selected .avatar::before,
.selectable-card.selected .avatar::before {
  content: "" !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background-color: var(--bs-primary) !important;
  border-radius: 50% !important;
  z-index: 5 !important;
  box-sizing: border-box !important;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

tr.selected .avatar::after,
tr.user-row-selected .avatar::after,
.selected .avatar::after,
.user-row-selected .avatar::after,
.user-row-clickable.selected .avatar::after,
.user-row-clickable.user-row-selected .avatar::after,
.participant-row.selected .avatar::after,
.participant-row.user-row-selected .avatar::after,
.participant-row-clickable.selected .avatar::after,
.participant-row-clickable.user-row-selected .avatar::after,
.export-participant-row.selected .avatar::after,
.export-participant-row.user-row-selected .avatar::after,
.recovery-user-row.selected .avatar::after,
.selectable-card.selected .avatar::after {
  content: "" !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffffff'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E") no-repeat center / 55% !important;
  border-radius: 50% !important;
  border: none !important;
  box-shadow: none !important;
  z-index: 10 !important;
}
