/* ch_support_ticket_detail_html (Support Tickets ticket detail), linked from anvil.yaml head_html.
 * Every rule is scoped :where(.ch-detail-container), which adds no specificity; the root rule
 * itself stays bare.
 * Keyframes are rs-td-* (keyframe names are global across the page).
 * At the end: the td-hidden classes (compound, because each of those blocks sets display itself,
 *   except the viewer banners; the module's inline display still wins over both).
 */

.ch-detail-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Back button (mobile only) */
:where(.ch-detail-container) .ch-back-btn {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--ch-font-primary);
  color: var(--ch-accent-primary-text, #b45309);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ch-border);
  cursor: pointer;
  width: 100%;
  text-align: left;
}

@media (max-width: 768px) {
  :where(.ch-detail-container) .ch-back-btn { display: flex; }
}

/* Metadata card */
:where(.ch-detail-container) .ch-detail-meta {
  padding: 16px;
  border-bottom: 1px solid var(--ch-border);
  flex-shrink: 0;
}

:where(.ch-detail-container) .ch-detail-subject {
  font-size: 18px;
  font-weight: 600;
  color: var(--ch-text-primary);
  margin: 0 0 8px 0;
  word-break: break-word;
}

:where(.ch-detail-container) .ch-detail-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: var(--ch-text-muted);
  align-items: center;
}

:where(.ch-detail-container) .ch-detail-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

:where(.ch-detail-container) .ch-detail-meta-label {
  font-weight: 500;
}

/* Badge reuse from list */
:where(.ch-detail-container) .ch-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

:where(.ch-detail-container) .ch-badge-open { background: #dbeafe; color: #1d4ed8; }
:where(.ch-detail-container) .ch-badge-awaiting { background: #fef3c7; color: #b45309; }
:where(.ch-detail-container) .ch-badge-resolved { background: #e5e7eb; color: #4b5563; }

/* Conversation thread */
:where(.ch-detail-container) .ch-detail-thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

:where(.ch-detail-container) .ch-detail-description {
  background: var(--ch-bg-secondary);
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius-md);
  padding: 12px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--ch-text-primary);
  line-height: 1.5;
}

:where(.ch-detail-container) .ch-detail-description-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ch-text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

:where(.ch-detail-container) .ch-comment {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--ch-border);
}

:where(.ch-detail-container) .ch-comment:last-child {
  border-bottom: none;
}

:where(.ch-detail-container) .ch-comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

:where(.ch-detail-container) .ch-comment-author {
  font-size: 14px;
  font-weight: 600;
  color: var(--ch-text-primary);
}

:where(.ch-detail-container) .ch-comment-time {
  font-size: 12px;
  color: var(--ch-text-muted);
}

:where(.ch-detail-container) .ch-comment-body {
  font-size: 14px;
  color: var(--ch-text-primary);
  line-height: 1.6;
  word-break: break-word;
}

:where(.ch-detail-container) .ch-comment-body p { margin: 0 0 8px 0; }
:where(.ch-detail-container) .ch-comment-body p:last-child { margin-bottom: 0; }
:where(.ch-detail-container) .ch-comment-body ul, :where(.ch-detail-container) .ch-comment-body ol { margin: 4px 0; padding-left: 20px; }

/* Attachments */
:where(.ch-detail-container) .ch-comment-attachments {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

:where(.ch-detail-container) .ch-attachment-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-size: 13px;
  color: var(--ch-accent-primary-text, #b45309);
  text-decoration: none;
  border-radius: var(--ch-radius-sm);
  cursor: pointer;
  transition: background-color var(--ch-transition-fast);
}

:where(.ch-detail-container) .ch-attachment-link:hover {
  background: var(--ch-accent-secondary);
  text-decoration: underline;
}

:where(.ch-detail-container) .ch-attachment-link--loading {
  opacity: 0.7;
  cursor: default;
}

:where(.ch-detail-container) .ch-attachment-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--ch-accent-primary-text, #b45309);
  border-top-color: transparent;
  border-radius: 50%;
  animation: rs-td-attachment-spin 0.6s linear infinite;
  vertical-align: middle;
}

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

