/* ==============================================
   KG Chat — Premium Full-Page Design
   ============================================== */

/* ---- Layout Container ---- */
.kgchat {
    display: flex;
    height: calc(100vh - 64px);
    max-height: calc(100vh - 64px);
    background: #0c0c1d;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(37, 99, 235, 0.12);
    position: relative;
}

/* ---- Login Required ---- */
.kgchat-login {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 70vh;
    padding: 40px 20px;
}

.kgchat-login-card {
    text-align: center;
    max-width: 420px;
    padding: 48px 40px;
    background: rgba(20, 20, 40, 0.9);
    border: 1px solid rgba(37, 99, 235, 0.15);
    border-radius: 24px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(20px);
}

.kgchat-login-glow {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.15), transparent 70%);
    pointer-events: none;
}

.kgchat-login-icon {
    margin-bottom: 20px;
    animation: loginIconFloat 3s ease-in-out infinite;
}

@keyframes loginIconFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.kgchat-login-card h2 {
    color: #f1f5f9;
    font-size: 1.5rem;
    margin: 0 0 10px;
    font-weight: 700;
}

.kgchat-login-card p {
    color: #94a3b8;
    font-size: 0.9rem;
    margin: 0 0 24px;
    line-height: 1.6;
}

.kgchat-login-features {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.kgchat-login-features span {
    padding: 6px 14px;
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.12);
    border-radius: 999px;
    font-size: 0.78rem;
    color: #c4b5fd;
}

/* ---- Glow Button ---- */
.kgchat-btn-glow {
    display: inline-block;
    padding: 12px 32px;
    background: linear-gradient(135deg, #2563EB, #1d4ed8);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
    box-shadow: 0 4px 24px rgba(37, 99, 235, 0.3);
}

.kgchat-btn-glow:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(37, 99, 235, 0.5);
}

/* ---- Chat App Layout ---- */
.kgchat-app {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* ---- Left Panel ---- */
.kgchat-panel {
    width: 320px;
    display: flex;
    flex-direction: column;
    background: rgba(12, 12, 30, 0.95);
    border-right: 1px solid rgba(37, 99, 235, 0.05);
    flex-shrink: 0;
}

.kgchat-panel-header {
    padding: 8px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(37, 99, 235, 0.08);
    flex-shrink: 0;
}

.kgchat-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kgchat-brand-icon {
    font-size: 1.3rem;
}

.kgchat-brand-text {
    font-weight: 700;
    font-size: 1.05rem;
    color: #f1f5f9;
    letter-spacing: -0.01em;
}

.kgchat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: #64748b;
}

.kgchat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #64748b;
    transition: background 0.3s;
}

.kgchat-status.connected .kgchat-status-dot {
    background: #4ade80;
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
}

.kgchat-status.connected {
    color: #4ade80;
}

.kgchat-status.error .kgchat-status-dot {
    background: #f87171;
}

.kgchat-status.error {
    color: #f87171;
}

/* ---- Tabs ---- */
.kgchat-tabs {
    display: flex;
    padding: 3px;
    margin: 6px 10px;
    background: rgba(30, 30, 60, 0.5);
    border-radius: 10px;
    flex-shrink: 0;
    gap: 2px;
}

.kgchat-tab {
    flex: 1;
    padding: 7px 4px;
    border: none;
    background: none;
    color: #64748b;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 8px;
    transition: all 0.2s;
    position: relative;
    white-space: nowrap;
}

.kgchat-tab svg {
    display: none;
}

.kgchat-tab:hover {
    color: #e2e8f0;
}

