/* ============================================
   RIGHT SIDEBAR — CHAT  (redesigned)
   Overrides main.css positioning completely
   ============================================ */

/* ── Core positioning — override main.css ── */
.right-sidebar {
    position: fixed !important;
    right: 0 !important;
    top: 60px !important;
    bottom: 0 !important;
    width: 320px !important;
    height: auto !important;
    transform: translateX(100%) !important;
    transition: transform 0.32s cubic-bezier(0.4,0,0.2,1),
                box-shadow 0.32s ease !important;
    /* Visual */
    background: linear-gradient(180deg, rgba(10,9,21,0.98) 0%, rgba(13,12,24,0.99) 100%) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid rgba(200,168,75,0.1) !important;
    z-index: 1010 !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Both the #btnchat toggle (.slideIn) and mobile menu toggle (.opened) show the sidebar */
.right-sidebar.slideIn,
.right-sidebar.opened {
    transform: translateX(0) !important;
    box-shadow: -6px 0 40px rgba(0,0,0,0.6);
}

.right-sidebar.slideOut {
    transform: translateX(100%) !important;
    box-shadow: none;
}

/* ── Toggle tab ── */
#btnchat {
    position: absolute !important;
    left: -36px !important;
    top: 50% !important;
    right: auto !important;
    transform: translateY(-50%) !important;
    width: 36px;
    height: 56px;
    background: linear-gradient(180deg, rgba(10,9,21,0.96) 0%, rgba(13,12,24,0.97) 100%);
    border: 1px solid rgba(200,168,75,0.12) !important;
    border-right: none !important;
    border-radius: 10px 0 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
    z-index: 1;
}
#btnchat:hover { background: rgba(200,168,75,0.08) !important; }
#btnchat svg {
    width: 18px;
    height: 18px;
    fill: rgba(200,168,75,0.6);
    transition: transform 0.3s ease, fill 0.2s ease;
}
#btnchat:hover svg { fill: #d4af37; }
.right-sidebar.slideIn #btnchat svg { transform: rotate(180deg); }

/* ── Inner container ── */
.right-sidebar .sidebar-container {
    flex: 1;
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    overflow: hidden !important;
    padding-bottom: 0 !important;
}

/* ── Tabs ── */
.right-sidebar .tab { display: none; flex-direction: column; height: 100%; overflow: hidden; }
.right-sidebar .tab.current { display: flex; }

/* ── Header ── */
.chat-params {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0 14px !important;
    height: 52px !important;
    flex-shrink: 0 !important;
    border-bottom: 1px solid rgba(255,255,255,0.05) !important;
    background: rgba(255,255,255,0.02) !important;
    margin-top: 0 !important;
}
.chat-params .item { display: flex; align-items: center; gap: 6px; }

