/**
 * Chat Page Styles
 * Секс чат куколдов и дрочеров
 */

/* Скрытый SEO-контент для поисковиков */
.seo-content {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* На десктопе скрываем сайдбар и расширяем контент */
@media (min-width: 901px) {
    .layout {
        grid-template-columns: 1fr !important;
    }
    
    .sidebar {
        display: none !important;
    }
}

/* ========================================
   Chat Page Layout
   ======================================== */

.chat-page {
    --chat-header-h: 74px;
    padding: 16px;
    min-height: calc(100vh - 80px);
    background: var(--bg);
    padding-bottom: 48px;
}

.chat-shell {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: calc(100vh - 140px);
    height: calc(100vh - 140px);
    max-height: calc(100vh - 140px);
}

/* ========================================
   Chat Header
   ======================================== */

.chat-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    position: sticky;
    top: 64px; /* ниже глобальной шапки */
    z-index: 4;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dot-live {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4dd0e1, #26a69a);
    box-shadow: 0 0 12px rgba(77,208,225,0.5);
}

.label {
    font-weight: 700;
    font-size: 16px;
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

/* Кнопка информации в шапке чата */
.chat-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-info-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-info-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.chat-info-btn svg {
    width: 18px;
    height: 18px;
}

/* ========================================
   Chat Info Overlay
   ======================================== */

.chat-info-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.chat-info-overlay.active {
    opacity: 1;
    visibility: visible;
}

.chat-info-modal {
    background: linear-gradient(145deg, #1e1e2f 0%, #151521 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    max-width: 520px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 100px rgba(229, 62, 62, 0.1);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
}

.chat-info-overlay.active .chat-info-modal {
    transform: scale(1) translateY(0);
}

.chat-info-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 24px 0;
}

.chat-info-icon {
    font-size: 32px;
}

.chat-info-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    margin: 0;
    background: linear-gradient(135deg, #ff6b6b, #e53e3e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.chat-info-body {
    padding: 20px 24px;
}

.chat-info-body p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    line-height: 1.7;
    margin: 0 0 12px;
}

.chat-info-body p:last-child {
    margin-bottom: 0;
}

.chat-info-body strong {
    color: #fff;
}

.chat-info-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    margin: 16px 0;
}

.chat-info-rules {
    background: rgba(255, 183, 77, 0.1);
    border: 1px solid rgba(255, 183, 77, 0.2);
    border-radius: 12px;
    padding: 12px 14px !important;
    font-size: 13px !important;
    color: rgba(255, 183, 77, 0.9) !important;
}

.chat-info-ok {
    display: block;
    width: calc(100% - 48px);
    margin: 0 24px 24px;
    padding: 14px 24px;
    background: linear-gradient(135deg, #e53e3e, #c53030);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-info-ok:hover {
    background: linear-gradient(135deg, #f56565, #e53e3e);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(229, 62, 62, 0.4);
}

/* ========================================
   Chat Body Layout
   ======================================== */

.chat-body {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 12px;
    min-height: 0;
    height: calc(100vh - 210px);
    max-height: calc(100vh - 210px);
}

/* ========================================
   Chat Rail (Online Users Sidebar)
   ======================================== */

.chat-rail {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 720px;
}

.rail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
    font-weight: 600;
}

.pill {
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(77,205,94,0.15);
    color: var(--success);
    font-size: 12px;
    font-weight: 700;
}

.rail-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    min-height: 0;
}

.rail-empty {
    padding: 32px 0;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

.online-user-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    transition: all 0.2s ease;
    color: var(--text);
    text-decoration: none;
}

.online-user-item:hover {
    background: var(--bg-elevated);
}

.online-user-avatar,
.online-user-avatar-default {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    flex-shrink: 0;
}

