/* ─── Chat de Suporte (cliente) ─────────────────────────────────────────── */

.nav-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 0.7rem;
  font-weight: 800;
  border-radius: 999px;
  background: #d76a5a;
  color: #fff;
  vertical-align: middle;
}

.support-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  min-height: 520px;
}

.support-list-pane {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
  min-width: 0;
}

.support-list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.support-list-head strong { color: var(--ink); font-size: 0.92rem; }
.support-list-head .compact { width: auto; min-height: 32px; padding: 5px 10px; font-size: 0.8rem; }

.support-tickets {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  gap: 6px;
  align-content: start;
}

.support-empty {
  padding: 22px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.support-ticket-item {
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  gap: 4px;
  cursor: pointer;
  min-height: auto;
  box-shadow: none;
  color: var(--ink);
  font-weight: 500;
}

.support-ticket-item:hover {
  border-color: rgba(74, 154, 212, 0.4);
  transform: none;
  box-shadow: none;
}

.support-ticket-item.active {
  border-color: var(--accent-text);
  background: rgba(30, 82, 135, 0.18);
  box-shadow: inset 2px 0 0 var(--accent-text);
}

.support-ticket-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.support-ticket-head strong {
  font-size: 0.88rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.support-ticket-unread {
  flex-shrink: 0;
  background: #d76a5a;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
}

.support-ticket-item small {
  color: var(--muted);
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.support-ticket-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--muted);
}

.support-tag {
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(100, 120, 140, 0.18);
  color: #b0c0d0;
}

.support-tag--open { background: rgba(74, 154, 212, 0.18); color: #80c0e8; }
.support-tag--in_progress { background: rgba(200, 164, 93, 0.18); color: #ddc287; }
.support-tag--resolved { background: rgba(94, 192, 122, 0.18); color: #9adfb0; }

/* Chat pane — vive dentro do modal, herda borda/raio do container */
.support-chat-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.support-empty-state {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 480px;
  min-width: 0;
  overflow: hidden;
}

/* ─── Chat modal popup ─────────────────────────────────────────────────── */
.support-chat-backdrop {
  align-items: center;
  justify-content: center;
}

.support-chat-modal {
  display: flex;
  flex-direction: column;
  width: min(700px, calc(100vw - 32px));
  height: min(82vh, 720px);
  background: linear-gradient(180deg, #1d2226 0%, #161a1d 100%);
  border: 1px solid rgba(30, 82, 135, 0.32);
  border-radius: 16px;
  box-shadow:
    0 0 0 1px rgba(74, 154, 212, 0.08),
    0 40px 100px rgba(0, 0, 0, 0.78),
    0 0 60px rgba(30, 82, 135, 0.12);
  overflow: hidden;
  animation: supportModalIn 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes supportModalIn {
  from { opacity: 0; transform: scale(0.94) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.support-empty-state {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  color: var(--muted);
}

.support-empty-state i {
  font-size: 3rem;
  color: var(--accent-text);
  opacity: 0.6;
  margin-bottom: 14px;
}

.support-empty-state h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 1.05rem;
}

.support-empty-state p {
  margin: 0;
  max-width: 360px;
  font-size: 0.86rem;
  line-height: 1.5;
}

.support-chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 14, 22, 0.72);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.support-close-btn {
  width: 34px !important;
  height: 34px;
  min-height: 34px;
  padding: 0;
  flex-shrink: 0;
  border-radius: 8px;
  background: rgba(30, 82, 135, 0.14);
  border: 1px solid var(--line);
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: background 140ms, color 140ms;
}

.support-close-btn:hover {
  background: rgba(215, 106, 90, 0.18);
  border-color: rgba(215, 106, 90, 0.4);
  color: #f0a094;
}

.support-chat-info { min-width: 0; flex: 1; }

.support-chat-info strong {
  display: block;
  color: var(--ink);
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.support-chat-info small { color: var(--muted); font-size: 0.78rem; }

.support-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  gap: 10px;
  align-content: start;
  background:
    radial-gradient(circle at 20% 10%, rgba(30, 82, 135, 0.06), transparent 50%),
    radial-gradient(circle at 80% 90%, rgba(19, 87, 94, 0.06), transparent 50%),
    var(--surface);
  -webkit-overflow-scrolling: touch;
}

.support-msg { display: flex; }
.support-msg--me { justify-content: flex-end; }
.support-msg--them { justify-content: flex-start; }

.support-msg-bubble {
  max-width: 78%;
  padding: 9px 12px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid;
  gap: 6px;
  min-width: 0;
}

.support-msg--me .support-msg-bubble {
  background: linear-gradient(135deg, rgba(30, 82, 135, 0.36), rgba(19, 87, 94, 0.30));
  border-color: rgba(74, 154, 212, 0.35);
  border-bottom-right-radius: 4px;
}

.support-msg--them .support-msg-bubble { border-bottom-left-radius: 4px; }

.support-msg-bubble p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.support-msg-bubble small { color: var(--muted); font-size: 0.7rem; align-self: end; }
.support-msg--me .support-msg-bubble small { text-align: right; }

.support-media img { max-width: 100%; max-height: 280px; border-radius: 8px; display: block; }
.support-audio { width: 100%; min-width: 200px; height: 36px; }

.support-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(7, 11, 18, 0.4);
  border: 1px solid var(--line);
  color: var(--accent-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.86rem;
}

.support-file:hover { border-color: rgba(74, 154, 212, 0.5); }
.support-msg-empty { color: var(--muted); font-style: italic; }

.support-chat-compose {
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  background: var(--surface-2);
  display: grid;
  gap: 8px;
  flex-shrink: 0; /* garante que o compose não encolhe quando o attach-preview aparece */
}

.support-chat-row {
  display: flex;
  align-items: end;
  gap: 6px;
  min-width: 0;
}

.support-chat-row textarea {
  flex: 1 1 0%;   /* flex-basis 0 garante que a textarea não tenta ser 100% da linha */
  width: auto;    /* cancela qualquer width: 100% herdado */
  min-width: 0;
  min-height: 40px;
  max-height: 120px;
  resize: none;
  border-radius: 18px;
  padding: 10px 14px;
  background: var(--surface);
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.4;
  border: 1px solid var(--line);
}

.support-chat-row .icon-button,
.support-chat-row .primary-action {
  width: 40px !important;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.support-chat-row .icon-button.recording {
  background: #d76a5a;
  color: #fff;
  border-color: #d76a5a;
  animation: supportRecordPulse 1.2s ease-in-out infinite;
}

@keyframes supportRecordPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(215, 106, 90, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(215, 106, 90, 0); }
}

.support-record-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(215, 106, 90, 0.12);
  border: 1px solid rgba(215, 106, 90, 0.32);
  border-radius: 8px;
  color: #f0a094;
  font-size: 0.85rem;
}

.recording-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d76a5a;
  animation: supportRecordPulse 1.2s ease-in-out infinite;
}

.support-record-status .compact { width: auto; min-height: 28px; padding: 4px 10px; font-size: 0.78rem; margin-left: auto; }

.support-attach-preview { display: block; }

.support-attach-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(7, 11, 18, 0.45);
  border: 1px dashed rgba(74, 154, 212, 0.4);
}

.support-attach-card img {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.support-attach-card i { font-size: 1.6rem; color: var(--accent-text); flex-shrink: 0; }
.support-attach-card div { flex: 1; min-width: 0; }
.support-attach-card strong {
  display: block;
  color: var(--ink);
  font-size: 0.86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.support-attach-card small { color: var(--muted); font-size: 0.74rem; }

.support-attach-card .icon-button {
  width: 30px !important;
  height: 30px;
  min-height: 30px;
  padding: 0;
}

/* Modal genérico para abrir ticket */
.modal-card {
  position: relative;
  width: min(520px, 100%);
  background: linear-gradient(180deg, #1d2226 0%, #161a1d 100%);
  border: 1px solid rgba(30, 82, 135, 0.32);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
  color: var(--ink);
}

.modal-head h2 { margin: 0 0 6px; font-size: 1.2rem; color: #e1ecf6; }
.modal-head p { margin: 0 0 16px; color: var(--muted); font-size: 0.9rem; }

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 8px;
  background: rgba(30, 82, 135, 0.14);
  border: 1px solid var(--line);
  color: var(--ink);
  display: grid;
  place-items: center;
  box-shadow: none;
}

.modal-form { display: grid; gap: 12px; }
.modal-form label { display: grid; gap: 6px; font-size: 0.86rem; color: var(--muted); }
.modal-form input, .modal-form select, .modal-form textarea { color: var(--ink); }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 6px;
}
.modal-actions button { width: auto; flex: 0 0 auto; }

@media (max-width: 760px) {
  .support-layout { grid-template-columns: 1fr; }
  .support-list-pane { min-height: 280px; }
  .support-empty-state { min-height: 320px; }
  .support-chat-modal {
    width: calc(100vw - 24px);
    height: calc(100dvh - 48px);
    border-radius: 12px;
  }
}

/* ─── Admin: QR Code do suporte ─────────────────────────────────────────── */

.support-qr-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  margin-bottom: 16px;
}

.support-qr-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.support-qr-panel-head h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--ink);
}

.support-qr-panel-head small { color: var(--muted); font-size: 0.78rem; }

.support-qr-body {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.support-qr-image {
  width: 180px;
  height: 180px;
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  place-items: center;
}

.support-qr-image img,
.support-qr-image canvas { width: 100%; height: 100%; }

.support-qr-info { display: grid; gap: 6px; min-width: 0; }
.support-qr-info strong { color: var(--ink); }
.support-qr-info small { color: var(--muted); font-size: 0.82rem; line-height: 1.5; }

.support-qr-info code {
  display: block;
  word-break: break-all;
  background: rgba(7, 11, 18, 0.45);
  padding: 6px 10px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.78rem;
  color: var(--accent-text);
}

@media (max-width: 640px) {
  .support-qr-body { grid-template-columns: 1fr; justify-items: center; text-align: center; }
}

/* ─── Botão flutuante de WhatsApp ───────────────────────────────────────── */

.whatsapp-fab {
  position: fixed;
  right: max(env(safe-area-inset-right, 0px), 18px);
  bottom: max(env(safe-area-inset-bottom, 0px), 18px);
  z-index: 9000;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 14px 16px;
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
  color: #fff;
  text-decoration: none;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  box-shadow:
    0 12px 28px rgba(18, 140, 126, 0.42),
    0 0 0 3px rgba(37, 211, 102, 0.18);
  transition: transform 200ms cubic-bezier(0.2, 1, 0.3, 1),
              box-shadow 200ms ease,
              padding 200ms ease;
  animation: whatsappPulse 2.6s ease-in-out infinite;
}

.whatsapp-fab i {
  font-size: 1.45rem;
  line-height: 1;
  display: inline-grid;
  place-items: center;
}

.whatsapp-fab:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow:
    0 18px 36px rgba(18, 140, 126, 0.55),
    0 0 0 4px rgba(37, 211, 102, 0.25);
  animation: none;
}

.whatsapp-fab:active {
  transform: translateY(0) scale(0.98);
}

@keyframes whatsappPulse {
  0%, 100% { box-shadow: 0 12px 28px rgba(18, 140, 126, 0.42), 0 0 0 0 rgba(37, 211, 102, 0.55); }
  50% { box-shadow: 0 12px 28px rgba(18, 140, 126, 0.42), 0 0 0 14px rgba(37, 211, 102, 0); }
}

@media (max-width: 640px) {
  .whatsapp-fab {
    padding: 14px;
    font-size: 0;
    width: 56px;
    height: 56px;
    justify-content: center;
  }
  .whatsapp-fab i { font-size: 1.6rem; }
  .whatsapp-fab span { display: none; }
}
