/* =========================================
   CHANNELS — Stage / Floor / Vault / Widgets
   Uses the existing app tokens from chatStyles.css
   ========================================= */

/* ---------- Layout scaffolding ---------- */
/* ---------- Layout scaffolding ---------- */
#view-channel {
  display: none; /* Hide by default like other main views */
  flex-direction: column;
  height: 100%;
}

#view-channel.active {
  display: flex; /* ONLY render when toggled active by JS */
}

#view-channel .channel-feed {
  flex: 1;
  min-height: 0;
}

#channel-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  gap: 10px;
  flex-shrink: 0;
}

#channel-header .user-info-text {
  flex: 1;
  min-width: 0;
}

#channel-title {
  font-weight: 700;
  color: var(--text-dark);
  font-size: 15px;
}

#channel-subtitle {
  font-size: 12px;
  color: var(--text-grey);
}

.channel-header-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: var(--white);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.channel-header-action:hover { box-shadow: var(--shadow-md); }
.channel-header-action .material-icons { font-size: 20px; }

.channel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
}

.channel-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 12px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-grey);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.channel-tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.channel-feed {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  overflow-y: auto;
}

/* ---------- Broadcast card (The Stage) ---------- */
.broadcast-card {
  position: relative;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  overflow: hidden;
}

.broadcast-card-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 6px;
}

.broadcast-tier-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--secondary-bg);
  color: var(--text-grey);
}

.broadcast-tier-badge.tier-vip {
  background: linear-gradient(135deg, #fde68a, #f59e0b);
  color: #78350f;
}

.broadcast-tier-badge.tier-plus {
  background: var(--primary-gradient);
  color: var(--white);
}

.broadcast-content {
  color: var(--text-dark);
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.broadcast-media {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.broadcast-media:hover {
  filter: brightness(0.94);
}

/* ---------- Photo gallery grid ---------- */
.broadcast-media-grid {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  border-radius: 10px;
  overflow: hidden;
}

.broadcast-media-grid.count-1 {
  grid-template-columns: 1fr;
}

.broadcast-media-grid.count-1 .broadcast-media-tile {
  max-height: 340px;
}

.broadcast-media-grid.count-2 {
  grid-template-columns: 1fr 1fr;
}

.broadcast-media-grid.count-2 .broadcast-media-tile {
  aspect-ratio: 1 / 1;
}

.broadcast-media-grid.count-3 {
  grid-template-columns: 1.1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.broadcast-media-grid.count-3 .broadcast-media-tile:first-child {
  grid-row: 1 / 3;
}

.broadcast-media-grid.count-3 .broadcast-media-tile {
  aspect-ratio: 1 / 1;
}

.broadcast-media-grid.count-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.broadcast-media-grid.count-4 .broadcast-media-tile {
  aspect-ratio: 1 / 1;
}

.broadcast-media-tile {
  position: relative;
  overflow: hidden;
  background: var(--secondary-bg);
}

.broadcast-media-more {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  color: var(--white);
  font-size: 22px;
  font-weight: 700;
  pointer-events: none;
}

.broadcast-card-footer {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.broadcast-floor-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-grey);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

.broadcast-floor-btn:hover { color: var(--primary-color); }
.broadcast-floor-btn .material-icons { font-size: 18px; }

/* ---------- Teaser / Locked card ---------- */
.broadcast-card-locked {
  padding: 0;
  min-height: 140px;
}

.broadcast-teaser-blur {
  padding: 16px;
  filter: blur(5px);
  user-select: none;
  pointer-events: none;
}

.broadcast-lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(2px);
}

.broadcast-lock-icon {
  color: var(--primary-color);
  font-size: 26px;
}

.broadcast-lock-text {
  font-size: 13px;
  color: var(--text-grey);
}

.broadcast-upgrade-btn {
  margin-top: 4px;
  background: var(--primary-gradient);
  color: var(--white);
  border: none;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.broadcast-upgrade-btn:hover { box-shadow: var(--shadow-md); }

/* ---------- RSVP widget ---------- */
.widget-card {
  margin-top: 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 12px;
}

.widget-rsvp {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--secondary-bg);
}

.widget-rsvp-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.widget-rsvp-icon {
  color: var(--primary-color);
  font-size: 22px;
}

.widget-rsvp-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
}

.widget-rsvp-count {
  font-size: 11.5px;
  color: var(--text-grey);
}

.widget-rsvp-btn {
  background: var(--primary-color);
  color: var(--white);
  border: none;
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.widget-rsvp-btn:disabled {
  background: var(--success);
  cursor: default;
}

/* ---------- Reactions (shared: broadcast cards + Floor replies) ---------- */
@keyframes reactionPopIn {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}

.reaction-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* Wraps the reaction bar + viewer badge together so they read as one
   engagement line under a broadcast (used only on Stage cards — Floor
   replies just render a bare .reaction-bar with its own top margin). */
.broadcast-engagement-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.broadcast-engagement-row .reaction-bar {
  flex: 1;
  min-width: 0;
}

.viewer-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-grey);
  padding: 4px 2px;
}

.viewer-badge .material-icons { font-size: 16px; }

.floor-reply .reaction-bar {
  margin-top: 8px;
}

.reaction-pill-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border-color);
  background: var(--secondary-bg);
  border-radius: 20px;
  padding: 4px 9px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-dark);
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  animation: reactionPopIn 0.18s ease;
}