.online-user-avatar-default {
    background: linear-gradient(135deg, #4dd0e1, #26a69a);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
}

.online-user-name {
    flex: 1;
    font-weight: 600;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.online-user-badge {
    padding: 2px 6px;
    border-radius: 8px;
    background: rgba(255,183,77,0.15);
    color: var(--accent-2);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

/* ========================================
   Chat Panel (Messages Area)
   ======================================== */

.chat-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

.messages {
    flex: 1;
    padding: 14px 16px;
    padding-bottom: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg);
    min-height: 0;
    overscroll-behavior-y: contain;
    scroll-padding-bottom: 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.messages::-webkit-scrollbar {
    width: 8px;
}

.messages::-webkit-scrollbar-track {
    background: transparent;
}

.messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 6px;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.18);
}

/* ========================================
   Message Styles
   ======================================== */

.message {
    display: flex;
    gap: 8px;
}

.message.own {
    flex-direction: row-reverse;
}

.message-avatar,
.message-avatar-default {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    flex-shrink: 0;
    cursor: pointer;
}

.message-avatar-default {
    background: linear-gradient(135deg, #4dd0e1, #26a69a);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
}

.bubble {
    max-width: min(78%, 640px);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    position: relative;
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
}

.message.own .bubble {
    background: rgba(122,146,176,0.12);
    border-color: rgba(122,146,176,0.25);
}

.bubble.pending {
    opacity: 1;
    border-style: solid;
    border-color: rgba(255,255,255,0.3);
}

.bubble.failed {
    border-color: #ff6b6b;
    background: rgba(255, 107, 107, 0.08);
}

.meta {
    display: flex;
    align-items: center;
    gap: 6px 10px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--muted);
}

.meta .time {
    min-width: 70px;
    display: inline-block;
}

.name {
    font-weight: 700;
    color: var(--text);
}

.time {
    font-size: 11px;
}

.badge {
    padding: 2px 6px;
    border-radius: 8px;
    background: rgba(255,183,77,0.15);
    color: var(--accent-2);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.text {
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
}

.delete-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 80, 80, 0.85);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 5;
}

.message:hover .delete-btn {
    opacity: 1;
}

.delete-btn:hover {
    background: rgba(255, 60, 60, 1);
    transform: scale(1.1);
}

.loading {
    padding: 32px 0;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

.empty {
    padding: 48px 0;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

/* ========================================
   Composer (Message Input)
   ======================================== */

.composer {
    position: sticky;
    bottom: 0;
    z-index: 6;
    padding: 10px 12px;
    background: var(--card);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 48px 48px 48px;
    gap: 8px;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.08);
}

.composer.disabled {
    opacity: 0.7;
    pointer-events: none;
}

.composer-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.composer-box:focus-within {
    border-color: var(--border);
}

.composer-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    min-height: 36px;
    max-height: 160px;
    font-family: inherit;
    font-weight: 400;
    caret-color: var(--accent);
}

.composer-input::placeholder {
    color: var(--muted);
    font-weight: 400;
}

.composer-input:focus {
    outline: none;
}

.composer-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--muted);
    gap: 8px;
}

/* ========================================
   Mention Suggestions
   ======================================== */

.mention-suggest {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    margin-bottom: 10px;
    background: rgba(12, 12, 14, 0.96);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(0,0,0,0.45);
    padding: 8px;
    z-index: 30;
    max-height: 260px;
    overflow: auto;
    backdrop-filter: blur(10px);
}

.mention-suggest[hidden] {
    display: none !important;
}

.mention-item {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
}

.mention-item:hover,
.mention-item.is-active {
    background: rgba(255,255,255,0.06);
    border-color: rgba(77,208,225,0.16);
}

.mention-item .m-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.04);
}

.mention-item .m-avatar-fallback {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 800;
    color: var(--text);
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    flex: 0 0 auto;
    font-size: 12px;
    text-transform: uppercase;
}

.mention-item .m-name {
    font-weight: 800;
    letter-spacing: 0.2px;
    font-size: 13px;
}

.mention-item .m-hint {
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
    opacity: 0.9;
}

.mention-item b {
    color: rgba(77,208,225,1);
    font-weight: 900;
}

