/* ═══════ GLOBAL CHAT WIDGET ═══════ */

/* ── Floating Button ── */
.gchat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 900;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transition: all 0.3s cubic-bezier(.4, 0, .2, 1);
}

.gchat-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(99, 102, 241, 0.5);
}

.gchat-btn.active {
    display: none;
}

.gchat-btn .gchat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    background: #ef4444;
    color: white;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--chat-bg, #1a1a2e);
}

.gchat-badge.show {
    display: flex;
}

/* ── Panel ── */
.gchat-panel {
    position: fixed;
    top: 66px !important;
    bottom: 60px !important;
    right: -420px;
    z-index: 1060;
    width: 400px;
    display: flex;
    flex-direction: column;
    transition: right 0.35s cubic-bezier(.4, 0, .2, 1);
    border-left: 2px solid rgba(99, 102, 241, 0.3);
    border-radius: 24px 0 0 24px;
    overflow: hidden;
    --chat-bg: #0f0f1a;
    --chat-input-bg: #131325;
    --chat-input-field: #1a1a2e;
    --chat-border: rgba(255, 255, 255, 0.06);
    --chat-text: #d1d5db;
    --chat-name: #c4b5fd;
    --chat-time: #4b5563;
    --chat-placeholder: #4b5563;
    --chat-emoji-bg: #1a1a2e;
    --chat-scroll-thumb: #333;
    --chat-reply-bg: rgba(99, 102, 241, 0.08);
    --chat-reply-border: #6366f1;
    --chat-hover-bg: rgba(255, 255, 255, 0.03);
    background: var(--chat-bg);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.4);
}

.gchat-panel.open {
    right: 0;
}

/* ── Header ── */
.gchat-head {
    padding: 16px 20px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.gchat-head-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gchat-head-left>i {
    font-size: 1.2rem;
}

.gchat-head h3 {
    font-size: 1rem;
    font-weight: 700;
    color: white;
    margin: 0;
}

.gchat-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.gchat-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ── Admin Header Controls ── */
.gchat-head-admin {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}

.gchat-head-admin-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.gchat-head-admin-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.gchat-head-admin-btn.gchat-links-off {
    background: rgba(239, 68, 68, 0.4);
}

/* ── Messages Area ── */
.gchat-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--chat-scroll-thumb) transparent;
}

.gchat-msgs::-webkit-scrollbar {
    width: 4px;
}

.gchat-msgs::-webkit-scrollbar-thumb {
    background: var(--chat-scroll-thumb);
    border-radius: 4px;
}

/* ── Single Message ── */
.gchat-msg {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    animation: gchatIn 0.25s ease;
    padding: 4px 6px;
    border-radius: 10px;
    transition: background 0.15s;
    position: relative;
}

.gchat-msg.is-me {
    flex-direction: row-reverse;
}

.gchat-msg.is-me .gchat-msg-body {
    text-align: right;
}

.gchat-msg.is-me .gchat-msg-head {
    flex-direction: row-reverse;
}

.gchat-msg:hover {
    background: var(--chat-hover-bg);
}

@keyframes gchatIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Highlight when scrolling to replied message */
.gchat-msg-highlight {
    background: rgba(99, 102, 241, 0.15) !important;
    transition: background 0.3s;
}

.gchat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    flex-shrink: 0;
    color: white;
    text-transform: uppercase;
    margin-top: 2px;
}

.gchat-msg-body {
    flex: 1;
    min-width: 0;
}

.gchat-msg-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
    flex-wrap: wrap;
}

.gchat-msg-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--chat-name);
    cursor: default;
}

.gchat-msg-time {
    font-size: 0.65rem;
    color: var(--chat-time);
}

.gchat-msg-text {
    font-size: 0.88rem;
    color: var(--chat-text);
    line-height: 1.5;
    word-break: break-word;
}

/* ── Message Bubble ── */
.gchat-msg-bubble {
    display: inline-block;
    padding: 8px 14px;
    background: var(--chat-input-field);
    border-radius: 4px 18px 18px 18px;
    margin-top: 4px;
    max-width: 90%;
    position: relative;
    border: 1px solid var(--chat-border);
}

.gchat-msg.is-me .gchat-msg-bubble {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.2);
    border-radius: 18px 4px 18px 18px;
}

