/* ===================================================================
   TeleClone — security.css
   Стили для UI ботов и токенов. Вынесено отдельно, чтобы не трогать
   основной style.css. Использует те же CSS-переменные темы.
   =================================================================== */

/* бейдж бота рядом с именем */
.bot-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  background: var(--accent, #3390ec);
  color: #fff;
  padding: 1px 6px;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: 1px;
}

/* строка бота в списке */
.bot-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.bot-list-item:last-child { border-bottom: none; }
.bot-list-item .bli-info { flex: 1; min-width: 0; }
.bot-list-item .bli-name { font-size: 15px; font-weight: 500; }
.bot-list-item .bli-user { font-size: 13px; color: var(--text-secondary, #707991); }
.bot-list-item .bli-act {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary, #707991);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s;
}
.bot-list-item .bli-act:hover { background: var(--bg-hover, rgba(0,0,0,.05)); }
.bot-list-item .bli-act svg {
  width: 19px; height: 19px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* предупреждение про токен */
.token-warn {
  display: flex; gap: 8px; align-items: flex-start;
  color: #d98718;
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 12px;
}
.token-warn svg {
  width: 20px; height: 20px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* сам токен */
.token-box {
  background: var(--bg-secondary, #f1f3f5);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
  color: var(--text, #000);
  user-select: all;
}

/* индикатор замка E2EE в шапке (если используется) */
.head-lock {
  width: 15px; height: 15px;
  color: var(--tick, #4fae4e);
  flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -2px;
  margin-left: 5px;
}

/* блок отпечатка безопасности (E2EE) */
.fingerprint-box {
  background: var(--bg-secondary, #f1f3f5);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 8px 0;
}
.fingerprint-box .fp-title {
  font-size: 13px;
  color: var(--text-secondary, #707991);
  margin-bottom: 8px;
}
.fingerprint-code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 15px;
  letter-spacing: 1px;
  line-height: 1.7;
  word-break: break-all;
  color: var(--text, #000);
}

/* ===================================================================
   messages-extra: контекстное меню, кнопка «Начать», волна, команды
   =================================================================== */

/* пункт «Удалить» в контекстном меню — красный */
#msg-context .ctx-danger { color: #e0533d; }
#msg-context .ctx-danger svg { stroke: #e0533d; }

/* индикатор редактирования (reply-bar в режиме editing) */
.reply-bar.editing .reply-bar-line { background: #f5a623; }
.reply-bar.editing .reply-bar-name { color: #f5a623; }

/* пометка «изменено» в мета сообщения */
.edited-mark {
  font-size: 11px;
  opacity: .6;
  margin-right: 4px;
  font-style: italic;
}

/* кнопка «Начать» у бота */
#bot-start-bar {
  display: flex;
  padding: 10px 16px 14px;
  background: var(--bg-composer, #fff);
  border-top: 1px solid var(--border, #e5e7eb);
}
#bot-start-btn {
  flex: 1;
  height: 48px;
  border: none;
  border-radius: 10px;
  background: var(--accent, #3390ec);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .5px;
  cursor: pointer;
  transition: filter .15s;
}
#bot-start-btn:hover { filter: brightness(1.06); }
#bot-start-btn:active { filter: brightness(.95); }

/* волна голосового: заполнение по мере проигрывания */
.voice-wave span {
  transition: background .12s, opacity .12s;
}
.voice-wave span.played {
  background: var(--accent, #3390ec) !important;
  opacity: 1 !important;
}
.voice-wave { cursor: pointer; }

/* команды бота в модалке настройки */
.cmd-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border, #eee);
}
.cmd-row:last-child { border-bottom: none; }
.cmd-name {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  color: var(--accent, #3390ec);
  flex-shrink: 0;
}
.cmd-desc { flex: 1; font-size: 13px; color: var(--text-secondary, #707991); min-width: 0; }
.cmd-del {
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: var(--text-secondary, #999);
  padding: 0 4px;
}
.cmd-del:hover { color: #e0533d; }
.cmd-add {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.cmd-add input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border, #ddd);
  border-radius: 8px;
  background: var(--bg-input, transparent);
  color: var(--text, #000);
  font-size: 13px;
}
.cmd-add #cmd-new-name { flex: 0 0 110px; }
.cmd-add .btn-ghost {
  flex: 0 0 40px;
  font-size: 20px;
  padding: 0;
  cursor: pointer;
}

/* ===================================================================
   media-extra: подпись к фото, GIF-панель, рендер гифок/стикеров
   =================================================================== */

/* превью при отправке фото/видео с подписью */
.cap-preview {
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-secondary, #f1f3f5);
  border-radius: 10px;
  padding: 8px;
  min-height: 120px;
}

/* кнопка стикеров в композере */
#btn-sticker svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

/* панель стикеров (вкладки: паки + GIF-загрузка) */
.sticker-panel {
  position: absolute;
  bottom: 64px;
  left: 12px;
  right: 12px;
  max-width: 420px;
  height: 320px;
  background: var(--bg-panel, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.18);
  z-index: 60;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sticker-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border, #eee);
  flex-shrink: 0;
}
.sticker-tab {
  width: 40px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  transition: background .12s;
}
.sticker-tab:hover { background: var(--bg-hover, rgba(0,0,0,.05)); }
.sticker-tab.active { background: var(--bg-secondary, #eef1f4); }
.sticker-tab[data-gif] {
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
  color: var(--accent, #3390ec);
  margin-left: auto;
}
.sticker-body { flex: 1; overflow-y: auto; padding: 10px; }
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.sticker-cell {
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  cursor: pointer;
  padding: 4px;
  transition: transform .1s, background .12s;
  display: flex; align-items: center; justify-content: center;
}
.sticker-cell:hover { background: var(--bg-hover, rgba(0,0,0,.06)); transform: scale(1.06); }
.sticker-cell svg { width: 100%; height: 100%; display: block; }

/* сообщение-гифка */
.msg-gif, .msg-sticker { position: relative; display: inline-block; }
.msg-gif img {
  max-width: 260px;
  max-height: 260px;
  border-radius: 14px;
  display: block;
  cursor: pointer;
}
.msg-sticker img {
  max-width: 160px;
  max-height: 160px;
  display: block;
  cursor: pointer;
}
/* мета (время) поверх гифки */
.gif-meta {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(0,0,0,.45);
  color: #fff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.gif-meta .tick { width: 14px; height: 14px; stroke: #fff; fill: none; }
.msg-gifwrap .bubble { background: transparent !important; padding: 0 !important; }

/* ===================================================================
   calls: окно звонка и входящий вызов
   =================================================================== */
#btn-call-audio svg, #btn-call-video svg {
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round;
}

/* окно активного/исходящего звонка */
.call-window {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: #0e1621;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.call-remote-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
#call-remote {
  width: 100%; height: 100%; object-fit: cover;
  background: #0e1621;
  display: none;          /* показываем только при видео */
}
.call-window.video #call-remote { display: block; }
.call-window.video .call-audio-face { display: none; }

/* лицо/аватар для аудиозвонка */
.call-audio-face { display: flex; flex-direction: column; align-items: center; }
.call-av {
  width: 140px; height: 140px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 54px; font-weight: 600; color: #fff;
  box-shadow: 0 0 0 6px rgba(255,255,255,.08);
}

/* локальное видео (картинка-в-картинке) */
#call-local {
  position: absolute;
  right: 16px; bottom: 96px;
  width: 150px; max-height: 200px;
  border-radius: 12px;
  object-fit: cover;
  background: #1c2733;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  z-index: 3;
}

/* верхняя плашка с именем/статусом */
.call-top {
  position: absolute; top: 0; left: 0; right: 0;
  padding: 28px 20px;
  text-align: center;
  color: #fff;
  background: linear-gradient(to bottom, rgba(0,0,0,.5), transparent);
  z-index: 2;
}
.call-name { font-size: 22px; font-weight: 600; }
.call-sub { font-size: 14px; opacity: .8; margin-top: 4px; }

/* нижние кнопки управления */
.call-controls {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 24px;
  display: flex; gap: 20px; justify-content: center;
  background: linear-gradient(to top, rgba(0,0,0,.55), transparent);
  z-index: 3;
}
.call-btn {
  width: 60px; height: 60px; border-radius: 50%;
  border: none; cursor: pointer;
  background: rgba(255,255,255,.18);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s;
}
.call-btn:hover { background: rgba(255,255,255,.28); }
.call-btn:active { transform: scale(.92); }
.call-btn svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.call-btn.off { background: #fff; color: #0e1621; }
.call-btn.hangup { background: #e0533d; }
.call-btn.hangup:hover { background: #f3654f; }
.call-btn.hangup svg { transform: rotate(135deg); }

/* входящий звонок */
.incoming-call {
  position: fixed;
  inset: 0;
  z-index: 2100;
  background: rgba(8,12,18,.72);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.inc-card {
  background: var(--bg-panel, #fff);
  border-radius: 20px;
  padding: 32px 36px;
  text-align: center;
  box-shadow: 0 16px 50px rgba(0,0,0,.4);
  min-width: 280px;
}
.inc-avatar { display: flex; justify-content: center; margin-bottom: 14px; }
.inc-avatar .call-av { width: 96px; height: 96px; font-size: 38px; box-shadow: none; }
.inc-name { font-size: 20px; font-weight: 600; color: var(--text, #000); }
.inc-sub { font-size: 14px; color: var(--text-secondary, #707991); margin-top: 4px; }
.inc-actions { display: flex; gap: 40px; justify-content: center; margin-top: 26px; }
.inc-btn {
  width: 62px; height: 62px; border-radius: 50%;
  border: none; cursor: pointer; color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s;
}
.inc-btn svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.inc-btn:active { transform: scale(.92); }
.inc-btn.accept { background: #4caf50; animation: inc-pulse 1.2s infinite; }
.inc-btn.decline { background: #e0533d; }
.inc-btn.decline svg { transform: rotate(135deg); }
@keyframes inc-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(76,175,80,.5); }
  50% { box-shadow: 0 0 0 14px rgba(76,175,80,0); }
}

@media (max-width: 640px) {
  #call-local { width: 100px; bottom: 90px; right: 10px; }
  .call-av { width: 110px; height: 110px; font-size: 42px; }
}

/* фикс: кнопки в шапке чата (инфо + звонки) — в ряд, не внахлёст */
.chat-head-actions {
  display: flex !important;
  align-items: center;
  gap: 4px;
  width: auto !important;
  flex-shrink: 0;
}

/* ===================================================================
   video-msg: запись видео-сообщений разной формы + рендер
   =================================================================== */
#btn-roundvideo svg { fill: none; stroke: currentColor; stroke-width: 2; }

/* оверлей записи */
.rv-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: #0e1621;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px;
}
.rv-stage { position: relative; display: flex; align-items: center; justify-content: center; }
.rv-frame {
  width: 280px; height: 280px;
  background: #1c2733;
  overflow: hidden;
  transition: clip-path .2s;
}
.rv-frame video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.rv-timer {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(224,83,61,.9); color: #fff; font-size: 13px;
  padding: 3px 10px; border-radius: 12px;
}
/* чипы форм */
.rv-shapes { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 340px; }
.rv-chip {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #aeb9c6; cursor: pointer;
  background: rgba(255,255,255,.08); transition: all .15s;
}
.rv-chip:hover { background: rgba(255,255,255,.16); color: #fff; }
.rv-chip.active { background: var(--accent, #3390ec); color: #fff; }
/* кнопки управления */
.rv-controls { display: flex; gap: 28px; align-items: center; }
.rv-btn {
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.16); color: #fff;
  display: flex; align-items: center; justify-content: center; transition: transform .1s, background .15s;
}
.rv-btn:hover { background: rgba(255,255,255,.26); }
.rv-btn:active { transform: scale(.92); }
.rv-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rv-btn.rec { width: 72px; height: 72px; background: #fff; }
.rv-btn.rec .rv-dot { width: 26px; height: 26px; border-radius: 50%; background: #e0533d; transition: all .15s; }
.rv-btn.rec.on .rv-dot { width: 22px; height: 22px; border-radius: 5px; }  /* стоп = квадрат */
.rv-btn.send { background: var(--accent, #3390ec); }
.rv-btn.send:disabled { opacity: .4; cursor: default; }
.rv-btn.send svg { fill: none; }

/* видео-сообщение в ленте */
.msg-rvwrap .bubble { background: transparent !important; padding: 0 !important; }
.rv-msg { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
.rv-msg-frame {
  width: 200px; height: 200px; position: relative;
  background: #1c2733; overflow: hidden; cursor: pointer;
}
.rv-msg-frame video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.rv-msg-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.rv-msg-play svg { width: 46px; height: 46px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.6)); opacity: .85; }
.rv-msg-meta {
  font-size: 11px; color: var(--text-secondary, #707991);
  display: flex; align-items: center; gap: 3px;
}
.rv-msg-meta .tick { width: 14px; height: 14px; fill: none; stroke: var(--accent, #3390ec); }

/* ===================================================================
   vibe: оформление (атмосферы + свои обои)
   =================================================================== */
.vibe-section-title { font-size: 13px; color: var(--text-secondary, #707991); margin: 4px 2px 8px; }
.vibe-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}
.vibe-card { cursor: pointer; text-align: center; }
.vibe-prev {
  width: 100%; aspect-ratio: 1 / 1; border-radius: 12px;
  border: 2px solid transparent; transition: border-color .15s, transform .1s;
  background-size: cover !important;
}
.vibe-card:hover .vibe-prev { transform: scale(1.04); }
.vibe-card.active .vibe-prev { border-color: var(--accent, #3390ec); }
.vibe-name { font-size: 12px; color: var(--text, #000); margin-top: 5px; }
.vibe-card.active .vibe-name { color: var(--accent, #3390ec); font-weight: 600; }

.vibe-wp-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.vibe-wp-btn { flex: 1; }
.vibe-wp-clear { font-size: 13px; color: #e0533d; cursor: pointer; }
.vibe-wp-clear:hover { text-decoration: underline; }

/* ===================================================================
   reactions: пикер в контекстном меню + чипы под сообщением
   =================================================================== */
.react-picker {
  display: flex; gap: 2px; padding: 6px 8px;
  border-bottom: 1px solid var(--border, #eee);
  margin-bottom: 4px;
}
.react-picker span {
  font-size: 22px; cursor: pointer; padding: 2px 4px; border-radius: 8px;
  transition: transform .1s, background .12s;
}
.react-picker span:hover { transform: scale(1.25); background: var(--bg-hover, rgba(0,0,0,.06)); }

.msg-reactions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
/* чипы реакций адаптируются к теме (светлая/тёмная) и к выбранному акценту */
.reaction-chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 10px; border-radius: 14px;
  font-size: 16px; line-height: 1; cursor: pointer; user-select: none;
  background: var(--bg-secondary);                                  /* fallback */
  background: color-mix(in srgb, var(--accent) 14%, transparent);   /* лёгкий тон акцента */
  transition: background .12s, transform .07s;
}
.reaction-chip b { font-weight: 600; font-size: 13px; color: var(--accent); }
.reaction-chip:hover {
  background: var(--bg-hover);
  background: color-mix(in srgb, var(--accent) 26%, transparent);
}
.reaction-chip:active { transform: scale(.92); }
/* «твоя» реакция — залита акцентом, счётчик контрастным цветом темы */
.reaction-chip.mine { background: var(--accent); }
.reaction-chip.mine b { color: var(--text-on-accent, #fff); }

/* на исходящих (цветных) пузырях — полупрозрачный белый, читается в любой теме */
.msg.out .reaction-chip { background: rgba(255, 255, 255, .20); }
.msg.out .reaction-chip b { color: #fff; }
.msg.out .reaction-chip:hover { background: rgba(255, 255, 255, .32); }
.msg.out .reaction-chip.mine { background: #fff; }
.msg.out .reaction-chip.mine b { color: var(--accent); }

/* ===================================================================
   pin-forward: закреплённое + пересылка
   =================================================================== */
.pin-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; cursor: pointer;
  background: var(--bg-panel, #fff);
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.pin-bar:hover { background: var(--bg-hover, rgba(0,0,0,.03)); }
.pin-ico svg { width: 18px; height: 18px; fill: none; stroke: var(--accent, #3390ec); stroke-width: 2; }
.pin-text { flex: 1; min-width: 0; }
.pin-title { font-size: 12px; color: var(--accent, #3390ec); font-weight: 600; }
.pin-preview { font-size: 13px; color: var(--text-secondary, #707991); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-close { background: none; border: none; cursor: pointer; padding: 4px; color: var(--text-secondary, #888); }
.pin-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.pin-close:hover { color: #e0533d; }

/* подсветка сообщения при переходе к закреплённому */
.msg-flash > .bubble, .msg-flash { animation: msg-flash 1.2s ease; }
@keyframes msg-flash {
  0%, 100% { background-color: transparent; }
  30% { background-color: color-mix(in srgb, var(--accent, #3390ec) 25%, transparent); }
}

/* пометка «Переслано от …» */
.fwd-tag {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--accent, #3390ec);
  margin-bottom: 4px; opacity: .9;
}
.fwd-tag svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; }
.fwd-tag b { font-weight: 600; }
.msg.out .fwd-tag { color: rgba(255,255,255,.9); }

/* список выбора чата для пересылки */
.fwd-list { max-height: 50vh; overflow-y: auto; }
.fwd-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px; border-radius: 10px; cursor: pointer;
}
.fwd-item:hover { background: var(--bg-hover, rgba(0,0,0,.05)); }
.fwd-av {
  width: 42px; height: 42px; border-radius: 50%; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600;
  flex-shrink: 0;
}
.fwd-name { font-size: 15px; color: var(--text, #000); }
.fwd-empty { text-align: center; color: var(--text-secondary, #888); padding: 24px; }

/* ===================================================================
   polls: опросы
   =================================================================== */
#btn-poll svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.poll-input {
  width: 100%; padding: 11px 12px; margin-bottom: 10px;
  border: 1.5px solid var(--border, #e5e7eb); border-radius: 10px;
  background: var(--bg-input, #fff); color: var(--text, #000); font-size: 15px;
  box-sizing: border-box;
}
.poll-input:focus { outline: none; border-color: var(--accent, #3390ec); }
.poll-add { color: var(--accent, #3390ec); cursor: pointer; font-size: 14px; margin: 2px 2px 12px; }
.poll-add:hover { text-decoration: underline; }
.poll-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 2px; font-size: 15px; color: var(--text, #000);
}

/* сообщение-опрос */
.poll-bubble { min-width: 240px; max-width: 320px; }
.poll-box { display: flex; flex-direction: column; gap: 8px; }
.poll-question { font-weight: 600; font-size: 15px; }
.poll-meta { font-size: 12px; color: var(--text-secondary, #707991); margin-top: 2px; }
.msg.out .poll-meta { color: rgba(255,255,255,.7); }
.poll-rows { display: flex; flex-direction: column; gap: 9px; margin-top: 4px; }
.poll-opt-row { cursor: pointer; }
.poll-opt-top { display: flex; align-items: center; gap: 6px; font-size: 14px; margin-bottom: 4px; }
.poll-mark { width: 14px; color: var(--accent, #3390ec); font-weight: 700; }
.msg.out .poll-mark { color: #fff; }
.poll-opt-text { flex: 1; }
.poll-pct { font-weight: 600; font-size: 13px; opacity: .85; }
.poll-bar { height: 6px; border-radius: 3px; background: rgba(127,127,127,.2); overflow: hidden; }
.poll-bar-fill {
  height: 100%; border-radius: 3px; background: var(--accent, #3390ec);
  transition: width .35s ease;
}
.msg.out .poll-bar-fill { background: #fff; }
.poll-opt-row.chosen .poll-opt-text { font-weight: 600; }
.poll-total { font-size: 12px; color: var(--text-secondary, #707991); margin-top: 2px; }
.msg.out .poll-total { color: rgba(255,255,255,.7); }

/* ===================================================================
   folders: папки чатов
   =================================================================== */
.folder-tabs {
  display: flex; gap: 4px; padding: 6px 8px; overflow-x: auto;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: var(--bg-sidebar, #fff);
  scrollbar-width: thin;
}
.folder-tabs::-webkit-scrollbar { height: 0; }
.folder-tab {
  flex-shrink: 0; padding: 6px 14px; border-radius: 16px; cursor: pointer;
  font-size: 14px; color: var(--text-secondary, #707991); white-space: nowrap;
  transition: background .12s, color .12s;
}
.folder-tab:hover { background: var(--bg-hover, rgba(0,0,0,.05)); }
.folder-tab.active { background: var(--accent, #3390ec); color: #fff; }
.folder-add { font-size: 18px; font-weight: 600; padding: 4px 12px; }

/* менеджер/редактор папок */
.fld-list { display: flex; flex-direction: column; gap: 4px; }
.fld-row { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-radius: 8px; }
.fld-row:hover { background: var(--bg-hover, rgba(0,0,0,.04)); }
.fld-row-name { flex: 1; font-size: 15px; color: var(--text, #000); }
.fld-row-meta { font-size: 12px; color: var(--text-secondary, #888); }
.fld-edit, .fld-del { cursor: pointer; opacity: .7; }
.fld-edit:hover, .fld-del:hover { opacity: 1; }
.fld-empty { text-align: center; color: var(--text-secondary, #888); padding: 18px; }
.fld-section { font-size: 13px; color: var(--text-secondary, #707991); margin: 6px 2px 8px; }
.fld-chats { max-height: 44vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.fld-chat { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; cursor: pointer; }
.fld-chat:hover { background: var(--bg-hover, rgba(0,0,0,.04)); }
.fld-chat-av { width: 38px; height: 38px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; }
.fld-chat-name { flex: 1; font-size: 15px; color: var(--text, #000); }
.fld-chk { width: 20px; height: 20px; accent-color: var(--accent, #3390ec); }

/* ===================================================================
   search: поиск по сообщениям в чате
   =================================================================== */
#btn-chat-search svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.msg-search-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--bg-panel, #fff);
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.msg-search-bar .mss-ico { width: 18px; height: 18px; fill: none; stroke: var(--text-secondary, #888); stroke-width: 2; flex-shrink: 0; }
#mss-input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 15px; color: var(--text, #000); min-width: 0;
}
#mss-input::placeholder { color: var(--text-secondary, #999); }
.mss-count { font-size: 13px; color: var(--text-secondary, #888); white-space: nowrap; }
.mss-nav { background: none; border: none; cursor: pointer; padding: 4px; color: var(--text-secondary, #888); border-radius: 6px; }
.mss-nav:hover { background: var(--bg-hover, rgba(0,0,0,.06)); }
.mss-nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
/* подсветка найденных сообщений */
.mss-hit > .bubble { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #3390ec) 50%, transparent); }
.mss-active > .bubble { box-shadow: 0 0 0 2px var(--accent, #3390ec); }

/* ===================================================================
   mentions: автодополнение @ и подсветка
   =================================================================== */
.mention { color: var(--accent, #3390ec); font-weight: 500; }
.msg.out .mention { color: #fff; text-decoration: underline; }
.mention-me { background: color-mix(in srgb, var(--accent, #3390ec) 22%, transparent); border-radius: 4px; padding: 0 3px; font-weight: 600; }

.mention-pop {
  position: absolute; left: 8px; right: 8px; bottom: 100%;
  margin-bottom: 6px; max-height: 240px; overflow-y: auto;
  background: var(--bg-panel, #fff);
  border: 1px solid var(--border, #e5e7eb); border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,.18); z-index: 50;
}
.mention-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; }
.mention-item:hover, .mention-item.active { background: var(--bg-hover, rgba(51,144,236,.1)); }
.mention-av { width: 34px; height: 34px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex-shrink: 0; }
.mention-name { font-size: 14px; color: var(--text, #000); font-weight: 500; }
.mention-uname { font-size: 13px; color: var(--text-secondary, #888); margin-left: auto; }

/* ===================================================================
   МОБИЛЬНАЯ АДАПТАЦИЯ новых фич (телефоны ≤ 600px)
   =================================================================== */
@media (max-width: 600px) {
  /* модалки — почти на весь экран, снизу */
  .modal {
    width: 100% !important; max-width: 100% !important;
    max-height: 92vh; border-radius: 16px 16px 0 0;
    position: fixed; bottom: 0; left: 0; top: auto;
    transform: none; animation: modal-up .25s ease;
  }
  @keyframes modal-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .modal-overlay { align-items: flex-end; }

  /* композер: компактнее, чтобы влезли все кнопки */
  #composer { gap: 2px; padding: 6px 6px; }
  #composer .icon-btn { width: 38px; height: 38px; padding: 6px; }
  #msg-input { font-size: 16px; }   /* 16px — чтобы iOS не зумил при фокусе */

  /* папки: вкладки шире под палец */
  .folder-tab { padding: 7px 16px; font-size: 15px; }

  /* опрос — во всю ширину пузыря */
  .poll-bubble { min-width: 0; max-width: 80vw; }

  /* видео-сообщение и рекордер — под экран */
  .rv-frame { width: 70vw; height: 70vw; max-width: 300px; max-height: 300px; }
  .rv-msg-frame { width: 60vw; height: 60vw; max-width: 220px; max-height: 220px; }
  .rv-chip { width: 40px; height: 40px; font-size: 20px; }

  /* окно звонка — кнопки крупнее, локальное видео меньше */
  #call-local { width: 96px; bottom: 92px; right: 10px; }
  .call-av { width: 120px; height: 120px; font-size: 46px; }

  /* реакции — чуть крупнее тач-таргет */
  .reaction-chip { height: 30px; }

  /* поиск по сообщениям — счётчик не сжимает инпут */
  .msg-search-bar { padding: 8px 10px; gap: 6px; }

  /* контекстное меню сообщения — не за краем экрана */
  #msg-context { max-width: 84vw; }
  .react-picker { flex-wrap: wrap; }

  /* пикер пересылки/папок — список во всю высоту */
  .fwd-list, .fld-chats { max-height: 60vh; }

  /* лайтбокс/инфо — на весь экран */
  .lightbox img, .lightbox video { max-width: 100vw; max-height: 100vh; }
}

/* совсем узкие телефоны */
@media (max-width: 380px) {
  #composer .icon-btn { width: 34px; height: 34px; }
  .folder-tab { padding: 6px 12px; font-size: 14px; }
  .call-av { width: 100px; height: 100px; }
}

/* ===================================================================
   mentions: @упоминания
   =================================================================== */

.mention-box {
  margin: 0 12px 6px; max-height: 220px; overflow-y: auto;
  background: var(--bg-panel, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.mention-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; }
.mention-item.active, .mention-item:hover { background: var(--bg-hover, rgba(0,0,0,.05)); }
.mention-av {
  width: 34px; height: 34px; border-radius: 50%; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; flex-shrink: 0;
}
.mention-name { font-size: 15px; color: var(--text, #000); }
.mention-un { font-size: 13px; color: var(--text-secondary, #888); margin-left: auto; }

/* подсветка @упоминаний в тексте */
.mention { color: var(--accent, #3390ec); font-weight: 500; cursor: pointer; }
.msg.out .mention { color: #fff; font-weight: 600; }

/* ПК: скрываем кнопку "Назад" в чате */
@media (min-width: 601px) {
  #btn-back { display: none !important; }
}

/* ===================================================================
   AUTH: живой фон + анимация появления
   =================================================================== */

/* Живой градиентный фон для auth-screen (весь экран) */
.auth-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    -45deg,
    #667eea 0%,
    #764ba2 25%,
    #f093fb 50%,
    #4facfe 75%,
    #667eea 100%
  );
  background-size: 400% 400%;
  animation: auth-gradient 15s ease infinite;
  z-index: -2;
}

/* Плавающие пузыри/пятна (для всего экрана) */
.auth-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(255,255,255,0.08) 0%, transparent 50%),
    radial-gradient(circle at 40% 80%, rgba(255,255,255,0.06) 0%, transparent 50%);
  animation: auth-blobs 20s ease-in-out infinite;
  z-index: -1;
}

@keyframes auth-gradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes auth-blobs {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -50px) scale(1.1); }
  66% { transform: translate(-20px, 20px) scale(0.9); }
}

/* Анимация появления всей auth-карточки */
.auth-screen {
  opacity: 0;
  animation: auth-fade-in 0.8s ease-out forwards;
}

@keyframes auth-fade-in {
  to { opacity: 1; }
}

/* Живой фон для правой части (auth-right) - отдельный слой */
.auth-right {
  position: relative;
  overflow: hidden;
}

.auth-right::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    #a8edea 0%,
    #fed6e3 50%,
    #a8edea 100%
  );
  background-size: 300% 300%;
  animation: auth-right-gradient 12s ease infinite;
  z-index: -1;
}

@keyframes auth-right-gradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Контент правой части поверх фона */
.auth-brand {
  animation: auth-right-fade 0.8s ease-out 0.3s forwards;
  opacity: 0;
}

@keyframes auth-right-fade {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Анимация появления левой части */
.auth-left {
  position: relative;
  z-index: 1;
  animation: auth-left-fade 0.8s ease-out 0.2s forwards;
  opacity: 0;
  transform: translateY(20px);
}

@keyframes auth-left-fade {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Плавное появление формы */
.auth-form {
  animation: auth-form-fade 0.6s ease-out 0.4s forwards;
  opacity: 0;
}

@keyframes auth-form-fade {
  to { opacity: 1; }
}

/* ===================================================================
   Ultra: реферальная система + ULTRA
   =================================================================== */
.Ultra-badge { font-size: .85em; }
#menu-Ultra svg { color: #f5b301; }
.admin-badge { font-size: .75em; font-weight: 700; }
.admin-badge-small {
  background: #e53935; color: #fff; font-size: 10px; font-weight: 700;
  padding: 2px 5px; border-radius: 4px; margin-left: 4px; display: inline-block;
}

/* ===================================================================
   admin: админ-панель
   =================================================================== */
.admin-tabs {
  display: flex; gap: 4px; padding: 16px; border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.admin-tab {
  padding: 10px 20px; border: none; border-radius: 8px; cursor: pointer;
  background: transparent; color: var(--text-secondary); font-size: 14px; font-weight: 500;
  transition: all 0.2s;
}
.admin-tab:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.admin-tab.active { background: var(--accent); color: #fff; }
.admin-loading {
  padding: 40px; text-align: center; color: var(--text-secondary); font-size: 15px;
}

/* Бейджи в списках участников */
.im-role {
  font-size: 11px; color: var(--accent); background: rgba(51,144,236,0.1);
  padding: 2px 6px; border-radius: 4px; margin-left: 6px; font-weight: 500;
}


.Ultra-loading { text-align: center; padding: 30px; color: var(--text-secondary, #888); }
.Ultra-hero {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 44px; padding: 6px 0 12px;
}
.Ultra-hero-text { font-size: 20px; color: var(--text, #000); }
.Ultra-hero-text b { color: #f5b301; }
.Ultra-status {
  text-align: center; font-size: 14px; padding: 10px; border-radius: 10px;
  background: var(--bg-secondary, #f4f4f5); color: var(--text-secondary, #555);
}
.Ultra-status.active { background: linear-gradient(90deg,#ffd86b,#f5b301); color: #5a3d00; font-weight: 600; }
.Ultra-progress { height: 8px; border-radius: 4px; background: rgba(127,127,127,.2); overflow: hidden; margin: 14px 0 4px; }
.Ultra-progress-bar { height: 100%; background: linear-gradient(90deg,#ffd86b,#f5b301); transition: width .4s; }
.Ultra-progress-label { text-align: center; font-size: 13px; color: var(--text-secondary, #888); }
.Ultra-section { font-size: 13px; color: var(--text-secondary, #707991); margin: 16px 2px 8px; font-weight: 600; }
.Ultra-link-row { display: flex; gap: 8px; }
#Ultra-link {
  flex: 1; padding: 10px 12px; border: 1.5px solid var(--border, #e5e7eb);
  border-radius: 10px; background: var(--bg-secondary, #f7f7f8); color: var(--text, #000);
  font-size: 13px;
}
.Ultra-hint { font-size: 13px; color: var(--text-secondary, #888); margin-top: 8px; text-align: center; }
.Ultra-perks { display: flex; flex-direction: column; gap: 10px; }
.Ultra-perk { display: flex; align-items: center; gap: 12px; }
.Ultra-perk-ico {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  background: var(--bg-secondary, #f4f4f5);
}
.Ultra-perk-title { font-size: 15px; color: var(--text, #000); font-weight: 500; }
.Ultra-perk-sub { font-size: 13px; color: var(--text-secondary, #888); }

.ref-hint {
  background: linear-gradient(90deg,#ffd86b,#f5b301); color: #5a3d00;
  padding: 10px 14px; border-radius: 10px; font-size: 14px; text-align: center;
  margin-bottom: 14px;
}