.kgchat-tab.active {
    color: #fff;
    background: rgba(37, 99, 235, 0.2);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.kgchat-tab-badge {
    background: #ef4444;
    color: #fff;
    font-size: 0.6rem;
    padding: 1px 5px;
    border-radius: 99px;
    font-weight: 700;
    min-width: 16px;
    text-align: center;
}

/* ---- Tab Content ---- */
.kgchat-tabcontent {
    display: none;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.kgchat-tabcontent.active {
    display: flex;
    flex-direction: column;
}

/* ---- Room List ---- */
.kgchat-rooms {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.kgchat-room {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    cursor: pointer;
    transition: all 0.15s;
    border-left: 3px solid transparent;
    margin: 1px 0;
}

.kgchat-room:hover {
    background: rgba(37, 99, 235, 0.06);
}

.kgchat-room.active {
    background: rgba(37, 99, 235, 0.12);
    border-left-color: #2563EB;
}

.kgchat-room-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(37, 99, 235, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.kgchat-room-meta {
    flex: 1;
    min-width: 0;
}

.kgchat-room-name {
    color: #e2e8f0;
    font-size: 0.84rem;
    font-weight: 600;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kgchat-room-desc {
    color: #475569;
    font-size: 0.7rem;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.kgchat-room-count {
    font-size: 0.65rem;
    color: #4ade80;
    background: rgba(74, 222, 128, 0.08);
    padding: 2px 8px;
    border-radius: 99px;
    flex-shrink: 0;
}

/* Empty & Loading */
.kgchat-empty-hint {
    text-align: center;
    padding: 40px 20px;
    color: #475569;
}

.kgchat-empty-hint span {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
}

.kgchat-empty-hint p {
    font-size: 0.82rem;
    margin: 0;
}

.kgchat-loading {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.kgchat-spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid rgba(37, 99, 235, 0.15);
    border-top-color: #2563EB;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---- Random Chat Start ---- */
.kgchat-random-start {
    text-align: center;
    padding: 48px 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.kgchat-random-anim {
    font-size: 3rem;
    animation: randomBounce 2s infinite;
    margin-bottom: 16px;
}

@keyframes randomBounce {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    25% {
        transform: translateY(-12px) rotate(10deg);
    }

    75% {
        transform: translateY(-6px) rotate(-5deg);
    }
}

.kgchat-random-start h3 {
    color: #f1f5f9;
    font-size: 1.1rem;
    margin: 0 0 8px;
}

.kgchat-random-start p {
    color: #64748b;
    font-size: 0.82rem;
    margin: 0 0 24px;
    max-width: 280px;
}

/* Panel Footer */
.kgchat-panel-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(37, 99, 235, 0.05);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.68rem;
    color: #475569;
    flex-shrink: 0;
}

.kgchat-online-dot {
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.4);
}

/* ============================================
   RIGHT: CHAT AREA
   ============================================ */
.kgchat-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: #0f0f1e;
}

/* Welcome */
.kgchat-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    opacity: 0.9;
}

.kgchat-welcome-icon {
    margin-bottom: 8px;
}

.kgchat-welcome h3 {
    color: #cbd5e1;
    font-size: 1.1rem;
    margin: 0;
    font-weight: 600;
}

.kgchat-welcome p {
    color: #64748b;
    font-size: 0.85rem;
    margin: 0;
}

/* Room Bar */
.kgchat-room-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(37, 99, 235, 0.04);
    border-bottom: 1px solid rgba(37, 99, 235, 0.1);
    flex-shrink: 0;
}

.kgchat-back-btn {
    display: none;
    background: none;
    border: none;
    color: #60a5fa;
    cursor: pointer;
    padding: 4px;
}

.kgchat-room-bar-info {
    flex: 1;
    min-width: 0;
}

.kgchat-room-bar-info .rb-name {
    font-weight: 600;
    color: #f1f5f9;
    font-size: 0.88rem;
}

.kgchat-room-bar-info .rb-sub {
    color: #4ade80;
    font-size: 0.7rem;
    margin-left: 8px;
}

.kgchat-icon-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(37, 99, 235, 0.06);
    border: none;
    border-radius: 8px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s;
}

.kgchat-icon-btn:hover {
    background: rgba(37, 99, 235, 0.14);
    color: #e2e8f0;
}

/* ---- Messages ---- */
.kgchat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
    min-height: 0;
}

.kgchat-msg {
    display: flex;
    gap: 10px;
    max-width: 75%;
    animation: msgSlide 0.2s ease-out;
}

@keyframes msgSlide {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

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

.kgchat-msg--me {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.kgchat-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
    object-fit: cover;
}

.kgchat-msg-body {
    padding: 8px 14px;
    border-radius: 14px;
    background: rgba(30, 30, 55, 0.8);
    border: 1px solid rgba(37, 99, 235, 0.06);
    position: relative;
}

.kgchat-msg--me .kgchat-msg-body {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.2), rgba(109, 40, 217, 0.12));
    border-color: rgba(37, 99, 235, 0.2);
}

