/* Cabeçalho do detalhe do ticket (espelha detail.html legado) */

.container-ticket-modern {
  width: 100%;
}

.ticket-header-modern {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  margin-bottom: 0;
  position: relative;
  overflow: hidden;
}

.ticket-header-modern::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(135deg, #ab3939 0%, #b57777 100%);
  background-size: 200% 100%;
  animation: ticket-shimmer 3s ease-in-out infinite;
}

@keyframes ticket-shimmer {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.ticket-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e2e8f0;
  position: relative;
}

.ticket-header-top::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 60px;
  height: 2px;
  background: linear-gradient(135deg, #ab3939 0%, #b57777 100%);
  border-radius: 2px;
}

.ticket-id-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ticket-id-title {
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
  letter-spacing: -0.3px;
}

.copy-btn-modern {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.2s;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.copy-btn-modern:hover {
  background: #e2e8f0;
  color: #334155;
  transform: translateY(-1px);
}

.ticket-status-badge-modern {
  display: flex;
  align-items: center;
}

.status-badge {
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.status-open {
  background: #fee2e2;
  color: #991b1b;
}

.status-badge.status-ongoing {
  background: #fef3c7;
  color: #92400e;
}

.status-badge.status-pending {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-badge.status-closed {
  background: #e5e7eb;
  color: #374151;
}

.status-badge.status-aguardando-fatura {
  background: #d1fae5;
  color: #065f46;
}

.ticket-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 4px;
}

.info-card-modern {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.info-card-modern:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

.info-card-header {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-card-header i {
  color: #667eea;
  font-size: 14px;
}

.info-card-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}

.info-card-body {
  padding: 16px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
}

.info-value {
  font-size: 13px;
  color: #1e293b;
  font-weight: 500;
  text-align: right;
}

.status-form-modern {
  margin: 0 0 12px;
}

.form-group-modern {
  margin: 0;
}

.form-label-modern {
  display: block;
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
  margin-bottom: 8px;
}

.status-control-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.form-control-modern {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  transition: all 0.2s;
  background: #fff;
}

.form-control-modern:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-modern {
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  color: white;
}

.btn-modern:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-sm-modern {
  padding: 6px 10px;
  font-size: 11px;
}

.btn-primary-modern {
  background: #667eea;
}

.btn-primary-modern:hover:not(:disabled) {
  background: #5568d3;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.btn-success-modern {
  background: #10b981;
  width: 100%;
}

.btn-success-modern:hover:not(:disabled) {
  background: #059669;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

.agent-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agent-assign-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.agent-assign-row select {
  flex: 1;
  min-width: 0;
}

.agent-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.agent-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
}

.agent-name-wrapper {
  margin-top: 4px;
}

.agent-name {
  display: inline-block;
  font-size: 13px;
  color: #667eea;
  font-weight: 700;
  padding: 6px 10px;
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.1) 0%,
    rgba(118, 75, 162, 0.1) 100%
  );
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(102, 126, 234, 0.1);
  transition: all 0.2s;
  word-break: break-all;
}

.agent-name.agent-unassigned {
  color: #94a3b8;
  background: linear-gradient(
    135deg,
    rgba(148, 163, 184, 0.1) 0%,
    rgba(148, 163, 184, 0.05) 100%
  );
  border-color: rgba(148, 163, 184, 0.2);
  font-weight: 500;
  font-style: italic;
}

.tags-container {
  margin-top: 0;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 15px;
  min-height: 30px;
}

.tag-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: default;
  transition: all 0.2s;
}

.tag-remove {
  background: none;
  border: none;
  color: inherit;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  margin-left: 6px;
  padding: 0;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
  line-height: 1;
}

.tag-remove:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

.no-tags {
  color: #999;
  font-style: italic;
  font-size: 13px;
}

.tags-actions {
  margin-top: 10px;
}

.tags-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tag-select {
  flex: 1;
  max-width: 100%;
}

.section-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #e2e8f0 20%, #e2e8f0 80%, transparent);
  margin: 32px 0;
  border: none;
}

