/* ==========================================================================
   ACTION TOOLBAR COMPONENT
   Modern replacement for optionsRibbon.
   Uses existing .btn and .btn-primary; only toolbar layout/variants here.
   ========================================================================== */

/* -----------------------------------------------------------------------------
   Base Toolbar
   -------------------------------------------------------------------------- */
.action-toolbar {
  --toolbar-gap: 0.5rem;

  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--toolbar-gap);
  padding: 0;
  /* Match legacy optionsRibbon so toolbar doesn’t collapse to 0×0 in flex/float layouts */
  width: fit-content;
  min-height: 1px;
}

/* -----------------------------------------------------------------------------
   Alignment Modifiers
   -------------------------------------------------------------------------- */
.action-toolbar--right {
  justify-content: flex-end;
  align-self: flex-end;
  margin-left: auto !important;
}

.action-toolbar--left {
  justify-content: flex-start;
}

.action-toolbar--between {
  justify-content: space-between;
  margin-left: auto;
  margin-right: auto;
}

.inline_tabs_options.has_tabs .action-toolbar--right {
  align-self: flex-start;
}

.mobile\:flex-col .action-toolbar--right{
  align-self: flex-start;
  margin-left: 0;
}

@media (max-width: 768px) {
  .inline_tabs_options.has_tabs .action-toolbar--right {
    align-self: flex-start;
    margin-left: 0;
  }
}

/* -----------------------------------------------------------------------------
   Toolbar Groups
   -------------------------------------------------------------------------- */
.action-toolbar__group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}

/* Grouped buttons with shared border */
.action-toolbar__group--joined {
  gap: 0;
}

.action-toolbar__group--joined .btn {
  border-radius: 0;
  position: relative;
}

.action-toolbar__group--joined .btn:first-child {
  border-radius: var(--border-r-rounded, 50px) 0 0 var(--border-r-rounded, 50px);
}

.action-toolbar__group--joined .btn:last-child {
  border-radius: 0 var(--border-r-rounded, 50px) var(--border-r-rounded, 50px) 0;
}

/* Divider between joined buttons */
.action-toolbar__group--joined .btn + .btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  height: 50%;
  width: 1px;
  background: currentColor;
  opacity: 0.3;
}

.action-toolbar__group .btn i {
  margin-right: 6px;
  margin-top: 1px;
}

/* The open quick-search UI is taller than a button, so keep the other actions
   pinned to the top instead of letting them shift down around it. */
.action-toolbar__group:has(.quick_search) {
  align-items: flex-start;
}

/* -----------------------------------------------------------------------------
   Toolbar buttons: use .btn / .btn-primary; only layout and variants here
   -------------------------------------------------------------------------- */
.action-toolbar .btn {
  display: inline-flex;
  align-items: center;
  /* gap: 0.375rem; - removed because it distances icon from text */ 
  white-space: nowrap;
  text-decoration: none;
  padding: 5px;
  border-radius: 50px;
  color: var(--button-color-2) !important;
  background: var(--button-bg-3);
  border: 1px solid var(--content-bg-color);
  box-shadow: var(--box-shadow-btn);
  line-height: normal;
}

.action-toolbar .btn:hover,
.action-toolbar a.btn:hover {
  text-decoration: none;
}

.action-toolbar .btn:has(i.add) {
  background: var(--active-color) !important;
  border: 1px solid var(--active-color) !important;
  color: #fff !important;
}

.action-toolbar .btn:has(i.add):hover {
  filter: brightness(1.05) !important;
}

.action-toolbar .btn:has(i.add) i:after,
.action-toolbar .btn:has(i.add) span {
  color: #fff !important;
}

.action-toolbar--table .btn,
#SearchResultsWrapper .action-toolbar .btn,
.admin-panel-container .action-toolbar .btn {
  background: var(--th-bg-color);
  color: var(--main-text-color);
  border: 1px solid var(--button-border-color);
  box-shadow: none;
}

.action-toolbar--table .btn:hover {
  background: var(--th-bg-color);
}

/* Icon-only: hide label, reduce padding (override .btn padding) */
.action-toolbar .btn.btn--icon-only {
  padding: 5px 15px !important;
}

@media screen and (max-width: 1025px) {
  .action-toolbar .btn.btn--icon-only {
    padding: 5px 10px !important;
  }
}

.action-toolbar .btn.btn--icon-only i {
  margin-left: 0;
  margin-right: 0;
}

.action-toolbar .btn.btn--icon-only span:not(.textOffScreen) {
  display: none;
}

