/* ch_support_tickets_html (Support Tickets sub-shell), linked from anvil.yaml head_html.
 * Every rule is scoped :where(.ch-support-tickets-root), the wrapper root the template adds around
 * its top-level nodes, which adds no specificity.
 * Keyframes are rs-st-* (keyframe names are global across the page); rs-st-spin is the spinner's
 *   own keyframe, so it depends on no other form's.
 */

:where(.ch-support-tickets-root) .ch-support-container {
  position: relative;
  min-height: 400px;
}

:where(.ch-support-tickets-root) .ch-support-split {
  display: flex;
  gap: 0;
  min-height: 500px;
  height: calc(100vh - 220px);
}

:where(.ch-support-tickets-root) .ch-support-left {
  width: 40%;
  border-right: 1px solid var(--ch-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

:where(.ch-support-tickets-root) .ch-support-right {
  width: 60%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

:where(.ch-support-tickets-root) .ch-support-right-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--ch-text-muted);
  font-size: 15px;
  padding: var(--ch-space-lg);
  text-align: center;
}

/* Error banner */
:where(.ch-support-tickets-root) .ch-support-error {
  background: var(--ch-danger-bg);
  color: var(--ch-danger);
  border: 1px solid var(--ch-danger-border);
  border-radius: var(--ch-radius-md);
  padding: 12px 16px;
  margin-bottom: var(--ch-space-md);
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

:where(.ch-support-tickets-root) .ch-support-error.visible {
  display: flex;
}

:where(.ch-support-tickets-root) .ch-support-error-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--ch-danger);
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  line-height: 1;
}

/* Partial-sort hint: shown briefly while the server is patching
   latest_comment_added_at for visible rows (§C block-on-missing). */
:where(.ch-support-tickets-root) .ch-support-partial-sort-hint {
  display: none;
  font-size: 12px;
  color: var(--ch-text-muted);
  padding: 4px 12px;
  opacity: 0;
  transition: opacity 200ms ease-out;
}
:where(.ch-support-tickets-root) .ch-support-partial-sort-hint.visible {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: 1;
}
:where(.ch-support-tickets-root) .ch-support-partial-sort-hint::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid var(--ch-text-muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: rs-st-partial-sort-spin 0.9s linear infinite;
}
@keyframes rs-st-partial-sort-spin {
  to { transform: rotate(360deg); }
}

/* Slide-in overlay for new ticket */
:where(.ch-support-tickets-root) .ch-slide-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.4);
  z-index: var(--ch-z-modal);
  display: none;
  opacity: 0;
  transition: opacity 200ms ease;
}

:where(.ch-support-tickets-root) .ch-slide-overlay.visible {
  display: block;
  opacity: 1;
}

:where(.ch-support-tickets-root) .ch-slide-panel {
  width: min(540px, 90vw);
  background: var(--ch-bg-card);
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
  z-index: calc(var(--ch-z-modal) + 1);
  transition: transform 300ms ease;
  overflow-y: auto;
}

/* Designer gate: the panel is pinned off the right edge only once
   supportTickets_init marks the root ch-support-tickets-live. The designer
   runs no module, so the New Ticket slot sits in the page flow on the canvas. */
:where(.ch-support-tickets-root.ch-support-tickets-live) .ch-slide-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  transform: translateX(100%);
}

:where(.ch-support-tickets-root) .ch-slide-panel.visible {
  transform: translateX(0);
}

:where(.ch-support-tickets-root) .ch-support-loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--ch-bg-overlay);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: var(--ch-z-overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--ch-transition-normal), visibility var(--ch-transition-normal);
}

:where(.ch-support-tickets-root) .ch-support-loading.visible {
  opacity: 1;
  visibility: visible;
}

:where(.ch-support-tickets-root) .ch-support-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--ch-border);
  border-top-color: var(--ch-accent-primary);
  border-radius: 50%;
  animation: rs-st-spin 1s linear infinite;
}

:where(.ch-support-tickets-root) .ch-support-loading-text {
  margin-top: 12px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
}

/* Mobile responsive: stacked layout */
@media (max-width: 768px) {
  :where(.ch-support-tickets-root) .ch-support-split {
    flex-direction: column;
    min-height: auto;
    height: auto;
  }

  :where(.ch-support-tickets-root) .ch-support-left {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--ch-border);
    overflow-y: visible;
  }

  :where(.ch-support-tickets-root) .ch-support-right {
    width: 100%;
    overflow-y: visible;
  }

  :where(.ch-support-tickets-root) .ch-support-left.mobile-hidden {
    display: none;
  }

  :where(.ch-support-tickets-root) .ch-support-right.mobile-hidden {
    display: none;
  }
}

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