/* ── Role Tags & Effects ── */
.gchat-role-badge, .gchat-plan-badge {
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 6px;
    margin: 0 4px;
    letter-spacing: 0.6px;
    display: inline-flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.badge-admin {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
    border: 1px solid rgba(255,255,255,0.2);
}

/* Membership Badges */
.badge-silver {
    background: linear-gradient(135deg, #94a3b8, #475569);
    color: white;
    border: 1px solid rgba(255,255,255,0.1);
}

.badge-gold {
    background: linear-gradient(135deg, #fbbf24, #d97706);
    color: white;
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
    border: 1px solid rgba(255,255,255,0.2);
}

.badge-platinum {
    background: linear-gradient(135deg, #38bdf8, #1d4ed8);
    color: white;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
    border: 1px solid rgba(255,255,255,0.2);
}

.badge-vip {
    background: linear-gradient(135deg, #ec4899, #8b5cf6, #3b82f6);
    background-size: 200% auto;
    color: white;
    box-shadow: 0 0 15px rgba(236, 72, 153, 0.5);
    border: 1px solid rgba(255,255,255,0.3);
    animation: vipShimmer 3s linear infinite;
}

@keyframes vipShimmer {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Tier-specific Message Bubbles */
.gchat-msg.plan-gold .gchat-msg-bubble {
    border-color: rgba(251, 191, 36, 0.2);
}
.gchat-msg.plan-platinum .gchat-msg-bubble {
    border-color: rgba(56, 189, 248, 0.3);
    box-shadow: 0 2px 10px rgba(56, 189, 248, 0.05);
}
.gchat-msg.plan-vip .gchat-msg-bubble {
    border-color: rgba(236, 72, 153, 0.3);
    background: linear-gradient(to bottom right, rgba(236, 72, 153, 0.03), rgba(139, 92, 246, 0.03));
    box-shadow: 0 4px 20px rgba(236, 72, 153, 0.1);
}

/* Admin Message Glow */
.gchat-msg.role-admin .gchat-msg-bubble {
    border-color: rgba(239, 68, 68, 0.4);
    background: linear-gradient(to bottom right, rgba(239, 68, 68, 0.05), rgba(245, 158, 11, 0.05));
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.12);
}

.gchat-msg.role-admin .gchat-msg-name {
    color: #f87171;
    text-shadow: 0 0 10px rgba(248, 113, 113, 0.2);
}

.gchat-msg.is-me .gchat-msg-name {
    color: #6ee7b7;
}

/* Light Mode Overrides */
[data-theme="light"] .gchat-msg-bubble {
    background: #f3f4f6;
    border-color: #e5e7eb;
}

[data-theme="light"] .gchat-msg.is-me .gchat-msg-bubble {
    background: rgba(99, 102, 241, 0.08);
}

/* ── User Link (admin) ── */
.gchat-user-link {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.6rem;
    text-decoration: none;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
}

.gchat-user-link:hover {
    color: #6366f1;
}

/* ── Message Actions (hover) ── */
.gchat-msg-actions {
    display: none;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}

.gchat-msg:hover .gchat-msg-actions {
    display: flex;
}

.gchat-act-btn {
    background: none;
    border: none;
    color: var(--chat-time);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 0.75rem;
    border-radius: 6px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gchat-act-btn:hover {
    color: var(--chat-text);
    background: rgba(255, 255, 255, 0.08);
}

.gchat-act-reply:hover {
    color: #6366f1;
}

.gchat-act-delete:hover {
    color: #ef4444;
}

.gchat-act-ban:hover {
    color: #f59e0b;
}

.gchat-act-profile:hover {
    color: #3b82f6;
}

/* ── Reply Preview in Message ── */
.gchat-msg-reply {
    background: var(--chat-reply-bg);
    border-left: 3px solid var(--chat-reply-border);
    border-radius: 0 8px 8px 0;
    padding: 4px 10px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.gchat-msg-reply:hover {
    background: rgba(99, 102, 241, 0.15);
}

.gchat-msg-reply-name {
    font-size: 0.7rem;
    font-weight: 700;
    color: #6366f1;
}

.gchat-msg-reply-preview {
    font-size: 0.75rem;
    color: var(--chat-time);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

/* ── Reply Bar (input area) ── */
.gchat-reply-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: var(--chat-reply-bg);
    border-left: 3px solid var(--chat-reply-border);
    border-radius: 0 12px 12px 0;
}

.gchat-reply-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.gchat-reply-label {
    font-size: 0.7rem;
    color: #6366f1;
}

.gchat-reply-label strong {
    color: #818cf8;
}

.gchat-reply-text {
    font-size: 0.75rem;
    color: var(--chat-time);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gchat-reply-close {
    background: none;
    border: none;
    color: var(--chat-time);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 4px;
    flex-shrink: 0;
    transition: color 0.15s;
}

.gchat-reply-close:hover {
    color: #ef4444;
}

/* ── System Message ── */
.gchat-sys {
    text-align: center;
    font-size: 0.75rem;
    color: var(--chat-time);
    padding: 8px 0;
}

/* ── Input Area ── */
.gchat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--chat-border);
    background: var(--chat-input-bg);
    flex-shrink: 0;
}

.gchat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--chat-input-field);
    border: 1px solid var(--chat-border);
    border-radius: 16px;
    padding: 6px 6px 6px 14px;
    transition: border-color 0.2s;
}

.gchat-input-wrap:focus-within {
    border-color: #6366f1;
}

.gchat-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--chat-text);
    font-size: 0.9rem;
    outline: none;
    resize: none;
    max-height: 80px;
    min-height: 24px;
    line-height: 1.4;
    padding: 6px 0;
    font-family: inherit;
}

.gchat-input::placeholder {
    color: var(--chat-placeholder);
}

.gchat-emoji-btn {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
    flex-shrink: 0;
}

.gchat-emoji-btn:hover {
    color: #fbbf24;
}

.gchat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: all 0.2s;
}

.gchat-send-btn:hover {
    transform: scale(1.08);
}

.gchat-send-btn:disabled {
    opacity: 0.4;
    cursor: default;
    transform: none;
}

/* ── Emoji Picker ── */
.gchat-emoji-picker {
    display: none;
    position: absolute;
    bottom: 60px;
    right: 16px;
    background: var(--chat-emoji-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    z-index: 10;
    width: 280px;
}

.gchat-emoji-picker.show {
    display: block;
}

.gchat-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.gchat-emoji-grid span {
    font-size: 1.3rem;
    text-align: center;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: background 0.15s;
}

.gchat-emoji-grid span:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ── Guest login prompt ── */
.gchat-login {
    padding: 16px;
    text-align: center;
    border-top: 1px solid var(--chat-border);
    background: var(--chat-input-bg);
    flex-shrink: 0;
}

.gchat-login p {
    color: #6b7280;
    font-size: 0.85rem;
    margin: 0 0 10px 0;
}

.gchat-login a {
    display: inline-block;
    padding: 10px 24px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

/* ═══════ LIGHT MODE ═══════ */
[data-theme="light"] .gchat-panel {
    --chat-bg: #ffffff;
    --chat-input-bg: #f9fafb;
    --chat-input-field: #f3f4f6;
    --chat-border: #e5e7eb;
    --chat-text: #374151;
    --chat-name: #6366f1;
    --chat-time: #9ca3af;
    --chat-placeholder: #9ca3af;
    --chat-emoji-bg: #ffffff;
    --chat-scroll-thumb: #d1d5db;
    --chat-reply-bg: rgba(99, 102, 241, 0.06);
    --chat-hover-bg: rgba(0, 0, 0, 0.02);
    border-left-color: #e5e7eb;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .gchat-emoji-picker {
    background: #fff;
    border-color: #e5e7eb;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .gchat-emoji-grid span:hover {
    background: #f3f4f6;
}

[data-theme="light"] .gchat-badge {
    border-color: #fff;
}

[data-theme="light"] .gchat-msg.is-me .gchat-msg-name {
    color: #059669;
}

[data-theme="light"] .gchat-act-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .gchat-user-link {
    color: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .gchat-reply-label strong {
    color: #6366f1;
}

[data-theme="light"] .gchat-msg-highlight {
    background: rgba(99, 102, 241, 0.1) !important;
}

/* ── Mobile ── */
@media (max-width: 480px) {
    .gchat-panel {
        width: 100vw;
        right: -100vw;
    }

    .gchat-btn {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
    }

    .gchat-msg-actions {
        display: flex;
    }
}

/* ── Pinned Message ── */
.gchat-pinned {
    margin: 0 0 12px 0;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(239, 68, 68, 0.1));
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 12px;
    position: sticky;
    top: 0;
    z-index: 5;
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: gchatPinnedFade 0.4s ease;
}

@keyframes gchatPinnedFade {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.gchat-pinned-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.gchat-pinned-label {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #f59e0b;
    display: flex;
    align-items: center;
    gap: 4px;
}

.gchat-unpin-btn {
    background: none;
    border: none;
    color: var(--chat-time);
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    line-height: 1;
    transition: color 0.15s;
}

.gchat-unpin-btn:hover {
    color: #ef4444;
}

.gchat-pinned-body {
    font-size: 0.82rem;
    color: var(--chat-text);
    line-height: 1.4;
    word-break: break-word;
}

.gchat-pinned-body strong {
    color: var(--chat-name);
}

.gchat-act-pin:hover {
    color: #f59e0b;
}

[data-theme="light"] .gchat-pinned {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.05), rgba(239, 68, 68, 0.05));
    border-color: rgba(245, 158, 11, 0.2);
}

/* ── Typing Indicator ── */
.gchat-typing {
    font-size: 0.7rem;
    color: var(--chat-time);
    padding: 0 4px;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1;
}

.gchat-typing::after {
    content: "";
    width: 4px;
    height: 4px;
    background: #6366f1;
    border-radius: 50%;
    animation: gchatTypePulse 0.8s infinite alternate;
}

@keyframes gchatTypePulse {
    from { transform: scale(0.7); opacity: 0.4; }
    to { transform: scale(1.3); opacity: 1; }
}