.reaction-pill-mini:hover { transform: translateY(-1px); }

.reaction-pill-mini.mine {
  background: color-mix(in srgb, var(--primary-color) 14%, var(--white));
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.reaction-mini-count {
  font-size: 11px;
  font-weight: 700;
  color: inherit;
}

.reaction-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px dashed var(--border-color);
  background: none;
  color: var(--text-grey);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.reaction-add-btn:hover {
  color: var(--primary-color);
  border-color: var(--primary-color);
  background: color-mix(in srgb, var(--primary-color) 8%, transparent);
}

.reaction-add-btn .material-icons { font-size: 16px; }

/* Floating emoji picker popover, spawned from openReactionPicker() */
.emoji-reaction-popover {
  position: fixed;
  z-index: 3200;
  display: flex;
  gap: 4px;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 6px 8px;
  box-shadow: var(--shadow-md);
  animation: reactionPopIn 0.15s ease;
}

.emoji-reaction-option {
  font-size: 20px;
  padding: 4px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
  line-height: 1;
}

.emoji-reaction-option:hover {
  transform: scale(1.25);
  background: var(--secondary-bg);
}

/* ---------- The Floor (thread panel) ---------- */
.floor-panel {
  border-top: 1px solid var(--border-color);
  background: var(--secondary-bg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 320px;
  overflow-y: auto;
}

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

.floor-reply {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: floorReplyIn 0.22s ease;
}

.floor-reply-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.floor-reply-body {
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  border-top-left-radius: 4px;
  padding: 9px 12px;
  max-width: 82%;
  box-shadow: var(--shadow-sm);
}

.floor-reply-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 3px;
  flex-wrap: wrap;
}

.floor-reply-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-dark);
}

.floor-reply-tier {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 1.5px 6px;
  border-radius: 20px;
  background: var(--secondary-bg);
  color: var(--text-grey);
}

.floor-reply-tier.tier-vip {
  background: linear-gradient(135deg, #fde68a, #f59e0b);
  color: #78350f;
}

.floor-reply-tier.tier-plus {
  background: var(--primary-gradient);
  color: var(--white);
}

.floor-reply-time {
  font-size: 11px;
  color: var(--text-grey);
  margin-left: auto;
}

.floor-reply-content {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-dark);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Own replies: mirror to the right, primary-tinted bubble, like a chat */
.floor-reply.own {
  flex-direction: row-reverse;
}

.floor-reply.own .floor-reply-body {
  background: color-mix(in srgb, var(--primary-color) 8%, var(--white));
  border-color: color-mix(in srgb, var(--primary-color) 30%, var(--border-color));
  border-top-left-radius: 14px;
  border-top-right-radius: 4px;
}

.floor-reply.own .floor-reply-time { margin-left: 0; margin-right: auto; order: -1; }
.floor-reply.own .floor-reply-header { flex-direction: row-reverse; justify-content: flex-end; }
.floor-reply.own .reaction-bar { justify-content: flex-end; }

/* ---------- Channel list (picker) ---------- */
.channel-list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.channel-list-item:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.channel-list-item:active { transform: translateY(0); }

.channel-card-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.3px;
  box-shadow: var(--shadow-sm);
}

.channel-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.channel-card-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.channel-card-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-dark);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-card-owner-tag {
  flex-shrink: 0;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--primary-color);
  background: color-mix(in srgb, var(--primary-color) 12%, var(--white));
  border: 1px solid color-mix(in srgb, var(--primary-color) 30%, transparent);
  border-radius: 20px;
  padding: 2px 8px;
}

