/* BCMonster Community Chat — Royal Blue Theme */

#bcm-chat-widget {
    position: fixed !important;
    bottom: 20px;
    right: 20px !important;
    left: auto !important;
    width: 480px;
    max-width: calc(100vw - 40px);
    background: #1e293b;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.45), 0 0 0 1px rgba(65,105,225,0.15);
    z-index: 10001 !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    transition: box-shadow 0.25s ease, border-radius 0.3s;
    overflow: hidden;
}
#bcm-chat-widget.bcm-dragging {
    box-shadow: 0 16px 56px rgba(65,105,225,0.45), 0 0 0 1px rgba(65,105,225,0.3);
    cursor: grabbing !important;
}
#bcm-chat-widget.bcm-chat-minimized { width: 60px; height: 60px; border-radius: 50%; overflow: hidden; }
#bcm-chat-widget.bcm-chat-open { height: 520px; max-height: calc(100vh - 100px); display: flex; flex-direction: column; }

/* ── Header ── */
.bcm-chat-header {
    background: linear-gradient(135deg, #2c4fbd 0%, #4169E1 50%, #5a82f0 100%);
    color: white; padding: 12px 16px; display: flex; align-items: center;
    justify-content: space-between; cursor: grab; user-select: none;
    position: relative; overflow: hidden;
}
.bcm-chat-header::before {
    content: ''; position: absolute; inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='40' height='40' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='20' cy='20' r='1' fill='rgba(255,255,255,0.07)'/%3E%3C/svg%3E");
    pointer-events: none;
}
#bcm-chat-widget.bcm-chat-minimized .bcm-chat-header {
    padding: 0; width: 60px; height: 60px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; cursor: grab;
    box-shadow: 0 4px 16px rgba(65,105,225,0.4);
}
#bcm-chat-widget.bcm-dragging .bcm-chat-header { cursor: grabbing; }
#bcm-chat-widget.bcm-chat-minimized .bcm-chat-title span,
#bcm-chat-widget.bcm-chat-minimized .bcm-chat-controls,
#bcm-chat-widget.bcm-chat-minimized .bcm-drag-handle { display: none; }
#bcm-chat-widget.bcm-chat-minimized .bcm-chat-title { gap: 0; }
#bcm-chat-widget.bcm-chat-minimized .bcm-chat-title i.fa-comments { font-size: 1.8rem; }

.bcm-drag-handle { opacity: 0.5; margin-right: 4px; cursor: grab; font-size: 0.8rem; }
.bcm-chat-header:active .bcm-drag-handle { cursor: grabbing; }
.bcm-chat-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 0.95rem; position: relative; z-index: 1; }
.bcm-chat-title i { font-size: 1.1rem; }

.bcm-chat-badge {
    display: none; background: #ef4444; color: white;
    font-size: 0.65rem; font-weight: 700; padding: 2px 6px;
    border-radius: 10px; min-width: 18px; text-align: center;
    box-shadow: 0 2px 6px rgba(239,68,68,0.4);
}
#bcm-chat-widget.bcm-chat-minimized .bcm-chat-badge { position: absolute; top: 2px; right: 2px; padding: 3px 6px; font-size: 0.6rem; }
.bcm-chat-controls { display: flex; gap: 4px; position: relative; z-index: 1; }
.bcm-chat-btn {
    background: rgba(255,255,255,0.25);
    border: none; color: white; width: 30px; height: 30px; border-radius: 8px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.2s, transform 0.15s;
}
.bcm-chat-btn:hover { background: rgba(255,255,255,0.25); transform: scale(1.05); }

