/**
 * @file
 * Styles for the ACM Treeselect form element.
 */

/* ---------- Design tokens ---------- */
.treeselect-wrapper {
  --ts-primary: #3b82f6;
  --ts-primary-hover-bg: #eff6ff;
  --ts-text-main: #1e293b;
  --ts-text-muted: #64748b;
  --ts-border: #e2e8f0;
  --ts-bg-panel: #ffffff;
  --ts-bg-header: #f8fafc;
  --ts-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);

  position: relative;
  width: 100%;
}

/* ---------- Input wrapper ---------- */
.treeselect-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

/* ---------- Text input ---------- */
.treeselect-input {
  width: 100%;
  padding: 12px 40px 12px 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ts-text-main);
  background: var(--ts-bg-panel);
  border: 2px solid var(--ts-border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.treeselect-input:focus {
  border-color: var(--ts-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

/* ---------- Clear button ---------- */
.treeselect-clear-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--ts-text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
}

.treeselect-clear-btn:hover {
  color: var(--ts-text-main);
  background: #f1f5f9;
}

/* ---------- Dropdown panel ---------- */
.treeselect-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--ts-bg-panel);
  border: 1px solid var(--ts-border);
  border-radius: 10px;
  box-shadow: var(--ts-shadow);
  max-height: 360px;
  overflow-y: auto;
  z-index: 200;
}

/* ---------- Dropdown header (breadcrumb / back button) ---------- */
.treeselect-dropdown-header {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ts-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--ts-bg-header);
  border-bottom: 1px solid var(--ts-border);
  display: none;
  align-items: center;
  gap: 8px;
}

.treeselect-back-btn {
  background: none;
  border: none;
  color: var(--ts-primary);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.treeselect-back-btn:hover {
  text-decoration: underline;
}

/* ---------- List items ---------- */
.treeselect-item {
  padding: 11px 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--ts-text-main);
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
  transition: background 0.12s, color 0.12s;
}

.treeselect-item:last-child {
  border-bottom: none;
}

.treeselect-item:hover {
  background: var(--ts-primary-hover-bg);
  color: var(--ts-primary);
}

/* Category items (root level) */
.treeselect-item--category {
  font-weight: 500;
}

.treeselect-item--category .treeselect-item-arrow {
  color: var(--ts-text-muted);
  font-size: 18px;
  line-height: 1;
}

/* "Select entire category" item */
.treeselect-item--select-all {
  background: var(--ts-bg-header);
  color: var(--ts-primary);
  font-weight: 600;
  border-bottom: 2px solid var(--ts-border);
}

.treeselect-item--select-all:hover {
  background: var(--ts-primary-hover-bg);
}

/* Parent label pill (shown in search results) */
.treeselect-parent-pill {
  font-size: 10px;
  background: #e2e8f0;
  color: var(--ts-text-muted);
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---------- No results ---------- */
.treeselect-no-results {
  padding: 18px 14px;
  text-align: center;
  color: var(--ts-text-muted);
  font-style: italic;
  font-size: 14px;
}

/* ---------- Keyboard focus (aria-activedescendant) ---------- */

/*
 * Visual focus indicator for items navigated with ArrowUp/Down.
 * Distinct from :hover so keyboard and mouse users both get clear feedback.
 */
.treeselect-item--keyboard-focus,
.treeselect-back-btn.treeselect-item--keyboard-focus {
  background: var(--ts-primary-hover-bg);
  color: var(--ts-primary);
  outline: 2px solid var(--ts-primary);
  outline-offset: -2px;
}

/* Clear button: show a visible focus ring when tabbed to. */
.treeselect-clear-btn:focus-visible {
  outline: 2px solid var(--ts-primary);
  outline-offset: 2px;
  color: var(--ts-text-main);
  background: #f1f5f9;
}