.channel-card-tiers {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.channel-card-tier-pill {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--secondary-bg);
  color: var(--text-grey);
}

.channel-card-tier-pill.tier-vip {
  background: linear-gradient(135deg, #fde68a, #f59e0b);
  color: #78350f;
}

.channel-card-tier-pill.tier-plus {
  background: var(--primary-gradient);
  color: var(--white);
}

.channel-card-chevron {
  color: var(--text-grey);
  flex-shrink: 0;
  transition: transform 0.15s ease, color 0.15s ease;
}

.channel-list-item:hover .channel-card-chevron {
  color: var(--primary-color);
  transform: translateX(2px);
}

/* ---------- Vault tab ---------- */
.vault-category {
  margin-bottom: 18px;
}

.vault-category-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary-color);
  margin-bottom: 8px;
}

.vault-item {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 13.5px;
  color: var(--text-dark);
}

/* ---------- Empty states ---------- */
.channel-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  margin: auto;
  padding: 40px 24px;
  color: var(--text-grey);
}

.channel-empty-icon {
  font-size: 42px;
  color: var(--primary-color);
  opacity: 0.5;
  margin-bottom: 4px;
}

.channel-empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark);
}

.channel-empty-subtitle {
  font-size: 13px;
  color: var(--text-grey);
  max-width: 260px;
}

.channel-empty-action {
  margin-top: 10px;
  background: var(--primary-gradient);
  color: var(--white);
  border: none;
  border-radius: 20px;
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.channel-empty-action:hover { box-shadow: var(--shadow-md); }

/* ---------- Photo lightbox (fullscreen viewer) ---------- */
.channel-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 4000;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
  animation: lightboxFadeIn 0.15s ease;
}

@keyframes lightboxFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.channel-lightbox-img {
  max-width: min(92vw, 900px);
  max-height: 88vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.channel-lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.channel-lightbox-close:hover { background: rgba(255, 255, 255, 0.22); }

.channel-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.channel-lightbox-nav:hover { background: rgba(255, 255, 255, 0.22); }
.channel-lightbox-nav.prev { left: 18px; }
.channel-lightbox-nav.next { right: 18px; }

.channel-lightbox-counter {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.12);
  padding: 4px 12px;
  border-radius: 20px;
}

/* ---------- Broadcast composer (owner only) ---------- */
.channel-composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  background: var(--secondary-bg);
  flex-shrink: 0;
}

.channel-composer-textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text-dark);
  background: var(--white);
  box-sizing: border-box;
}

.channel-composer-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.channel-composer-select {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12.5px;
  color: var(--text-dark);
  background: var(--white);
}

.channel-composer-checkbox {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  color: var(--text-grey);
  cursor: pointer;
  white-space: nowrap;
}

.channel-composer-send {
  margin-left: auto;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: var(--primary-gradient);
  color: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.channel-composer-send:disabled { opacity: 0.6; cursor: default; }
.channel-composer-send .material-icons { font-size: 18px; }

/* ---------- Composer photo attachments ---------- */
.channel-composer-photo-btn {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--white);
  color: var(--text-grey);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.channel-composer-photo-btn:hover {
  color: var(--primary-color);
  border-color: var(--primary-color);
  background: color-mix(in srgb, var(--primary-color) 8%, transparent);
}

.channel-composer-photo-btn .material-icons { font-size: 19px; }

.channel-composer-photo-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 0;
}

.channel-photo-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--white);
  flex-shrink: 0;
}

.channel-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.channel-photo-thumb.has-error img { opacity: 0.5; }

.channel-photo-thumb-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.55);
}

.channel-photo-thumb-spinner::after {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--primary-color) 30%, transparent);
  border-top-color: var(--primary-color);
  animation: channelPhotoSpin 0.7s linear infinite;
}

@keyframes channelPhotoSpin {
  to { transform: rotate(360deg); }
}

.channel-photo-thumb-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger, #ef4444);
  cursor: pointer;
}

.channel-photo-thumb-error .material-icons { font-size: 18px; }

.channel-photo-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.channel-photo-thumb-remove .material-icons { font-size: 12px; }
.channel-photo-thumb-remove:hover { background: rgba(0, 0, 0, 0.75); }