/* ch_support_ticket_list_html (theme/assets/request_services/ch_support_ticket_list_html.css).
 *
 * Linked from head_html, so the designer canvas is styled too. Every rule is scoped
 * :where(.ch-ticket-list-container), which adds no specificity; the root rule itself stays bare.
 * Section-wide, scoped :where(.ch-services-container) because they also style the ticket detail:
 *   .ch-badge, the only badge rule with line-height: 1.4, and the .ch-badge-category chip.
 * Keyframes are rs-tl-* (keyframe names are global across the page).
 * The empty-state icon is a span around the <svg> (the designer cannot set a class on an <svg>);
 *   the tl-hidden classes are compound, because two of those blocks set display: flex
 *   themselves; the module's inline display still wins over both.
 */

.ch-ticket-list-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  padding: 0;
}

/* Tray badge pair: no --ch-* or --px-* equivalent */
:where(.ch-ticket-list-container) {
  --tl-badge-tray-bg: #ffedd5;
  --tl-badge-tray-text: #c2410c;
}

@media not print {
  [data-theme="dark"] :where(.ch-ticket-list-container) {
    --tl-badge-tray-bg: #7c2d12;
    --tl-badge-tray-text: #fdba74;
  }
}

/* Ticket row */
:where(.ch-ticket-list-container) .ch-ticket-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ch-border);
  cursor: pointer;
  transition: background-color var(--ch-transition-fast);
}

:where(.ch-ticket-list-container) .ch-ticket-row:hover {
  background: var(--ch-bg-secondary);
}

:where(.ch-ticket-list-container) .ch-ticket-row.selected {
  background: var(--ch-accent-secondary);
  border-left: 3px solid var(--ch-accent-primary);
}

:where(.ch-ticket-list-container) .ch-ticket-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

:where(.ch-ticket-list-container) .ch-ticket-id {
  font-size: 12px;
  color: var(--ch-text-muted);
  font-family: monospace;
}

:where(.ch-ticket-list-container) .ch-ticket-subject {
  font-size: 14px;
  font-weight: 500;
  color: var(--ch-text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 150px;
}

/* Status badges */
:where(.ch-services-container) .ch-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
}

:where(.ch-ticket-list-container) .ch-badge-open {
  background: var(--ch-category-chip-bg);
  color: var(--ch-category-chip-text);
}

:where(.ch-ticket-list-container) .ch-badge-awaiting {
  background: var(--ch-warning-bg);
  color: var(--ch-accent-primary-text);
}

:where(.ch-ticket-list-container) .ch-badge-resolved {
  background: var(--ch-pill-cancelled-bg);
  color: var(--ch-text-secondary);
}

/* Type badges */
:where(.ch-ticket-list-container) .ch-badge-returns { background: var(--ch-category-chip-bg); color: var(--ch-category-chip-text); }
:where(.ch-ticket-list-container) .ch-badge-complaint { background: var(--ch-danger-bg); color: var(--ch-danger-text); }
:where(.ch-ticket-list-container) .ch-badge-tray-change { background: var(--tl-badge-tray-bg); color: var(--tl-badge-tray-text); }
:where(.ch-ticket-list-container) .ch-badge-feedback { background: var(--ch-success-bg); color: var(--ch-pill-bagged-text); }
:where(.ch-ticket-list-container) .ch-badge-interim { background: var(--ch-info-bg); color: var(--ch-pill-processing-text); }
:where(.ch-ticket-list-container) .ch-badge-support { background: var(--px-purple-bg); color: var(--px-purple-text); }
:where(.ch-ticket-list-container) .ch-badge-unassigned { background: var(--ch-pill-prescribed-bg); color: var(--ch-pill-prescribed-text); }

/* Request category: its own line under the subject; the name wraps, the +N does not */
:where(.ch-ticket-list-container) .ch-ticket-category {
  display: flex;
  flex-basis: 100%;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
}

:where(.ch-services-container) .ch-badge.ch-badge-category {
  background: var(--ch-category-chip-bg);
  color: var(--ch-category-chip-text);
  white-space: normal;
  text-align: left;
  line-height: 1.25;
  border-radius: 10px;
  padding: 3px 9px;
  max-width: 230px;
}

:where(.ch-ticket-list-container) .ch-badge.ch-badge-category-more {
  white-space: nowrap;
}

:where(.ch-ticket-list-container) .ch-assign-select {
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--px-border-strong);
  border-radius: 6px;
  background: var(--ch-bg-card);
  color: var(--ch-text-secondary);
  cursor: pointer;
  margin-left: auto;
}
:where(.ch-ticket-list-container) .ch-assign-select:hover:not(:disabled) { border-color: var(--px-border-hover); }
:where(.ch-ticket-list-container) .ch-assign-select:focus-visible {
  outline: 2px solid var(--px-focus-ring);
  outline-offset: 2px;
}
:where(.ch-ticket-list-container) .ch-assign-select:disabled {
  background: var(--px-bg-disabled);
  color: var(--px-text-disabled);
  border-color: var(--px-border-disabled);
  cursor: default;
}

