/**
 * Recent record tabs overlay (bottom-left, chrome-tab style).
 *
 * Cards are rendered by recent-tabs.js into #aim-recent-tabs (mounted in the
 * default layout outside .content-wrapper). Each card carries its own
 * data-aim-primary + inline --aim-page-primary, so the tint formulas below
 * mirror the 15%/85% color-mix convention from aim-component-colors.css.
 */

.aim-recent-tabs {
  position: fixed;
  bottom: 0;
  left: 1rem;
  /* Single row: the strip hugs its cards and scrolls horizontally on overflow.
     Width is content-driven so the empty area never blocks clicks underneath. */
  width: max-content;
  max-width: calc(100vw - 2rem);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  /* Above .aim-sticky-scrollbar (1000), below offcanvas/modals (1045+) and toasts */
  z-index: 1001;
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 0.25rem;
}

.aim-recent-tabs::-webkit-scrollbar {
  height: 5px;
}

.aim-recent-tabs::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 3px;
}

.aim-recent-tabs::-webkit-scrollbar-track {
  background: transparent;
}

/* The menu is only fixed at >=1200px (core.css layout-menu-fixed breakpoint) */
@media (min-width: 1200px) {
  .aim-recent-tabs {
    left: calc(var(--bs-menu-width, 16.25rem) + 1rem);
    max-width: calc(100vw - var(--bs-menu-width, 16.25rem) - 2rem);
  }

  html.layout-menu-collapsed .aim-recent-tabs {
    left: calc(var(--bs-menu-collapsed-width, 4.375rem) + 1rem);
    max-width: calc(100vw - var(--bs-menu-collapsed-width, 4.375rem) - 2rem);
  }
}

/* Lift above the list-page sticky scrollbar (~14px tall) when it is active */
body:has(.aim-sticky-scrollbar.active) .aim-recent-tabs {
  bottom: 16px;
}

/* Reserve room at the page bottom so the strip never covers the last rows of
   non-paginated content. Applies only while the strip actually has cards (the
   mount ships empty; :has() re-evaluates as JS adds/removes them). !important
   is needed because core.css forces padding-block-end: 0 !important on
   non-fixed-footer layouts; this file loads after core.css and the selector
   is more specific, so this rule wins. */
@media screen {
  body:has(.aim-recent-tabs:not(:empty)) .content-wrapper {
    padding-block-end: 1.75rem !important;
  }
}

@media print {
  .aim-recent-tabs {
    display: none;
  }
}

.aim-recent-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  /* Cards keep their size in the nowrap row - the strip scrolls instead */
  flex: 0 0 auto;
  max-width: 11rem;
  min-width: 0;
  padding: 0.2rem 0.3rem 0.2rem 0.55rem;
  border-radius: 0.5rem 0.5rem 0 0;
  border: 1px solid color-mix(in sRGB, var(--aim-page-primary) 35%, white);
  border-bottom: none;
  background-color: color-mix(in sRGB, var(--aim-page-primary) 15%, white);
  color: color-mix(in sRGB, var(--aim-page-primary) 85%, black);
  font-size: 0.75rem;
  line-height: 1.4;
  text-decoration: none;
  box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.08);
}

.aim-recent-tab:hover {
  background-color: color-mix(in sRGB, var(--aim-page-primary) 25%, white);
  color: color-mix(in sRGB, var(--aim-page-primary) 85%, black);
}

.aim-recent-tab.active {
  background-color: var(--aim-page-primary);
  border-color: var(--aim-page-primary);
  color: var(--aim-text-on-primary);
}

.aim-recent-tab > i {
  flex-shrink: 0;
  font-size: 0.875rem;
}

.aim-recent-tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aim-recent-tab-close {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: inherit;
  opacity: 0.6;
  padding: 0 0.15rem;
  line-height: 1;
  border-radius: 0.25rem;
  cursor: pointer;
}

.aim-recent-tab-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.1);
}