.ticket-detail-action-error {
  margin-top: 12px;
  margin-bottom: 0;
  font-size: 13px;
}

/* Chat header (override style.css legado — igual chat.html) */
.chat-header {
  background: linear-gradient(135deg, #dc3545, #c82333, #a71e2a) !important;
  color: white;
  padding: 1.5rem 2rem !important;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  box-shadow: 0 4px 20px rgba(220, 53, 69, 0.3);
  position: relative;
  overflow: hidden;
}

.chat-header::after {
  content: '';
  position: absolute;
  right: 2rem;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  background: #28a745;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.3);
  animation: ticket-chat-pulse 2s infinite;
}

@keyframes ticket-chat-pulse {
  0% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(40, 167, 69, 0); }
  100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); }
}

.img-chat {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.3);
  object-fit: cover;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.chat-subtitle {
  font-size: 1.2rem !important;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.98);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 1;
}

/* Mantém a altura do chat igual ao legado (style.css: calc(150vh - 40px)) */
.main-container {
  height: calc(150vh - 40px);
  min-height: 800px;
}

.order-section .status-badge.status-processing {
  background: #3b82f6;
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.nav-pills .nav-link {
  border: none;
  background: transparent;
  cursor: pointer;
}

.wa-status {
  margin-left: 4px;
}

/* Sidebar histórico de mensagens (tickets relacionados) */
.sidebar {
  width: min(480px, 92vw);
  z-index: 1050;
}

.sidebar-overlay {
  z-index: 1040;
}

.sidebar-header-preview {
  background: linear-gradient(135deg, #ab3939 0%, #8b2e2e 100%);
  color: #fff;
  padding: 20px 24px;
  position: relative;
  flex-shrink: 0;
}

.sidebar-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.4);
  background: transparent;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.no-messages {
  text-align: center;
  padding: 48px 24px;
  color: #64748b;
}

.no-messages-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

/* Barra de tabs em largura total */
.ticket-detail-tabs {
  width: 100%;
}

.ticket-detail-tabs .nav-pills {
  width: 100%;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.ticket-detail-tabs-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
}

/* Mensagens com erro de envio (paridade com o chat legado) */
.message.message-error .message-bubble {
  background: linear-gradient(135deg, #fee2e2, #fecaca) !important;
  border: 2px solid #f87171 !important;
  position: relative;
}

.message.message-error .message-bubble label {
  color: #7f1d1d !important;
}

.message.message-error .message-info .info-content {
  color: #991b1b !important;
}

.wa-pending { color: #9ca3af; }
.wa-queued { color: #9ca3af; }
.wa-send { color: #22c55e; }
.wa-error { color: #ef4444; }

.message .message-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.message.user .message-info {
  justify-content: space-between;
}

.message .message-info .info-actions {
  display: inline-flex;
  gap: 6px;
}

.btn-retry-message,
.btn-edit-message,
.btn-view-error {
  border: none;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.btn-retry-message {
  background-color: #3b82f6;
  color: white;
}

.btn-edit-message,
.btn-view-error {
  background-color: #f59e0b;
  color: white;
}

.error-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  justify-content: center;
  align-items: center;
}

.error-modal-overlay.active {
  display: flex;
}

.error-modal {
  background: white;
  border-radius: 16px;
  max-width: 500px;
  width: 90%;
  overflow: hidden;
}

.error-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: white;
}

.error-modal-header h3 {
  margin: 0;
  font-size: 16px;
  flex: 1;
}

.error-modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: white;
  font-size: 20px;
  cursor: pointer;
}

.error-modal-body {
  padding: 20px;
}

.error-message-label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 8px;
}

.error-message-content {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 16px;
  font-size: 13px;
  color: #991b1b;
  white-space: pre-wrap;
  word-break: break-word;
}

.error-modal-footer {
  padding: 16px 20px;
  background: #f9fafb;
  display: flex;
  justify-content: flex-end;
}

.error-modal-btn {
  background: #6366f1;
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.upload-modal {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.upload-modal.active {
  display: flex;
}

.upload-modal .modal-content {
  transform: none;
  margin: 0;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}