:where(.ch-ticket-list-container) .ch-ticket-row-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

:where(.ch-ticket-list-container) .ch-ticket-home {
  font-size: 12px;
  color: var(--ch-text-muted);
}

:where(.ch-ticket-list-container) .ch-ticket-requester {
  color: var(--ch-text-secondary);
  font-size: 0.82rem;
}

:where(.ch-ticket-list-container) .ch-ticket-dates {
  font-size: 11px;
  color: var(--ch-text-muted);
  margin-left: auto;
}

/* Skeleton loading */
:where(.ch-ticket-list-container) .ch-skeleton-list {
  padding: 12px 16px;
}

:where(.ch-ticket-list-container) .ch-skeleton-row {
  height: 56px;
  background: linear-gradient(90deg, var(--ch-bg-secondary) 25%, var(--ch-bg-elevated) 50%, var(--ch-bg-secondary) 75%);
  background-size: 200% 100%;
  animation: rs-tl-skel-shimmer 1.5s infinite;
  border-radius: var(--ch-radius-md);
  margin-bottom: 8px;
}

@keyframes rs-tl-skel-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Empty state */
:where(.ch-ticket-list-container) .ch-ticket-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 12px;
}

:where(.ch-ticket-list-container) .ch-ticket-empty-icon {
  width: 48px;
  height: 48px;
  color: var(--ch-text-disabled);
  line-height: 0;
}

:where(.ch-ticket-list-container) .ch-ticket-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ch-text-primary);
}

:where(.ch-ticket-list-container) .ch-ticket-empty-text {
  font-size: 14px;
  color: var(--ch-text-muted);
}

:where(.ch-ticket-list-container) .ch-ticket-empty-btn {
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  background: var(--ch-accent-primary);
  color: var(--px-ink-on-bright);
  border: none;
  border-radius: var(--ch-radius-md);
  cursor: pointer;
  margin-top: 8px;
  transition: background-color var(--ch-transition-fast);
  min-height: 40px;
}

:where(.ch-ticket-list-container) .ch-ticket-empty-btn:hover {
  background: var(--ch-accent-primary-hover);
}

:where(.ch-ticket-list-container) .ch-ticket-empty-btn:focus-visible,
:where(.ch-ticket-list-container) .ch-ticket-older-btn:focus-visible {
  outline: 2px solid var(--px-focus-ring);
  outline-offset: 2px;
}

/* Info banner */
:where(.ch-ticket-list-container) .ch-ticket-banner {
  padding: 8px 16px;
  font-size: 13px;
  color: var(--px-info-text);
  background: var(--ch-info-bg);
  border-bottom: 1px solid var(--ch-info-border);
}

/* Load older: the banner's button and the one after the last row */
:where(.ch-ticket-list-container) .ch-ticket-older {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

:where(.ch-ticket-list-container) .ch-ticket-older-end {
  display: flex;
  justify-content: center;
  padding: 16px;
}

:where(.ch-ticket-list-container) .ch-ticket-older-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  background: var(--ch-accent-primary);
  color: var(--px-ink-on-bright);
  border: none;
  border-radius: var(--ch-radius-md);
  cursor: pointer;
  min-height: 32px;
}

:where(.ch-ticket-list-container) .ch-ticket-older-btn:disabled {
  background: var(--px-bg-disabled);
  color: var(--px-text-disabled);
  cursor: default;
}

/* Infinite scroll sentinel */
:where(.ch-ticket-list-container) .ch-scroll-sentinel {
  height: 1px;
  width: 100%;
}

:where(.ch-ticket-list-container) .ch-load-more-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

:where(.ch-ticket-list-container) .ch-load-more-spinner .ch-mini-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--ch-border);
  border-top-color: var(--ch-accent-primary);
  border-radius: 50%;
  animation: rs-tl-skel-shimmer-spin 0.8s linear infinite;
}

@keyframes rs-tl-skel-shimmer-spin {
  to { transform: rotate(360deg); }
}

:where(.ch-ticket-list-container) .ch-ticket-empty-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

:where(.ch-ticket-list-container) .ch-ticket-banner.tl-hidden,
:where(.ch-ticket-list-container) .ch-ticket-older-end.tl-hidden,
:where(.ch-ticket-list-container) .ch-ticket-empty.tl-hidden,
:where(.ch-ticket-list-container) .ch-ticket-empty-btn.tl-hidden,
:where(.ch-ticket-list-container) .ch-load-more-spinner.tl-hidden {
  display: none;
}