a.mention,
span.mention {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(140, 160, 185, 0.16);
    border: 1px solid rgba(140, 175, 210, 0.22);
    color: rgba(180, 195, 215, 0.95);
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

a.mention:hover {
    background: rgba(140, 160, 185, 0.22);
    color: rgba(200, 212, 228, 1);
}

/* ========================================
   Reply Bar
   ======================================== */

.reply-bar {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 10px;
    border-radius: 12px;
    background: rgba(77,208,225,0.10);
    border: 1px solid rgba(77,208,225,0.18);
}

.reply-bar[hidden] {
    display: none !important;
}

.reply-bar-main {
    flex: 1;
    min-width: 0;
    border-left: 3px solid rgba(77,208,225,0.55);
    padding-left: 10px;
}

.reply-bar-title {
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
    letter-spacing: 0.2px;
    margin-bottom: 3px;
}

.reply-bar-user {
    color: var(--text);
    font-weight: 800;
}

.reply-bar-snippet {
    font-size: 13px;
    color: var(--text);
    opacity: 0.92;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.reply-bar-cancel {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(0,0,0,0.15);
    color: var(--text);
    cursor: pointer;
    flex: 0 0 auto;
    font-size: 18px;
    line-height: 1;
    display: grid;
    place-items: center;
    padding: 0;
}

.reply-bar-cancel:hover {
    background: rgba(0,0,0,0.22);
}

/* ========================================
   Reply Preview (in messages)
   ======================================== */

.reply-preview {
    border-left: 3px solid rgba(77,208,225,0.45);
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
    margin-top: 8px;
    cursor: pointer;
    user-select: none;
}

.reply-preview:hover {
    background: rgba(255,255,255,0.06);
}

.reply-preview .reply-meta {
    font-size: 12px;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 4px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.reply-preview .reply-meta .reply-to-user {
    color: var(--text);
    font-weight: 800;
}

.reply-preview .reply-snippet {
    font-size: 13px;
    color: var(--text);
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message.reply-selected .bubble {
    box-shadow: 0 0 0 2px rgba(77,208,225,0.22);
}

.message.reply-highlight {
    animation: replyFlash 1.2s ease;
}

@keyframes replyFlash {
    0% { filter: brightness(1.12); }
    100% { filter: brightness(1); }
}

/* ========================================
   Attachment State
   ======================================== */

.attach-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.attach-label,
.attach-sub {
    display: none !important;
}

.attach-thumb {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #26a69a;
    background: var(--bg);
    flex-shrink: 0;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(38,166,154,0.25);
}

.attach-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.attach-sub {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.9;
}

.attach-state[hidden] {
    display: none !important;
}

.upload-progress {
    font-variant-numeric: tabular-nums;
}

.upload-bar {
    width: 86px;
    height: 4px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
}

.upload-bar[hidden] {
    display: none !important;
}

.upload-bar-fill {
    display: block;
    height: 100%;
    width: 0%;
    background: var(--text);
    opacity: 0.7;
    transition: width 0.1s linear;
}

.attach-clear {
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 4px;
    border-radius: 6px;
}

.attach-clear:hover {
    background: var(--card);
    color: var(--text);
}

.send-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.attach-under-send {
    font-size: 12px;
    color: var(--muted);
    gap: 6px;
    padding: 6px 8px;
    border-radius: 999px;
    border: 1px solid rgba(38,166,154,0.22);
    background: rgba(38,166,154,0.10);
}

.attach-ok {
    color: #26a69a;
    font-weight: 900;
    font-size: 16px;
    line-height: 1;
}

/* ========================================
   Composer Buttons
   ======================================== */

.composer-attach {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    display: grid;
    place-items: center;
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    font-weight: 600;
}

.composer-attach.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.composer-attach:hover {
    background: var(--bg);
}

.composer-emoji {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    display: grid;
    place-items: center;
    cursor: pointer;
    user-select: none;
    font-size: 20px;
    line-height: 1;
    padding: 0;
}

.composer-emoji:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.composer-emoji:hover:not(:disabled) {
    background: var(--bg);
}

.composer-send {
    border: none;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, #4dd0e1 0%, #26a69a 100%);
    color: #0a0c10;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.2s;
    box-shadow: 0 6px 18px rgba(77,208,225,0.35);
    font-weight: 600;
}

.composer-send:hover:not(:disabled) {
    box-shadow: 0 8px 24px rgba(77,208,225,0.45);
}

.composer-send:active:not(:disabled) {
    transform: translateY(1px);
}

.composer-send svg {
    width: 20px;
    height: 20px;
}

.composer-send:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ========================================
   Emoji Picker
   ======================================== */

.emoji-popover {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--chat-mobile-ui-gap, 0px) + 74px);
    z-index: 9999;
    max-width: 420px;
    margin: 0 auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(0,0,0,0.35);
    overflow: hidden;
}

.emoji-popover[hidden] {
    display: none !important;
}

.emoji-popover.hiden-emoji-root {
    width: 100%;
    padding: 10px;
}

.hiden-emoji-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 6px 10px;
    border-bottom: 1px solid var(--border);
}

.hiden-emoji-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.hiden-emoji-tabs::-webkit-scrollbar {
    display: none;
}

.hiden-emoji-tab {
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 20px;
    cursor: pointer;
    flex-shrink: 0;
}

.hiden-emoji-tab.active {
    border-color: rgba(77,208,225,0.45);
    box-shadow: 0 0 0 3px rgba(77,208,225,0.10);
}

.hiden-emoji-body {
    padding: 10px 6px 6px;
    max-height: min(360px, 52vh);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.18) transparent;
}