/* Online indicator */
.point-online {
    width: 7px;
    height: 7px;
    background: #c8a84b;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(200,168,75,0.6);
    animation: chat-pulse 2.5s infinite;
    flex-shrink: 0;
}
@keyframes chat-pulse {
    0%, 100% { box-shadow: 0 0 6px rgba(200,168,75,0.55); }
    50%       { box-shadow: 0 0 3px rgba(200,168,75,0.25); }
}
.chat-online {
    font-size: 12px;
    color: rgba(255,255,255,0.35);
    font-weight: 500;
}
.chat-online span { color: #c8a84b; font-weight: 700; }

/* Header icon buttons */
.toggle-btn, .banned-btn, .clear-btn, .share-btn, .close-btn {
    width: 30px !important;
    height: 30px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    border: none !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: background 0.18s ease !important;
    padding: 0 !important;
    flex-shrink: 0;
}
.toggle-btn:hover, .banned-btn:hover, .clear-btn:hover,
.share-btn:hover { background: rgba(255,255,255,0.06) !important; }
.close-btn:hover  { background: rgba(255,255,255,0.06) !important; }

.toggle-btn .icon, .banned-btn .icon, .clear-btn .icon,
.share-btn .icon, .close-btn .icon {
    width: 15px;
    height: 15px;
    fill: rgba(255,255,255,0.35) !important;
    transition: fill 0.18s ease;
}
.toggle-btn:hover .icon, .banned-btn:hover .icon,
.clear-btn:hover .icon, .share-btn:hover .icon { fill: #d4af37 !important; }
.close-btn:hover .icon { fill: rgba(255,255,255,0.75) !important; }

/* ── Message list ── */
.chat-conversation {
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden;
    padding: 6px 0 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(200,168,75,0.15) transparent;
}
.chat-conversation::-webkit-scrollbar { width: 2px; }
.chat-conversation::-webkit-scrollbar-track { background: transparent; }
.chat-conversation::-webkit-scrollbar-thumb {
    background: rgba(200,168,75,0.2);
    border-radius: 2px;
}

.chat-conversation-inner {
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
}

/* ── Single message ── */
.message-block {
    display: flex !important;
    gap: 8px !important;
    padding: 5px 12px !important;
    background: transparent !important;
    border-radius: 0 !important;
    transition: background 0.1s ease;
    position: relative;
    align-items: center !important;
}
.message-block:hover { background: rgba(255,255,255,0.025) !important; }

/* Avatar */
.message-avatar {
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    overflow: hidden;
    flex-shrink: 0 !important;
    border: 1.5px solid rgba(255,255,255,0.06) !important;
    margin-top: 0;
    align-self: center !important;
}
.message-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.message-avatar.isAdmin     { border-color: rgba(239,68,68,0.55) !important; }
.message-avatar.isModerator { border-color: rgba(34,197,94,0.55) !important; }

/* Content */
.message-content {
    flex: 1;
    min-width: 0;
}

/* Name row */
.user-link {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    max-width: 100%;
    line-height: 1;
    margin-bottom: 2px;
    vertical-align: middle;
}

.sanitize-name {
    font-size: 11.5px !important;
    font-weight: 700 !important;
    color: #b8943e !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
    display: inline-flex !important;
    align-items: center !important;
    gap: 3px;
    letter-spacing: 0.1px;
    transition: color 0.12s ease;
    line-height: 1;
}
.sanitize-text {
    display: inline-flex !important;
    align-items: center !important;
    gap: 3px;
    line-height: 1;
}
.user-link:hover .sanitize-name { color: #d4af37 !important; }

/* Badges */
.admin-badge {
    display: inline-flex !important;
    align-items: center !important;
    gap: 2px;
    padding: 1px 4px !important;
    border-radius: 3px !important;
    font-size: 8.5px !important;
    font-weight: 800 !important;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    flex-shrink: 0;
    line-height: 1.4;
}
.admin-badge.isAdmin    { background: rgba(239,68,68,0.12); color: #f87171; border: 1px solid rgba(239,68,68,0.25); }
.admin-badge.isModerator{ background: rgba(130,100,255,0.14); color: #a78bfa; border: 1px solid rgba(130,100,255,0.28); }
.admin-badge.isYouTuber { background: rgba(239,68,68,0.12); color: #f87171; border: 1px solid rgba(239,68,68,0.25); }
.admin-badge .icon { width: 9px; height: 9px; fill: currentColor; flex-shrink: 0; }

/* Message text */
.message-text {
    color: rgba(255,255,255,0.72) !important;
    font-size: 12.5px !important;
    line-height: 1.45 !important;
    margin-top: 0 !important;
    word-break: break-word;
    overflow-wrap: anywhere;
    max-width: 100%;
}
/* Highlight links in chat */
.message-text a { color: rgba(200,168,75,0.8); text-decoration: none; }
.message-text a:hover { color: #d4af37; text-decoration: underline; }

/* ── Mod actions (shown on hover, float to the right) ── */
.delete {
    display: none;
    position: absolute;
    top: 4px;
    right: 8px;
    gap: 3px;
    background: rgba(10,9,20,0.92);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 8px;
    padding: 3px 5px;
    backdrop-filter: blur(8px);
    z-index: 10;
}
.message-block:hover .delete { display: flex; }
.delete .btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 7px;
    font-size: 10px;
    font-weight: 600;
    background: transparent !important;
    border: none !important;
    color: rgba(255,255,255,0.4) !important;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.12s ease;
    font-family: inherit;
}
.delete .btn:hover {
    background: rgba(239,68,68,0.12) !important;
    color: #f87171 !important;
}
.delete .icon { width: 9px; height: 9px; fill: currentColor; }

/* ── Chat input (injected by JS) ── */
.chat-message-input {
    flex-shrink: 0 !important;
    padding: 10px 12px !important;
    border-top: 1px solid rgba(255,255,255,0.05) !important;
    background: rgba(255,255,255,0.015) !important;
    display: flex !important;
    align-items: flex-end !important;
    gap: 8px !important;
}

.chat-textarea {
    flex: 1 !important;
    min-height: 38px;
    max-height: 96px;
    background: rgba(255,255,255,0.05) !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    border-radius: 12px !important;
    padding: 9px 12px !important;
    overflow-y: auto;
    scrollbar-width: none;
    transition: border-color 0.2s ease, background 0.2s ease;
}
.chat-textarea::-webkit-scrollbar { display: none; }
.chat-textarea:focus-within {
    border-color: rgba(200,168,75,0.4) !important;
    background: rgba(255,255,255,0.07) !important;
}

.chat-editable {
    color: rgba(255,255,255,0.85) !important;
    font-size: 13px !important;
    font-family: inherit !important;
    line-height: 1.5;
    outline: none;
    min-height: 20px;
    word-break: break-word;
}
.chat-editable:empty::before {
    content: "Написать сообщение…";
    color: rgba(255,255,255,0.22);
    pointer-events: none;
}

.chat-controls {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    flex-shrink: 0;
}
.chat-controls .item {
    width: 36px !important;
    height: 36px !important;
    border-radius: 10px !important;
    border: none !important;
    background: rgba(255,255,255,0.05) !important;
    cursor: pointer;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.18s ease;
    padding: 0 !important;
    flex-shrink: 0;
}
.chat-controls .item:hover { background: rgba(255,255,255,0.09) !important; }
.chat-controls .item .icon {
    width: 16px;
    height: 16px;
    fill: rgba(255,255,255,0.38);
    transition: fill 0.18s ease;
}
.chat-controls .item:hover .icon { fill: rgba(255,255,255,0.7); }

.chat-controls .sendMessage {
    background: linear-gradient(135deg, #c8a84b 0%, #e8c86a 100%) !important;
    box-shadow: 0 2px 10px rgba(200,168,75,0.25);
}
.chat-controls .sendMessage:hover {
    background: linear-gradient(135deg, #d4b855 0%, #f0d070 100%) !important;
    box-shadow: 0 4px 16px rgba(200,168,75,0.4);
}
.chat-controls .sendMessage .icon,
.chat-controls .sendMessage:hover .icon { fill: #120f1e; }

/* ── Empty / ban ── */
.chat-empty-block {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    text-align: center;
    color: rgba(255,255,255,0.28);
    font-size: 13px;
    line-height: 1.5;
}
.chat-ban-block {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.chat-ban-block .title {
    color: #f87171 !important;
    font-size: 13px;
    font-weight: 600;
}

/* ── User profile tab ── */
.right-sidebar .user-profile {
    padding: 16px !important;
    overflow-y: auto;
    margin-top: 0 !important;
    height: 100% !important;
}

.user-block {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 16px 0 20px !important;
    margin-top: 0 !important;
}
.user-avatar { position: relative; display: flex; justify-content: center; }
.user-avatar .close-btn { position: absolute; top: 0; right: 0; }

.user-block .avatar {
    width: 68px !important;
    height: 68px !important;
    border-radius: 50% !important;
    overflow: hidden;
    border: 2px solid rgba(200,168,75,0.3) !important;
}
.user-block .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.user-name .nickname {
    font-size: 15px !important;
    font-weight: 700 !important;
    color: #d4af37 !important;
    text-align: center;
}

.profile-nav {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 0 12px !important;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.profile-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 13px !important;
    background: rgba(255,255,255,0.04) !important;
    border: 1px solid rgba(255,255,255,0.06) !important;
    border-radius: 11px !important;
    color: rgba(255,255,255,0.65) !important;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.profile-nav a:hover {
    background: rgba(200,168,75,0.08) !important;
    border-color: rgba(200,168,75,0.22) !important;
    color: #e8c86a !important;
}
.profile-nav .item-icon .icon,
.profile-nav .icon { width: 15px; height: 15px; fill: rgba(255,255,255,0.38); }
.profile-nav a:hover .icon { fill: #d4af37; }

.btn-logout {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px;
    padding: 10px 13px !important;
    background: rgba(239,68,68,0.07) !important;
    border: 1px solid rgba(239,68,68,0.18) !important;
    border-radius: 11px !important;
    color: #f87171 !important;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.18s ease, border-color 0.18s ease;
    margin-top: auto;
}
.btn-logout:hover {
    background: rgba(239,68,68,0.13) !important;
    border-color: rgba(239,68,68,0.35) !important;
    color: #fca5a5 !important;
}
.btn-logout .item-icon .icon,
.btn-logout .icon { width: 14px; height: 14px; fill: currentColor; }

/* ── Mobile ── */
@media (max-width: 820px) {
    .right-sidebar {
        width: 100% !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        border-left: none !important;
    }
    #btnchat { display: none !important; }
    .message-block:hover .delete { display: none; }
}
