/* ==========================================================================
   PeerTube Chat Overlay Plugin — styles
   ========================================================================== */

.pt-chat-sidebar {
  position: fixed;
  top: var(--header-height, 94px);
  right: 0;
  width: 340px;
  height: calc(100vh - var(--header-height, 94px));
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: #18181b;
  color: #efeff1;
  font-family: "Inter", "Roobert", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  overflow: hidden;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.4);
}

.pt-chat-sidebar.pt-chat-hidden {
  display: none;
}

/* Only push main content in fixed/wide mode */
body:has(#pt-chat-sidebar:not(.pt-chat-hidden):not(.pt-chat-fullscreen):not(.pt-chat-narrow)) main {
  padding-right: 340px;
  box-sizing: border-box;
}

/* Narrow / portrait: sidebar flows inline below the player */
.pt-chat-sidebar.pt-chat-narrow {
  position: static !important;
  width: 100% !important;
  height: min(400px, 50vh);
  top: auto !important;
  right: auto !important;
  box-shadow: none;
  border-top: 1px solid #2f2f35;
}

.pt-chat-playlist-under-player-panel {
  width: auto !important;
  max-width: none !important;
  min-width: 0 !important;
  flex: none !important;
  position: static !important;
  margin: 0 0 16px !important;
}

.pt-chat-wide-secondary-layout {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) clamp(340px, 28vw, 520px);
  align-items: start !important;
  gap: 16px;
}

.pt-chat-wide-main-column,
.pt-chat-wide-secondary-column {
  min-width: 0 !important;
  width: auto !important;
  max-width: none !important;
}

.pt-chat-wide-secondary-column {
  width: clamp(340px, 28vw, 520px) !important;
}

/* Fullscreen: sidebar is absolutely positioned inside the VideoJS player element */
.pt-chat-sidebar.pt-chat-fullscreen {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 300px;
  z-index: 10; /* above vjs-control-bar (~3) so the sidebar and its children are interactive */
  box-shadow: none;
}

/* Re-assert button styles that VideoJS's global .video-js button reset strips away */
.video-js .pt-chat-resume-btn {
  position: absolute;
  bottom: 50px; /* clear the ~40px VideoJS control bar */
  left: 50%;
  transform: translateX(-50%);
  background: #9147ff !important;
  color: #fff !important;
  border: none !important;
  border-radius: 20px !important;
  padding: 6px 16px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  white-space: nowrap !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5) !important;
  z-index: 10;
  pointer-events: all;
}
.video-js .pt-chat-resume-btn:hover { background: #a855f7 !important; }
.video-js .pt-chat-resume-hidden { display: none !important; }

/* Shrink the video element so it doesn't sit under the chat sidebar */
.video-js:has(#pt-chat-sidebar.pt-chat-fullscreen:not(.pt-chat-hidden)) video.vjs-tech {
  width: calc(100% - 300px) !important;
}

/* ==========================================================================
   Player toggle button
   ========================================================================== */

.pt-chat-player-btn {
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.05em;
  color: #adadb8 !important;
  padding: 0 8px !important;
  text-transform: uppercase;
}
.pt-chat-player-btn:hover,
.pt-chat-player-btn-active {
  color: #efeff1 !important;
}

/* ==========================================================================
   Header
   ========================================================================== */

.pt-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: #1f1f23;
  border-bottom: 1px solid #2f2f35;
  flex-shrink: 0;
}

