/* ============================================================
   Chat System - Responsive, Dark-themed UI
   ============================================================ */

:root {
    --chat-bg: #0f1923;
    --chat-sidebar-bg: #162029;
    --chat-header-bg: #1a2733;
    --chat-input-bg: #1a2733;
    --chat-msg-bg: #1e2d3d;
    --chat-msg-own: #1a3a50;
    --chat-text: #e0e6ed;
    --chat-text-muted: #8899aa;
    --chat-border: #243447;
    --chat-primary: #4f8cff;
    --chat-success: #4caf50;
    --chat-danger: #ef5350;
    --chat-warning: #ff9800;
    --role-admin: #ef5350;
    --role-editor: #4f8cff;
    --role-member: #4caf50;
    --role-guest: #8899aa;
    --chat-radius: 12px;
    --chat-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── Layout ─────────────────────────────────────────────── */
.chat-container {
    display: flex;
    height: calc(100vh - 80px);
    max-height: 700px;
    background: var(--chat-bg);
    border-radius: var(--chat-radius);
    overflow: hidden;
    border: 1px solid var(--chat-border);
    font-family: var(--chat-font);
    font-size: 14px;
    color: var(--chat-text);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* ── Main Chat Panel (left) ─────────────────────────────── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--chat-header-bg);
    border-bottom: 1px solid var(--chat-border);
    flex-shrink: 0;
}

.chat-header-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header-title .status-dot {
    width: 8px;
    height: 8px;
    background: var(--chat-success);
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.chat-header-actions {
    display: flex;
    gap: 8px;
}

.chat-header-actions button {
    background: none;
    border: 1px solid var(--chat-border);
    color: var(--chat-text-muted);
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.chat-header-actions button:hover {
    background: var(--chat-msg-bg);
    color: var(--chat-text);
}

/* ── Pinned Message Bar ──────────────────────────────── */
.chat-pinned {
    display: none;
    padding: 10px 20px;
    background: linear-gradient(90deg, rgba(79, 140, 255, 0.15), rgba(79, 140, 255, 0.05));
    border-bottom: 2px solid var(--chat-primary);
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.3s;
}

.chat-pinned:hover {
    background: rgba(79, 140, 255, 0.2);
}

.chat-pinned.visible {
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slide-down 0.3s ease-out;
}

@keyframes slide-down {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.chat-pinned .pinned-icon {
    font-size: 16px;
    color: var(--chat-primary);
    animation: pin-pulse 2s infinite;
}

@keyframes pin-pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.chat-pinned .pinned-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    font-weight: 500;
}

.chat-pinned .pinned-close {
    background: none;
    border: none;
    color: var(--chat-text-muted);
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-pinned .pinned-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--chat-danger);
}

/* ── Messages Area ──────────────────────────────────── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--chat-border) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--chat-border);
    border-radius: 3px;
}

.chat-load-more {
    text-align: center;
    padding: 8px;
}

.chat-load-more button {
    background: var(--chat-msg-bg);
    border: 1px solid var(--chat-border);
    color: var(--chat-text-muted);
    padding: 6px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.chat-load-more button:hover {
    background: var(--chat-primary);
    color: white;
    border-color: var(--chat-primary);
}

/* ── Single Message ──────────────────────────────────── */
.chat-message {
    display: flex;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    position: relative;
    transition: background 0.15s;
    animation: msg-in 0.25s ease-out;
}

@keyframes msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message:hover {
    background: rgba(255, 255, 255, 0.03);
}

.chat-message:hover .msg-actions {
    opacity: 1;
}

.chat-message.own-message {
    background: var(--chat-msg-own);
    border-radius: 8px;
}

.chat-message.system-message {
    justify-content: center;
    color: var(--chat-text-muted);
    font-size: 12px;
    padding: 4px;
    gap: 0;
}

.chat-message.system-message .msg-avatar,
.chat-message.system-message .msg-actions {
    display: none;
}

.msg-avatar {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--chat-msg-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: var(--chat-text-muted);
}

.msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msg-body {
    flex: 1;
    min-width: 0;
}

.msg-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.msg-username {
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}

.msg-username.role-admin {
    color: var(--role-admin);
    font-weight: 700;
}

.msg-username.role-editor {
    color: var(--role-editor);
}

.msg-username.role-member {
    color: var(--role-member);
}

.msg-username.role-guest {
    color: var(--role-guest);
}

.msg-role-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.msg-role-badge.badge-admin {
    background: rgba(239, 83, 80, 0.2);
    color: var(--role-admin);
}

.msg-role-badge.badge-editor {
    background: rgba(79, 140, 255, 0.2);
    color: var(--role-editor);
}

.msg-role-badge.badge-member {
    background: rgba(76, 175, 80, 0.2);
    color: var(--role-member);
}

.msg-role-badge.badge-guest {
    background: rgba(136, 153, 170, 0.15);
    color: var(--role-guest);
}

.msg-time {
    font-size: 11px;
    color: var(--chat-text-muted);
}

.msg-edited {
    font-size: 10px;
    color: var(--chat-text-muted);
    font-style: italic;
}

.msg-content {
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.msg-content a {
    color: var(--chat-primary);
    text-decoration: none;
}

.msg-content a:hover {
    text-decoration: underline;
}

.msg-reply-ref {
    background: rgba(79, 140, 255, 0.08);
    border-left: 3px solid var(--chat-primary);
    padding: 4px 8px;
    margin-bottom: 4px;
    border-radius: 0 6px 6px 0;
    font-size: 12px;
    color: var(--chat-text-muted);
    cursor: pointer;
}

/* ── Message Hover Actions ──────────────────────────── */
.msg-actions {
    position: absolute;
    top: 4px;
    right: 8px;
    opacity: 0;
    display: flex;
    gap: 2px;
    background: var(--chat-header-bg);
    border: 1px solid var(--chat-border);
    border-radius: 6px;
    padding: 2px;
    transition: opacity 0.15s;
}

.msg-actions button {
    background: none;
    border: none;
    color: var(--chat-text-muted);
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    transition: all 0.15s;
}

.msg-actions button:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--chat-text);
}