.hiden-emoji-body::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.hiden-emoji-body::-webkit-scrollbar-track {
    background: transparent;
}

.hiden-emoji-body::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.16);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.hiden-emoji-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.24);
    background-clip: padding-box;
}

.hiden-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}

.hiden-emoji-item {
    border: none;
    background: transparent;
    width: 100%;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
    display: grid;
    place-items: center;
    transition: transform 0.08s ease, background 0.12s ease;
}

.hiden-emoji-item:hover {
    background: rgba(77,208,225,0.12);
    transform: scale(1.06);
}

.hiden-emoji-item:active {
    transform: scale(0.98);
}

/* ========================================
   Chat Images
   ======================================== */

.chat-image-link {
    display: inline-block;
    margin-top: 8px;
    max-width: 100%;
}

.chat-image-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    cursor: pointer;
    user-select: none;
}

.chat-image {
    display: block;
    max-width: 260px;
    width: 100%;
    height: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: transform 0.18s ease, filter 0.18s ease;
}

.chat-image-wrap::after {
    content: 'Развернуть';
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    background: rgba(0,0,0,0.35);
    border-radius: 12px;
    opacity: 0;
    transform: translateY(2px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
}

.chat-image-wrap:hover .chat-image {
    transform: scale(1.02);
    filter: saturate(1.05);
}

.chat-image-wrap:hover::after {
    opacity: 1;
    transform: translateY(0);
}

/* На тач-устройствах нет hover — показываем подсказку всегда */
@media (hover: none) {
    .chat-image-wrap::after {
        opacity: 1;
        transform: none;
        background: rgba(0,0,0,0.28);
    }
    .chat-image {
        max-width: 100%;
    }
}

/* ========================================
   Chat Image Overlay (Lightbox)
   ======================================== */

.chat-image-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10050;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.72);
    backdrop-filter: blur(6px);
    padding: 20px;
}

.chat-image-overlay.active {
    display: flex;
    animation: chatImageOverlayFadeIn 0.16s ease;
}

@keyframes chatImageOverlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.chat-image-modal {
    position: relative;
    max-width: min(92vw, 980px);
    max-height: 88vh;
}

.chat-image-modal img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 88vh;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--card);
    box-shadow: 0 24px 80px rgba(0,0,0,0.55);
    transform: scale(0.985);
    transition: transform 0.16s ease;
}

.chat-image-overlay.active .chat-image-modal img {
    transform: scale(1);
}

