/* MEETUS CHANNEL CONTROLS V3 — event-driven, no polling */

.channel-post-context-actions.hidden,
.channel-linked-group-controls.hidden {
  display: none !important;
}

.channel-post-context-actions > button {
  width: 100%;
}

.channel-context-symbol {
  width: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: .78;
}

.channel-linked-group-controls {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(127, 127, 127, .18);
}

.channel-linked-group-current {
  padding: 12px 13px;
  border-radius: 13px;
  background: rgba(127, 127, 127, .08);
}

.channel-linked-group-current strong,
.channel-linked-group-current small {
  display: block;
}

.channel-linked-group-current small {
  margin-top: 4px;
  opacity: .7;
  line-height: 1.35;
}

.channel-linked-group-actions,
.channel-modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.channel-visibility-body,
.channel-group-link-body {
  padding: 18px;
}

.channel-timezone-note,
.channel-group-link-warning {
  padding: 11px 12px;
  margin-bottom: 13px;
  border-radius: 12px;
  background: rgba(61, 164, 130, .11);
  line-height: 1.4;
  font-size: 13px;
}

.channel-visibility-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(125px, .6fr);
  gap: 10px;
}

.channel-date-picker-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.channel-group-link-list {
  display: grid;
  gap: 8px;
  max-height: min(55vh, 460px);
  overflow: auto;
}

.channel-group-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 13px;
  border: 1px solid rgba(127, 127, 127, .18);
  border-radius: 13px;
  background: rgba(255, 255, 255, .055);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.channel-group-choice span:first-child strong,
.channel-group-choice span:first-child small {
  display: block;
}

.channel-group-choice small {
  margin-top: 3px;
  opacity: .68;
}

.channel-group-choice.active {
  outline: 2px solid rgba(61, 164, 130, .3);
}

.channel-visibility-admin-badge {
  display: inline-flex;
  max-width: 100%;
  margin: 0 0 7px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 173, 0, .15);
  color: #9a6500;
  font-size: 11px;
  line-height: 1.25;
  font-weight: 700;
}

.channel-message-hidden-admin .message-bubble {
  opacity: .78;
  outline: 1px dashed rgba(255, 173, 0, .4);
}

@media (max-width: 620px) {
  .channel-visibility-grid {
    grid-template-columns: 1fr;
  }

  .channel-linked-group-actions > button,
  .channel-modal-actions > button {
    flex: 1 1 auto;
  }
}

.channel-group-choice:hover {
  background: rgba(255, 255, 255, .09);
}
.channel-group-choice.active {
  background: rgba(61, 164, 130, .12);
}


/* V3.2 — dark-theme group picker specificity hotfix */
#channelGroupLinkModal .channel-group-link-body {
  background: #17191d;
  color: #f3f4f6;
}

#channelGroupLinkModal .channel-group-link-warning {
  background: rgba(28, 115, 96, .22) !important;
  color: #eefbf7 !important;
  border: 1px solid rgba(71, 199, 164, .12);
}

#channelGroupLinkModal .channel-group-choice,
#channelGroupLinkModal button.channel-group-choice {
  appearance: none;
  -webkit-appearance: none;
  width: 100% !important;
  min-height: 64px;
  margin: 0 !important;
  padding: 11px 13px !important;
  border: 1px solid rgba(255, 255, 255, .09) !important;
  border-radius: 13px !important;
  background: #22252a !important;
  color: #f5f7fa !important;
  box-shadow: none !important;
  opacity: 1 !important;
  text-align: left !important;
}

#channelGroupLinkModal .channel-group-choice:hover {
  background: #292d33 !important;
  border-color: rgba(139, 115, 238, .45) !important;
}

#channelGroupLinkModal .channel-group-choice.active {
  background: rgba(132, 105, 230, .18) !important;
  border-color: rgba(153, 126, 246, .55) !important;
}

#channelGroupLinkModal .channel-group-choice > span {
  color: inherit !important;
  opacity: 1 !important;
}

#channelGroupLinkModal .channel-group-choice > span:first-child {
  min-width: 0;
  flex: 1 1 auto;
}

