/* ============================================================
   FEATURES CSS — стили для новых фич (вложения в чат и др.).
   Отдельный файл, не трогает main.css, подключается
   после mobile-fixes.css.
   ============================================================ */

.chat-message-count {
    font-size: .72rem;
    color: var(--text-tertiary, #8a8d97);
}

/* ---------- Видео-превью в чате: клик открывает кастомный просмотрщик ---------- */
.file-message-video {
    position: relative;
    cursor: pointer;
}

.file-video-play-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(0,0,0,0.45);
    color: #fff;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.file-message-image img {
    cursor: pointer;
}

/* ---------- Поддержка: персистентный тред ---------- */
.support-thread-modal {
    display: flex;
    flex-direction: column;
    max-height: 80vh;
}

.support-thread {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: .55rem;
    padding: .25rem 0 .75rem;
    min-height: 120px;
    max-height: 50vh;
}

.support-bubble {
    max-width: 85%;
    padding: .6rem .8rem;
    border-radius: 14px;
    font-size: .88rem;
    line-height: 1.35;
}

.support-bubble-user {
    align-self: flex-end;
    background: var(--primary-orange, #FFB347);
    color: #1a1a1a;
    border-bottom-right-radius: 4px;
}

.support-bubble-reply {
    align-self: flex-start;
    background: var(--bg-hover, rgba(0,0,0,0.05));
    border-bottom-left-radius: 4px;
}

.support-bubble-label {
    font-size: .72rem;
    font-weight: 600;
    opacity: .65;
    margin-bottom: .2rem;
    display: flex;
    align-items: center;
    gap: .3rem;
}

.support-bubble-pending {
    align-self: flex-start;
    font-size: .78rem;
    color: var(--text-tertiary, #8a8d97);
    padding: .2rem .3rem;
}

.support-bubble-time {
    font-size: .68rem;
    opacity: .6;
    margin-top: .25rem;
    text-align: right;
}

.support-thread-input-row {
    display: flex;
    gap: .5rem;
    align-items: flex-end;
    border-top: 1px solid var(--border-subtle, #eee);
    padding-top: .6rem;
}

.support-thread-input-row textarea {
    flex: 1;
    max-height: 100px;
}

.support-thread-input-row button {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* ---------- Контакты ---------- */
.contacts-view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .5rem;
}

.contacts-view-header h2 {
    margin: 0;
}

.contacts-list {
    display: flex;
    flex-direction: column;
    margin-bottom: .5rem;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .65rem .2rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-subtle, #eee);
}

.contact-item:active {
    background: var(--bg-hover, rgba(255,179,71,.08));
}

.contact-info {
    min-width: 0;
}

.contact-name {
    font-weight: 600;
    font-size: .95rem;
    color: var(--text-primary, #222);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-status {
    font-size: .78rem;
    color: var(--text-tertiary, #8a8d97);
}

.contacts-search-divider {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin: .75rem 0 .6rem;
    color: var(--text-tertiary, #8a8d97);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.contacts-search-divider::before,
.contacts-search-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-subtle, #eee);
}

/* ---------- Пикер эмодзи: заблокированная вкладка Minva+ ---------- */
.emoji-cat-tab-locked {
    position: relative;
}

.emoji-cat-tab-locked::after {
    content: '\f023';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: .55rem;
    background: #FFB347;
    color: #1a1a1a;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---------- Minva+: переливающийся градиент ника ---------- */
.name-gradient-text {
    background: linear-gradient(90deg, #FFB347, #FF6FD8, #4A90D9, #FFB347);
    background-size: 300% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    animation: nameGradientShift 4s linear infinite;
    font-weight: 600;
}

@keyframes nameGradientShift {
    to { background-position: 300% center; }
}

/* ---------- Minva+: анимированные рамки аватарки (0 байт — чистый CSS) ---------- */
.avatar-frame-gold, .avatar-frame-neon, .avatar-frame-aurora {
    position: relative;
}

.avatar-frame-gold::before,
.avatar-frame-neon::before,
.avatar-frame-aurora::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    z-index: -1;
    animation: avatarFrameSpin 3.5s linear infinite;
}

.avatar-frame-gold::before {
    background: conic-gradient(from 0deg, #FFD700, #FFB347, #FF9A3C, #FFD700);
}

.avatar-frame-neon::before {
    background: conic-gradient(from 0deg, #00F5FF, #7B2FFF, #FF2FD0, #00F5FF);
}

.avatar-frame-aurora::before {
    background: conic-gradient(from 0deg, #4CAF50, #4A90D9, #9B6FD9, #4CAF50);
}

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

@media (prefers-reduced-motion: reduce) {
    .name-gradient-text { animation: none; background-position: 0 center; }
    .avatar-frame-gold::before, .avatar-frame-neon::before, .avatar-frame-aurora::before { animation: none; }
}

/* ---------- Настройки: шапка аккаунта с аватаром ---------- */
.settings-account-header {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: .5rem 0 1rem;
    cursor: pointer;
}

.settings-account-avatar {
    width: 56px;
    height: 56px;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.settings-account-name {
    font-weight: 600;
    font-size: 1.02rem;
    color: var(--text-primary, #222);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 68vw;
}

.settings-account-hint {
    font-size: .78rem;
    color: var(--text-tertiary, #8a8d97);
    margin-top: 2px;
}

/* ---------- Настройки: группа "Минва+ / Монеты / Кошелёк / Бизнес / Подарок" ---------- */
.settings-link-item {
    cursor: pointer;
}

/* .settings-item по умолчанию — justify-content:space-between для РОВНО
   двух детей (label + value). У строк с иконкой их было 3-4, и то же
   space-between растягивало их равными промежутками по всей ширине —
   иконка/лейбл/значение/стрелочка расползались, а не группировались.
   Группируем "иконку+лейбл" и "значение+стрелочку" каждые в один flex-
   элемент — тогда родителю снова достаётся ровно два ребёнка, и старое
   space-between работает так, как и было задумано изначально. */
.settings-link-main {
    display: flex;
    align-items: center;
    gap: .8rem;
    min-width: 0;
}

.settings-link-main .setting-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-link-trailing {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-shrink: 0;
}

.settings-link-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .9rem;
    flex-shrink: 0;
}

/* ---------- Кошелёк / Бизнес — простые информационные экраны ---------- */
.wallet-view, .business-view {
    padding: 1rem;
    max-width: 640px;
    margin: 0 auto;
}

.wallet-balance-card {
    background: linear-gradient(135deg, #FFC94A, #FFB347);
    border-radius: 18px;
    padding: 1.5rem;
    color: #1A1D24;
    text-align: center;
    margin-bottom: 1.25rem;
}

.wallet-balance-card .wallet-balance-value {
    font-size: 2.2rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
}

.wallet-balance-card .wallet-balance-label {
    font-size: .85rem;
    opacity: .75;
    margin-top: .25rem;
}

.wallet-actions {
    display: flex;
    gap: .6rem;
    margin-bottom: 1.25rem;
}

.wallet-actions button {
    flex: 1;
}

.business-hero {
    text-align: center;
    padding: 1.5rem 1rem;
}

.business-hero .business-icon {
    font-size: 2.6rem;
    margin-bottom: .75rem;
}

.business-feature-list {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    margin-top: 1rem;
}

.business-feature-item {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .8rem;
    border-radius: 12px;
    background: var(--bg-hover, rgba(0,0,0,0.04));
}

.business-feature-item i {
    color: #E75C4C;
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
}

/* ---------- Архив чатов ---------- */
.archive-folder-icon {
    background: linear-gradient(135deg, #8a8d97, #5f6270) !important;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
}

.archive-folder-row {
    opacity: .92;
}

.unarchive-btn {
    border: none;
    background: transparent;
    color: var(--text-tertiary, #8a8d97);
    font-size: 1.05rem;
    padding: .5rem;
    flex-shrink: 0;
    min-width: 40px;
    min-height: 40px;
}

.unarchive-btn:active {
    color: var(--primary-orange, #FFB347);
}

/* ---------- Подсветка секции настроек после deep-link скролла (напр. "Темы") ---------- */
.settings-section-highlight {
    animation: settingsSectionPulse 1.4s ease;
}

@keyframes settingsSectionPulse {
    0% { box-shadow: 0 0 0 2px rgba(255, 179, 71, 0.7); }
    100% { box-shadow: 0 0 0 2px rgba(255, 179, 71, 0); }
}

/* ---------- Секретный чат: зелёная тема ---------- */
.chat-view.secret-chat-theme .chat-name-large {
    color: #34C759;
}

.chat-view.secret-chat-theme .message.sent {
    background: rgba(52, 199, 89, 0.18);
    border: 1px solid rgba(52, 199, 89, 0.3);
}

.chat-view.secret-chat-theme .message.received {
    background: rgba(52, 199, 89, 0.08);
}

.chat-view.secret-chat-theme .message-content,
.chat-view.secret-chat-theme .message-sender {
    color: #1f7a3d;
}

body.dark-theme .chat-view.secret-chat-theme .message-content,
body.dark-theme .chat-view.secret-chat-theme .message-sender {
    color: #4ee281;
}

.secret-chat-item .chat-name {
    color: #34C759;
}

/* ---------- Меню чата (три точки) ---------- */
.chat-menu-list {
    display: flex;
    flex-direction: column;
    gap: .1rem;
}

.chat-menu-item {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .75rem .2rem;
    font-size: .92rem;
    cursor: pointer;
    color: var(--text-primary, #222);
    min-height: 44px;
    border-bottom: 1px solid var(--border-subtle, #eee);
}

.chat-menu-item:last-child {
    border-bottom: none;
}

.chat-menu-item i:first-child {
    width: 20px;
    text-align: center;
    color: #FFB347;
}

.chat-menu-arrow {
    margin-left: auto;
    opacity: .4;
    font-size: .8rem;
}

.chat-menu-danger {
    color: #f44336;
}

.chat-menu-danger i:first-child {
    color: #f44336;
}

/* ---------- Обои чата ---------- */
.wallpaper-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .6rem;
}

.wallpaper-option {
    height: 70px;
    border-radius: 12px;
    display: flex;
    align-items: flex-end;
    padding: .4rem;
    font-size: .72rem;
    color: #fff;
    cursor: pointer;
    text-shadow: 0 1px 2px rgba(0,0,0,.5);
    border: 2px solid transparent;
}

.wallpaper-option:active {
    border-color: #FFB347;
}

.wallpaper-default { background: var(--bg-hover, #e8e8ec); color: #333; text-shadow: none; }
.wallpaper-1 { background: linear-gradient(160deg, #1B1E2C, #2E5077); }
.wallpaper-2 { background: linear-gradient(160deg, #2b1b2c, #4a2545); }
.wallpaper-3 { background: linear-gradient(160deg, #16231a, #234a2e); }
.wallpaper-4 { background: linear-gradient(160deg, #2c2416, #4a3a1e); }

#messages-container.wallpaper-1,
#messages-container.wallpaper-2,
#messages-container.wallpaper-3,
#messages-container.wallpaper-4 {
    background-size: cover;
}
#messages-container.wallpaper-1 { background: linear-gradient(160deg, #1B1E2C, #2E5077); }
#messages-container.wallpaper-2 { background: linear-gradient(160deg, #2b1b2c, #4a2545); }
#messages-container.wallpaper-3 { background: linear-gradient(160deg, #16231a, #234a2e); }
#messages-container.wallpaper-4 { background: linear-gradient(160deg, #2c2416, #4a3a1e); }

/* ---------- Поиск внутри чата ---------- */
.in-chat-search-results {
    max-height: 320px;
    overflow-y: auto;
}

.in-chat-search-result {
    padding: .6rem .3rem;
    border-bottom: 1px solid var(--border-subtle, #eee);
    cursor: pointer;
    font-size: .88rem;
}

.in-chat-search-result:active {
    background: var(--bg-hover, rgba(255,179,71,.1));
}

/* ---------- Меню вложений (модалка) ---------- */
.attachment-menu-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-top: .5rem;
}

.attachment-menu-option {
    display: flex;
    align-items: center;
    gap: .9rem;
    width: 100%;
    padding: .85rem 1rem;
    border: 1px solid var(--border-subtle, #e2e4e9);
    border-radius: 12px;
    background: var(--bg-surface, #fff);
    color: var(--text-primary, #222);
    font-size: .95rem;
    cursor: pointer;
    text-align: left;
    min-height: 44px; /* тач-таргет */
    transition: background .15s ease;
}

.attachment-menu-option:hover,
.attachment-menu-option:active {
    background: var(--bg-hover, rgba(255, 179, 71, 0.1));
}

.attachment-menu-option i {
    font-size: 1.15rem;
    color: #FFB347;
    width: 22px;
    text-align: center;
}

/* ---------- Изображение в чате ---------- */
.file-message-image {
    max-width: 240px;
}

.file-message-image img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    cursor: pointer;
    display: block;
}

/* ---------- Видео в чате ---------- */
.file-message-video {
    max-width: 260px;
}

.file-message-video video {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    display: block;
    background: #000;
}

/* ---------- Документ/файл в чате ---------- */
.file-message-doc {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .7rem .9rem;
    border-radius: 12px;
    background: var(--bg-hover, rgba(0, 0, 0, 0.04));
    text-decoration: none;
    color: inherit;
    max-width: 260px;
    min-height: 44px;
}

.file-doc-icon {
    font-size: 1.6rem;
    color: #FFB347;
    flex-shrink: 0;
}

.file-doc-info {
    flex: 1;
    min-width: 0;
}

.file-doc-name {
    font-size: .9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-doc-size {
    font-size: .78rem;
    opacity: .65;
}

.file-doc-download {
    font-size: 1rem;
    opacity: .6;
    flex-shrink: 0;
}

.file-message-broken {
    padding: .7rem 1rem;
    border-radius: 10px;
    background: var(--bg-hover, rgba(0, 0, 0, 0.05));
    opacity: .7;
    font-size: .85rem;
}

/* Мобильные экраны — вложения чуть уже, чтобы не упираться в край */
@media (max-width: 480px) {
    .file-message-image,
    .file-message-video,
    .file-message-doc {
        max-width: 200px;
    }
}