/* Общие стили чата: превью картинок, просмотрщик, реакции, смайлики, форматирование рассылки.
   Подключается после основных стилей страницы. */

/* ---------- Картинки в ленте: компактная превью-карточка ---------- */
.message-attachment { margin: 0 0 6px; max-width: 240px; line-height: 0; }
.message-attachment .chat-thumb {
  display: block; width: auto; height: auto; max-width: 100%; max-height: 260px; min-width: 120px; min-height: 90px;
  object-fit: cover; border-radius: 12px; cursor: zoom-in; border: none;
  background: rgba(255, 255, 255, .08); -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
}
.message-attachment .chat-thumb.sized { min-width: 0; min-height: 0; max-width: 100%; }
.message-attachment .chat-thumb:active { opacity: .85; }
.message-item .message-bubble:has(> .message-attachment:first-child) { padding: 4px 4px 8px; }
.message-item .message-bubble:has(> .message-attachment) > .message-text { display: block; padding: 4px 10px 0; }
.message-item .message-bubble:has(> .message-attachment) > .message-text:empty { display: none; }
.message-item .message-bubble:has(> .message-attachment) > .message-quote { margin: 4px 8px 6px; }
.message-item .message-bubble:has(> .message-attachment) > .msg-reactions { padding: 0 6px; }

