/* ===== VARIÁVEIS GLOBAIS ===== */
:root {
  --bg:          #0f0f0f;
  --bg-2:        #1a1a1a;
  --pink:        #ff0050;   /* Rosa TikTok */
  --cyan:        #00f2ea;   /* Ciano TikTok */
  --gold:        #ffd700;
  --text:        #ffffff;
  --text-muted:  #a0a0a0;
  --glass-bg:    rgba(255, 255, 255, 0.05);
  --glass-border:rgba(255, 255, 255, 0.1);
  --danger:      #ff3b30;
  --success:     #34c759;
}

/* ===== BASE ===== */
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  min-height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

strong { font-weight: 700; }

/* ===== TELAS ===== */
.screen {
  display: none;
  position: fixed;
  inset: 0;
}
.screen.active {
  display: flex;
}

/* ===== TELA DE CONEXÃO ===== */
#screen-connect {
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 0, 80, 0.15), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(0, 242, 234, 0.15), transparent 40%),
    linear-gradient(135deg, #0f0f0f 0%, #1a0010 50%, #001a1a 100%);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.connect-box {
  max-width: 420px;
  width: 100%;
  padding: 40px 30px;
  text-align: center;
  border-radius: 20px;
}

.connect-box h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 10px;
  background: linear-gradient(90deg, var(--pink), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 0.95rem;
}

.input-wrapper {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  transition: border-color 0.2s, background 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--cyan);
  background: rgba(0, 242, 234, 0.08);
}

.input-prefix {
  color: var(--cyan);
  font-weight: 700;
  margin-right: 8px;
  font-size: 1.1rem;
}

.input-wrapper input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 1rem;
  flex: 1;
  min-width: 0;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(90deg, var(--pink), var(--cyan));
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(255, 0, 80, 0.35);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.status-text {
  margin-top: 18px;
  color: var(--text-muted);
  font-size: 0.9rem;
  min-height: 1.2em;
  transition: color 0.2s;
}

/* ===== GLASSMORPHISM ===== */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
}

/* ===== TELA DE CHAT ===== */
#screen-chat {
  flex-direction: column;
  background: var(--bg);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(15, 15, 15, 0.95);
  border-bottom: 1px solid var(--glass-border);
  position: relative;
  z-index: 2;
  flex-wrap: wrap;
}

.live-badge {
  background: var(--pink);
  color: white;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  animation: pulse 2s ease-in-out infinite;
  letter-spacing: 0.5px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255, 0, 80, 0.6); }
  50%      { opacity: 0.85; box-shadow: 0 0 0 8px rgba(255, 0, 80, 0); }
}

.chat-header h2 {
  font-size: 1rem;
  flex: 1;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-counter {
  color: var(--cyan);
  font-size: 0.9rem;
  font-weight: 500;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.15);
}

.chat-main {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

#chat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100%;
}

/* ===== MENSAGENS ===== */
.chat-item {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  border-left: 3px solid transparent;
  font-size: 0.95rem;
  line-height: 1.4;
  word-break: break-word;
}

.chat-item-chat {
  border-left-color: rgba(255, 255, 255, 0.3);
}

.chat-item-gift {
  border-left-color: var(--gold);
  background: rgba(255, 215, 0, 0.08);
  box-shadow: 0 0 0 1px rgba(255, 215, 0, 0.1);
}

.chat-item-like {
  border-left-color: var(--pink);
  background: rgba(255, 0, 80, 0.08);
}

.chat-item-follow {
  border-left-color: var(--cyan);
  background: rgba(0, 242, 234, 0.08);
}

.chat-item-system {
  border-left-color: transparent;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
}

.user {
  color: var(--cyan);
  font-weight: 600;
  margin-right: 4px;
}

.gift-icon, .like-icon, .follow-icon {
  margin-right: 5px;
}

.chat-item-gift strong {
  color: var(--gold);
}

/* ===== ANIMAÇÃO DE ENTRADA ===== */
.animate-in {
  animation: slideIn 0.4s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===== BOTÃO FLUTUANTE (FAB) ===== */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--cyan));
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.6), 0 0 0 2px rgba(255, 255, 255, 0.05);
  z-index: 50;
  transition: transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab:hover {
  transform: scale(1.08) rotate(-6deg);
}

.fab:active {
  transform: scale(0.95);
}

/* ===== PAINEL DE DIAGNÓSTICO ===== */
.panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 330px;
  max-height: 75vh;
  border-radius: 16px;
  padding: 16px;
  z-index: 45;
  display: none;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
}

.panel.active {
  display: flex;
  animation: panelIn 0.3s ease;
}

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

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 10px;
}

.panel-header h3 {
  font-size: 1rem;
  color: var(--cyan);
  font-weight: 700;
}

.panel-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.diag-item {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  min-width: 0;
}

.diag-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.diag-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}

/* ===== LOG ===== */
.panel-log {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-top: 1px solid var(--glass-border);
  padding-top: 10px;
}

.panel-log h4 {
  font-size: 0.75rem;
  color: var(--cyan);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.panel-log ul {
  overflow-y: auto;
  max-height: 180px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  padding-right: 4px;
}

.panel-log li {
  padding: 5px 8px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 5px;
  line-height: 1.3;
  word-break: break-word;
}

.log-time {
  color: var(--pink);
  margin-right: 6px;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 0.72rem;
}

/* ===== BOTÕES DO PAINEL ===== */
.panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.panel-actions button {
  padding: 9px 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  transition: background 0.2s, transform 0.1s;
}

.panel-actions button:hover {
  background: rgba(255, 255, 255, 0.16);
}

.panel-actions button:active {
  transform: scale(0.95);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ===== RESPONSIVO ===== */
@media (max-width: 600px) {
  .panel {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 84px;
    max-height: 65vh;
  }

  .fab {
    bottom: 18px;
    right: 18px;
    width: 52px;
    height: 52px;
    font-size: 1.3rem;
  }

  .connect-box {
    padding: 30px 20px;
  }

  .connect-box h1 {
    font-size: 1.7rem;
  }

  .chat-header {
    padding: 12px 14px;
    gap: 8px;
  }

  .chat-header h2 {
    font-size: 0.9rem;
  }

  .event-counter {
    font-size: 0.8rem;
  }

  .chat-item {
    font-size: 0.9rem;
    padding: 9px 12px;
  }
}

@media (max-width: 380px) {
  .panel-body {
    grid-template-columns: 1fr;
  }

  .panel-actions {
    grid-template-columns: 1fr;
  }
}