
/* ============================================================
   la-combo.css – Suggestion dropdown for window.laCombo
   Palette: primary #5D87FF · success #13DEB9 · danger #FA896B
   Neutrals: Tailwind slate scale
   ============================================================ */

/* --- Custom properties ------------------------------------ */
:root {
  --lac-primary:      #5D87FF;
  --lac-primary-15:   rgba(93, 135, 255, .15);
  --lac-primary-10:   rgba(93, 135, 255, .10);
  --lac-success:      #13DEB9;
  --lac-danger:       #FA896B;
  --lac-slate-50:     #f8fafc;
  --lac-slate-100:    #f1f5f9;
  --lac-slate-200:    #e2e8f0;
  --lac-slate-300:    #cbd5e1;
  --lac-slate-400:    #94a3b8;
  --lac-slate-500:    #64748b;
  --lac-slate-600:    #475569;
  --lac-slate-700:    #334155;
  --lac-slate-800:    #1e293b;
  --lac-slate-900:    #0f172a;
  --lac-z:            10050;
  --lac-radius:       0.75rem;   /* rounded-xl */
  --lac-border:       1px solid var(--lac-slate-200);
  --lac-shadow:       0 4px 6px -1px rgba(0,0,0,.07),
                      0 10px 15px -3px rgba(0,0,0,.08);
  --lac-transition:   120ms cubic-bezier(.4,0,.2,1);
}

/* --- Keyframes -------------------------------------------- */
@keyframes lac-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

@keyframes lac-spin {
  to { transform: rotate(360deg); }
}

/* --- List container --------------------------------------- */
.la-combo-list {
  position: fixed;
  z-index: var(--lac-z);
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;

  min-width: 12rem;
  max-height: 14rem;
  overflow-y: auto;
  overscroll-behavior: contain;

  background: #fff;
  border: var(--lac-border);
  border-radius: var(--lac-radius);
  box-shadow: var(--lac-shadow);

  contain: content;
  scrollbar-width: thin;
  scrollbar-color: var(--lac-slate-300) transparent;

  /* Closed state (pre-animation) */
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity var(--lac-transition),
              transform var(--lac-transition);
}

/* Thin scrollbar – WebKit */
.la-combo-list::-webkit-scrollbar {
  width: 6px;
}
.la-combo-list::-webkit-scrollbar-track {
  background: transparent;
}
.la-combo-list::-webkit-scrollbar-thumb {
  background: var(--lac-slate-300);
  border-radius: 3px;
}

/* Open state */
.la-combo-list.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Upward flip */
.la-combo-list.is-above {
  transform: translateY(4px);
}
.la-combo-list.is-above.is-open {
  transform: translateY(0);
}

/* Hidden attribute override (JS toggles) */
.la-combo-list[hidden] {
  display: none;
}

/* Loading state – subtle top-border pulse */
.la-combo-list.is-loading {
  border-top-color: var(--lac-primary);
}

/* --- Sticky header & footer ------------------------------- */
.la-combo-head,
.la-combo-foot {
  position: sticky;
  padding: 0.375rem 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  color: var(--lac-slate-500);
  background: var(--lac-slate-50);
  user-select: none;
}

.la-combo-head {
  top: 0;
  border-bottom: var(--lac-border);
  border-radius: var(--lac-radius) var(--lac-radius) 0 0;
  z-index: 1;
}

.la-combo-foot {
  bottom: 0;
  border-top: var(--lac-border);
  border-radius: 0 0 var(--lac-radius) var(--lac-radius);
  z-index: 1;
}

/* --- Options ---------------------------------------------- */
.la-combo-opt {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;          /* 44px touch target */
  padding: 0.5rem 0.875rem 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--lac-slate-800);
  /* No transition on background – instant class toggle for 60fps */
}

/* Highlighted (keyboard / hover) */
.la-combo-opt.is-active {
  background-color: var(--lac-primary-15);
  color: var(--lac-slate-900);
}

/* Current value marker */
.la-combo-opt.is-current {
  position: relative;
}
.la-combo-opt.is-current::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.375rem;
  bottom: 0.375rem;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--lac-primary);
}