.msg-actions button.action-danger:hover {
    color: var(--chat-danger);
}

/* ── Translation Toggle ─────────────────────────────── */
.msg-translate-toggle {
    display: inline-block;
    background: none;
    border: 1px solid rgba(79, 140, 255, 0.3);
    color: var(--chat-primary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    cursor: pointer;
    margin-top: 3px;
    transition: all 0.2s;
    font-family: var(--chat-font);
}

.msg-translate-toggle:hover {
    background: rgba(79, 140, 255, 0.1);
    border-color: var(--chat-primary);
}

/* ── Auto-Translate Toggle Button ──────────────────── */
.auto-translate-toggle {
    position: relative;
    display: flex !important;
    align-items: center;
    gap: 4px;
    font-size: 13px;
}

.auto-translate-toggle.active {
    background: rgba(76, 175, 80, 0.15) !important;
    border-color: var(--chat-success) !important;
    color: var(--chat-success) !important;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.2);
}

.auto-translate-toggle.active::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 6px;
    height: 6px;
    background: var(--chat-success);
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

.msg-translate-toggle i {
    font-size: 10px;
    margin-right: 2px;
}

/* ── Input Area ──────────────────────────────────────── */
.chat-input-area {
    padding: 12px 20px;
    background: var(--chat-input-bg);
    border-top: 1px solid var(--chat-border);
    flex-shrink: 0;
}