.pt-chat-header-left {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.pt-chat-title {
  font-weight: 600;
  font-size: 13px;
  color: #efeff1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.2;
}

.pt-chat-moncton {
  font-size: 11px;
  color: #adadb8;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  white-space: nowrap;
}

.pt-chat-header-btns {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.pt-chat-icon-btn {
  background: none;
  border: none;
  color: #adadb8;
  cursor: pointer;
  font-size: 20px;
  padding: 3px 5px;
  border-radius: 4px;
  line-height: 1;
}
.pt-chat-icon-btn:hover {
  background: #2f2f35;
  color: #efeff1;
}

/* ==========================================================================
   Settings popup
   ========================================================================== */

.pt-settings-popup {
  position: absolute;
  top: 44px;
  right: 8px;
  width: 280px;
  background: #18181b;
  border: 1px solid #3f3f46;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
  z-index: 200;
  font-size: 13px; /* fixed — does not scale with sidebar font size */
  overflow: hidden;
}

.pt-settings-popup.pt-settings-hidden {
  display: none;
}

.pt-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
  font-weight: 700;
  font-size: 14px;
  color: #efeff1;
  border-bottom: 1px solid #2f2f35;
}

.pt-settings-close {
  background: none;
  border: none;
  color: #adadb8;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1;
}
.pt-settings-close:hover {
  color: #efeff1;
}

.pt-settings-body {
  padding: 6px 0 10px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #3f3f46 transparent;
}

.pt-settings-section-title {
  padding: 8px 14px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7d7d8f;
}

.pt-settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  min-height: 36px;
}
.pt-settings-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.pt-settings-label {
  color: #efeff1;
  font-size: 13px;
  flex: 1;
}

/* Toggle switch */
.pt-toggle {
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}
.pt-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.pt-toggle-track {
  display: block;
  width: 36px;
  height: 20px;
  background: #3f3f46;
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
}
.pt-toggle input:checked + .pt-toggle-track {
  background: #9147ff;
}

.pt-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.pt-toggle input:checked + .pt-toggle-track .pt-toggle-thumb {
  left: 18px;
}

/* Font size control */
.pt-font-size-ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pt-font-btn {
  background: #3f3f46;
  border: none;
  color: #efeff1;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pt-font-btn:hover {
  background: #52525b;
}

#pt-font-val {
  font-size: 12px;
  color: #adadb8;
  min-width: 28px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Events area
   ========================================================================== */

.pt-chat-events {
  flex-shrink: 0;
  max-height: 50%;
  overflow-y: auto;
  overflow-x: hidden;
  border-bottom: 1px solid #2f2f35;
  scrollbar-width: thin;
  scrollbar-color: #3f3f46 transparent;
}
.pt-chat-events:empty {
  display: none;
}

.chat-event-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: #adadb8;
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}
.chat-event-dismiss:hover {
  color: #efeff1;
}

.chat-event {
  padding: 8px 10px;
  border-bottom: 1px solid #2f2f35;
}
.chat-event:last-child {
  border-bottom: none;
}

.chat-event-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.chat-event-label {
  font-size: 0.85em;
  font-weight: 600;
  text-transform: uppercase;
  color: #adadb8;
  letter-spacing: 0.05em;
}

/* --- Pin --- */