/* Disabled */
.la-combo-opt.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* --- Option parts ----------------------------------------- */
.la-combo-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.la-combo-detail {
  flex: 0 0 auto;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  color: var(--lac-slate-500);
}

.la-combo-badge {
  flex: 0 0 auto;
  padding: 0.125rem 0.375rem;
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 1;
  border-radius: 9999px;
  background: var(--lac-primary-10);
  color: var(--lac-primary);
}

/* Match highlight <mark> */
.la-combo-hl {
  background: transparent;
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--lac-primary);
  text-underline-offset: 2px;
  text-decoration-thickness: 1.5px;
}

.la-combo-opt.is-active .la-combo-hl {
  text-decoration-color: currentColor;
}

/* --- Message area (empty / error) ------------------------- */
.la-combo-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  color: var(--lac-slate-500);
  user-select: none;
}

.la-combo-list.is-error .la-combo-msg {
  color: var(--lac-danger);
}

.la-combo-list.is-empty .la-combo-msg {
  color: var(--lac-slate-400);
}

/* --- Loading shimmer row ---------------------------------- */
.la-combo-shimmer {
  min-height: 2.5rem;
  margin: 0.25rem 0.75rem;
  border-radius: 0.375rem;
  background: linear-gradient(
    90deg,
    var(--lac-slate-100) 25%,
    var(--lac-slate-200) 50%,
    var(--lac-slate-100) 75%
  );
  background-size: 200% 100%;
  animation: lac-shimmer 1.4s ease-in-out infinite;
}

/* --- Input & wrapper -------------------------------------- */
.la-combo-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.la-combo-input {
  width: 100%;
  min-height: 2.5rem;           /* 40px touch target */
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: var(--lac-slate-800);
  background: #fff;
  border: var(--lac-border);
  border-radius: 0.5rem;
  outline: none;
  transition: border-color 120ms ease;
}

.la-combo-input.is-expanded {
  border-color: var(--lac-primary);
}

/* Focus-visible ring on wrapper */
.la-combo-wrap:has(.la-combo-input:focus-visible) {
  border-radius: 0.5rem;
  box-shadow: 0 0 0 2px #fff,
              0 0 0 4px var(--lac-primary);
}

/* Fallback for browsers without :has() */
@supports not selector(:has(*)) {
  .la-combo-input:focus-visible {
    box-shadow: 0 0 0 2px #fff,
                0 0 0 4px var(--lac-primary);
  }
}

/* --- Input spinner (pure CSS, SVG data-URI) --------------- */
.la-combo-wrap.is-loading .la-combo-input {
  padding-right: 2.5rem;
}

.la-combo-wrap.is-loading::after {
  content: '';
  position: absolute;
  right: 0.75rem;
  top: 50%;
  width: 1rem;
  height: 1rem;
  margin-top: -0.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Ccircle cx='12' cy='12' r='10' stroke='%23cbd5e1' stroke-width='3'/%3E%3Cpath d='M12 2a10 10 0 0 1 10 10' stroke='%235D87FF' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  animation: lac-spin 0.75s linear infinite;
  pointer-events: none;
}

/* --- Font Awesome spinner (alternative, inside list) ------ */
.la-combo-spinner {
  display: none;
  color: var(--lac-primary);
  font-size: 0.875rem;
}

.la-combo-list.is-loading .la-combo-spinner {
  display: inline-block;
}

/* --- Screen-reader only ----------------------------------- */
.la-combo-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --- Reduced motion --------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .la-combo-list {
    transition: none;
    transform: none;
  }
  .la-combo-list.is-above {
    transform: none;
  }
  .la-combo-shimmer {
    animation: none;
    background: var(--lac-slate-100);
  }
  .la-combo-wrap.is-loading::after {
    animation: none;
  }
}


/* Part 163 polish (visual review): header/footer separation + current-row weight */
.la-combo-head, .la-combo-foot { background: var(--lac-slate-100); }
.la-combo-head { box-shadow: 0 1px 2px rgba(15, 23, 42, .06); }
.la-combo-foot { box-shadow: 0 -1px 2px rgba(15, 23, 42, .06); }
.la-combo-opt.is-current { font-weight: 600; }
