/* TipArena Chat — modern messenger UI */

.chat-page {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 820px;
    margin: 0 auto;
}

/* ── Header ── */
.chat-hub-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chat-hub-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-hub-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    font-size: 22px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.18), rgba(0, 255, 170, 0.1));
    border: 1px solid rgba(0, 240, 255, 0.22);
    box-shadow: 0 8px 24px rgba(0, 240, 255, 0.08);
}

.chat-hub-title h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #fff;
}

.chat-hub-sub {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}

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

.chat-dm-btn {
    position: relative;
    background: rgba(0, 240, 255, 0.1) !important;
    border: 1px solid rgba(0, 240, 255, 0.28) !important;
    color: var(--accent-cyan) !important;
}

.chat-dm-btn.has-unread {
    animation: chatDmPulse 2s ease-in-out infinite;
    border-color: rgba(0, 255, 170, 0.5) !important;
    box-shadow: 0 0 0 0 rgba(0, 255, 170, 0.35);
}

@keyframes chatDmPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 255, 170, 0.35); }
    50% { box-shadow: 0 0 0 6px rgba(0, 255, 170, 0); }
}

.chat-dm-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ff0055;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(255, 0, 85, 0.45);
}

.chat-dm-alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 10px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(255, 0, 85, 0.12), rgba(0, 240, 255, 0.08));
    border: 1px solid rgba(255, 0, 85, 0.28);
    animation: chatDmAlertIn 0.35s ease-out both;
}

@keyframes chatDmAlertIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-dm-alert-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.chat-dm-alert-text {
    flex: 1;
    font-size: 13px;
    line-height: 1.4;
    color: #fff;
    min-width: 0;
}

.chat-dm-alert-btn {
    flex-shrink: 0;
    border: none;
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    background: var(--accent-cyan);
    color: #041018;
}

.chat-dm-alert-btn:hover {
    filter: brightness(1.08);
}

.chat-clear-btn {
    opacity: 0.85;
}

/* ── Main panel (glass) ── */
.chat-panel {
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    background:
        linear-gradient(165deg, rgba(15, 23, 42, 0.88), rgba(8, 12, 24, 0.92));
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    overflow: hidden;
}

/* ── Online bar ── */
.chat-online-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.18);
    min-height: 46px;
}

.chat-online-bar.has-online {
    flex-wrap: nowrap;
}

.chat-online-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #86efac;
    white-space: nowrap;
    flex-shrink: 0;
}

.chat-online-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
    animation: chatOnlinePulse 2s ease-out infinite;
}

@keyframes chatOnlinePulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
    70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.chat-online-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 2px;
    flex: 1;
    min-width: 0;
}

.chat-online-scroll::-webkit-scrollbar { display: none; }

.chat-online-empty {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-online-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    border-radius: 999px;
    padding: 5px 12px 5px 8px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.chat-online-chip:hover {
    background: rgba(0, 240, 255, 0.1);
    border-color: rgba(0, 240, 255, 0.25);
    transform: translateY(-1px);
}

.chat-online-dot,
.chat-user-online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.55);
    display: inline-block;
    flex-shrink: 0;
}

.chat-online-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-user-online-dot {
    width: 6px;
    height: 6px;
    margin-left: 2px;
}

/* ── Message area ── */
.chat-window-box {
    height: 340px;
    max-height: 340px;
    overflow-y: auto;
    padding: 16px 14px 20px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 240, 255, 0.25) transparent;
}

.chat-window-box::-webkit-scrollbar { width: 6px; }
.chat-window-box::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.22);
    border-radius: 999px;
}

.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    text-align: center;
    padding: 32px 20px;
    color: var(--text-muted);
}

.chat-empty-icon {
    font-size: 42px;
    margin-bottom: 12px;
    opacity: 0.7;
    filter: grayscale(0.2);
}

.chat-date-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 18px 0 14px;
}

.chat-date-divider span {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

/* ── Messages ── */
.chat-page .chat-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 14px;
    max-width: 100%;
}

.chat-page .chat-msg-row.chat-msg-own {
    justify-content: flex-end;
}