.kgchat-msg-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
}

.kgchat-msg-name {
    font-size: 0.73rem;
    font-weight: 600;
    color: #60a5fa;
}

.kgchat-msg--me .kgchat-msg-name {
    color: #c4b5fd;
}

.kgchat-msg-time {
    font-size: 0.6rem;
    color: #475569;
}

.kgchat-msg-text {
    color: #e2e8f0;
    font-size: 0.86rem;
    line-height: 1.55;
    word-break: break-word;
}

/* ---- Reaction Bar (new) ---- */
.kgchat-msg-react-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    flex-wrap: wrap;
    position: relative;
}

.kgchat-react-trigger {
    background: none;
    border: none;
    font-size: 0.82rem;
    padding: 2px 4px;
    cursor: pointer;
    border-radius: 6px;
    opacity: 0;
    transition: all 0.15s;
}

.kgchat-msg:hover .kgchat-react-trigger {
    opacity: 0.6;
}

.kgchat-react-trigger:hover {
    opacity: 1 !important;
    background: rgba(37, 99, 235, 0.1);
}

.kgchat-react-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.1);
    border-radius: 99px;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s;
    color: #cbd5e1;
}

.kgchat-react-pill span {
    font-size: 0.65rem;
    font-weight: 600;
}

.kgchat-react-pill:hover {
    background: rgba(37, 99, 235, 0.18);
    border-color: rgba(37, 99, 235, 0.25);
}

.kgchat-react-pill.mine {
    background: rgba(37, 99, 235, 0.2);
    border-color: #2563EB;
}

/* Emoji Picker */
.kgchat-emoji-picker {
    position: absolute;
    bottom: 100%;
    left: 0;
    display: flex;
    gap: 2px;
    padding: 6px 8px;
    background: rgba(20, 20, 50, 0.97);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 50;
    backdrop-filter: blur(12px);
    opacity: 0;
    transform: translateY(6px);
    transition: all 0.15s ease;
}

.kgchat-emoji-picker.visible {
    opacity: 1;
    transform: translateY(0);
}

.kgchat-emoji-btn {
    background: none;
    border: none;
    font-size: 1.15rem;
    padding: 4px 5px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.1s;
    line-height: 1;
}

.kgchat-emoji-btn:hover {
    background: rgba(37, 99, 235, 0.15);
    transform: scale(1.25);
}

/* Empty messages state */
.kgchat-msg-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
}

.kgchat-msg-empty p {
    font-size: 0.85rem;
    color: #64748b;
    margin: 0;
}

/* ---- Inbox Styles ---- */
.kgchat-inbox-header {
    padding: 8px 12px;
    flex-shrink: 0;
}

.kgchat-new-chat-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.15), rgba(109, 40, 217, 0.08));
    border: 1px dashed rgba(37, 99, 235, 0.25);
    border-radius: 12px;
    color: #60a5fa;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.kgchat-new-chat-btn:hover {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.25), rgba(109, 40, 217, 0.15));
    border-color: #2563EB;
    transform: translateY(-1px);
}

.kgchat-inbox-item {
    padding: 12px 16px !important;
}

.kgchat-inbox-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(37, 99, 235, 0.1);
}

.kgchat-inbox-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.kgchat-inbox-time {
    font-size: 0.62rem;
    color: #475569;
    white-space: nowrap;
}

