/* ═══════════════════════════════════════════════════════════
   STREAM MANAGER – Layout & Styles
   ═══════════════════════════════════════════════════════════ */

/* ── Stream Manager Edge-to-Edge Full Width Stretch ──────── */
.app-container:has(#stream-manager-tab.active) .main-content {
  padding: 12px 16px 28px !important;
}

/* Hide top workspace operations bar when Stream Manager is active */
.app-container:has(#stream-manager-tab.active) .workspace-bar {
  display: none !important;
}

#stream-manager-tab.active {
  width: 100%;
}

.sm-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: none !important;
}

.sm-top-bar {
  width: 100%;
}

.sm-main-grid {
  display: grid;
  grid-template-columns: 250px minmax(380px, 1fr) minmax(500px, 580px);
  gap: 1rem;
  width: 100%;
  align-items: start;
}

/* Links: Aktivitäts-Feed (Kompakt) */
.sm-feed-col {
  min-width: 220px;
}

.sm-center-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

/* Rechter Bereich: Chat + Benutzer-Liste NEBENEINANDER */
.sm-right-area {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 220px;
  gap: 0.85rem;
  align-items: stretch;
  min-height: 560px;
}

.sm-chat-panel,
.sm-chatters-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sm-chatters-panel {
  min-width: 180px;
}