.chat-image-close {
    position: absolute;
    top: -10px;
    right: -10px;
    z-index: 2;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 22px;
    line-height: 1;
}

/* ========================================
   User Profile Overlay
   ======================================== */

.user-profile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.user-profile-overlay.active {
    display: flex;
}

.user-profile-popup {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: popupAppear 0.3s ease;
}

@keyframes popupAppear {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.user-profile-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.user-profile-popup-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.user-profile-popup-close {
    background: transparent;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.user-profile-popup-close:hover {
    background: var(--bg-elevated);
}

.user-profile-popup-avatar {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.user-profile-popup-avatar img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--border);
    object-fit: cover;
}

.user-profile-popup-avatar-default {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4dd0e1, #26a69a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    color: #fff;
    border: 3px solid var(--border);
}

.user-profile-popup-info {
    text-align: center;
    margin-bottom: 20px;
}

.user-profile-popup-username {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.user-profile-popup-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}

.user-profile-popup-status.online {
    background: rgba(77, 205, 94, 0.15);
    color: var(--success);
}

.user-profile-popup-status.offline {
    background: rgba(122, 146, 176, 0.15);
    color: var(--text-muted);
}

.user-profile-popup-bio {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 16px;
}

.user-profile-popup-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.user-profile-popup-stat {
    padding: 12px;
    background: var(--bg-elevated);
    border-radius: 10px;
    border: 1px solid var(--border);
    text-align: center;
}

.user-profile-popup-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.user-profile-popup-stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

.user-profile-popup-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-profile-popup-btn {
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
}

.user-profile-popup-btn.primary {
    background: var(--accent);
    color: #fff;
}

.user-profile-popup-btn.primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.user-profile-popup-btn.secondary {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text);
}

.user-profile-popup-btn.secondary:hover {
    background: var(--bg-input);
}

/* ========================================
   Mobile Rail Toggle
   ======================================== */

.mobile-rail-toggle {
    display: none;
    padding: 8px 0;
    background: transparent;
    position: sticky;
    top: 0;
    z-index: 7;
}

.mobile-rail-toggle button {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    padding: 10px 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0,0,0,0.06);
}

.mobile-rail {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg);
    max-height: 60vh;
    overflow-y: auto;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 16px;
    top: calc(var(--chat-header-h) + 12px);
    z-index: 12;
    box-shadow: 0 18px 40px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.mobile-rail.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.mobile-rail-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(2px);
    z-index: 11;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.mobile-rail-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.chevron {
    color: var(--muted);
}

.mobile-rail-lock {
    overflow: hidden;
}

/* ========================================
   Emoji Picker Responsive
   ======================================== */

@media (max-width: 520px) {
    .emoji-popover {
        max-width: none;
        left: 8px;
        right: 8px;
        bottom: calc(var(--chat-mobile-ui-gap, 0px) + 78px);
    }
    .hiden-emoji-body {
        max-height: min(420px, 58vh);
    }
    .hiden-emoji-grid {
        grid-template-columns: repeat(9, 1fr);
    }
    .hiden-emoji-item {
        height: 44px;
        font-size: 34px;
    }
    .attach-sub {
        max-width: 160px;
    }
    .attach-thumb {
        width: 34px;
        height: 34px;
        border-radius: 10px;
    }
    .composer-emoji {
        font-size: 22px;
    }
}

/* ========================================
   Chat Image Overlay Responsive
   ======================================== */

@media (max-width: 900px) {
    .chat-image-overlay {
        padding: 12px;
    }
    .chat-image-modal {
        max-width: 96vw;
        max-height: 92vh;
    }
    .chat-image-modal img {
        max-height: 92vh;
        border-radius: 12px;
    }
    .chat-image-close {
        top: -8px;
        right: -8px;
    }
}

/* ========================================
   Mobile Styles (max-width: 900px)
   ======================================== */

