/* ==========================================================================
   PREMIUM CUSTOM PAGE-SIZE DROPDOWN
   Replaces the native <select> UI for #page-size-select with a fully custom
   dropdown. The native select stays in the DOM (visually hidden) as the
   value/state control and is synced by js/page-size-dropdown.js, so the
   existing pagination change-handler keeps working unchanged.
   ========================================================================== */

/* Wrapper wraps the hidden native select + custom trigger + menu */
.page-size-dropdown {
  position: relative;
  display: inline-block;
  z-index: 5;
}

/* Visually hide the native select but keep it focusable/synced. It stays in
   the DOM; the custom trigger mirrors its value. We use a clip so it's still
   positioned for keyboard/AT, but not visible. */
.page-size-dropdown select.page-size-select {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}

/* ── Trigger (closed state) ─────────────────────────────────────────────── */
.page-size-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 76px;
  height: 36px;
  padding: 0 10px 0 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01)),
    rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
  border-top-color: rgba(255,255,255,0.16);
  border-radius: 10px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.05) inset,
    0 1px 2px rgba(0,0,0,0.25);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.2px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition:
    border-color 0.18s ease,
    background-color 0.18s ease,
    box-shadow 0.18s ease;
}
.page-size-trigger:hover {
  background-color: rgba(255,255,255,0.06);
  border-color: rgba(var(--accent-primary-rgb, 59,130,246), 0.45);
}
.page-size-trigger:focus-visible {
  outline: none;
  border-color: rgba(var(--accent-primary-rgb, 59,130,246), 0.6);
  box-shadow:
    0 0 0 3px rgba(var(--accent-primary-rgb, 59,130,246), 0.14),
    0 1px 0 rgba(255,255,255,0.05) inset;
}
.page-size-trigger.open {
  border-color: rgba(var(--accent-primary-rgb, 59,130,246), 0.6);
  box-shadow: 0 0 0 3px rgba(var(--accent-primary-rgb, 59,130,246), 0.14);
}

/* Custom chevron */
.page-size-chevron {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--text-muted, #5a6a7d);
  transition: transform 0.2s ease, color 0.2s ease;
}
.page-size-trigger.open .page-size-chevron {
  transform: rotate(180deg);
  color: #cbd5e1;
}

/* Selected value label */
.page-size-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ── Floating menu ──────────────────────────────────────────────────────── */
.page-size-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  padding: 5px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.015)),
    var(--bg-elevated, #232d3d);
  border: 1px solid rgba(255,255,255,0.12);
  border-top-color: rgba(255,255,255,0.16);
  border-radius: 12px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.05) inset,
    0 12px 30px rgba(0,0,0,0.45),
    0 4px 10px rgba(0,0,0,0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 40;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top left;
  pointer-events: none;
  transition:
    opacity 0.16s ease,
    transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.page-size-menu.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Option */
.page-size-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}
.page-size-option:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}
.page-size-option.selected {
  background: rgba(var(--accent-primary-rgb, 59,130,246), 0.12);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(var(--accent-primary-rgb, 59,130,246), 0.2);
}
.page-size-option.selected::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 0 8px rgba(var(--accent-primary-rgb, 59,130,246), 0.6);
  flex-shrink: 0;
}

/* ── Mobile: comfortable, never overflow ────────────────────────────────── */
@media (max-width: 480px) {
  .page-size-trigger {
    min-width: 64px;
    height: 36px;
    padding: 0 8px 0 10px;
  }
  .page-size-menu {
    min-width: 120px;
    left: 0;
    right: auto;
    max-width: calc(100vw - 32px);
  }
  .page-size-option {
    padding: 10px 12px; /* larger touch target */
  }
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .page-size-trigger,
  .page-size-menu,
  .page-size-chevron {
    transition: none !important;
  }
}