.rb-private {
    color: #60a5fa !important;
    font-style: italic;
}

/* ---- User Search Modal ---- */
.kgchat-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.2s;
}

.kgchat-modal.visible {
    opacity: 1;
}

.kgchat-modal-content {
    width: 90%;
    max-width: 420px;
    max-height: 70vh;
    background: #14142a;
    border: 1px solid rgba(37, 99, 235, 0.15);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    transform: translateY(12px);
    transition: transform 0.2s;
}

.kgchat-modal.visible .kgchat-modal-content {
    transform: translateY(0);
}

.kgchat-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(37, 99, 235, 0.08);
}

.kgchat-modal-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #f1f5f9;
}

.kgchat-modal-close {
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.15s;
}

.kgchat-modal-close:hover {
    background: rgba(248, 113, 113, 0.1);
    color: #f87171;
}

.kgchat-modal-body {
    padding: 16px 20px;
    overflow-y: auto;
}

.kgchat-search-input {
    width: 100%;
    padding: 11px 16px;
    background: rgba(30, 30, 55, 0.6);
    border: 1px solid rgba(37, 99, 235, 0.12);
    color: #f1f5f9;
    border-radius: 12px;
    font-size: 0.88rem;
    outline: none;
    box-sizing: border-box;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}

.kgchat-search-input:focus {
    border-color: #2563EB;
}

.kgchat-search-input::placeholder {
    color: #475569;
}

.kgchat-search-results {
    min-height: 80px;
}

.kgchat-search-hint {
    color: #475569;
    font-size: 0.82rem;
    text-align: center;
    padding: 20px 0;
    margin: 0;
}

.kgchat-search-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.kgchat-search-user:hover {
    background: rgba(37, 99, 235, 0.08);
}

.kgchat-search-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.kgchat-search-name {
    flex: 1;
    color: #e2e8f0;
    font-size: 0.86rem;
    font-weight: 500;
}

.kgchat-search-chat-btn {
    padding: 6px 14px;
    background: linear-gradient(135deg, #2563EB, #1d4ed8);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.kgchat-search-chat-btn:hover {
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
}

/* ---- Typing ---- */
.kgchat-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    font-size: 0.72rem;
    color: #64748b;
    flex-shrink: 0;
}

.kgchat-typing-dots {
    display: flex;
    gap: 3px;
}

.kgchat-typing-dots span {
    width: 5px;
    height: 5px;
    background: #2563EB;
    border-radius: 50%;
    animation: typeDot 1.2s infinite;
}

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

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

@keyframes typeDot {

    0%,
    60%,
    100% {
        opacity: 0.3;
        transform: scale(1);
    }

    30% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* ---- Input Area ---- */
.kgchat-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid rgba(37, 99, 235, 0.08);
    background: rgba(12, 12, 30, 0.6);
    flex-shrink: 0;
}

.kgchat-input-wrap {
    flex: 1;
    position: relative;
}

.kgchat-input-wrap input {
    width: 100%;
    padding: 11px 16px;
    background: rgba(30, 30, 55, 0.6);
    border: 1px solid rgba(37, 99, 235, 0.12);
    color: #f1f5f9;
    border-radius: 12px;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.kgchat-input-wrap input:focus {
    border-color: #2563EB;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.kgchat-input-wrap input::placeholder {
    color: #475569;
}

.kgchat-send-btn {
    width: 42px;
    height: 42px;
    border: none;
    background: linear-gradient(135deg, #2563EB, #1d4ed8);
    color: #fff;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}

.kgchat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.4);
}

.kgchat-send-btn:active {
    transform: scale(0.96);
}

/* ---- Toast ---- */
.kgchat-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(20, 20, 50, 0.95);
    color: #e2e8f0;
    padding: 10px 24px;
    border-radius: 12px;
    font-size: 0.82rem;
    border: 1px solid rgba(37, 99, 235, 0.2);
    opacity: 0;
    transition: all 0.3s;
    z-index: 999;
    pointer-events: none;
    backdrop-filter: blur(10px);
}

