﻿/* =============================================
   CHAT PANEL
   ============================================= */

#chat-panel {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background: var(--bg-0);
  overflow: hidden;
}

#chat-messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.chat-message {
  padding: 4px 6px;
  border-radius: 4px;
  font-size: var(--chat-font-size);
  line-height: 1.45;
  word-break: break-word;
  transition: background 0.1s;
}

.chat-message:hover { background: var(--bg-2); }

.chat-badges {
  margin-right: 2px;
  font-size: 12px;
}

.badge-icon {
  display: inline-block;
  margin-right: 2px;
  font-size: 11px;
}

.chat-username {
  font-weight: 800;
  cursor: pointer;
  transition: opacity 0.15s;
}
.chat-username:hover { opacity: 0.8; }

.chat-colon {
  color: var(--text-3);
  margin-right: 2px;
}

.chat-text { color: var(--text-1); font-weight: 500; }

.chat-emote {
  height: 28px;
  width: auto;
  max-width: 112px;
  vertical-align: middle;
  display: inline-block;
  margin: 0 2px;
  image-rendering: auto;
}

.twitch-emote { height: 28px; }

/* =============================================
   CHANNEL POINTS REWARDS PANEL
   ============================================= */

#rewards-panel {
  display: none;
  flex-direction: column;
  max-height: 260px;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  animation: slide-up 0.2s ease;
}

#rewards-panel.open { display: flex; }

@keyframes slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.rewards-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.rewards-panel-header .panel-title { flex: 1; }

#rewards-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.rewards-placeholder {
  width: 100%;
  color: var(--text-3);
  font-size: 13px;
  padding: 12px 4px;
  text-align: center;
}

.rewards-error { color: #ff6b6b; }

.reward-card {
  background: var(--bg-2);
  border-radius: var(--radius-md);
  overflow: hidden;
  width: 150px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}

.reward-card:hover { border-color: var(--purple); }

.reward-color-strip {
  height: 4px;
  width: 100%;
  flex-shrink: 0;
}

.reward-body {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 4px;
}

.reward-img {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  flex-shrink: 0;
}

.reward-img-fallback {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.reward-info { flex: 1; min-width: 0; }

.reward-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reward-cost {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  margin-top: 2px;
}

.reward-trigger-btn {
  margin: 6px 8px 8px;
  background: var(--purple);
  border: none;
  border-radius: 4px;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 8px;
  cursor: pointer;
  width: calc(100% - 16px);
  transition: background 0.15s;
}

.reward-trigger-btn:hover { background: #a970ff; }

/* Toggle button active state */
.rewards-toggle-btn.active {
  color: var(--purple);
  background: rgba(145, 71, 255, 0.15);
}

/* =============================================
   EMOTE PICKER
   ============================================= */

#emote-picker {
  display: none;
  flex-direction: column;
  max-height: 240px;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  animation: slide-up 0.2s ease;
}

#emote-picker.open { display: flex; }

.emote-picker-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#emote-search {
  flex: 1;
  min-width: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text-1);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  outline: none;
  transition: border-color 0.15s;
}
#emote-search:focus { border-color: var(--purple); }
#emote-search::placeholder { color: var(--text-3); }

#emote-grid {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-content: flex-start;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#emote-grid::-webkit-scrollbar { width: 4px; }
#emote-grid::-webkit-scrollbar-track { background: transparent; }
#emote-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.emote-item {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
  transition: background 0.1s;
  position: relative;
}
.emote-item:hover { background: var(--bg-3); }
.emote-item img { max-width: 36px; max-height: 36px; object-fit: contain; }

.emote-picker-empty {
  width: 100%;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  padding: 24px 16px;
}

.emote-picker-btn.active {
  color: var(--purple);
  background: rgba(145, 71, 255, 0.15);
}

/* =============================================
   EMOTE AUTOCOMPLETE
   ============================================= */

#emote-autocomplete {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  max-height: 220px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 -6px 20px rgba(0,0,0,0.45);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.ac-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.ac-item:hover,
.ac-item.ac-active { background: var(--bg-3); }

.ac-emote-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.ac-code {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}

.ac-source {
  font-size: 10px;
  color: var(--text-3);
  margin-left: auto;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* =============================================
   CHAT INPUT
   ============================================= */

#chat-input-area {
  order: 100; /* immer als letztes Flex-Item im Dashboard */
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

#chat-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-1);
  font-size: 15px;
  font-family: inherit;
  font-weight: 500;
  outline: none;
  transition: border-color 0.15s;
}

#chat-input:focus        { border-color: var(--purple); }
#chat-input::placeholder { color: var(--text-3); }

#chat-send-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  background: var(--purple);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  touch-action: manipulation;
}

#chat-send-btn:hover  { background: #a970ff; }
#chat-send-btn:active { transform: scale(0.90); }

/* =============================================
   AUTO-SCROLL TOGGLE
   ============================================= */

.auto-scroll-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}

.auto-scroll-toggle input { display: none; }

.toggle-track {
  width: 36px;
  height: 22px;
  border-radius: 11px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.auto-scroll-toggle input:checked + .toggle-track {
  background: var(--purple);
  border-color: var(--purple);
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform 0.2s, background 0.2s;
}

.auto-scroll-toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(14px);
  background: white;
}

/* =============================================
   EMPTY STATES
   ============================================= */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 16px;
  color: var(--text-3);
  text-align: center;
}

.empty-state p { font-size: 13px; }
.empty-state .empty-sub { font-size: 12px; color: var(--text-3); }

/* Im Chat-Bereich: Empty-State fÃ¼llt den gesamten schwarzen Platz */
#chat-messages .empty-state {
  flex: 1;
  padding-top: 0;
  padding-bottom: 0;
}

/* =============================================
   VIEWER BADGE
   ============================================= */

.name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#viewer-badge {
  display: none;
  align-items: center;
  gap: 4px;
  background: rgba(230,53,53,0.15);
  border: 1px solid rgba(230,53,53,0.35);
  border-radius: 10px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-1);
}

.live-dot-red {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e63535;
  animation: pulse-dot 1.5s ease infinite;
  flex-shrink: 0;
}