/* Selected state (toolbar-specific) */
.action-toolbar .btn.btn--selected {
  border-color: var(--active-color, #007bff);
  background: rgba(var(--active-color-rgb, 0, 123, 255), 0.1);
}

.action-toolbar .btn.btn-primary span {
  color: #fff !important;
}

/* -----------------------------------------------------------------------------
   Icons
   -------------------------------------------------------------------------- */
.action-toolbar .btn i {
  flex-shrink: 0;
  vertical-align: middle;
}

.action-toolbar .btn i.iconRight {
  order: 1;
  margin-left: 0.25rem;
  margin-right: 0;
}

/* -----------------------------------------------------------------------------
   Overflow Menu
   -------------------------------------------------------------------------- */
.action-toolbar__overflow {
  position: relative;
  /* margin-left: auto; - messes up layout on mobile: see Users > List */
}

.action-menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 100;
  min-width: 160px;
  margin-top: 0.25rem;
  padding: 0.5rem;
  background: var(--block-bg-color, #fff);
  border: 1px solid var(--main-border-color, #e2e0e0);
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex !important;
  gap: 0.25rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.action-menu[hidden] {
  display: none !important;
}

.action-menu__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 85% !important;
  padding: 0.5rem 1rem;
  font-size: var(--btn-font-size);
  color: var(--main-text-color, inherit);
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}

.action-menu__item:hover,
.action-menu__item:focus-visible {
  background: var(--highlight-bg-color, #f5f5f5);
}

/* Icon-only actions keep their label off-screen in the toolbar, but in the
   dropdown the icon alone is unidentifiable -- undo .textOffScreen clipping. */
.action-menu__item.btn--icon-only {
  padding: 0.5rem 1rem !important;
}

.action-menu__item.btn--icon-only span.textOffScreen {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0;
  clip: auto;
  overflow: visible;
  transform: none;
}

.btn.btn--icon-only.show-filter-field i.search {
  margin-top: 1px;
}

/* -----------------------------------------------------------------------------
   Context Variants
   -------------------------------------------------------------------------- */

/* Above tables */
.action-toolbar--table {
  margin-bottom: 0;
  margin-left: 10px;
  width: 100%;
}

.action-toolbar--table.mt10 {
  margin-top: 0px;
}

.action-toolbar--table .action-toolbar__group {
  align-items: flex-start;
}

/* In right column sidebar */
.rightColumn .action-toolbar {
  margin: 0 14px;
}

.rightColumn .action-toolbar .btn {
  padding: 2px 8px;
}

/* In table cells */
td .action-toolbar {
  --toolbar-gap: 0.25rem;
  padding: 0;
}

td .action-toolbar .btn {
  padding: 0.25rem 0.5rem;
  border: none;
  background: transparent;
}

/* With heading inline */
.inline-heading-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.inline-heading-toolbar h2 {
  margin: 0;
  flex: 1;
}

.inline-heading-toolbar .action-toolbar {
  flex: none;
}

/* -----------------------------------------------------------------------------
   Responsive Behavior
   -------------------------------------------------------------------------- */
@media screen and (max-width: 767px) {
  .action-toolbar .btn:not(.btn--icon-only) span:not(.textOffScreen) {
    display: block;
  }

  .action-toolbar .btn:not(.btn--icon-only) {
    padding: 5px 10px !important;
  }
}

/* Hide overflow menu on desktop unless needed */
.action-toolbar:not(.action-toolbar--has-overflow) .action-toolbar__overflow {
  display: none;
}

/* -----------------------------------------------------------------------------
   Screen Reader Utilities
   -------------------------------------------------------------------------- */
.action-toolbar .textOffScreen {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* -----------------------------------------------------------------------------
   Backward Compatibility (Deprecation Layer)
   During migration, map old classes to new styles
   -------------------------------------------------------------------------- */
.optionsRibbon {
  /* old size, kept till caller opt into .use-new-styles */
  padding: 0 3px 2rem 0;
  left: -3px;
  width: 100%;
  height: 29px;
  overflow: hidden;
}

.optionsRight, .optionsLeft {
  border-width: 0;
  float: right;
  top: -2px;
  padding: 0 0 5px 0;
  width: auto;
}

body.new_action_toolbar .optionsRibbon {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

/* Remove old problematic styles gradually */
.optionsRibbon.use-new-styles {
  height: auto;
  overflow: visible;
  padding: 0.25rem 0;
  left: 0;
}

.optionsRibbon.use-new-styles ul {
  display: contents; /* Flatten list structure */
  border: none;
  background: transparent;
}

.optionsRibbon.use-new-styles ul li {
  display: contents;
}

.optionsRibbon.use-new-styles ul li::after {
  display: none; /* Remove pseudo-element dividers */
}
