/* Customer support tickets — list, table, chat */

.shop-account-tickets-page {
  max-width: 1100px;
}

.cust-tickets {
  display: grid;
  gap: 20px;
}

.cust-tickets-loading,
.cust-tickets-error,
.cust-tickets-empty {
  text-align: center;
  padding: 40px 20px;
  border-radius: 16px;
  border: 1px dashed var(--border);
  background: var(--w);
  color: var(--g5);
}

.cust-tickets-empty-icon {
  font-size: 2rem;
  color: var(--a1, #c67b4e);
  margin-bottom: 12px;
}

.cust-tickets-error-actions {
  margin-top: 16px;
}

/* Summary */
.cust-tickets-summary {
  display: grid;
  gap: 12px;
}

.cust-tickets-summary-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 640px) {
  .cust-tickets-summary-cards {
    grid-template-columns: repeat(2, minmax(140px, 220px));
  }
}

.cust-tickets-summary-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  background: linear-gradient(180deg, #fff 0%, rgba(248, 248, 248, 0.8) 100%);
}

.cust-tickets-summary-card--accent {
  border-color: rgba(198, 123, 78, 0.35);
  background: linear-gradient(135deg, rgba(198, 123, 78, 0.08) 0%, #fff 100%);
}

.cust-tickets-summary-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--dark);
  line-height: 1.2;
}

.cust-tickets-summary-label {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--g5);
}

.cust-tickets-unread-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: #1d4ed8;
  font-size: 14px;
  font-weight: 700;
}

.cust-tickets-unread-alert i {
  font-size: 1.1rem;
}

/* Toolbar */
.cust-tickets-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cust-tickets-section-title {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 800;
  color: var(--dark);
}

.cust-tickets-table-section {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  background: var(--w);
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.04);
}

