/* ── Streaming Plugin ── */

.stream-container {
  height: 100%;
  overflow-y: auto;
  padding: 16px;
}

/* ── Top Bar ── */
.stream-topbar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.stream-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stream-field-grow { flex: 1; min-width: 180px; }
.stream-field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  padding-left: 2px;
}

.stream-input {
  padding: 10px 14px;
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text-normal);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.stream-input:focus { border-color: var(--accent); }
.stream-input::placeholder { color: var(--text-faint); }
.stream-input-name { width: 150px; }
.stream-input-title { width: 100%; }

.stream-btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.stream-btn:hover { background: var(--accent-hover); }
.stream-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.stream-btn-stop {
  background: var(--danger);
}
.stream-btn-stop:hover { background: #c93b3e; }

/* ── Grid ── */
.stream-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ── Tile (Kachel) ── */
.stream-tile {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative;
}
.stream-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}
.stream-tile.own {
  border: 2px solid var(--accent);
}

/* Preview area (16:9) */
.stream-tile-preview {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 */
  background: var(--bg-deep);
  overflow: hidden;
}
.stream-tile-preview video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.stream-tile-preview .stream-tile-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  opacity: 0.3;
}

/* LIVE badge */
.stream-live-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stream-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  animation: stream-pulse 1.5s ease-in-out infinite;
}
@keyframes stream-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Viewer count on tile */
.stream-tile-viewers {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Info bar below preview */
.stream-tile-info {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.stream-tile-meta {
  min-width: 0;
  flex: 1;
}
.stream-tile-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-normal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stream-tile-title {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stream-tile-time {
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
}

/* Three-dot menu */
.stream-tile-menu-wrap {
  position: relative;
}
.stream-tile-menu {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  font-size: 18px;
  line-height: 1;
  border-radius: 4px;
  transition: background var(--transition);
}
.stream-tile-menu:hover {
  background: var(--bg-tertiary);
  color: var(--text-normal);
}

/* Dropdown menu */
.stream-tile-dropdown {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-lg);
  min-width: 220px;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.stream-tile-dropdown-header {
  padding: 12px 14px;
}
.stream-tile-dropdown-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-normal);
}
.stream-tile-dropdown-title {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.stream-tile-dropdown-detail {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 6px;
}
.stream-tile-dropdown-divider {
  height: 1px;
  background: var(--bg-tertiary);
}
.stream-tile-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  color: var(--text-normal);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}
.stream-tile-dropdown-item:hover {
  background: var(--bg-tertiary);
}

/* ── Fullscreen Viewer ── */
.stream-viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
  display: flex;
  flex-direction: column;
}
.stream-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  z-index: 1;
}
.stream-viewer-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.stream-viewer-title {
  font-weight: 600;
  font-size: 16px;
}
.stream-viewer-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}
.stream-viewer-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stream-viewer-fullscreen {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.stream-viewer-fullscreen:hover {
  background: rgba(255, 255, 255, 0.25);
}
.stream-viewer-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: background var(--transition);
}
.stream-viewer-close:hover {
  background: rgba(255, 255, 255, 0.2);
}
.stream-viewer-video {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.stream-viewer-video video {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.stream-viewer-connecting {
  color: var(--text-muted);
  font-size: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.stream-viewer-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-tertiary);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: stream-spin 0.8s linear infinite;
}
@keyframes stream-spin {
  to { transform: rotate(360deg); }
}

/* ── Empty state ── */
.stream-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.stream-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}
.stream-empty h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-normal);
  margin-bottom: 6px;
}
.stream-empty p {
  font-size: 14px;
}

/* ── Error ── */
.stream-error {
  background: rgba(237, 66, 69, 0.12);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.stream-error-dismiss {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  margin-left: auto;
  font-size: 16px;
  padding: 0 4px;
}

/* ── Broadcaster local preview tile ── */
.stream-tile.broadcasting .stream-tile-preview {
  border: 2px solid var(--danger);
  border-bottom: none;
}

/* ── Password input in topbar ── */
.stream-input-password {
  width: 180px;
}

.stream-select-quality {
  width: 210px;
  box-sizing: border-box;
  padding: 10px 14px;
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text-normal);
  font-size: 14px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}
.stream-select-quality:focus { border-color: var(--accent); }
.stream-select-quality:disabled { opacity: 0.5; cursor: not-allowed; }
.stream-select-quality option { background: var(--bg-secondary); color: var(--text-normal); }

/* ── Lock icon on tile ── */
.stream-tile-lock {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 16px;
  opacity: 0.6;
}

/* ── Password modal ── */
.stream-pw-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stream-pw-modal {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 340px;
  max-width: 90vw;
}
.stream-pw-modal h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}
.stream-pw-modal p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.stream-pw-modal .stream-input {
  width: 100%;
  margin-bottom: 12px;
}
.stream-pw-modal-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 8px;
}
.stream-pw-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.stream-pw-cancel {
  padding: 8px 16px;
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
}
.stream-pw-cancel:hover {
  color: var(--text-normal);
  border-color: var(--text-faint);
}

/* ── Admin Button ── */
.stream-admin-btn {
  margin-left: auto;
  padding: 8px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1;
}
.stream-admin-btn:hover { color: var(--text-normal); background: var(--bg-tertiary); }

/* ── Admin Overlay ── */
.stream-admin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.stream-admin-panel {
  background: var(--bg-secondary);
  border-radius: 12px;
  width: 560px;
  max-width: 95vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .4);
  overflow: hidden;
}

.stream-admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--bg-tertiary);
}
.stream-admin-header h3 { margin: 0; font-size: 16px; color: var(--text-normal); }
.stream-admin-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
}
.stream-admin-close:hover { color: var(--text-normal); background: var(--bg-tertiary); }

/* ── Admin Login ── */
.stream-admin-login { padding: 24px 20px; }
.stream-admin-login p { margin: 0 0 12px; color: var(--text-muted); font-size: 14px; }
.stream-admin-login-row { display: flex; gap: 8px; }
.stream-admin-login-row .stream-input { flex: 1; }
.stream-admin-error { color: #ed4245; font-size: 13px; margin-top: 8px; }

/* ── Admin Content ── */
.stream-admin-content { padding: 16px 20px; overflow-y: auto; }

.stream-admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--bg-tertiary);
}
.stream-admin-status { font-size: 13px; color: var(--text-muted); }
.stream-admin-status b { color: var(--text-normal); }
.stream-admin-logout {
  padding: 4px 12px;
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
}
.stream-admin-logout:hover { color: #ed4245; border-color: #ed4245; }

.stream-admin-loading, .stream-admin-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 14px;
}
.stream-admin-hint { margin: 0 0 12px; color: var(--text-muted); font-size: 13px; }

/* ── Channel List ── */
.stream-admin-channel-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 45vh;
  overflow-y: auto;
}
.stream-admin-channel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-deep);
  border-radius: var(--radius);
  gap: 12px;
}
.stream-admin-channel-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stream-admin-channel-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-normal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stream-admin-channel-guild {
  font-size: 11px;
  color: var(--text-faint);
}
.stream-admin-channel-events {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.stream-admin-event-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.stream-admin-event-toggle input { display: none; }
.stream-admin-event-toggle:hover { color: var(--text-normal); }
.stream-admin-event-toggle.active {
  background: var(--accent);
  color: #fff;
}

/* ── Actions ── */
.stream-admin-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}
.stream-admin-save {
  padding: 8px 24px;
}