:where(.ch-detail-container) .ch-attachment-size {
  font-size: 11px;
  color: var(--ch-text-muted);
}

:where(.ch-detail-container) .ch-redacted-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  background: var(--ch-bg-secondary);
  color: var(--ch-text-muted);
  border-radius: 12px;
  font-size: 0.8em;
  font-style: italic;
}

/* Load older button */
:where(.ch-detail-container) .ch-load-older {
  display: flex;
  justify-content: center;
  padding: 12px;
}

:where(.ch-detail-container) .ch-load-older-btn {
  padding: 6px 16px;
  font-size: 13px;
  font-family: var(--ch-font-primary);
  color: var(--ch-accent-primary-text, #b45309);
  background: transparent;
  border: 1px solid var(--ch-accent-primary);
  border-radius: var(--ch-radius-md);
  cursor: pointer;
  transition: background-color var(--ch-transition-fast);
}

:where(.ch-detail-container) .ch-load-older-btn:hover {
  background: var(--ch-accent-secondary);
}

/* Viewer banner */
:where(.ch-detail-container) .ch-viewer-banner {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--ch-text-muted);
  background: var(--ch-bg-secondary);
  border-top: 1px solid var(--ch-border);
  text-align: center;
  flex-shrink: 0;
}

/* Closed ticket banner */
:where(.ch-detail-container) .ch-closed-banner {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--ch-warning);
  background: var(--ch-warning-bg);
  border-top: 1px solid var(--ch-warning-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

/* Stale (rate-limited) fallback banner — dismissible */
:where(.ch-detail-container) .ch-stale-banner {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--ch-warning);
  background: var(--ch-warning-bg);
  border-bottom: 1px solid var(--ch-warning-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

:where(.ch-detail-container) .ch-stale-dismiss {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--ch-warning);
  padding: 0 4px;
  flex-shrink: 0;
}

:where(.ch-detail-container) .ch-followup-btn {
  padding: 6px 16px;
  font-size: 13px;
  font-family: var(--ch-font-primary);
  font-weight: 500;
  color: #fff;
  background: var(--ch-accent-primary);
  border: none;
  border-radius: var(--ch-radius-md);
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--ch-transition-fast);
}

:where(.ch-detail-container) .ch-followup-btn:hover { opacity: 0.9; }

/* Unassigned-claim banner */
:where(.ch-detail-container) .ch-claim-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  justify-content: center;
}
:where(.ch-detail-container) .ch-claim-label {
  font-size: 13px;
  color: var(--ch-text-muted);
}
:where(.ch-detail-container) .ch-claim-home-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ch-text-primary);
}
:where(.ch-detail-container) .ch-claim-select {
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  min-width: 160px;
}
:where(.ch-detail-container) .ch-claim-select:hover { border-color: #a16207; }
:where(.ch-detail-container) .ch-claim-btn {
  padding: 6px 16px;
  font-size: 13px;
  font-family: var(--ch-font-primary);
  font-weight: 500;
  color: #fff;
  background: var(--ch-accent-primary);
  border: none;
  border-radius: var(--ch-radius-md);
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--ch-transition-fast);
}
:where(.ch-detail-container) .ch-claim-btn:hover { opacity: 0.9; }
:where(.ch-detail-container) .ch-claim-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Reply form slot */
:where(.ch-detail-container) .ch-reply-slot {
  border-top: 1px solid var(--ch-border);
  flex-shrink: 0;
}

/* Template display:none styles, as classes (the module writes style.display inline to show them). */
:where(.ch-detail-container) .ch-stale-banner.td-hidden,
:where(.ch-detail-container) .ch-load-older.td-hidden,
:where(.ch-detail-container) .ch-viewer-banner.td-hidden,
:where(.ch-detail-container) .ch-closed-banner.td-hidden,
:where(.ch-detail-container) .ch-reply-slot.td-hidden { display: none; }