.chat-page .chat-msg-row.chat-msg-new {
    animation: chatSlideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.chat-page .chat-msg-row.chat-msg-new.chat-msg-own {
    animation-name: chatSlideInOwn;
}

@keyframes chatSlideIn {
    from { opacity: 0; transform: translateY(10px) translateX(-8px); }
    to { opacity: 1; transform: translateY(0) translateX(0); }
}

@keyframes chatSlideInOwn {
    from { opacity: 0; transform: translateY(10px) translateX(8px); }
    to { opacity: 1; transform: translateY(0) translateX(0); }
}

.chat-msg-avatar {
    flex-shrink: 0;
    align-self: flex-end;
}

.chat-msg-avatar .chat-user-avatar,
.chat-msg-avatar .user-avatar-wrap {
    --av-size: 34px;
}

.chat-msg-content {
    max-width: min(78%, 520px);
    min-width: 0;
}

.chat-page .chat-msg-own .chat-msg-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.chat-msg-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 5px;
    padding: 0 4px;
}

.chat-msg-meta-own {
    justify-content: flex-end;
    margin-top: 4px;
    margin-bottom: 0;
}

.chat-username {
    color: var(--accent-cyan);
    font-size: 12px;
    font-weight: 700;
}

.chat-time {
    color: var(--text-muted);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

.chat-bubble-wrap {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 100%;
}

.chat-page .chat-msg-own .chat-bubble-wrap {
    align-items: flex-end;
}

.chat-page .chat-bubble {
    display: inline-block;
    max-width: 100%;
    text-align: left;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 18px 18px 18px 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.chat-page .chat-msg-own .chat-bubble {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.18), rgba(0, 255, 170, 0.12));
    border-color: rgba(0, 240, 255, 0.22);
    border-radius: 18px 18px 6px 18px;
    color: #ecfeff;
}

.chat-msg-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    padding-left: 4px;
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 0.15s, transform 0.15s;
}

.chat-msg-row:hover .chat-msg-actions,
.chat-msg-row:focus-within .chat-msg-actions,
.chat-msg-meta-own .chat-msg-actions {
    opacity: 1;
    transform: translateY(0);
}

.chat-msg-meta-own .chat-msg-actions {
    display: inline-flex;
    margin-top: 0;
    margin-left: 6px;
}

.chat-action-btn {
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.chat-like-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.85);
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s, background 0.12s;
}

.chat-like-btn:hover {
    transform: scale(1.04);
    border-color: rgba(0, 240, 255, 0.3);
}

.chat-like-btn.liked {
    border-color: rgba(0, 240, 255, 0.4);
    background: rgba(0, 240, 255, 0.14);
    color: var(--accent-cyan);
}

.chat-like-btn.readonly { cursor: default; }

.chat-like-count:empty { display: none; }

.chat-img-bubble {
    max-width: min(100%, 280px);
    max-height: 260px;
    border-radius: 12px;
    margin: 0;
    display: block;
    object-fit: cover;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-page .chat-system-msg {
    text-align: center;
    margin: 10px auto;
    max-width: 92%;
    padding: 8px 14px;
    background: rgba(0, 240, 255, 0.06);
    border: 1px solid rgba(0, 240, 255, 0.12);
    border-radius: 999px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.45;
}

.chat-page .chat-system-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-cyan);
    margin-right: 6px;
    font-weight: 700;
}

/* ── Composer ── */
.chat-composer {
    border-radius: 16px;
    padding: 10px 12px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.chat-composer-guest {
    opacity: 0.65;
}

.chat-emoji-strip {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 8px;
    padding-bottom: 2px;
}

.chat-emoji-strip::-webkit-scrollbar { display: none; }

.chat-page .chat-emoji-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 6px 8px;
    line-height: 1;
    border-radius: 10px;
    transition: background 0.12s, transform 0.12s;
}

.chat-page .chat-emoji-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: scale(1.08);
}

.chat-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-attach-btn,
.chat-send-btn {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 16px;
    transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}

.chat-attach-btn {
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
}

.chat-attach-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.04);
}

.chat-input-shell {
    flex: 1;
    min-width: 0;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 2px 16px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-input-shell:focus-within {
    border-color: rgba(0, 240, 255, 0.35);
    box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1);
}

.chat-input-field {
    width: 100%;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 14px;
    padding: 10px 0;
    outline: none;
}

.chat-input-field::placeholder { color: rgba(148, 163, 184, 0.85); }
.chat-input-field:disabled { opacity: 0.5; cursor: not-allowed; }

.chat-send-btn {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-neon));
    color: #041018;
    font-weight: 800;
    box-shadow: 0 6px 20px rgba(0, 240, 255, 0.25);
}