/* ── Emoji Picker Button ─────────────────────────────── */
.chat-emoji-btn {
    background: none;
    border: none;
    color: var(--chat-text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-emoji-btn:hover {
    color: var(--chat-primary);
    background: rgba(79, 140, 255, 0.1);
}

/* ── Emoji Picker Popup ──────────────────────────────── */
.emoji-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 320px;
    max-height: 360px;
    background: var(--chat-header-bg);
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: none;
    flex-direction: column;
    z-index: 1000;
    margin-bottom: 8px;
    overflow: hidden;
}

.emoji-picker.visible {
    display: flex;
    animation: emoji-fade-in 0.15s ease-out;
}

@keyframes emoji-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.emoji-picker-search {
    padding: 8px 10px;
    border-bottom: 1px solid var(--chat-border);
}

.emoji-picker-search input {
    width: 100%;
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    color: var(--chat-text);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
}

.emoji-picker-search input:focus {
    border-color: var(--chat-primary);
}

.emoji-picker-categories {
    display: flex;
    gap: 2px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--chat-border);
    overflow-x: auto;
    scrollbar-width: none;
}

.emoji-picker-categories::-webkit-scrollbar {
    display: none;
}

.emoji-cat-btn {
    background: none;
    border: none;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: var(--chat-text-muted);
    white-space: nowrap;
    transition: all 0.15s;
    font-family: var(--chat-font);
}

.emoji-cat-btn:hover {
    background: rgba(255, 255, 255, 0.06);
}

.emoji-cat-btn.active {
    background: rgba(79, 140, 255, 0.15);
    color: var(--chat-primary);
}

.emoji-picker-grid {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    scrollbar-width: thin;
    scrollbar-color: var(--chat-border) transparent;
    max-height: 260px;
}

.emoji-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    font-size: 22px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.1s;
    border: none;
    background: none;
    padding: 0;
}

.emoji-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: scale(1.2);
}

/* ── Sound Toggle Button ─────────────────────────────── */
.chat-sound-btn {
    background: none;
    border: none;
    color: var(--chat-text-muted);
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.chat-sound-btn:hover {
    background: var(--chat-msg-bg);
    color: var(--chat-text);
}

.chat-sound-btn.muted {
    color: var(--chat-danger);
}

.chat-reply-preview {
    display: none;
    padding: 6px 10px;
    margin-bottom: 8px;
    background: rgba(79, 140, 255, 0.08);
    border-left: 3px solid var(--chat-primary);
    border-radius: 0 6px 6px 0;
    font-size: 12px;
    color: var(--chat-text-muted);
    align-items: center;
    justify-content: space-between;
}

.chat-reply-preview.visible {
    display: flex;
}

.chat-reply-preview .cancel-reply {
    background: none;
    border: none;
    color: var(--chat-text-muted);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 14px;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.chat-input-wrapper textarea {
    flex: 1;
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    color: var(--chat-text);
    padding: 10px 14px;
    border-radius: 20px;
    font-family: var(--chat-font);
    font-size: 14px;
    resize: none;
    max-height: 120px;
    min-height: 40px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-wrapper textarea:focus {
    border-color: var(--chat-primary);
}

.chat-input-wrapper textarea::placeholder {
    color: var(--chat-text-muted);
}

.chat-send-btn {
    background: var(--chat-primary);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    flex-shrink: 0;
    transition: all 0.2s;
}

.chat-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(79, 140, 255, 0.4);
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.chat-login-prompt {
    display: none;
    padding: 12px 20px;
    text-align: center;
    color: var(--chat-text-muted);
    font-size: 13px;
    background: var(--chat-input-bg);
    border-top: 1px solid var(--chat-border);
}

.chat-login-prompt a {
    color: var(--chat-primary);
    font-weight: 600;
    text-decoration: none;
}

.chat-login-prompt a:hover {
    text-decoration: underline;
}

/* ── Sidebar (right) ────────────────────────────────── */
.chat-sidebar {
    width: 240px;
    background: var(--chat-sidebar-bg);
    border-left: 1px solid var(--chat-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.chat-sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--chat-border);
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-sidebar-header .online-count {
    background: var(--chat-primary);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.chat-user-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-user-group-label {
    padding: 6px 8px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--chat-text-muted);
    font-weight: 700;
}

.chat-user-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}

.chat-user-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.chat-user-item .user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--chat-msg-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--chat-text-muted);
    flex-shrink: 0;
    overflow: hidden;
}

.chat-user-item .user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-user-item .user-name {
    font-size: 13px;
    font-weight: 500;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-user-item .user-name.role-admin {
    color: var(--role-admin);
    font-weight: 700;
}

.chat-user-item .user-name.role-editor {
    color: var(--role-editor);
}

.chat-user-item .user-name.role-member {
    color: var(--role-member);
}

.chat-user-item .user-name.role-guest {
    color: var(--role-guest);
}

.chat-user-item .online-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chat-success);
    flex-shrink: 0;
}