/* ---------- Просмотр картинок на весь экран ---------- */
.lb { position: fixed; inset: 0; z-index: 100000; background: rgba(0, 0, 0, .94); display: flex; flex-direction: column; animation: lbIn .18s ease; touch-action: none; }
@keyframes lbIn { from { opacity: 0; } to { opacity: 1; } }
.lb-top { position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: center; gap: 4px; padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 22px; background: linear-gradient(rgba(0, 0, 0, .65), transparent); color: #fff; }
.lb-spacer { flex: 1; }
.lb-count { font-size: 14px; font-weight: 600; padding-left: 6px; }
.lb-btn { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border: none; border-radius: 50%; background: transparent; color: #fff; cursor: pointer; text-decoration: none; }
.lb-btn:hover { background: rgba(255, 255, 255, .14); }
.lb-btn .material-icons-round { font-size: 26px; }
.lb-stage { position: relative; flex: 1; overflow: hidden; touch-action: none; cursor: grab; }
.lb-stage:active { cursor: grabbing; }
.lb-img { position: absolute; left: 50%; top: 50%; max-width: none; transform-origin: center; will-change: transform; user-select: none; -webkit-user-select: none; transition: opacity .15s; box-shadow: 0 10px 50px rgba(0, 0, 0, .6); }
.lb-nav { position: absolute; top: 50%; z-index: 3; width: 48px; height: 48px; margin-top: -24px; border: none; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.lb-nav:hover { background: rgba(255, 255, 255, .24); }
.lb-nav .material-icons-round { font-size: 30px; }
.lb-prev { left: 14px; } .lb-next { right: 14px; }
.lb-single .lb-nav { display: none; }
@media (pointer: coarse) { .lb-nav { display: none; } }

/* ---------- Реакции ---------- */
.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; line-height: 1; }
.msg-reactions.empty { display: none; }
.react-chip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 9px 0 7px; border: 1px solid rgba(255, 255, 255, .16); border-radius: 13px; background: rgba(255, 255, 255, .1); color: inherit; font-family: inherit; font-size: 12px; cursor: pointer; transition: background .15s, transform .12s; }
.react-chip .re { font-size: 15px; line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.react-chip .rn { font-weight: 600; font-size: 12px; }
.react-chip.mine { background: rgba(167, 139, 250, .38); border-color: rgba(196, 181, 253, .7); }
.react-chip:active { transform: scale(.92); }

.react-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px 4px 6px; margin: 0 0 4px; border-bottom: 1px solid rgba(255, 255, 255, .08); max-width: 288px; }
.react-bar button { display: inline-flex !important; align-items: center; justify-content: center; width: 38px !important; height: 38px; padding: 0 !important; border: none; border-radius: 50% !important; background: transparent; cursor: pointer; font-size: 23px !important; line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; transition: transform .12s, background .12s; }
.react-bar button:hover { background: rgba(255, 255, 255, .1) !important; transform: scale(1.18); }
.react-bar button.active { background: rgba(167, 139, 250, .32) !important; }
.react-bar .react-more { width: 30px !important; height: 30px; margin-left: auto; font-size: 0 !important; color: #8896ab; }
.react-bar .react-more .material-icons-round { font-size: 22px; }
.react-bar .react-pick.extra { display: none !important; }
.react-bar.expanded .react-pick.extra { display: inline-flex !important; }
.react-bar.expanded .react-more .material-icons-round { transform: rotate(180deg); }
.context-menu.with-react, .ux-menu.with-react { min-width: 292px; }

/* ---------- Смайлики ---------- */
.emoji-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex-shrink: 0; padding: 0; border: none; border-radius: 50%; background: transparent; color: #8899b0; cursor: pointer; }
.emoji-btn:hover, .emoji-btn.active { color: #c4b5fd; }
.emoji-btn:active { background: rgba(255, 255, 255, .06); }
.emoji-btn .material-icons-round { font-size: 24px; }
.emoji-panel { position: absolute; left: 0; right: 0; bottom: 100%; z-index: 60; display: flex; flex-direction: column; max-height: min(268px, 42vh); background: #131b2e; border: 1px solid rgba(255, 255, 255, .08); border-bottom: none; border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .45); animation: emojiUp .14s ease; }
.emoji-panel[hidden] { display: none; }
.emoji-panel.docked { position: static; width: 100%; flex: 0 0 100%; order: 99; height: min(272px, 40vh); max-height: none; margin-top: 8px; border: none; border-top: 1px solid rgba(255, 255, 255, .08); border-radius: 0; box-shadow: none; animation: none; }
.emoji-panel.below { bottom: auto; top: calc(100% + 4px); border: 1px solid rgba(255, 255, 255, .1); border-radius: 12px; z-index: 70; }
@keyframes emojiUp { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.emoji-tabs { display: flex; gap: 2px; padding: 6px 8px 4px; border-bottom: 1px solid rgba(255, 255, 255, .06); overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.emoji-tabs::-webkit-scrollbar { display: none; }
.emoji-tab { flex-shrink: 0; width: 38px; height: 34px; border: none; border-radius: 10px; background: transparent; font-size: 19px; cursor: pointer; opacity: .55; }
.emoji-tab.active { background: rgba(167, 139, 250, .22); opacity: 1; }
.emoji-grid { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 0; padding: 6px 8px 10px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.emoji-item { height: 40px; border: none; border-radius: 10px; background: transparent; font-size: 25px; line-height: 1; cursor: pointer; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.emoji-item:hover { background: rgba(255, 255, 255, .1); }
.emoji-item:active { transform: scale(1.25); }
.emoji-empty { grid-column: 1 / -1; padding: 22px 8px; text-align: center; font-size: 13px; color: #64748b; }

/* ---------- Админка: форматирование рассылки, картинка в рассылке и в карточке товара ---------- */
.fmt-bar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.fmt-bar button { min-width: 36px; height: 34px; padding: 0 9px; border: 1px solid #222f4c; border-radius: 8px; background: #0a0e17; color: #cbd5e1; font-size: 13px; font-family: inherit; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.fmt-bar button:hover { border-color: #8b5cf6; color: #fff; }
.fmt-bar .material-icons-round { font-size: 19px; }
.fmt-bar .sep { width: 1px; background: #222f4c; margin: 4px 2px; }
.img-field { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px dashed #2d3b5c; border-radius: 12px; background: rgba(255, 255, 255, .02); }
.img-field .img-prev { width: 76px; height: 76px; flex-shrink: 0; border-radius: 10px; background: #0a0e17 center / cover no-repeat; border: 1px solid #222f4c; display: flex; align-items: center; justify-content: center; color: #475569; }
.img-field .img-prev .material-icons-round { font-size: 30px; }
.img-field .img-prev.has { color: transparent; }
.img-field .img-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.img-field .img-hint { font-size: 11px; color: #64748b; line-height: 1.3; }
.img-field .img-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.img-field button { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border: 1px solid #2d3b5c; border-radius: 8px; background: #0a0e17; color: #cbd5e1; font-size: 12px; font-family: inherit; cursor: pointer; }
.img-field button:hover { border-color: #8b5cf6; color: #fff; }
.img-field button.danger { color: #f87171; }
.img-field button .material-icons-round { font-size: 16px; }
.img-field.busy { opacity: .6; pointer-events: none; }
.mail-image-preview { margin-bottom: 8px; line-height: 0; }
.mail-image-preview img { max-width: 100%; max-height: 220px; border-radius: 10px; }
.cat-thumb { width: 100%; height: 120px; object-fit: cover; border-radius: 10px; margin-bottom: 10px; cursor: zoom-in; background: #0a0e17; }
.cat-thumb + .absolute { padding: 4px; border-radius: 10px; background: rgba(10, 14, 23, .72); backdrop-filter: blur(4px); }
tg-spoiler { background: #4b5563; color: transparent; border-radius: 4px; cursor: pointer; transition: all .2s; }
tg-spoiler:hover { background: transparent; color: inherit; }
blockquote.tg-quote, #mail-preview blockquote { margin: 4px 0; padding: 2px 0 2px 10px; border-left: 3px solid #8b5cf6; color: #cbd5e1; }
#mail-preview pre, #mail-preview code { font-family: "Fira Code", monospace; background: rgba(255, 255, 255, .08); border-radius: 4px; padding: 1px 5px; }
#mail-preview pre { padding: 8px 10px; white-space: pre-wrap; }

/* ---------- Админка: компактные фото в карточках, категории, описание, окна ---------- */
.product-card, .service-card { position: relative; }
.cat-thumb { position: absolute; left: 16px; top: 16px; width: 56px; height: 56px; border-radius: 10px; object-fit: cover; }
.product-card .cat-thumb + .absolute, .service-card .cat-thumb + .absolute { padding: 0; background: none; backdrop-filter: none; }
.product-card .cat-thumb ~ .space-y-1, .service-card .cat-thumb ~ .space-y-1 { padding-left: 68px; min-height: 56px; }
.cat-add .ux-btn { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.cat-add .ux-btn .material-icons-round { font-size: 20px; }
.cat-manage-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid #2d3b5c; border-radius: 8px; background: #0a0e17; color: #cbd5e1; font-size: 12px; font-family: inherit; cursor: pointer; }
.cat-manage-btn:hover { border-color: #8b5cf6; color: #fff; }
.cat-manage-btn .material-icons-round { font-size: 18px; }
.cat-add { display: flex; gap: 8px; margin-bottom: 12px; }
.cat-add .ux-input { flex: 1; }
.cat-list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; margin-bottom: 8px; }
.cat-row { display: flex; align-items: center; gap: 8px; }
.cat-row .ux-input { flex: 1; min-width: 0; }
.cat-row .ux-input:disabled { opacity: .7; }
.cat-count { font-size: 11px; color: #64748b; white-space: nowrap; min-width: 34px; text-align: right; }
.cat-ico { width: 34px; height: 34px; flex-shrink: 0; border: 1px solid #2d3b5c; border-radius: 8px; background: #0a0e17; color: #cbd5e1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.cat-ico:hover { border-color: #10b981; color: #10b981; }
.cat-ico.danger:hover { border-color: #ef4444; color: #f87171; }
.cat-ico .material-icons-round { font-size: 19px; }
.desc-wrap { position: relative; }
.desc-area { min-height: 150px; resize: vertical; line-height: 1.5; padding-right: 44px !important; }
.desc-emoji { position: absolute; right: 8px; top: 8px; width: 32px; height: 32px; border: none; border-radius: 8px; background: transparent; color: #8899b0; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.desc-emoji:hover { background: rgba(255, 255, 255, .08); color: #c4b5fd; }
.desc-emoji .material-icons-round { font-size: 22px; }
.desc-count { margin-top: 4px; }
.modal-card { max-width: 42rem !important; max-height: 92vh; overflow-y: auto; }
.modal-overlay .modal-box { max-height: 92vh; overflow-y: auto; }
.ux-modal { max-height: 90vh; overflow-y: auto; }

#active-chat-avatar.has-photo, #users-table-body [data-avatar-uid].has-photo { cursor: zoom-in; }

/* ---------- Администраторы и пароль ---------- */
.pw-wrap { position: relative; }
.pw-wrap .ux-input { width: 100%; padding-right: 42px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border: none; background: none; color: #8896ab; cursor: pointer; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.pw-eye:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.adm-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.adm-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid #1a2744; border-radius: 12px; background: rgba(255, 255, 255, .02); }
.adm-main { flex: 1; min-width: 0; }
.adm-name { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #fff; }
.adm-me { font-size: 10px; padding: 1px 7px; border-radius: 999px; background: rgba(139, 92, 246, .25); color: #c4b5fd; }
.adm-perms { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.adm-actions { display: flex; gap: 6px; }
.perm-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .06); color: #cbd5e1; }
.perm-chip .material-icons-round { font-size: 14px; }
.perm-chip.full { background: rgba(16, 185, 129, .18); color: #6ee7b7; }
.perm-row { display: flex !important; align-items: center; gap: 10px; padding: 9px 10px; margin: 4px 0 !important; border: 1px solid #1a2744; border-radius: 10px; cursor: pointer; font-size: 13px !important; color: #cbd5e1 !important; }
.perm-row.off { opacity: .55; }
.perm-row input { width: 18px; height: 18px; accent-color: #8b5cf6; flex-shrink: 0; }
.perm-row .material-icons-round { font-size: 18px; vertical-align: -4px; color: #8896ab; }
.perm-row.full-row { border-color: rgba(16, 185, 129, .4); background: rgba(16, 185, 129, .06); }