.cust-tickets-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.cust-tickets-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.cust-tickets-table th,
.cust-tickets-table td {
  padding: 12px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.cust-tickets-table th {
  font-size: 12px;
  font-weight: 800;
  color: var(--g5);
  background: rgba(248, 248, 248, 0.9);
  white-space: nowrap;
}

.cust-tickets-table tbody tr:hover {
  background: rgba(198, 123, 78, 0.04);
}

.cust-tickets-table tbody tr.has-unread {
  background: rgba(59, 130, 246, 0.04);
}

.cust-tickets-link {
  font-weight: 800;
  color: var(--a1, #c67b4e);
  text-decoration: none;
}

.cust-tickets-link:hover {
  text-decoration: underline;
}

.cust-tickets-row-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  margin-right: 6px;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.cust-tickets-view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--w);
  color: var(--g6);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cust-tickets-view-btn:hover {
  border-color: var(--a1, #c67b4e);
  background: rgba(198, 123, 78, 0.1);
  color: var(--a1, #c67b4e);
}

.cust-ticket-status {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.cust-ticket-status--open { background: rgba(59, 130, 246, 0.12); color: #2563eb; }
.cust-ticket-status--pending { background: rgba(245, 158, 11, 0.14); color: #b45309; }
.cust-ticket-status--reviewing { background: rgba(99, 102, 241, 0.14); color: #4338ca; }
.cust-ticket-status--answered { background: rgba(16, 185, 129, 0.14); color: #047857; }
.cust-ticket-status--closed { background: rgba(107, 114, 128, 0.14); color: #4b5563; }

/* Buttons */
.cust-ticket-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--w);
  color: var(--g6);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.cust-ticket-btn--primary {
  border-color: var(--a1, #c67b4e);
  background: var(--a1, #c67b4e);
  color: #fff;
}

.cust-ticket-btn--primary:hover {
  filter: brightness(1.05);
}

.cust-ticket-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Composer (reply + create) */
.cust-ticket-composer {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  background: var(--w);
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.05);
}

.cust-ticket-composer--closed {
  background: linear-gradient(180deg, rgba(248, 248, 248, 0.9) 0%, #fff 100%);
}

.cust-ticket-composer-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cust-ticket-composer-title {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 800;
  color: var(--dark);
}

.cust-ticket-composer--closed .cust-ticket-composer-title {
  margin-bottom: 0;
}

.cust-ticket-composer-note {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--g5);
}

.cust-ticket-composer-form textarea {
  width: 100%;
  min-height: 110px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font: inherit;
  resize: vertical;
  background: #fff;
  color: var(--dark);
}

.cust-ticket-composer-form textarea:focus {
  outline: none;
  border-color: rgba(198, 123, 78, 0.55);
  box-shadow: 0 0 0 3px rgba(198, 123, 78, 0.12);
}

.cust-ticket-composer-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.cust-ticket-file-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: rgba(248, 248, 248, 0.8);
  font-size: 12px;
  font-weight: 700;
  color: var(--g6);
  cursor: pointer;
}

.cust-ticket-file-btn input {
  display: none;
}

.cust-ticket-hint {
  font-size: 11px;
  color: var(--g5);
  flex: 1 1 auto;
}

.cust-ticket-field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--g6);
}

.cust-ticket-field input,
.cust-ticket-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: #fff;
}

.cust-ticket-form-error {
  margin-top: 10px;
  color: #b91c1c;
  font-size: 13px;
  font-weight: 700;
}

/* Modal */
.cust-tickets-modal[hidden] {
  display: none !important;
}

.cust-tickets-modal {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.cust-tickets-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.cust-tickets-modal-dialog {
  position: relative;
  width: min(100%, 560px);
  max-height: 90vh;
  overflow-y: auto;
}

.cust-tickets-modal-close {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--g6);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.cust-ticket-composer--modal {
  margin: 0;
}

/* Detail + chat */
.cust-tickets-detail-top {
  display: grid;
  gap: 12px;
}

.cust-ticket-back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--g6);
  text-decoration: none;
}

.cust-ticket-back-link:hover {
  color: var(--a1, #c67b4e);
}

.cust-tickets-detail-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.cust-tickets-detail-title-row h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--dark);
}

.cust-tickets-detail-sub {
  font-size: 13px;
  color: var(--g5);
}

.cust-ticket-chat-section {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.9) 0%, #fff 100%);
}

.cust-ticket-chat {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: min(60vh, 520px);
  overflow-y: auto;
  padding: 4px 2px;
}

.cust-ticket-chat-empty {
  text-align: center;
  padding: 24px;
  color: var(--g5);
  font-size: 14px;
}

.cust-ticket-bubble {
  max-width: min(85%, 420px);
  padding: 12px 14px;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
}

.cust-ticket-bubble.is-customer {
  align-self: flex-start;
  margin-left: 8%;
  background: linear-gradient(135deg, rgba(198, 123, 78, 0.14) 0%, rgba(198, 123, 78, 0.06) 100%);
  border: 1px solid rgba(198, 123, 78, 0.28);
  border-bottom-right-radius: 4px;
}

.cust-ticket-bubble.is-staff {
  align-self: flex-end;
  margin-right: 8%;
  background: #fff;
  border: 1px solid rgba(59, 130, 246, 0.22);
  border-bottom-left-radius: 4px;
}

.cust-ticket-bubble-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--g5);
}

.cust-ticket-bubble-head strong {
  font-size: 12px;
  color: var(--dark);
}

.cust-ticket-bubble-body {
  font-size: 14px;
  line-height: 1.85;
  color: var(--dark);
  white-space: pre-wrap;
  word-break: break-word;
}

.cust-ticket-bubble-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.cust-ticket-bubble-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  color: var(--g6);
  text-decoration: none;
}

/* Auth panel unread badge */
.menu-link--with-badge {
  position: relative;
}

.shop-support-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  margin-right: auto;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.shop-support-unread-badge[hidden] {
  display: none !important;
}

/* Responsive table */
@media (max-width: 768px) {
  .cust-tickets-table thead {
    display: none;
  }

  .cust-tickets-table tbody tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 12px;
    background: #fff;
  }

  .cust-tickets-table tbody td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-bottom: none;
    padding: 8px 0;
  }

  .cust-tickets-table tbody td::before {
    content: attr(data-label);
    font-weight: 800;
    color: var(--g5);
    flex-shrink: 0;
  }

  .cust-tickets-table tbody td.cust-tickets-actions::before {
    content: none;
  }

  .cust-ticket-bubble.is-customer,
  .cust-ticket-bubble.is-staff {
    max-width: 92%;
    margin-left: 0;
    margin-right: 0;
  }
}