.chat-send-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 8px 24px rgba(0, 240, 255, 0.35);
}

.chat-send-btn span {
    display: inline-block;
    transform: translateX(1px);
}

.chat-unread-badge { margin-left: 4px; }

/* ── DM drawer ── */
.dm-drawer {
    position: fixed;
    inset: 0;
    z-index: 12000;
    background: rgba(2, 6, 14, 0.62);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    justify-content: flex-end;
    animation: dmFadeIn 0.2s ease;
}

@keyframes dmFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.dm-drawer[hidden] { display: none !important; }

.dm-drawer-panel {
    width: min(420px, 100%);
    height: 100%;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(8, 12, 24, 0.99));
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    animation: dmSlideIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.4);
}

@keyframes dmSlideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.dm-drawer-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.dm-drawer-head strong {
    flex: 1;
    font-size: 15px;
}

.dm-back-btn,
.dm-close-btn {
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-radius: 10px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    transition: background 0.12s;
}

.dm-back-btn:hover,
.dm-close-btn:hover { background: rgba(255, 255, 255, 0.14); }

.dm-list,
.dm-thread { flex: 1; overflow: auto; }

.dm-empty {
    padding: 32px 24px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

.dm-conv-row {
    display: flex;
    align-items: center;
    width: 100%;
    text-align: left;
    padding: 14px 18px;
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: background 0.12s;
}

.dm-conv-row:hover { background: rgba(255, 255, 255, 0.04); }

.dm-conv-name {
    display: block;
    font-weight: 700;
    font-size: 14px;
}

.dm-conv-preview {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dm-unread-pill {
    display: inline-block;
    min-width: 20px;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--accent-cyan);
    color: #041018;
    font-size: 10px;
    font-weight: 800;
    margin-left: auto;
}

.dm-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dm-msg { max-width: 85%; align-self: flex-start; }
.dm-msg-own { align-self: flex-end; }

.dm-msg-bubble {
    padding: 10px 14px;
    border-radius: 18px 18px 18px 6px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.dm-msg-own .dm-msg-bubble {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.18), rgba(0, 255, 170, 0.1));
    border: 1px solid rgba(0, 240, 255, 0.22);
    border-radius: 18px 18px 6px 18px;
}

.dm-msg-time {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

.dm-compose {
    display: flex;
    gap: 8px;
    padding: 12px 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.15);
}

.dm-compose input {
    flex: 1;
    border-radius: 999px !important;
}

.dm-compose .btn {
    border-radius: 999px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-neon));
    color: #041018;
    font-weight: 700;
}

/* ── Profile extras ── */
.profile-install-panel,
.profile-chat-push-panel {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.profile-install-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.player-profile-dm {
    width: 100%;
    margin-bottom: 10px;
    background: rgba(0, 240, 255, 0.12);
    color: var(--accent-cyan);
    border: 1px solid rgba(0, 240, 255, 0.28);
}

/* ── Light theme ── */
html.landing-light body.is-app .chat-panel {
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.98));
    border-color: rgba(15, 23, 42, 0.08);
}

html.landing-light body.is-app .chat-page .chat-bubble {
    background: rgba(15, 23, 42, 0.06);
    color: #0f172a;
    border-color: rgba(15, 23, 42, 0.08);
}

html.landing-light body.is-app .chat-page .chat-msg-own .chat-bubble {
    background: linear-gradient(135deg, rgba(0, 180, 200, 0.15), rgba(0, 200, 150, 0.1));
    color: #0c4a6e;
}

html.landing-light body.is-app .chat-input-shell {
    background: rgba(15, 23, 42, 0.04);
}

html.landing-light body.is-app .chat-input-field { color: #0f172a; }

/* ── Mobile ── */
@media (max-width: 768px) {
    .chat-page {
        gap: 10px;
    }

    .chat-window-box {
        height: 300px;
        max-height: 300px;
    }

    .chat-msg-content { max-width: 88%; }

    .chat-hub-sub { display: none; }

    .chat-msg-actions { opacity: 1; transform: none; }
}

@media (max-width: 600px) {
    .dm-drawer-panel { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .chat-page .chat-msg-row.chat-msg-new,
    .chat-online-pulse,
    .dm-drawer,
    .dm-drawer-panel {
        animation: none !important;
    }
}
