/**
 * @file
 * Bridge styles between Drupal's admin markup and AdminLTE 4 / Bootstrap 5.3.
 *
 * Drupal core does not emit Bootstrap classes on its form elements, so this
 * file maps the most visible admin markup onto Bootstrap's look. AdminLTE +
 * Bootstrap (bundled in adminlte.css) supply everything else.
 */

/* -------------------------------------------------------------------------- *
 * Drupal toolbar coexistence
 * Drupal's admin toolbar is position:fixed and already pushes the page body
 * down (it pads the body and exposes the height as --drupal-displace-offset-top).
 * So we must NOT offset the AdminLTE header: it is position:relative, and a `top`
 * there shifts the opaque navbar down over the content header, hiding the page
 * title and breadcrumb. We only nudge the *sticky* sidebar's stick point so its
 * top items don't slide under the toolbar while scrolling.
 * -------------------------------------------------------------------------- */
.app-sidebar {
  top: var(--drupal-displace-offset-top, 0px);
}

/* -------------------------------------------------------------------------- *
 * z-index: sit below Drupal's admin toolbar chrome
 * AdminLTE ships very high stacking values on its persistent chrome
 * (.app-header: 1034, .app-sidebar: 1038). Those overlay Drupal's admin
 * toolbar and, notably, the Admin Toolbar Search autocomplete (z-index 600),
 * hiding the search results behind the theme header/sidebar. Drupal's core
 * toolbar lives around z-index 500, so we bring the theme chrome well below it
 * while preserving AdminLTE's own internal order: sidebar > mobile overlay >
 * header > content. Transient layers (Bootstrap dropdowns/modals, the account
 * menu, jQuery-UI dialogs) keep their own high z-index and are unaffected.
 * See https://www.drupal.org/project/adminlte/issues/3608932
 * -------------------------------------------------------------------------- */
.app-header {
  z-index: 20;
}

.app-sidebar {
  z-index: 30;
}

/* Mobile off-canvas overlay stays just under the sidebar it dims. The theme
   fixes the body to `sidebar-expand-lg`, so matching that selector (equal
   specificity, later in the cascade) reliably overrides AdminLTE's 1037. */
.sidebar-expand-lg.sidebar-open .sidebar-overlay {
  z-index: 25;
}

/* -------------------------------------------------------------------------- *
 * Form elements
 * -------------------------------------------------------------------------- */
input.form-text,
input.form-email,
input.form-tel,
input.form-url,
input.form-search,
input.form-number,
input.form-date,
input.form-time,
input.form-file,
input.form-color,
textarea.form-textarea,
.form-element {
  display: block;
  width: 100%;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--bs-body-color);
  background-color: var(--bs-body-bg);
  background-clip: padding-box;
  border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