#channelGroupLinkModal .channel-group-choice > span:last-child {
  flex: 0 0 auto;
  color: #b9a8ff !important;
  font-size: 12px;
  font-weight: 700;
}

#channelGroupLinkModal .channel-group-choice strong {
  display: block;
  color: #ffffff !important;
  font-weight: 700;
  line-height: 1.3;
  opacity: 1 !important;
}

#channelGroupLinkModal .channel-group-choice small {
  display: block;
  margin-top: 4px;
  color: #aeb3bc !important;
  opacity: 1 !important;
}

#channelGroupLinkModal .channel-group-link-list {
  gap: 8px;
}

@media (max-width: 620px) {
  #channelGroupLinkModal .small-settings-modal {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
  }
}


/* V3.3 — modal stacking fix.
   The community side panel is a later sibling with its own backdrop,
   so the group picker must explicitly sit above it. */
#channelGroupLinkModal,
#channelVisibilityModal {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483000 !important;
  isolation: isolate;
}

#channelGroupLinkModal.hidden,
#channelVisibilityModal.hidden {
  display: none !important;
}

#channelGroupLinkModal::before,
#channelVisibilityModal::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .58);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 0;
}

#channelGroupLinkModal > .channel-group-link-modal,
#channelVisibilityModal > .channel-visibility-modal {
  position: relative !important;
  z-index: 2 !important;
  pointer-events: auto;
}

#channelGroupLinkModal .channel-group-link-modal {
  width: min(560px, calc(100vw - 32px)) !important;
  max-height: min(720px, calc(100vh - 32px)) !important;
  overflow: hidden;
}

#channelGroupLinkModal .channel-group-link-body {
  max-height: calc(100vh - 150px);
  overflow-y: auto;
}

/* While the nested picker is open, the underlying community drawer remains
   in place but cannot steal mouse/touch events. */
body:has(#channelGroupLinkModal:not(.hidden)) #communityManageModal,
body:has(#channelVisibilityModal:not(.hidden)) #communityManageModal {
  pointer-events: none !important;
}

@media (max-width: 620px) {
  #channelGroupLinkModal,
  #channelVisibilityModal {
    padding: 12px !important;
  }

  #channelGroupLinkModal .channel-group-link-modal,
  #channelVisibilityModal .channel-visibility-modal {
    width: 100% !important;
    max-height: calc(100vh - 24px) !important;
  }
}


/* V3.4 current linked group summary */
#channelGroupLinkModal .channel-group-current-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(185, 168, 255, .22);
  border-radius: 12px;
  background: rgba(132, 105, 230, .10);
}
#channelGroupLinkModal .channel-group-current-summary span {
  color: #aeb3bc;
  font-size: 12px;
}
#channelGroupLinkModal .channel-group-current-summary strong {
  color: #c5b8ff;
  text-align: right;
}


/* FLOW V4 — rename community */
.community-rename-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}
.community-rename-row input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 11px 12px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  background: rgba(255,255,255,.055);
  color: inherit;
  outline: none;
}
.community-rename-row input:focus {
  border-color: rgba(153,126,246,.65);
  box-shadow: 0 0 0 3px rgba(132,105,230,.12);
}
@media (max-width: 620px) {
  .community-rename-row { grid-template-columns: 1fr; }
  .community-rename-row .telegram-primary-button { width: 100%; }
}


/* FLOW V4.2 — community editor title */
#workspace13Title {
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  padding: 0 15px;
  border: 1px solid rgba(137, 112, 226, .36);
  border-radius: 13px;
  outline: none;
  background: #111720;
  color: #f3f5fb;
  font: inherit;
  font-size: 15px;
  line-height: 1.35;
  transition:
    border-color .16s ease,
    box-shadow .16s ease,
    background .16s ease;
}

#workspace13Title::placeholder {
  color: #707989;
}

#workspace13Title:hover {
  border-color: rgba(137, 112, 226, .58);
}