.kgchat-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .kgchat-app {
        position: relative;
    }

    .kgchat-panel {
        width: 100%;
        position: absolute;
        inset: 0;
        z-index: 5;
        transition: transform 0.25s ease;
    }

    .kgchat-panel.panel-hidden {
        transform: translateX(-100%);
        pointer-events: none;
    }

    .kgchat-chat {
        width: 100%;
    }

    .kgchat-back-btn {
        display: flex;
    }

    .kgchat-msg {
        max-width: 88%;
    }

    .kgchat-login-card {
        padding: 36px 24px;
    }
}

/* ---- Clickable usernames ---- */
.kgchat-clickable-user {
    cursor: pointer;
    transition: all 0.15s;
}

.kgchat-msg-name.kgchat-clickable-user:hover {
    color: #60a5fa;
    text-decoration: underline;
}

.kgchat-msg-avatar.kgchat-clickable-user:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
}

/* ---- Friends Tab ---- */
.kgchat-friends-section {
    padding: 4px 0;
}

.kgchat-friends-section-title {
    padding: 10px 16px 6px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #60a5fa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kgchat-friend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 12px;
    margin: 2px 8px;
}

.kgchat-friend-item:hover {
    background: rgba(37, 99, 235, 0.06);
}

.kgchat-friend-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.kgchat-friend-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(37, 99, 235, 0.1);
}

.kgchat-online-indicator {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #475569;
    border: 2px solid #0c0c1e;
}

.kgchat-online-indicator.online {
    background: #4ade80;
}

.kgchat-friend-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.kgchat-friend-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #e2e8f0;
}

.kgchat-friend-status {
    font-size: 0.68rem;
    color: #64748b;
}

.kgchat-friend-time {
    font-size: 0.65rem;
    color: #475569;
}

.kgchat-friend-actions {
    display: flex;
    gap: 6px;
}

.kgchat-friend-accept {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #4ade80, #22c55e);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kgchat-friend-accept:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(74, 222, 128, 0.3);
}

.kgchat-friend-reject {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kgchat-friend-reject:hover {
    background: rgba(248, 113, 113, 0.25);
    transform: scale(1.1);
}

.kgchat-friend-msg-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(37, 99, 235, 0.1);
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kgchat-friend-msg-btn:hover {
    background: rgba(37, 99, 235, 0.2);
    transform: scale(1.08);
}

.kgchat-friend-request {
    background: rgba(37, 99, 235, 0.04);
    border: 1px solid rgba(37, 99, 235, 0.08);
}

/* ---- Profile Modal ---- */
.kgchat-profile-modal {
    max-width: 380px;
    padding: 0 !important;
    text-align: center;
    overflow: hidden;
}

.kgchat-profile-loading {
    padding: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kgchat-profile-header {
    padding: 32px 24px 16px;
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.1) 0%, transparent 100%);
    position: relative;
}

.kgchat-profile-avatar-wrap {
    position: relative;
    display: inline-block;
    margin-bottom: 12px;
}

.kgchat-profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(37, 99, 235, 0.3);
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.2);
}

.kgchat-profile-online {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #475569;
    border: 3px solid #14142a;
}

.kgchat-profile-online.online {
    background: #4ade80;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
}

.kgchat-profile-name {
    margin: 0 0 4px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #f1f5f9;
}

.kgchat-profile-bio {
    margin: 0;
    font-size: 0.82rem;
    color: #94a3b8;
    line-height: 1.5;
    max-height: 60px;
    overflow: hidden;
}

.kgchat-profile-stats {
    display: flex;
    justify-content: center;
    gap: 0;
    padding: 16px 24px;
    border-top: 1px solid rgba(37, 99, 235, 0.06);
    border-bottom: 1px solid rgba(37, 99, 235, 0.06);
}

.kgchat-profile-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0 8px;
}

.kgchat-profile-stat+.kgchat-profile-stat {
    border-left: 1px solid rgba(37, 99, 235, 0.06);
}

