/* ==========================================================================
   Tickets - List, Detail, Badges
   ========================================================================== */

/* ---------- Ticket Table ---------- */
.ticket-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.ticket-table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--sp-sm) var(--sp-md);
  text-align: left;
  border-bottom: 1px solid var(--glass-border-secondary);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.ticket-table th:hover {
  color: var(--base-text);
}

.ticket-table th.sorted {
  color: var(--primary);
}

.ticket-table td {
  padding: var(--sp-sm) var(--sp-md);
  font-size: 13px;
  border-bottom: 1px solid var(--glass-border-secondary);
  vertical-align: middle;
}

.ticket-table tr {
  transition: background 0.15s;
}

.ticket-table tbody tr:hover {
  background: var(--glass-bg-secondary);
}

.ticket-table tbody tr {
  cursor: pointer;
}

.ticket-row__number {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

.ticket-row__subject {
  font-weight: 500;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-row__meta {
  font-size: 11px;
  color: var(--muted-text);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-xs);
  padding: 2px var(--sp-sm);
  border-radius: var(--radius-lg);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* Status badges -- light-mode colors meet WCAG AA 4.5:1 on tinted backgrounds */
.badge--open {
  background: rgba(14, 165, 233, 0.15);
  color: #0369A1;
}
html.dark .badge--open { color: #38BDF8; }

.badge--in_progress {
  background: rgba(245, 158, 11, 0.15);
  color: #92400E;
}
html.dark .badge--in_progress { color: #FBBF24; }

.badge--pending {
  background: rgba(168, 85, 247, 0.15);
  color: #6D28D9;
}
html.dark .badge--pending { color: #A78BFA; }

.badge--resolved {
  background: rgba(16, 185, 129, 0.15);
  color: #047857;
}
html.dark .badge--resolved { color: #34D399; }

.badge--closed {
  background: rgba(100, 116, 139, 0.15);
  color: #334155;
}
html.dark .badge--closed { color: #94A3B8; }

/* Priority badges */
.badge--low {
  background: rgba(100, 116, 139, 0.15);
  color: #334155;
}
html.dark .badge--low { color: #94A3B8; }

.badge--medium {
  background: rgba(14, 165, 233, 0.15);
  color: #0369A1;
}
html.dark .badge--medium { color: #38BDF8; }

.badge--high {
  background: rgba(245, 158, 11, 0.15);
  color: #92400E;
}
html.dark .badge--high { color: #FBBF24; }

.badge--critical {
  background: rgba(239, 68, 68, 0.15);
  color: #B91C1C;
}
html.dark .badge--critical { color: #F87171; }

/* Category badges */
.badge--category {
  background: var(--glass-bg-secondary);
  color: var(--muted-text);
}

/* Source badges */
.badge--web { background: rgba(14, 165, 233, 0.1); color: var(--primary); }
.badge--agent { background: rgba(168, 85, 247, 0.1); color: #7C3AED; }
html.dark .badge--agent { color: #A78BFA; }
.badge--api { background: rgba(16, 185, 129, 0.1); color: #059669; }
html.dark .badge--api { color: #34D399; }

/* ---------- Ticket Detail ---------- */
.ticket-detail {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--sp-xl);
}

.ticket-detail__main {
  display: flex;
  flex-direction: column;
  gap: var(--sp-base);
}

.ticket-detail__sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--sp-base);
}

.ticket-detail__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-md);
  margin-bottom: var(--sp-md);
}

.ticket-detail__number {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted-text);
}

.ticket-detail__subject {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: var(--sp-xs);
}

.ticket-detail__description {
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Sidebar Info ---------- */
.info-group {
  margin-bottom: var(--sp-md);
}

.info-group__label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--sp-xs);
}

.info-group__value {
  font-size: 14px;
  font-weight: 500;
}

/* ---------- Notes Timeline ---------- */
.notes-section {
  margin-top: var(--sp-base);
}

.notes-section__title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: var(--sp-md);
}

.note-item {
  display: flex;
  gap: var(--sp-md);
  padding: var(--sp-md) 0;
  border-bottom: 1px solid var(--glass-border-secondary);
}

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

.note-item__avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--glass-bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-text);
}

.note-item--system .note-item__avatar {
  background: rgba(14, 165, 233, 0.15);
  color: var(--primary);
}

.note-item--internal .note-item__avatar {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.note-item__body {
  flex: 1;
  min-width: 0;
}

.note-item__header {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-xs);
}

.note-item__author {
  font-size: 13px;
  font-weight: 600;
}

.note-item__time {
  font-size: 11px;
  color: var(--muted-text);
}

.note-item__badge {
  font-size: 10px;
  padding: 1px var(--sp-sm);
  border-radius: var(--radius-md);
  font-weight: 600;
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.note-item__content {
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Add Note Form ---------- */
.add-note-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  margin-top: var(--sp-md);
}

.add-note-form__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  margin-top: var(--sp-xl);
}

.pagination__info {
  font-size: 13px;
  color: var(--muted-text);
  margin: 0 var(--sp-sm);
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: var(--sp-4xl) var(--sp-xl);
  color: var(--muted-text);
}

.empty-state__icon {
  font-size: 48px;
  margin-bottom: var(--sp-md);
  opacity: 0.5;
}

.empty-state__logo {
  width: 72px;
  height: 72px;
}

.empty-state__title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: var(--sp-sm);
}

.empty-state__text {
  font-size: 14px;
}

/* ---------- Attachments ---------- */
.attachment-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-sm) var(--sp-md);
  background: var(--glass-bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.attachment-item__name {
  font-weight: 500;
  word-break: break-all;
}

.attachment-item__size {
  color: var(--muted-text);
  font-size: 11px;
  white-space: nowrap;
  margin-left: var(--sp-sm);
}

/* ---------- Table Cell Modifiers ---------- */
.td--name {
  font-weight: 600;
}

.td--meta {
  font-size: 12px;
  color: var(--muted-text);
}

.td--you {
  font-size: 12px;
  color: var(--muted-text);
}

.td--role-select {
  width: 110px;
}

/* ---------- Device ID Value ---------- */
.info-group__value--mono {
  font-family: var(--font-mono);
}

/* ---------- Ticket Badge Row ---------- */
.ticket-detail__badges {
  display: flex;
  gap: var(--sp-sm);
  flex-shrink: 0;
}

/* ---------- Upload Section ---------- */
.upload-section {
  margin-top: var(--sp-md);
}

/* ---------- Empty / Muted Message ---------- */
.muted-message {
  font-size: 13px;
  color: var(--muted-text);
}

.muted-message--padded {
  font-size: 13px;
  color: var(--muted-text);
  padding: var(--sp-md) 0;
}

/* ---------- Ticket Number Inline ---------- */
.ticket-number-inline {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--primary);
  margin-right: var(--sp-sm);
}

/* ---------- Activity Link ---------- */
.activity-ticket-link {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--primary);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .ticket-detail {
    grid-template-columns: 1fr;
  }

  .ticket-table--tickets th:nth-child(n+5),
  .ticket-table--tickets td:nth-child(n+5) {
    display: none;
  }

  .ticket-row__subject {
    max-width: 180px;
  }
}

@media (max-width: 480px) {
  .ticket-detail__header {
    flex-direction: column;
    gap: var(--sp-sm);
  }

  .ticket-detail__badges {
    flex-wrap: wrap;
  }

  .ticket-row__subject {
    max-width: 120px;
  }
}