#workspace13Title:focus {
  border-color: #8b70e6;
  background: #131a24;
  box-shadow: 0 0 0 3px rgba(139, 112, 230, .14);
}

/* FLOW V4.2 — linked group picker */
.channel-group-choice {
  border-radius: 14px !important;
  transition:
    border-color .14s ease,
    background .14s ease,
    transform .14s ease !important;
}

.channel-group-choice:not(.active):hover {
  transform: translateY(-1px);
  border-color: rgba(139, 112, 230, .62) !important;
  background: rgba(139, 112, 230, .08) !important;
}

.channel-group-choice.active {
  border-color: #8b70e6 !important;
  background:
    linear-gradient(
      135deg,
      rgba(139, 112, 230, .20),
      rgba(139, 112, 230, .10)
    ) !important;
  box-shadow: inset 0 0 0 1px rgba(139, 112, 230, .12);
}

.channel-group-choice.active > span:last-child {
  color: #bcaeff !important;
  font-weight: 700;
}

.channel-group-choice:disabled {
  cursor: wait;
  opacity: .72;
}

.channel-group-current.is-linked {
  border-color: rgba(139, 112, 230, .48) !important;
  background: rgba(139, 112, 230, .08) !important;
}

#channelGroupLinkStatus:not(:empty) {
  margin-top: 10px;
  color: #bcaeff;
  font-size: 13px;
  font-weight: 600;
}


/* FLOW V4.3 — stable media send preview */
#mediaPreviewModal.media-preview-modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: #0d131c;
}

#mediaPreviewModal.hidden {
  display: none !important;
}

#mediaPreviewModal .media-preview-header {
  position: relative;
  z-index: 5;
  min-height: 72px;
  flex: 0 0 auto;
  background: rgba(13, 19, 28, .98);
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}

#mediaPreviewModal .media-preview-stage {
  min-width: 0;
  min-height: 0;
  height: auto !important;
  padding: 18px 24px 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#mediaPreviewModal .media-preview-content {
  display: block;
  width: auto !important;
  height: auto !important;
  max-width: min(88vw, 920px) !important;
  max-height: 100% !important;
  object-fit: contain !important;
  border-radius: 16px;
}

#mediaPreviewModal .media-preview-footer {
  position: relative;
  z-index: 6;
  min-height: 0;
  padding: 8px 16px max(14px, env(safe-area-inset-bottom));
  background: rgba(13, 19, 28, .99);
  border-top: 1px solid rgba(255, 255, 255, .08);
  overflow: visible;
}

#mediaPreviewModal .media-preview-thumbnails {
  max-height: 62px;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0 auto 8px;
}

#mediaPreviewModal .media-preview-caption-row {
  position: relative;
  width: min(900px, calc(100vw - 32px));
  min-height: 50px;
  max-height: 112px;
  margin: 0 auto;
  align-items: flex-end;
  overflow: visible;
}

#mediaPreviewModal #mediaPreviewCaption {
  box-sizing: border-box;
  min-height: 44px !important;
  max-height: 92px !important;
  height: 44px !important;
  overflow-y: auto !important;
  resize: none !important;
  padding: 11px 14px !important;
  line-height: 1.35 !important;
  white-space: pre-wrap;
  word-break: break-word;
}

#mediaPreviewModal .media-preview-emoji-button,
#mediaPreviewModal .media-preview-send {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
}

#mediaPreviewModal .media-preview-emoji-picker {
  bottom: 58px;
  max-height: min(340px, 48vh);
}

@media (max-width: 600px) {
  #mediaPreviewModal .media-preview-header {
    min-height: 58px;
  }

  #mediaPreviewModal .media-preview-stage {
    padding: 8px 8px 5px;
  }

  #mediaPreviewModal .media-preview-content {
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 12px;
  }

  #mediaPreviewModal .media-preview-footer {
    padding: 7px 8px max(10px, env(safe-area-inset-bottom));
  }

  #mediaPreviewModal .media-preview-caption-row {
    width: 100%;
    max-height: 102px;
  }

  #mediaPreviewModal #mediaPreviewCaption {
    max-height: 82px !important;
  }
}