.kgchat-profile-stat-num {
    font-size: 0.88rem;
    font-weight: 700;
    color: #e2e8f0;
}

.kgchat-profile-stat-label {
    font-size: 0.65rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kgchat-profile-actions {
    padding: 20px 24px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.kgchat-profile-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    flex: 1;
    min-width: 100px;
}

.kgchat-profile-btn--primary {
    background: linear-gradient(135deg, #2563EB, #1d4ed8);
    color: #fff;
}

.kgchat-profile-btn--primary:hover {
    box-shadow: 0 4px 18px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

.kgchat-profile-btn--secondary {
    background: rgba(37, 99, 235, 0.1);
    color: #60a5fa;
}

.kgchat-profile-btn--secondary:hover {
    background: rgba(37, 99, 235, 0.18);
}

.kgchat-profile-btn--danger {
    background: rgba(248, 113, 113, 0.1);
    color: #f87171;
}

.kgchat-profile-btn--danger:hover {
    background: rgba(248, 113, 113, 0.2);
}

.kgchat-profile-btn--muted {
    background: rgba(100, 116, 139, 0.1);
    color: #94a3b8;
    cursor: default;
}

/* ============================================
   LIGHT MODE
   ============================================ */
.kgai-light .kgchat {
    background: #fafafa;
    border-color: rgba(0, 0, 0, 0.06);
}

.kgai-light .kgchat-login-card {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.06);
}

.kgai-light .kgchat-login-card h2 {
    color: #1e293b;
}

.kgai-light .kgchat-login-card p {
    color: #64748b;
}

.kgai-light .kgchat-login-features span {
    background: rgba(37, 99, 235, 0.04);
    color: #1d4ed8;
    border-color: rgba(37, 99, 235, 0.1);
}

.kgai-light .kgchat-panel {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.06);
}

.kgai-light .kgchat-brand-text {
    color: #1e293b;
}

.kgai-light .kgchat-tabs {
    background: #f1f5f9;
}

.kgai-light .kgchat-tab {
    color: #64748b;
}

.kgai-light .kgchat-tab.active {
    background: #fff;
    color: #1d4ed8;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.kgai-light .kgchat-room:hover {
    background: rgba(37, 99, 235, 0.03);
}

.kgai-light .kgchat-room.active {
    background: rgba(37, 99, 235, 0.06);
}

.kgai-light .kgchat-room-name {
    color: #1e293b;
}

.kgai-light .kgchat-room-desc {
    color: #94a3b8;
}

.kgai-light .kgchat-chat {
    background: #f8f9fa;
}

.kgai-light .kgchat-welcome h3 {
    color: #334155;
}

.kgai-light .kgchat-msg-body {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.06);
}

.kgai-light .kgchat-msg--me .kgchat-msg-body {
    background: rgba(37, 99, 235, 0.06);
    border-color: rgba(37, 99, 235, 0.1);
}

.kgai-light .kgchat-msg-text {
    color: #1e293b;
}

.kgai-light .kgchat-msg-name {
    color: #1d4ed8;
}

.kgai-light .kgchat-input-wrap input {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.1);
    color: #1e293b;
}

.kgai-light .kgchat-input-row {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.06);
}

.kgai-light .kgchat-room-bar {
    background: rgba(37, 99, 235, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
}

.kgai-light .kgchat-profile-header {
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.05) 0%, transparent 100%);
}

.kgai-light .kgchat-profile-name {
    color: #1e293b;
}

.kgai-light .kgchat-profile-avatar {
    border-color: rgba(37, 99, 235, 0.15);
}

.kgai-light .kgchat-profile-online {
    border-color: #fff;
}

.kgai-light .kgchat-friend-name {
    color: #1e293b;
}

.kgai-light .kgchat-modal-content {
    background: #fff;
}

.kgai-light .kgchat-modal-header h3 {
    color: #1e293b;
}

.kgai-light .kgchat-room-bar-info .rb-name {
    color: #1e293b;
}