@media (max-width: 1550px) {
  .sm-main-grid {
    grid-template-columns: 240px minmax(360px, 1fr) minmax(320px, 460px);
  }
  .sm-right-area {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1250px) {
  .sm-main-grid {
    grid-template-columns: minmax(360px, 1fr) minmax(320px, 420px);
  }
  .sm-feed-col {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .sm-main-grid {
    grid-template-columns: 1fr;
  }
  .sm-right-area {
    grid-template-columns: 1fr;
  }
}

/* ── Stream Embed ───────────────────────────────────────── */
.sm-stream-embed {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #0e0e10;
  border: 1px solid var(--border-default);
}

.sm-stream-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.sm-stream-offline {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0e0e10 0%, #18181b 100%);
  color: var(--text-muted);
  gap: 0.75rem;
  font-size: 0.9rem;
}

.sm-stream-offline .offline-icon {
  font-size: 3rem;
  opacity: 0.5;
}

/* ── Chat Embed ─────────────────────────────────────────── */
.sm-chat-area {
  display: flex;
  flex-direction: column;
  min-height: 480px;
}

.sm-chat-container {
  flex-grow: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #0e0e10;
  border: 1px solid var(--border-default);
  position: relative;
  min-height: 400px;
}

.sm-chat-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  position: absolute;
  inset: 0;
}

/* ── Live Status Bar ────────────────────────────────────── */
.sm-live-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.sm-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sm-live-badge.is-live {
  background: rgba(255, 0, 0, 0.15);
  color: #ff4444;
  border: 1px solid rgba(255, 0, 0, 0.3);
}

.sm-live-badge.is-live .pulse-dot {
  width: 8px;
  height: 8px;
  background: #ff4444;
  border-radius: 50%;
  animation: sm-pulse 1.5s ease-in-out infinite;
}

.sm-live-badge.is-offline {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

@keyframes sm-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.sm-stat-chips {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.sm-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding: 0.3rem 0.6rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.sm-stat-chip .chip-value {
  font-weight: 700;
  color: var(--text-primary);
}

/* ── Stream Info Cards ──────────────────────────────────── */
.sm-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.sm-info-card {
  padding: 1rem 1.15rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.sm-info-card .info-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.sm-info-card .info-value {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-word;
  line-height: 1.3;
}

/* ── Quick Actions ──────────────────────────────────────── */
.sm-quick-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.sm-qa-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.sm-qa-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent);
  transform: translateY(-1px);
}

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

.sm-qa-btn .qa-icon {
  font-size: 1rem;
}

.sm-qa-btn.qa-prediction { border-left: 3px solid #a970ff; }
.sm-qa-btn.qa-poll       { border-left: 3px solid #00b8ff; }
.sm-qa-btn.qa-announce   { border-left: 3px solid #ffa500; }

/* ── Bottom Grid (Feed + Chatters) ──────────────────────── */
.sm-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.25rem;
}

@media (max-width: 900px) {
  .sm-bottom-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Activity Feed ──────────────────────────────────────── */
.sm-feed-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 240px;
  overflow-y: auto;
}

.sm-feed-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.sm-feed-item:last-child {
  border-bottom: none;
}

.sm-feed-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.sm-feed-text {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.sm-feed-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.sm-feed-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.sm-feed-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* ── Chatters Panel ─────────────────────────────────────── */
.sm-chatters-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 320px;
  overflow-y: auto;
}

/* Gruppen: Streamer → Moderatoren → VIPs → Zuschauer */
.sm-chatter-group + .sm-chatter-group {
  margin-top: 0.85rem;
}

.sm-chatter-group-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0 0.35rem;
  margin-bottom: 0.15rem;
  border-bottom: 1px solid var(--border-subtle);
  /* Deckend, damit beim Scrollen keine Namen unter der Überschrift durchscheinen */
  background: #0f1520;
}

.sm-chatter-group-label {
  color: #607086;
  font-size: 0.61rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sm-chatter-group-count {
  padding: 0.05rem 0.4rem;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.sm-chatter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  font-size: 0.84rem;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.sm-chatter-group .sm-chatter:last-child {
  border-bottom: none;
}

.sm-chatter .chatter-badge {
  display: grid;
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  place-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.07);
  font-size: 0.66rem;
  line-height: 1;
}

.sm-chatter.is-broadcaster .chatter-badge {
  border-color: rgba(246, 200, 95, 0.34);
  background: rgba(246, 200, 95, 0.14);
}

.sm-chatter.is-moderator .chatter-badge {
  border-color: rgba(81, 232, 154, 0.32);
  background: rgba(81, 232, 154, 0.13);
}

.sm-chatter.is-vip .chatter-badge {
  border-color: rgba(155, 123, 255, 0.34);
  background: rgba(155, 123, 255, 0.14);
}

.sm-chatter .chatter-name {
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sm-chatter.is-broadcaster .chatter-name {
  color: #ffdf9b;
  font-weight: 700;
}

.sm-chatter.is-moderator .chatter-name {
  color: #9ff3c6;
  font-weight: 650;
}

.sm-chatter.is-vip .chatter-name {
  color: #cbbcff;
  font-weight: 650;
}

.sm-chatters-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.sm-chatters-hint {
  margin-top: 0.85rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(246, 200, 95, 0.22);
  border-radius: var(--radius-sm, 8px);
  background: rgba(246, 200, 95, 0.07);
  color: #e3c887;
  font-size: 0.73rem;
  line-height: 1.45;
}

.sm-chatters-hint a {
  color: #ffdf9b;
  font-weight: 700;
  text-decoration: underline;
}

/* ── Quick Action Modal ─────────────────────────────────── */
.sm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sm-modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.sm-modal {
  background: var(--bg-card, #1a1a2e);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg, 12px);
  padding: 1.75rem;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: translateY(10px) scale(0.97);
  transition: transform 0.25s ease;
}

.sm-modal-overlay.open .sm-modal {
  transform: translateY(0) scale(1);
}

.sm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.sm-modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.sm-modal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.sm-modal-btn-popout,
.sm-modal-btn-close {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  transition: all 0.2s ease;
  line-height: 1;
}

.sm-modal-btn-popout:hover,
.sm-modal-btn-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* ── Modal Form Fields ──────────────────────────────────── */
.sm-form-group {
  margin-bottom: 1rem;
}

.sm-form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.4rem;
}

.sm-form-group input,
.sm-form-group textarea,
.sm-form-group select {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.88rem;
  padding: 0.6rem 0.85rem;
  outline: none;
  transition: border-color 0.2s ease;
  box-sizing: border-box;
}

.sm-form-group input:focus,
.sm-form-group textarea:focus,
.sm-form-group select:focus {
  border-color: var(--accent);
}

.sm-form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.sm-form-row {
  display: flex;
  gap: 0.75rem;
}

.sm-form-row .sm-form-group {
  flex: 1;
}

.sm-color-options {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.sm-color-option {
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-main);
}

.sm-color-option:hover {
  transform: translateY(-1px);
}

.sm-color-option.selected {
  border-color: white;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.2);
}

.sm-color-option[data-color="primary"] { background: #9147ff; color: white; }
.sm-color-option[data-color="blue"]    { background: #2196F3; color: white; }
.sm-color-option[data-color="green"]   { background: #4CAF50; color: white; }
.sm-color-option[data-color="orange"]  { background: #FF9800; color: white; }
.sm-color-option[data-color="purple"]  { background: #9C27B0; color: white; }

.sm-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

/* ── Prediction Outcomes ────────────────────────────────── */
.sm-outcomes-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sm-outcome-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sm-outcome-row input {
  flex: 1;
}

.sm-outcome-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sm-btn-add-outcome,
.sm-btn-add-choice {
  background: none;
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.82rem;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 0.3rem;
}

.sm-btn-add-outcome:hover,
.sm-btn-add-choice:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Category Autocomplete Dropdown ────────────────────── */
.sm-suggestions-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--bg-card, #1a1a2e);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  margin-top: 4px;
}

.sm-suggestions-dropdown.hidden {
  display: none !important;
}

.sm-suggestion-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.84rem;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s ease;
}

.sm-suggestion-item:last-child {
  border-bottom: none;
}

.sm-suggestion-item:hover {
  background: rgba(72, 233, 226, 0.12);
  color: var(--accent);
}

.sm-suggestion-item img {
  width: 28px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

/* ── Preset Folder Pills & Preset Cards ────────────────── */
.sm-folder-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sm-folder-pill:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
}

.sm-folder-pill.active {
  background: rgba(72, 233, 226, 0.15);
  border-color: rgba(72, 233, 226, 0.4);
  color: var(--accent);
}

.sm-presets-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 280px;
  overflow-y: auto;
}

.sm-preset-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.sm-preset-card:hover {
  border-color: rgba(72, 233, 226, 0.3);
  background: rgba(72, 233, 226, 0.03);
}

.sm-preset-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  flex: 1;
}

.sm-preset-tags {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.sm-preset-folder-tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  background: rgba(72, 233, 226, 0.1);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.sm-preset-game-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sm-preset-title-text {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sm-preset-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.sm-btn-apply-preset {
  background: rgba(72, 233, 226, 0.12);
  border: 1px solid rgba(72, 233, 226, 0.3);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-family: var(--font-main);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sm-btn-apply-preset:hover {
  background: rgba(72, 233, 226, 0.25);
  transform: translateY(-1px);
}

.sm-btn-delete-preset {
  background: rgba(255, 82, 82, 0.08);
  border: 1px solid rgba(255, 82, 82, 0.2);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.78rem;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sm-btn-delete-preset:hover {
  background: rgba(255, 82, 82, 0.2);
}

.sm-presets-empty {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ── Section Headers ────────────────────────────────────── */
.sm-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
}

.sm-section-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
}

.sm-section-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}