.chat-user-item .online-indicator.offline {
    background: var(--chat-text-muted);
    opacity: 0.5;
}

/* ── Context Menu for User (Moderation) ────────────── */
.chat-user-context-menu {
    position: fixed;
    background: var(--chat-header-bg);
    border: 1px solid var(--chat-border);
    border-radius: 8px;
    padding: 4px;
    z-index: 10000;
    min-width: 160px;
    display: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.chat-user-context-menu.visible {
    display: block;
}

.chat-user-context-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: none;
    border: none;
    color: var(--chat-text);
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}

.chat-user-context-menu button:hover {
    background: rgba(255, 255, 255, 0.06);
}

.chat-user-context-menu button.danger {
    color: var(--chat-danger);
}

.chat-user-context-menu button.danger:hover {
    background: rgba(239, 83, 80, 0.12);
}

/* ── Room Status Alerts ─────────────────────────────── */
.chat-room-status {
    display: none;
    padding: 10px 20px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.chat-room-status.closed {
    display: block;
    background: rgba(239, 83, 80, 0.15);
    color: var(--chat-danger);
    border-bottom: 1px solid rgba(239, 83, 80, 0.2);
}

.chat-room-status.slow-mode {
    display: block;
    background: rgba(255, 152, 0, 0.12);
    color: var(--chat-warning);
    border-bottom: 1px solid rgba(255, 152, 0, 0.2);
}

.chat-room-status.admin-only {
    display: block;
    background: rgba(79, 140, 255, 0.12);
    color: var(--chat-primary);
    border-bottom: 1px solid rgba(79, 140, 255, 0.2);
}

/* ── Mobile Toggle ──────────────────────────────────── */
.chat-sidebar-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--chat-text);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
}

.chat-sidebar-toggle:active {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(0.95);
}

/* ── Mobile Responsive ──────────────────────────────── */
@media (max-width: 768px) {
    .chat-container {
        height: calc(100vh - 65px);
        /* Adjusted for typical mobile nav bar */
        max-height: none;
        border-radius: 0;
        border: none;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
    }

    .chat-header {
        padding: 12px 16px;
        background: var(--chat-header-bg);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        z-index: 10;
    }

    .chat-sidebar {
        position: fixed;
        top: 0;
        right: -280px;
        width: 280px;
        height: 100vh;
        z-index: 9999;
        transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.6);
        background: var(--chat-header-bg);
    }

    .chat-sidebar.open {
        right: 0;
    }

    .chat-sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .chat-sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(3px);
        z-index: 9998;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .chat-sidebar-overlay.visible {
        display: block;
        opacity: 1;
    }

    .chat-messages {
        padding: 16px 12px;
    }

    .chat-input-area {
        padding: 12px;
        background: var(--chat-bg);
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1);
    }

    .chat-input-row {
        gap: 8px;
    }

    .chat-input-row textarea {
        min-height: 44px;
        padding: 12px 16px;
        border-radius: 22px;
        font-size: 15px;
        /* Prevent iOS zoom */
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid rgba(255, 255, 255, 0.08);
    }

    .chat-input-row textarea:focus {
        background: rgba(255, 255, 255, 0.08);
        border-color: rgba(79, 140, 255, 0.3);
    }

    .chat-send-btn {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        font-size: 18px;
    }

    .msg-avatar {
        width: 32px;
        height: 32px;
    }

    .chat-message.own-message .msg-avatar {
        display: none;
        /* Often on mobile, own avatar is hidden to save space */
    }
}

