/* ========================================================
   CHAT DE ATENDIMENTO INTERNO BET BROTHERS (CLIENTE ↔ BANCA)
   Design System: Dark Glassmorphism, Mobile-First, Ergonomia
   ======================================================== */

/* Botão Flutuante de Suporte no App */
.floating-support-btn {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: 20px;
  z-index: 59;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #1d4ed8 100%);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45), 0 2px 8px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.84rem;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, bottom 0.25s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Botão Flutuante do Grupo VIP WhatsApp */
.floating-vip-btn {
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  right: 20px;
  z-index: 58;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.8rem;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 10px rgba(34, 197, 94, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, bottom 0.25s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.floating-vip-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 20px rgba(34, 197, 94, 0.5);
}

.floating-support-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.6), 0 4px 12px rgba(0, 0, 0, 0.6);
}

.floating-support-btn:active,
.floating-vip-btn:active {
  transform: translateY(0) scale(0.96);
}

.floating-support-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.floating-support-label {
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.support-label-mobile {
  display: none;
}

.support-label-desktop {
  display: inline;
}

.floating-support-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 900;
  min-width: 19px;
  height: 19px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  border: 2px solid #0f172a;
  animation: pulseBadge 1.8s infinite;
}

@keyframes pulseBadge {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Modal do Chat Overlay */
.support-chat-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(2, 6, 23, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10000;
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.support-chat-overlay.active {
  display: flex;
  opacity: 1;
}

/* Janela do Chat */
.support-chat-window {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 48px);
  background: #0b1329;
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 25px rgba(37, 99, 235, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUpChat 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10001;
}

@keyframes slideUpChat {
  from {
    transform: translateY(20px) scale(0.96);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Header do Chat */
.support-chat-header {
  background: linear-gradient(135deg, #0d1a38 0%, #172554 100%);
  border-bottom: 1px solid rgba(56, 189, 248, 0.2);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.support-chat-agent {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.support-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.support-chat-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.support-chat-title {
  font-size: 0.95rem;
  font-weight: 900;
  color: #ffffff;
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.support-chat-status {
  font-size: 0.72rem;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  font-weight: 700;
}

.support-chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  display: inline-block;
}

.support-chat-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.25rem;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.support-chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* Corpo das Mensagens */
.support-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: radial-gradient(circle at top right, rgba(37, 99, 235, 0.04), transparent 40%),
              radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.03), transparent 40%),
              #070d1e;
  scrollbar-width: thin;
  scrollbar-color: #1e293b transparent;
}

.support-chat-body::-webkit-scrollbar {
  width: 6px;
}
.support-chat-body::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 3px;
}

/* Balões de Mensagem */
.support-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  word-break: break-word;
  animation: popMessage 0.2s ease-out;
}

@keyframes popMessage {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mensagem da Banca (Admin) */
.support-msg-admin {
  align-self: flex-start;
}

.support-msg-admin .support-msg-bubble {
  background: #131d36;
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-top-left-radius: 4px;
  border-top-right-radius: 14px;
  border-bottom-right-radius: 14px;
  border-bottom-left-radius: 14px;
  color: #f8fafc;
}

.support-msg-admin-badge {
  font-size: 0.65rem;
  font-weight: 800;
  color: #fbbf24;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Mensagem do Cliente */
.support-msg-client {
  align-self: flex-end;
}

.support-msg-client .support-msg-bubble {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-top-left-radius: 14px;
  border-top-right-radius: 4px;
  border-bottom-right-radius: 14px;
  border-bottom-left-radius: 14px;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.support-msg-bubble {
  padding: 9px 12px;
  font-size: 0.85rem;
  line-height: 1.42;
}

.support-msg-text {
  white-space: pre-wrap;
}

.support-msg-time {
  font-size: 0.65rem;
  margin-top: 4px;
  text-align: right;
  opacity: 0.75;
}

/* Estado de Conversa Vazia */
.support-empty-notice {
  background: rgba(15, 23, 42, 0.85);
  border: 1px dashed rgba(56, 189, 248, 0.3);
  border-radius: 12px;
  padding: 18px 14px;
  text-align: center;
  color: #94a3b8;
  font-size: 0.8rem;
  line-height: 1.5;
  margin: auto 0;
}

.support-empty-notice strong {
  color: #38bdf8;
  display: block;
  font-size: 0.92rem;
  margin-bottom: 4px;
}

/* Banner de Login Necessário */
.support-login-gate {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 14px;
  padding: 20px 16px;
  text-align: center;
  margin: auto 8px;
}

.support-login-gate h4 {
  color: #fbbf24;
  margin: 0 0 6px 0;
  font-size: 1rem;
  font-weight: 900;
}

.support-login-gate p {
  color: #cbd5e1;
  font-size: 0.82rem;
  line-height: 1.45;
  margin: 0 0 14px 0;
}

.support-login-gate button {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  border: none;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
  font-family: inherit;
}

/* Rodapé / Input do Chat */
.support-chat-footer {
  background: #091124;
  border-top: 1px solid rgba(56, 189, 248, 0.15);
  padding: 10px 12px;
}

.support-chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.support-chat-input {
  flex: 1;
  background: #0f1a35;
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 20px;
  padding: 10px 14px;
  color: #ffffff;
  font-size: 0.86rem;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 90px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.support-chat-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.support-chat-input::placeholder {
  color: #64748b;
}

.support-chat-send-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: none;
  color: #ffffff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  transition: transform 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.support-chat-send-btn:hover:not(:disabled) {
  transform: scale(1.06);
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
}

.support-chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Responsividade Mobile (iPhone / Android) */
@media (max-width: 600px) {
  /* Botão Suporte: imediatamente acima da barra inferior (sem colisão) */
  .floating-support-btn {
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    right: 12px;
    padding: 7px 12px;
    font-size: 0.76rem;
    z-index: 59;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45), 0 0 10px rgba(37, 99, 235, 0.35);
  }

  /* Botão Grupo VIP: exatamente 8px acima do Suporte (alinhados na direita) */
  .floating-vip-btn {
    bottom: calc(112px + env(safe-area-inset-bottom, 0px));
    right: 12px;
    padding: 6px 11px;
    font-size: 0.74rem;
    z-index: 58;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4), 0 0 8px rgba(34, 197, 94, 0.3);
  }

  /* Quando o mini-slip de apostas estiver ativo: esconde VIP e sobe o Suporte */
  body.has-mini-slip .floating-vip-btn,
  body:has(#mini-slip-bar.active) .floating-vip-btn {
    display: none !important;
  }

  body.has-mini-slip .floating-support-btn,
  body:has(#mini-slip-bar.active) .floating-support-btn {
    bottom: calc(128px + env(safe-area-inset-bottom, 0px));
  }

  .support-label-desktop {
    display: none;
  }
  .support-label-mobile {
    display: inline;
  }

  .support-chat-window {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 92vh;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    border-left: none;
    border-right: none;
  }

  .support-chat-body {
    padding: 14px 12px;
  }

  .support-msg {
    max-width: 88%;
  }
}