.chat-pin-header {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #adadb8;
  font-size: 0.85em;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.chat-pin-body {
  color: #efeff1;
  font-size: 1em;
  line-height: 1.45;
  margin-bottom: 4px;
  word-break: break-word;
}
.chat-pin-footer {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

/* --- Poll --- */

.chat-poll .chat-poll-title {
  font-weight: 600;
  color: #efeff1;
  margin-bottom: 8px;
  font-size: 1em;
  line-height: 1.3;
}
.chat-poll-status {
  font-size: 0.85em;
  color: #adadb8;
}
.chat-poll-choice {
  margin-bottom: 5px;
}

.chat-poll-bar-bg {
  position: relative;
  height: 22px;
  background: #3f3f46;
  border-radius: 4px;
  overflow: hidden;
}
.chat-poll-bar-fill {
  position: absolute;
  inset: 0;
  width: 0;
  background: #52525b;
  border-radius: 4px;
  transition: width 0.4s ease;
}
.chat-poll-winner .chat-poll-bar-bg {
  background: #003d2d;
}
.chat-poll-winner .chat-poll-bar-fill {
  background: #00a36b;
}

.chat-poll-bar-overlay {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 7px;
  font-size: 0.92em;
  color: #efeff1;
}
.chat-poll-winner .chat-poll-bar-overlay {
  color: #fff;
  font-weight: 600;
}
.chat-poll-choice-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-poll-choice-pct {
  font-weight: 700;
  margin-left: 6px;
  flex-shrink: 0;
}
.chat-poll-total {
  text-align: right;
  color: #adadb8;
  font-size: 0.85em;
  margin-top: 4px;
}

/* --- Prediction --- */

.chat-prediction {
  background: #1f1f23;
}

.chat-pred-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 4px;
}
.chat-pred-header-left {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.chat-pred-label {
  font-size: 0.77em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #adadb8;
}
.chat-pred-status {
  font-size: 0.77em;
  color: #9147ff;
  font-weight: 600;
}

.chat-pred-title {
  font-size: 1.08em;
  font-weight: 700;
  color: #efeff1;
  line-height: 1.3;
  margin-bottom: 10px;
}

.chat-pred-outcomes {
  margin-bottom: 8px;
}

.chat-pred-outcome {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 0;
  font-size: 1em;
}
.chat-pred-outcome-num {
  color: #adadb8;
  font-size: 0.92em;
  flex-shrink: 0;
  min-width: 14px;
}
.chat-pred-outcome-title {
  flex: 1;
  color: #efeff1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pred-winner .chat-pred-outcome-title {
  color: #fff;
}
.chat-pred-outcome-pts {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.92em;
  color: #adadb8;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.pred-winner .chat-pred-outcome-pts {
  color: #efeff1;
  font-weight: 700;
}
.chat-pred-coin {
  font-size: 0.85em;
}

.chat-pred-split-bar {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}
.chat-pred-split-blue {
  background: #1f69ff;
  transition: width 0.4s ease;
}
.chat-pred-split-pink {
  background: #bf1fff;
  flex: 1;
}

.chat-pred-split-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.85em;
  margin-bottom: 2px;
}
.pred-blue-label {
  color: #6699ff;
}
.pred-pink-label {
  color: #cc66ff;
}
.chat-pred-total {
  font-size: 0.85em;
  color: #adadb8;
  text-align: center;
  margin-top: 2px;
}

/* ==========================================================================
   Messages
   ========================================================================== */

.pt-chat-messages-area {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-messages-scroll {
  flex: 1 1 0;
  overflow-y: scroll;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #3f3f46 transparent;
  display: flex;
  flex-direction: column;
}

.pt-chat-resume-btn {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: #9147ff;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  z-index: 10;
  transition: background 0.1s;
}
.pt-chat-resume-btn:hover { background: #a855f7; }
.pt-chat-resume-hidden { display: none; }
.chat-messages-scroll::-webkit-scrollbar {
  width: 6px;
}
.chat-messages-scroll::-webkit-scrollbar-thumb {
  background: #3f3f46;
  border-radius: 3px;
}

.pt-chat-spacer {
  flex: 1 0 0; /* grows to fill free space, pushing messages to the bottom */
}

.pt-chat-messages {
  flex: 0 0 auto; /* natural height — overflows the scroll container so it can scroll */
  list-style: none;
  margin: 0;
  padding: 4px 0;
}

.chat-message {
  padding: 2px 6px;
  border-radius: 3px;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.6;
}
.chat-message:hover {
  background: rgba(255, 255, 255, 0.04);
}

/* Timestamps */
.chat-ts {
  display: none;
  font-size: 10px;
  color: #52525b;
  margin-right: 3px;
  font-variant-numeric: tabular-nums;
}
.timestamps-on .chat-ts {
  display: inline;
}

.chat-badges {
  display: inline;
  margin-right: 2px;
}
.chat-badge {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  border-radius: 2px;
  display: inline;
}
.chat-username {
  font-weight: 700;
  display: inline;
}
.chat-sep {
  color: #efeff1;
  display: inline;
}
.chat-body {
  color: #efeff1;
  display: inline;
}

.chat-emote {
  height: 28px;
  width: auto;
  vertical-align: middle;
  display: inline;
  margin: 0 1px;
}

/* Text fallback for hidden emotes */
.chat-emote-text {
  display: none;
}
.chat-emote-text-tp {
  display: none;
}

/* When hiding 3rd party: hide their images, show their text */
.hide-third-party .chat-emote-tp {
  display: none !important;
}
.hide-third-party .chat-emote-text-tp {
  display: inline;
}