/* ── Main Area ── */
.bcm-main-area { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.bcm-chat-body { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; }

/* ── Messages ── */
.bcm-chat-messages {
    flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 12px;
    display: flex; flex-direction: column; gap: 2px;
    background: #0a0e1a;
}
.bcm-chat-messages::-webkit-scrollbar { width: 5px; }
.bcm-chat-messages::-webkit-scrollbar-track { background: transparent; }
.bcm-chat-messages::-webkit-scrollbar-thumb { background: rgba(65,105,225,0.3); border-radius: 3px; }
.bcm-chat-messages::-webkit-scrollbar-thumb:hover { background: rgba(65,105,225,0.5); }
.bcm-chat-msg { padding: 6px 10px; border-radius: 8px; transition: background 0.15s; animation: bcm-msg-in 0.2s ease; overflow: hidden; max-width: 100%; }
.bcm-chat-msg:hover { background: rgba(65,105,225,0.06); }
@keyframes bcm-msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.bcm-chat-msg-meta { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.bcm-msg-avatar { width: 22px; height: 22px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 0.6rem; font-weight: 800; color: #fff; flex-shrink: 0; text-transform: uppercase; }
.bcm-chat-msg-user { font-weight: 700; font-size: 0.8rem; color: #5a82f0; }
.bcm-chat-msg-time { font-size: 0.65rem; color: var(--text-muted, #64748b); margin-left: auto; }
.bcm-chat-msg-text { font-size: 0.85rem; color: var(--text-primary, #e2e8f0); word-wrap: break-word; overflow-wrap: break-word; word-break: break-word; line-height: 1.45; padding-left: 28px; max-width: 100%; overflow: hidden; }
.bcm-chat-msg-image { max-width: 240px; max-height: 200px; border-radius: 8px; margin-top: 4px; margin-left: 28px; cursor: pointer; border: 1px solid rgba(65,105,225,0.2); transition: transform 0.2s, box-shadow 0.2s; display: block; }
.bcm-chat-msg-image:hover { transform: scale(1.02); box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
.bcm-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.85); display: flex; align-items: center; justify-content: center; z-index: 99999; cursor: zoom-out; animation: bcm-fade-in 0.15s ease; }
.bcm-lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
@keyframes bcm-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ── User Info Bar ── */
.bcm-user-info { display: flex; align-items: center; padding: 0.45rem 0.85rem; background: rgba(65,105,225,0.08); border-bottom: 1px solid rgba(65,105,225,0.12); font-size: 0.8rem; color: var(--text-primary, #f8fafc); font-weight: 600; }
.bcm-load-more { width: calc(100% - 20px); margin: 0 auto 8px; padding: 6px 12px; background: rgba(65,105,225,0.08); border: 1px solid rgba(65,105,225,0.2); border-radius: 6px; color: #5a82f0; font-size: 0.78rem; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.bcm-load-more:hover { background: rgba(65,105,225,0.15); }

/* ── Input Area ── */
.bcm-chat-input-wrapper { padding: 8px 12px 12px; background: #1e293b; border-top: 1px solid rgba(65,105,225,0.12); display: flex; flex-direction: column; gap: 5px; flex-shrink: 0; }
.bcm-chat-tools-row { display: flex; gap: 6px; align-items: center; }
.bcm-chat-input-row { display: flex; gap: 6px; align-items: flex-end; }
.bcm-image-preview { position: relative; display: inline-block; margin-bottom: 4px; }
.bcm-image-preview img { max-height: 80px; border-radius: 8px; border: 1px solid rgba(65,105,225,0.3); }
.bcm-image-preview-remove { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; background: #ef4444; color: white; border: none; font-size: 0.65rem; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(0,0,0,0.3); }
#bcm-chat-message { flex: 1; padding: 9px 12px; background: #0a0e1a; border: 1px solid rgba(65,105,225,0.2); border-radius: 10px; color: var(--text-primary, #f8fafc); font-size: 0.85rem; outline: none; transition: border-color 0.2s, box-shadow 0.2s; min-height: 38px; }
#bcm-chat-message:focus { border-color: #4169E1; box-shadow: 0 0 0 2px rgba(65,105,225,0.1); }
#bcm-chat-message::placeholder { color: var(--text-muted, #64748b); }
.bcm-chat-img-btn { background: rgba(65,105,225,0.1); border: 1px solid rgba(65,105,225,0.2); color: #5a82f0; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0; font-size: 0.8rem; }
.bcm-chat-img-btn:hover { background: rgba(65,105,225,0.2); border-color: #4169E1; }
.bcm-chat-emoji-btn { background: rgba(65,105,225,0.1); border: 1px solid rgba(65,105,225,0.2); color: #5a82f0; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; flex-shrink: 0; font-size: 0.8rem; }
.bcm-chat-emoji-btn:hover { background: rgba(65,105,225,0.2); border-color: #4169E1; }

/* Emoji Picker */
.bcm-emoji-picker {
    background: #0f172a;
    border: 1px solid rgba(65,105,225,0.2);
    border-radius: 10px;
    padding: 0.4rem;
    margin-top: 0.3rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.bcm-emoji-tabs {
    display: flex;
    gap: 0.2rem;
    padding-bottom: 0.35rem;
    margin-bottom: 0.35rem;
    border-bottom: 1px solid rgba(65,105,225,0.1);
}
.bcm-emoji-tab {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0.2rem 0.4rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
}
.bcm-emoji-tab:hover { background: rgba(65,105,225,0.1); }
.bcm-emoji-tab.active { background: rgba(65,105,225,0.15); border-color: rgba(65,105,225,0.3); }
.bcm-emoji-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 0.15rem;
    max-height: 140px;
    overflow-y: auto;
}
.bcm-emoji-hidden { display: none !important; }
.bcm-emoji-item {
    font-size: 1.15rem;
    padding: 0.2rem;
    text-align: center;
    cursor: pointer;
    border-radius: 5px;
    transition: background 0.1s;
    line-height: 1.3;
    user-select: none;
}
.bcm-emoji-item:hover { background: rgba(65,105,225,0.15); }

/* Light mode emoji picker */
[data-theme="light"] .bcm-emoji-picker {
    background: #fff;
    border-color: rgba(65,105,225,0.15);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}
[data-theme="light"] .bcm-emoji-tab:hover { background: rgba(65,105,225,0.08); }
[data-theme="light"] .bcm-emoji-tab.active { background: rgba(65,105,225,0.1); border-color: rgba(65,105,225,0.2); }
[data-theme="light"] .bcm-emoji-item:hover { background: rgba(65,105,225,0.08); }
.bcm-chat-send { background: linear-gradient(135deg, #2c4fbd, #4169E1); border: none; color: white; width: 38px; height: 38px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform 0.15s, box-shadow 0.2s; flex-shrink: 0; }
.bcm-chat-send:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(65,105,225,0.4); }
.bcm-chat-send:active { transform: scale(0.95); }
.bcm-chat-send i { font-size: 0.9rem; }

/* ── Users Sidebar ── */
.bcm-users-sidebar { width: 140px; flex-shrink: 0; display: flex; flex-direction: column; border-left: 1px solid rgba(65,105,225,0.12); background: rgba(15,23,42,0.6); overflow: hidden; }
.bcm-users-header { display: flex; align-items: center; justify-content: center; gap: 5px; padding: 7px 8px; font-size: 0.68rem; font-weight: 700; color: var(--text-muted, #94a3b8); text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid rgba(65,105,225,0.1); flex-shrink: 0; background: rgba(65,105,225,0.05); }
.bcm-online-dot { color: #10b981; font-size: 0.45rem; animation: bcm-pulse 2s infinite; }
@keyframes bcm-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.bcm-users-list { overflow-y: auto; overflow-x: hidden; flex: 1; padding: 4px 0; }
.bcm-users-list::-webkit-scrollbar { width: 3px; }
.bcm-users-list::-webkit-scrollbar-thumb { background: rgba(65,105,225,0.2); border-radius: 2px; }
.bcm-user-entry { display: flex; align-items: center; gap: 5px; padding: 3px 7px; font-size: 0.72rem; color: var(--text-secondary, #cbd5e1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background 0.15s; cursor: default; line-height: 1.4; }
.bcm-user-entry:hover { background: rgba(65,105,225,0.06); }
.bcm-user-entry span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcm-user-icon { font-size: 0.6rem; flex-shrink: 0; }
.bcm-user-icon.reg  { color: #10b981; }
.bcm-user-icon.anon { color: #475569; }
.bcm-user-anon span { color: #64748b; }
.bcm-users-empty { padding: 10px 7px; font-size: 0.72rem; color: var(--text-muted, #64748b); font-style: italic; text-align: center; }

/* ── Mod ── */
.bcm-mod-badge { display: inline-block; margin-left: 5px; padding: 1px 5px; background: linear-gradient(135deg, #2c4fbd, #4169E1); color: white; font-size: 0.55rem; font-weight: 700; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.bcm-ban-btn { margin-left: auto; background: none; border: none; cursor: pointer; font-size: 0.85rem; opacity: 0.4; transition: opacity 0.2s; padding: 2px 4px; }
.bcm-ban-btn:hover { opacity: 1; }
.bcm-mod-controls { padding: 6px 10px; background: rgba(65,105,225,0.08); border-top: 1px solid rgba(65,105,225,0.2); display: flex; gap: 8px; justify-content: center; }
.bcm-mod-btn { padding: 5px 10px; border: 1px solid rgba(65,105,225,0.3); background: rgba(65,105,225,0.1); color: var(--text-primary, #f8fafc); border-radius: 6px; font-size: 0.72rem; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.bcm-mod-btn:hover { background: rgba(65,105,225,0.2); }
.bcm-clear-btn:hover { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.5); }

/* ── Resize ── */
.bcm-resize-handle { position: absolute; bottom: 0; right: 0; width: 18px; height: 18px; cursor: se-resize; display: flex; align-items: center; justify-content: center; opacity: 0.4; transition: opacity 0.2s; z-index: 10; color: var(--text-muted, #94a3b8); }
.bcm-resize-handle:hover { opacity: 1; }
.bcm-resize-handle i { font-size: 0.7rem; transform: rotate(90deg); }
#bcm-chat-widget.bcm-chat-minimized .bcm-resize-handle { display: none; }
#bcm-chat-widget.bcm-resizing, #bcm-chat-widget.bcm-resizing * { user-select: none; }
.bcm-user-icon.mod { color: #f59e0b; }
.bcm-user-mod span { color: #fbbf24; font-weight: 600; }
.bcm-users-sidebar .bcm-mod-badge { font-size: 0.5rem; background: #b45309; border-radius: 3px; padding: 1px 4px; flex-shrink: 0; margin-left: auto; }

/* ── Mobile ── */
#bcm-chat-widget.bcm-chat-fullscreen { position: fixed !important; left: 0 !important; top: 0 !important; width: 100vw !important; height: 100vh !important; max-width: none !important; max-height: none !important; border-radius: 0 !important; z-index: 99999 !important; }
@media (max-width: 480px) {
    #bcm-chat-widget { right: 10px; bottom: 10px; width: calc(100vw - 20px); }
    #bcm-chat-widget.bcm-chat-open { height: calc(100vh - 80px); max-height: none; }
    .bcm-users-sidebar { width: 110px; }
}

/* ── Light Theme ── */
[data-theme="light"] #bcm-chat-widget { background: #ffffff; box-shadow: 0 8px 40px rgba(0,0,0,0.12), 0 0 0 1px rgba(65,105,225,0.15); }
[data-theme="light"] .bcm-chat-messages { background: #f8fafc; }
[data-theme="light"] .bcm-chat-msg:hover { background: rgba(65,105,225,0.04); }
[data-theme="light"] .bcm-chat-msg-user { color: #2c4fbd; }
[data-theme="light"] .bcm-chat-msg-text { color: #1e293b; }
[data-theme="light"] #bcm-chat-message { background: #ffffff; border-color: #cbd5e1; color: #1e293b; }
[data-theme="light"] #bcm-chat-message::placeholder { color: #64748b; }
[data-theme="light"] .bcm-chat-input-wrapper { background: #ffffff; border-color: #e2e8f0; }
[data-theme="light"] .bcm-user-info { background: rgba(65,105,225,0.06); border-color: #e2e8f0; color: #1e293b; }
[data-theme="light"] .bcm-load-more { background: rgba(65,105,225,0.05); border-color: #cbd5e1; color: #2c4fbd; }
[data-theme="light"] .bcm-users-sidebar { background: #f1f5f9; border-left-color: #e2e8f0; }
[data-theme="light"] .bcm-users-header { background: #e2e8f0; }
[data-theme="light"] .bcm-user-entry { color: #334155; }
[data-theme="light"] .bcm-user-anon span { color: #94a3b8; }
[data-theme="light"] .bcm-mod-controls { background: rgba(65,105,225,0.04); }
[data-theme="light"] .bcm-mod-btn { color: #1e293b; }
[data-theme="light"] .bcm-chat-img-btn { background: rgba(65,105,225,0.06); border-color: #cbd5e1; color: #2c4fbd; }

/* ── User Tooltip ── */
.bcm-user-tooltip {
    position: fixed; z-index: 100002; width: 280px;
    background: rgba(15, 18, 35, 0.96); border: 1px solid rgba(65,105,225,0.35);
    border-radius: 10px; padding: 10px 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5); backdrop-filter: blur(10px);
    pointer-events: auto; animation: bcm-tip-in 0.15s ease-out;
}
@keyframes bcm-tip-in { from { opacity: 0; transform: scale(0.95) translateY(4px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.bcm-tip-username { font-weight: 700; font-size: 0.85rem; color: #7ba4f7; margin-bottom: 6px; white-space: normal; overflow: visible; display: flex; flex-wrap: wrap; align-items: center; gap: 3px; }
.bcm-tip-coin-row { margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid rgba(65,105,225,0.12); }
.bcm-tip-coin-row:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.bcm-tip-mining { font-size: 0.78rem; color: #e2e8f0; margin-bottom: 5px; line-height: 1.5; }
.bcm-tip-hashrate { font-weight: 600; font-size: 0.78rem; }
.bcm-tip-spectate { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; background: linear-gradient(135deg, rgba(65,105,225,0.25), rgba(44,79,189,0.25)); border: 1px solid rgba(65,105,225,0.35); border-radius: 5px; color: #7ba4f7; font-size: 0.7rem; font-weight: 600; text-decoration: none; cursor: pointer; transition: all 0.15s; }
.bcm-tip-spectate:hover { background: linear-gradient(135deg, rgba(65,105,225,0.4), rgba(44,79,189,0.4)); color: #fff; }
.bcm-user-entry { cursor: default; }
.bcm-user-entry[data-wallet] { cursor: pointer; }

[data-theme="light"] .bcm-user-tooltip { background: rgba(255,255,255,0.97); border-color: #cbd5e1; box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
[data-theme="light"] .bcm-tip-username { color: #2c4fbd; }
[data-theme="light"] .bcm-tip-mining { color: #334155; }
[data-theme="light"] .bcm-tip-coin-row { border-bottom-color: rgba(0,0,0,0.06); }
[data-theme="light"] .bcm-tip-spectate { background: rgba(65,105,225,0.08); border-color: rgba(65,105,225,0.25); color: #2c4fbd; }
[data-theme="light"] .bcm-tip-spectate:hover { background: rgba(65,105,225,0.15); color: #1a3380; }

/* Mobile chat fixes */
@media (max-width: 768px) {
    #bcm-chat-widget.bcm-chat-open {
        bottom: 10px !important;
        right: 10px !important;
        left: 10px !important;
        width: auto !important;
        max-width: none !important;
        height: calc(100vh - 80px);
        max-height: calc(100vh - 80px);
    }
    #bcm-chat-widget.bcm-chat-minimized {
        right: 20px !important;
        left: auto !important;
        width: 60px !important;
        bottom: 20px !important;
    }
    .bcm-chat-input-wrapper {
        padding: 6px 10px 10px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
}