input.form-text:focus,
input.form-email:focus,
input.form-tel:focus,
input.form-url:focus,
input.form-search:focus,
input.form-number:focus,
input.form-date:focus,
input.form-time:focus,
textarea.form-textarea:focus,
.form-element:focus {
  border-color: var(--bs-primary-border-subtle, #86b7fe);
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Drupal labels and descriptions. */
.form-item {
  margin-bottom: 1rem;
}

.form-item__label,
label.form-required,
.form-item label {
  display: inline-block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-item__description,
.description {
  margin-top: 0.25rem;
  font-size: 0.875em;
  color: var(--bs-secondary-color);
}

/* -------------------------------------------------------------------------- *
 * Buttons — map Drupal's .button to Bootstrap's .btn
 * -------------------------------------------------------------------------- */
.button,
a.button,
input.button {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  margin: 0 0.25rem 0 0;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
  border: var(--bs-border-width) solid transparent;
  border-radius: var(--bs-border-radius);
  color: var(--bs-body-color);
  background-color: var(--bs-secondary-bg);
  transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

.button:hover {
  filter: brightness(0.95);
}

.button--primary,
.button--small.button--primary {
  color: #fff;
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
}

.button--danger,
.button.delete {
  color: #fff;
  background-color: var(--bs-danger);
  border-color: var(--bs-danger);
}

.button--small {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

/* -------------------------------------------------------------------------- *
 * Tables — adopt Bootstrap table styling for admin listings.
 * -------------------------------------------------------------------------- */
main table:not(.views-ui-rearrange-filter-table) {
  width: 100%;
  margin-bottom: 1rem;
  color: var(--bs-body-color);
  vertical-align: top;
  border-color: var(--bs-border-color);
}

main table > thead {
  vertical-align: bottom;
  border-bottom: 2px solid var(--bs-border-color);
}

main table > tbody > tr {
  border-bottom: var(--bs-border-width) solid var(--bs-border-color);
}

main table th,
main table td {
  padding: 0.5rem 0.5rem;
}

/* -------------------------------------------------------------------------- *
 * Details / fieldset → AdminLTE card look
 * -------------------------------------------------------------------------- */
details {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background-color: var(--bs-body-bg);
  border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
}

details > summary {
  font-weight: 600;
  cursor: pointer;
}

/* -------------------------------------------------------------------------- *
 * Fallback for core AJAX messages that bypass our status-messages template.
 * -------------------------------------------------------------------------- */
.messages {
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border: var(--bs-border-width) solid transparent;
  border-radius: var(--bs-border-radius);
}

.messages--status {
  color: var(--bs-success-text-emphasis, #0a3622);
  background-color: var(--bs-success-bg-subtle, #d1e7dd);
  border-color: var(--bs-success-border-subtle, #a3cfbb);
}

.messages--warning {
  color: var(--bs-warning-text-emphasis, #664d03);
  background-color: var(--bs-warning-bg-subtle, #fff3cd);
  border-color: var(--bs-warning-border-subtle, #ffe69c);
}

.messages--error {
  color: var(--bs-danger-text-emphasis, #58151c);
  background-color: var(--bs-danger-bg-subtle, #f8d7da);
  border-color: var(--bs-danger-border-subtle, #f1aeb5);
}

/* Sidebar brand link should not look like a Bootstrap link underline. */
.sidebar-brand .brand-link {
  text-decoration: none;
}

/* -------------------------------------------------------------------------- *
 * Resizable sidebar (desktop only). The handle sits on the sidebar's inline-end
 * edge; the width is applied as `--lte-sidebar-width` and persisted by
 * adminlte-drupal.js. See https://www.drupal.org/project/adminlte/issues/3609296
 * -------------------------------------------------------------------------- */
.sidebar-resize-handle {
  display: none;
}

/* Suppress the width transition while dragging (and on the initial apply). */
.app-sidebar.is-resizing {
  transition: none;
}

.app-sidebar.is-resizing,
.app-sidebar.is-resizing * {
  user-select: none;
}

@media (min-width: 992px) {
  .sidebar-resize-handle {
    position: absolute;
    inset-block: 0;
    inset-inline-end: -3px;
    z-index: 5;
    display: block;
    width: 6px;
    cursor: col-resize;
    touch-action: none;
  }

  .sidebar-resize-handle:hover,
  .sidebar-resize-handle:focus-visible {
    background-color: rgba(var(--bs-primary-rgb), 0.5);
    outline: none;
  }

  /* No resize affordance when the sidebar is collapsed to icons. */
  .sidebar-collapse .sidebar-resize-handle {
    display: none;
  }
}

/* -------------------------------------------------------------------------- *
 * Sidebar treeview: the chevron is a separate toggle button so clicking the
 * link navigates to the section page while the chevron expands/collapses the
 * submenu in place. (AdminLTE's link-hijacking treeview is disabled on the
 * sidebar; expand/collapse + active trail are driven by adminlte-drupal.js.)
 * -------------------------------------------------------------------------- */
.app-sidebar .sidebar-menu .nav-item {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
}

.app-sidebar .sidebar-menu .nav-item > .nav-link {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
}

.app-sidebar .sidebar-menu .nav-treeview {
  flex: 0 0 100%;
}

.app-sidebar .sidebar-menu .nav-treeview-toggle {
  display: flex;
  flex: 0 0 2.75rem;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--lte-sidebar-color); /* same gray as the sidebar links */
  cursor: pointer;
  background: transparent;
  border: 0;
}

.app-sidebar .sidebar-menu .nav-treeview-toggle:hover {
  color: var(--lte-sidebar-hover-color);
  background-color: rgba(128, 128, 128, 0.2);
}

.app-sidebar .sidebar-menu .nav-treeview-toggle:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: -2px;
}

.app-sidebar .sidebar-menu .nav-treeview-toggle .nav-arrow {
  transition: transform 0.2s ease;
}

.app-sidebar .sidebar-menu .menu-open > .nav-treeview-toggle .nav-arrow {
  transform: rotate(90deg);
}

/* ========================================================================== *
 * Drupal admin components
 * Drupal core renders these widgets with markup that the Claro admin theme
 * styles. This theme is based on stable9 (minimal), so we bridge them to a
 * Bootstrap / AdminLTE look here.
 * ========================================================================== */

/* -------------------------------------------------------------------------- *
 * Dropbutton (operations menus: Edit ▾ Duplicate / Disable / Delete)
 * -------------------------------------------------------------------------- */
.dropbutton-wrapper {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  max-width: 100%;
}

.dropbutton-widget {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

ul.dropbutton {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: stretch;
  max-width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

ul.dropbutton li {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Action links and the toggle render as Bootstrap-like buttons. */
.dropbutton li > a,
.dropbutton li > .button,
.dropbutton-toggle > button {
  display: block;
  width: 100%;
  padding: 0.25rem 0.6rem;
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--bs-body-color);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  background-color: var(--bs-body-bg);
  border: var(--bs-border-width) solid var(--bs-border-color);
}

.dropbutton li > a:hover,
.dropbutton li > .button:hover,
.dropbutton-toggle > button:hover {
  background-color: var(--bs-secondary-bg);
  color: var(--bs-emphasis-color);
}

/* Primary action + toggle joined into one group (collapsed state). */
.dropbutton-action:first-child > a,
.dropbutton-action:first-child > .button {
  border-top-left-radius: var(--bs-border-radius);
  border-bottom-left-radius: var(--bs-border-radius);
}

.dropbutton-multiple .dropbutton-action:first-child > a,
.dropbutton-multiple .dropbutton-action:first-child > .button {
  border-right: 0;
}

.dropbutton-toggle {
  display: flex;
}

.dropbutton-toggle > button {
  width: auto;
  padding-inline: 0.45rem;
  background-color: var(--bs-secondary-bg);
  border-top-right-radius: var(--bs-border-radius);
  border-bottom-right-radius: var(--bs-border-radius);
}

/* Single-action dropbutton: a normal rounded button. */
.dropbutton-wrapper:not(.dropbutton-multiple) .dropbutton-action:first-child > a,
.dropbutton-wrapper:not(.dropbutton-multiple) .dropbutton-action:first-child > .button {
  border-radius: var(--bs-border-radius);
}

/* The toggle arrow. */
.dropbutton-arrow {
  display: inline-block;
  width: 0;
  height: 0;
  vertical-align: middle;
  border-top: 0.35em solid currentColor;
  border-right: 0.3em solid transparent;
  border-left: 0.3em solid transparent;
}

.dropbutton-multiple.open .dropbutton-toggle > button {
  background-color: var(--bs-tertiary-bg);
}

/* Secondary actions live in a floating menu (relocated by adminlte-drupal.js)
   so they overlay content like a Bootstrap dropdown instead of pushing or
   colliding with neighbouring table rows. */
ul.dropbutton-menu {
  position: absolute;
  z-index: 1000;
  inset-inline-start: 0;
  top: 100%;
  display: none;
  min-width: 100%;
  margin: 2px 0 0;
  padding: 0.25rem 0;
  list-style: none;
  background-color: var(--bs-body-bg);
  border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  box-shadow: var(--bs-box-shadow);
}

.dropbutton-wrapper.open ul.dropbutton-menu {
  display: block;
}

ul.dropbutton-menu .secondary-action {
  display: block;
}

ul.dropbutton-menu .secondary-action > a {
  display: block;
  width: 100%;
  padding: 0.35rem 1rem;
  white-space: nowrap;
  border: 0;
  border-radius: 0;
  background-color: transparent;
}

ul.dropbutton-menu .secondary-action > a:hover {
  background-color: var(--bs-secondary-bg);
}

/* No-JS fallback: if the menu was never built, keep the actions visible. */
.dropbutton-multiple .dropbutton .secondary-action {
  display: inline-block;
}

/* -------------------------------------------------------------------------- *
 * Tabledrag (drag-to-reorder handles + draggable rows)
 * -------------------------------------------------------------------------- */
a.tabledrag-handle {
  display: inline-block;
  height: 1.75rem;
  padding: 0 0.4rem;
  color: var(--bs-secondary-color);
  text-decoration: none;
  cursor: move;
}

a.tabledrag-handle .handle {
  display: block;
  width: 1rem;
  height: 1.75rem;
}

a.tabledrag-handle .handle::before {
  display: inline-block;
  font-family: "bootstrap-icons" !important;
  font-size: 1.1rem;
  line-height: 1.75rem;
  content: "\f3fe"; /* bi-grip-vertical */
}

a.tabledrag-handle:hover,
a.tabledrag-handle.tabledrag-handle-hover {
  color: var(--bs-primary);
}

tr.drag {
  background-color: var(--bs-warning-bg-subtle);
}

tr.drag-previous {
  background-color: var(--bs-info-bg-subtle);
}

.tabledrag-changed,
abbr.tabledrag-changed {
  color: var(--bs-warning-text-emphasis);
}

.indentation {
  position: relative;
  left: 0;
  display: inline-block;
  width: 1.25rem;
  height: 1.75rem;
  vertical-align: top;
}

/* -------------------------------------------------------------------------- *
 * Vertical tabs (built by core's vertical-tabs.js)
 * -------------------------------------------------------------------------- */
.vertical-tabs {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  overflow: hidden;
  border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
}

.vertical-tabs__menu {
  flex: 0 0 15rem;
  max-width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  background-color: var(--bs-secondary-bg);
  border-right: var(--bs-border-width) solid var(--bs-border-color);
}

.vertical-tabs__menu-item {
  margin: 0;
  list-style: none;
  border-bottom: var(--bs-border-width) solid var(--bs-border-color);
}

.vertical-tabs__menu-item:last-child {
  border-bottom: 0;
}

.vertical-tabs__menu-item > a {
  display: block;
  padding: 0.6rem 1rem;
  color: var(--bs-body-color);
  text-decoration: none;
}

.vertical-tabs__menu-item > a:hover,
.vertical-tabs__menu-item > a:focus {
  background-color: var(--bs-body-bg);
}

.vertical-tabs__menu-item.is-selected > a {
  background-color: var(--bs-body-bg);
  box-shadow: inset 3px 0 0 var(--bs-primary);
}

.vertical-tabs__menu-item-title {
  display: block;
  font-weight: 600;
}

.vertical-tabs__menu-item-summary {
  display: block;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--bs-secondary-color);
}

/* Panes: each is a <details>; only the selected one is shown by the JS. */
.vertical-tabs > details,
.vertical-tabs__pane {
  flex: 1 1 60%;
  min-width: 50%;
  margin: 0;
  padding: 0.5rem 1.25rem 1rem;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.vertical-tabs > details > summary {
  display: none; /* the menu replaces the summaries */
}

/* -------------------------------------------------------------------------- *
 * Pager → Bootstrap pagination
 * -------------------------------------------------------------------------- */
.pager__items {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
}

.pager__item {
  margin: 0;
  list-style: none;
}

.pager__item > a,
.pager__item > span {
  position: relative;
  display: block;
  padding: 0.375rem 0.75rem;
  margin-left: -1px;
  color: var(--bs-link-color);
  text-decoration: none;
  background-color: var(--bs-body-bg);
  border: var(--bs-border-width) solid var(--bs-border-color);
}

.pager__item > a:hover {
  background-color: var(--bs-secondary-bg);
}

.pager__item.is-active > a,
.pager__item.is-active > span {
  z-index: 1;
  color: #fff;
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
}

.pager__item:first-child > a,
.pager__item:first-child > span {
  margin-left: 0;
  border-top-left-radius: var(--bs-border-radius);
  border-bottom-left-radius: var(--bs-border-radius);
}

.pager__item:last-child > a,
.pager__item:last-child > span {
  border-top-right-radius: var(--bs-border-radius);
  border-bottom-right-radius: var(--bs-border-radius);
}

/* -------------------------------------------------------------------------- *
 * Misc form helpers
 * -------------------------------------------------------------------------- */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.form-actions .button {
  margin: 0;
}

.container-inline > .form-item,
.container-inline .form-item {
  display: inline-block;
  margin-right: 0.75rem;
  vertical-align: middle;
}

input.form-checkbox,
input.form-radio {
  width: 1rem;
  height: 1rem;
  vertical-align: -2px;
}

/* The exposed-filter "Add content" / actions list shouldn't show bullets. */
.action-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.action-links > li {
  margin: 0;
  list-style: none;
}

/* -------------------------------------------------------------------------- *
 * Modules (Extend) page: each module description sits in a collapsed <details>
 * that core clips to a single line (white-space: nowrap; overflow: hidden) and
 * only unclips when opened — but Claro's expand affordance isn't present here.
 * Just show the full, wrapping description so nothing is cut off.
 * -------------------------------------------------------------------------- */
.system-modules td.description details,
.system-modules td details,
.system-modules details {
  height: auto;
  overflow: visible;
  white-space: normal;
}

.system-modules details summary,
.system-modules details summary .text,
.system-modules .module-description {
  white-space: normal;
}

/* -------------------------------------------------------------------------- *
 * Authentication pages (log in / register / reset password)
 * Body carries `.adminlte-auth-page` (added in adminlte_preprocess_html) so the
 * otherwise full-width form renders as a centred, constrained card.
 * -------------------------------------------------------------------------- */
.adminlte-auth-page .app-content > .container-fluid {
  max-width: 30rem;
  margin: 2rem auto;
  padding: 2rem;
  background-color: var(--bs-body-bg);
  border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: var(--bs-border-radius-lg);
  box-shadow: var(--bs-box-shadow-sm);
}

.adminlte-auth-page .app-content .form-actions .button,
.adminlte-auth-page .app-content input.form-submit {
  width: 100%;
}

/* -------------------------------------------------------------------------- *
 * AJAX throbber + modal dialog safety
 * -------------------------------------------------------------------------- */
.ajax-progress-throbber .throbber,
.ajax-progress-fullscreen {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  margin: 0 0.3rem;
  vertical-align: middle;
  border: 2px solid var(--bs-secondary-color);
  border-right-color: transparent;
  border-radius: 50%;
  animation: adminlte-spin 0.7s linear infinite;
}

@keyframes adminlte-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Core modal dialogs (jQuery UI) need a solid surface in both colour modes. */
.ui-dialog {
  background-color: var(--bs-body-bg);
  border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  box-shadow: var(--bs-box-shadow);
}

.ui-dialog .ui-dialog-titlebar {
  position: relative;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  background-color: var(--bs-tertiary-bg);
  border-bottom: var(--bs-border-width) solid var(--bs-border-color);
}

.ui-dialog .ui-dialog-title {
  font-weight: 600;
  color: var(--bs-emphasis-color);
}

.ui-dialog .ui-dialog-content {
  background-color: var(--bs-body-bg);
  color: var(--bs-body-color);
}

.ui-dialog .ui-dialog-buttonpane {
  margin: 0;
  padding: 0.75rem 1rem;
  background-color: var(--bs-body-bg);
  border-top: var(--bs-border-width) solid var(--bs-border-color);
}

.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.ui-dialog .ui-dialog-titlebar-close {
  position: absolute;
  top: 0.55rem;
  inset-inline-end: 0.75rem;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  font-size: 0;
  line-height: 1;
  color: var(--bs-secondary-color);
  background: transparent;
  border: 0;
  border-radius: var(--bs-border-radius);
  cursor: pointer;
}

.ui-dialog .ui-dialog-titlebar-close:hover {
  background-color: var(--bs-secondary-bg);
  color: var(--bs-emphasis-color);
}

.ui-dialog .ui-dialog-titlebar-close::before {
  font-size: 1.5rem;
  line-height: 1.9rem;
  content: "\00D7"; /* × */
}

.ui-dialog .ui-dialog-titlebar-close .ui-icon {
  display: none;
}