@media (max-width: 900px) {
    html,
    body {
        height: 100dvh;
        overflow: hidden;
        overscroll-behavior: none;
    }

    body > *:not(.chat-page):not(.topbar):not(.layout):not(#userProfileOverlay):not(#chatImageOverlay):not(#chatInfoOverlay):not(#chatEmojiPopover):not(#authOverlayPrompt):not(.auth-overlay):not(#loginModal):not(#registerModal):not(.auth-modal):not(#verificationOverlay) {
        display: none !important;
    }

    /* Мобильные стили для оверлея информации */
    #chatInfoOverlay {
        z-index: 99999 !important;
        padding: 12px;
        align-items: flex-start;
        padding-top: 8vh;
    }

    #chatInfoOverlay .chat-info-modal {
        max-width: 100%;
        border-radius: 16px;
        max-height: 84vh;
    }

    #chatInfoOverlay .chat-info-header {
        padding: 16px 16px 0;
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    #chatInfoOverlay .chat-info-header h2 {
        font-size: 18px;
    }

    #chatInfoOverlay .chat-info-icon {
        font-size: 32px;
    }

    #chatInfoOverlay .chat-info-body {
        padding: 14px 16px;
    }

    #chatInfoOverlay .chat-info-body p {
        font-size: 13px;
        line-height: 1.6;
        margin-bottom: 10px;
    }

    #chatInfoOverlay .chat-info-rules {
        font-size: 12px !important;
        padding: 10px 12px !important;
    }

    #chatInfoOverlay .chat-info-divider {
        margin: 12px 0;
    }

    #chatInfoOverlay .chat-info-ok {
        width: calc(100% - 32px);
        margin: 0 16px 16px;
        padding: 14px 20px;
        font-size: 16px;
    }

    .layout {
        position: fixed;
        inset: 0;
        z-index: 25;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        display: grid;
        background: rgba(0, 0, 0, 0.8);
    }

    body.chat-sidebar-visible > .layout {
        opacity: 1;
        pointer-events: auto;
    }

    .chat-page {
        padding: 0;
        margin: 0;
        background: var(--bg);
        overflow-x: hidden;
        padding-bottom: 8px;
        position: fixed;
        top: var(--chat-topbar-height, 64px);
        left: 0;
        right: 0;
        height: calc(100dvh - var(--chat-topbar-height, 64px));
        display: flex;
        flex-direction: column;
        z-index: 15;
        width: 100%;
    }

    .chat-shell {
        max-width: 100%;
        width: 100%;
        gap: 0;
        padding: 0;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 100%;
        height: 100%;
        max-height: none;
    }

    .topbar.chat-fixed-topbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 20;
        width: 100%;
        padding: 12px 16px;
        background: rgba(15,18,24,0.95);
        border-bottom: 1px solid rgba(255,255,255,0.08);
        box-shadow: 0 4px 20px rgba(0,0,0,0.25);
        backdrop-filter: blur(15px);
    }

    .chat-top {
        position: relative;
        z-index: 1;
        background: var(--card);
        border-bottom: 1px solid var(--border);
        border-radius: 0;
        margin: 0;
        padding: 10px 12px;
        flex-shrink: 0;
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        gap: 12px;
    }

    .chat-top .chat-title {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
    }

    .chat-top .chat-title .label {
        font-size: 15px;
        font-weight: 700;
    }

    .chat-top .chat-title .muted {
        font-size: 12px;
        color: var(--muted);
    }

    .chat-top .chat-actions {
        display: none !important;
    }

    .chat-top .dot-live {
        width: 10px;
        height: 10px;
        flex-shrink: 0;
    }

    .chat-top .mobile-online-btn {
        background: var(--bg-elevated) !important;
        border: 1px solid var(--border) !important;
        border-radius: 10px !important;
        padding: 8px 10px !important;
        font-size: 12px !important;
        white-space: nowrap !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px !important;
        height: auto !important;
        width: auto !important;
        cursor: pointer !important;
        color: var(--text) !important;
        flex-shrink: 0;
    }

    .chat-top .mobile-online-btn:active {
        background: var(--bg) !important;
    }

    .chat-top .mobile-online-btn span:first-child {
        display: none;
    }

    .chat-top .mobile-online-btn .pill {
        padding: 2px 6px;
        border-radius: 999px;
        background: rgba(77,205,94,0.15);
        color: var(--success);
        font-size: 11px;
        font-weight: 700;
        margin: 0;
        display: inline-block !important;
    }

    .chat-top .mobile-online-btn .chevron {
        font-size: 14px;
        margin: 0;
        display: inline-block !important;
    }

    .chat-body {
        grid-template-columns: 1fr;
        min-height: 0;
        height: 100%;
        width: 100%;
        box-sizing: border-box;
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 0;
        max-height: none;
        padding-bottom: 92px;
    }

    .chat-rail {
        display: none;
    }

    .chat-panel {
        order: 1;
        height: 100%;
        border-radius: 0;
        width: 100%;
        border: none;
        box-shadow: none;
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
    }

    .bubble {
        max-width: 85%;
        word-wrap: break-word;
    }

    .mobile-rail-toggle {
        display: none;
        align-items: center;
        padding: 8px 12px;
        background: transparent;
        position: sticky;
        top: 0;
        z-index: 8;
        flex-shrink: 0;
        gap: 0;
    }

    .mobile-rail-toggle button {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: var(--bg-elevated);
        border: 1px solid var(--border);
        border-radius: 10px;
        color: var(--text);
        padding: 8px 12px;
        font-weight: 600;
        font-size: 13px;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        transition: all 0.2s ease;
    }

    .mobile-rail-toggle button:active {
        background: var(--bg);
    }

    /* Переместим кнопку онлайн в header */
    .chat-top::after {
        content: '';
        position: absolute;
        right: 12px;
        top: 50%;
        transform: translateY(-50%);
        width: auto;
    }

    .messages {
        padding: 12px 12px;
        gap: 8px;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

    .chat-panel {
        padding-bottom: 0;
    }

    .composer {
        padding: 10px 12px 10px;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
        background: var(--card);
        border-top: 1px solid var(--border);
        box-shadow: 0 -10px 30px rgba(0,0,0,0.35);
        flex-shrink: 0;
        z-index: 30;
    }

    .composer-box {
        padding: 12px 16px;
        border-radius: 18px;
        background: var(--card);
        border: 1px solid var(--border);
        min-height: 54px;
    }

    .composer-input {
        min-height: 62px;
        max-height: 150px;
        font-size: 15px;
        line-height: 1.65;
    }

    .composer-send {
        height: 40px;
        width: 40px;
        border-radius: 50%;
        box-shadow: 0 6px 16px rgba(77, 208, 225, 0.2);
    }

    .composer-attach,
    .composer-emoji {
        height: 40px;
        width: 40px;
        border-radius: 50%;
    }

    .composer-send:hover:not(:disabled) {
        transform: translateY(-1px);
        box-shadow: 0 8px 20px rgba(77, 208, 225, 0.28);
    }

    .composer-send:active:not(:disabled) {
        transform: translateY(0);
    }

    .composer-send svg {
        width: 18px;
        height: 18px;
    }

    .composer-meta {
        font-size: 11px;
        gap: 4px;
    }

    .hint {
        display: none;
    }

    .mobile-rail {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        top: var(--chat-topbar-height, 64px);
        bottom: 0;
        width: 100%;
        height: calc(100% - var(--chat-topbar-height, 64px));
        max-height: none;
        margin-top: 0;
        background: var(--bg);
        z-index: 18;
        border: none;
        border-radius: 0;
        box-shadow: none;
        flex-direction: column;
        overflow-y: auto;
        overscroll-behavior: contain;
        transform: translateX(100%);
        opacity: 1;
        pointer-events: auto;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mobile-rail.open {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-rail .rail-header {
        padding: 14px 12px;
        position: sticky;
        top: 0;
        background: var(--card);
        z-index: 13;
        border-bottom: 1px solid var(--border);
        margin: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .mobile-rail .rail-header::after {
        content: '✕';
        cursor: pointer;
        font-size: 20px;
        color: var(--text);
        margin-left: auto;
        padding: 4px 8px;
    }

    .mobile-rail .rail-list {
        padding: 0;
        gap: 2px;
    }

    .mobile-rail .rail-empty {
        padding: 40px 16px;
    }

    .mobile-rail-backdrop {
        display: block !important;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        backdrop-filter: blur(2px);
        z-index: 11;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .mobile-rail-backdrop.active {
        opacity: 1;
        pointer-events: auto;
    }

    .message {
        gap: 6px;
    }

    .message-avatar,
    .message-avatar-default {
        width: 28px;
        height: 28px;
    }

    .online-user-item {
        padding: 10px 12px;
    }

    .online-user-avatar,
    .online-user-avatar-default {
        width: 40px;
        height: 40px;
    }

    .chevron {
        transition: transform 0.3s ease;
        display: inline-block;
    }

    .mobile-rail-toggle button[aria-expanded="true"] .chevron {
        transform: rotate(180deg);
    }

    /* Показываем кнопку в header на мобилке */
    .chat-top .mobile-online-btn {
        display: flex !important;
        align-items: center;
        gap: 6px;
        padding: 6px 10px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--card);
        cursor: pointer;
        font-size: 13px;
        font-weight: 500;
        color: var(--text);
        transition: all 0.2s ease;
    }

    .chat-top .mobile-online-btn .pill {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 18px;
        padding: 2px 5px;
        border-radius: 10px;
        background: linear-gradient(135deg, #4dd0e1, #26a69a);
        color: #0a0c10;
        font-size: 11px;
        font-weight: 700;
    }

    .chat-top .mobile-online-btn .chevron {
        font-size: 16px;
        line-height: 1;
    }

    .chat-top .mobile-online-btn:active {
        transform: scale(0.98);
    }
}

/* ========================================
   Small Mobile Styles (max-width: 480px)
   ======================================== */

@media (max-width: 480px) {
    .chat-top {
        padding: 8px 10px;
    }

    .chat-top .chat-title {
        gap: 6px;
    }

    .chat-top .dot-live {
        width: 10px;
        height: 10px;
    }

    .chat-top .label {
        font-size: 14px;
    }

    .bubble {
        max-width: 90%;
        font-size: 13px;
        padding: 8px 10px;
    }

    .message-avatar,
    .message-avatar-default {
        width: 26px;
        height: 26px;
    }

    .messages {
        padding: 8px 8px;
        gap: 6px;
    }

    .meta {
        font-size: 11px;
    }

    .composer {
        padding: 6px 8px 8px;
        gap: 4px;
    }

    .composer-send {
        width: 36px;
        height: 36px;
    }

    .composer-send svg {
        width: 16px;
        height: 16px;
    }

    .char-count {
        display: none;
    }

    .composer-box {
        padding: 6px 8px;
    }

    .composer-input {
        min-height: 30px;
        font-size: 13px;
    }

    /* Мобильные стили для оверлея */
    .chat-info-overlay {
        padding: 12px;
        align-items: flex-start;
        padding-top: 10vh;
    }

    .chat-info-modal {
        max-width: 100%;
        border-radius: 16px;
        max-height: 80vh;
    }

    .chat-info-header {
        padding: 16px 16px 0;
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .chat-info-header h2 {
        font-size: 18px;
    }

    .chat-info-icon {
        font-size: 32px;
    }

    .chat-info-body {
        padding: 14px 16px;
    }

    .chat-info-body p {
        font-size: 13px;
        line-height: 1.6;
        margin-bottom: 10px;
    }

    .chat-info-rules {
        font-size: 12px !important;
        padding: 10px 12px !important;
    }

    .chat-info-divider {
        margin: 12px 0;
    }

    .chat-info-ok {
        width: calc(100% - 32px);
        margin: 0 16px 16px;
        padding: 14px 20px;
        font-size: 16px;
    }
}

/* ========================================
   Hide chat actions text on small screens
   ======================================== */

@media (max-width: 600px) {
    .chat-actions .muted {
        display: none;
    }
}