/* ── Emoji Picker Toggle ────────────────────────────── */
.emoji-picker-btn {
    background: none;
    border: none;
    color: var(--chat-text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

.emoji-picker-btn:hover {
    color: var(--chat-text);
}

/* ── Typing Indicator ───────────────────────────────── */
.chat-typing {
    padding: 0 20px 4px;
    font-size: 12px;
    color: var(--chat-text-muted);
    min-height: 20px;
    flex-shrink: 0;
}

.chat-typing .typing-dots {
    display: inline-flex;
    gap: 3px;
    margin-left: 4px;
}

.chat-typing .typing-dots span {
    width: 4px;
    height: 4px;
    background: var(--chat-text-muted);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.chat-typing .typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing .typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ── Mute Duration Modal ────────────────────────────── */
.chat-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10001;
    display: none;
    align-items: center;
    justify-content: center;
}

.chat-modal-backdrop.visible {
    display: flex;
}

.chat-modal {
    background: var(--chat-header-bg);
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 360px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.chat-modal h4 {
    margin: 0 0 16px;
    font-size: 16px;
    color: var(--chat-text);
}

.chat-modal label {
    display: block;
    font-size: 13px;
    color: var(--chat-text-muted);
    margin-bottom: 6px;
}

.chat-modal select,
.chat-modal input,
.chat-modal textarea {
    width: 100%;
    background: var(--chat-bg);
    border: 1px solid var(--chat-border);
    color: var(--chat-text);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 12px;
    outline: none;
    font-family: var(--chat-font);
}

.chat-modal select:focus,
.chat-modal input:focus,
.chat-modal textarea:focus {
    border-color: var(--chat-primary);
}

.chat-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

.chat-modal-actions button {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.chat-modal-actions .btn-cancel {
    background: var(--chat-msg-bg);
    color: var(--chat-text-muted);
}

.chat-modal-actions .btn-confirm {
    background: var(--chat-primary);
    color: white;
}

.chat-modal-actions .btn-confirm:hover {
    box-shadow: 0 0 12px rgba(79, 140, 255, 0.4);
}

.chat-modal-actions .btn-confirm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--chat-border, #243447);
    box-shadow: none;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.form-check-input {
    width: 18px !important;
    height: 18px !important;
    max-width: 18px !important;
    max-height: 18px !important;
    cursor: pointer;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: contain !important;
    flex-shrink: 0 !important;
    appearance: checkbox !important;
    /* Force browser default or standard look */
    -webkit-appearance: checkbox !important;
    margin: 0 !important;
}

.form-check-label {
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: var(--chat-text-muted);
}

/* ─── Reactions ─── */
.msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.reaction-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 0.85rem;
    color: var(--text-color, #eee);
    cursor: pointer;
    transition: all 0.2s;
}

.reaction-badge:hover {
    background: rgba(255, 255, 255, 0.2);
}

.reaction-badge.active {
    background: rgba(13, 110, 253, 0.2);
    border-color: rgba(13, 110, 253, 0.5);
}

.reaction-count {
    font-size: 0.75rem;
    opacity: 0.8;
}

.reaction-trigger {
    background: transparent;
    border: none;
    color: var(--text-color, #eee);
    opacity: 0.5;
    cursor: pointer;
    transition: opacity 0.2s;
    font-size: 1rem;
    padding: 0 4px;
}

.reaction-trigger:hover {
    opacity: 1;
}

/* Inline Picker */
.inline-reaction-picker {
    background: var(--bg-color, #2a2a2a);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 5px 10px;
    display: flex;
    gap: 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.inline-reaction-picker button {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: transform 0.2s;
}

.inline-reaction-picker button:hover {
    transform: scale(1.2);
    background: rgba(255, 255, 255, 0.1);
}