/* messaging.css */

:root {
    --bg:           #05070a;
    --bg-2:         #0d1117;
    --bg-card:      #111620;
    --bg-hover:     #181f2e;
    --border:       #1e2636;
    --border-hi:    #2a3550;
    --accent:       #00ff88;
    --accent-dim:   rgba(0,255,136,.12);
    --accent-glow:  rgba(0,255,136,.35);
    --blue:         #00d4ff;
    --text:         #d8e0ee;
    --text-2:       #7a88a6;
    --text-3:       #3d4a62;
    --danger:       #ff3366;
    --font-ui:      'Rajdhani', sans-serif;
    --font-mono:    'Share Tech Mono', monospace;
    --header-h:     108px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg);
    background-image:
        radial-gradient(ellipse at 70% -5%, rgba(0,255,136,.04) 0%, transparent 55%),
        radial-gradient(ellipse at -5% 90%, rgba(0,212,255,.03) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 14px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header sizing fix ── */
:root { --header-h: 108px; }
.site-header { height: 108px !important; }
.header-inner { height: 108px !important; padding: 0 !important; }
.brand-name { font-size: 1.38rem; }
.brand-sub  { font-size: 0.62rem; }

.header-live-stats {
    display: flex;
    align-items: stretch;
    background: rgba(255,255,255,0.025);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 6px;
    overflow: hidden;
    flex: 1;
    max-width: 540px;
    margin: 0 20px;
}
.header-live-stat {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 3px;
    padding: 0 14px;
    border-right: 1px solid rgba(255,255,255,0.06);
    flex: 1;
    min-width: 0;
}
.header-live-stat:last-child { border-right: none; }
.hls-num {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 1px;
    line-height: 1;
    white-space: nowrap;
}
.hls-label {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
    white-space: nowrap;
    line-height: 1;
}
#mini-profile {
    position: static !important;
    top: auto !important;
    right: auto !important;
}
#profile-guest {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
#profile-guest:hover .profile-guest-cta { color: var(--accent); }
.profile-guest-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(0,229,122,0.35);
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,229,122,0.07);
    flex-shrink: 0;
    transition: border-color 0.15s, background 0.15s;
}
#profile-guest:hover .profile-guest-avatar {
    border-color: var(--accent);
    background: rgba(0,229,122,0.13);
}
.profile-guest-avatar svg { width: 14px; height: 14px; fill: rgba(0,229,122,0.75); }
.profile-guest-cta {
    display: block;
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.15s;
}
.profile-guest-sub {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.50rem;
    color: var(--accent);
    letter-spacing: 2px;
    opacity: 0.8;
}
#profile-loggedin { display: flex; align-items: center; gap: 10px; }

/* ── Gate screens ── */
.msg-gate {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-2);
    padding: 40px;
}
.msg-gate-icon {
    font-size: 2.5rem;
    color: var(--text-3);
}
.msg-gate h2 {
    font-family: var(--font-ui);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text);
}
.msg-gate p { font-size: 0.9rem; color: var(--text-2); }
.msg-spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border-hi);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Main app layout ── */
.msg-app {
    flex: 1;
    display: flex;
    max-width: 1300px;
    width: 100%;
    margin: 32px auto;
    padding: 0 24px;
    gap: 0;
    height: calc(100vh - var(--header-h) - 64px);
    min-height: 500px;
}

/* ── Sidebar ── */
.msg-sidebar {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 8px 0 0 8px;
    overflow: hidden;
}
.msg-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.msg-sidebar-title {
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text);
}
.msg-compose-btn {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-dim);
    border: 1px solid rgba(0,255,136,0.2);
    border-radius: 5px;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s, border-color 0.15s;
}
.msg-compose-btn:hover {
    background: rgba(0,255,136,0.2);
    border-color: var(--accent);
}
.msg-search-wrap {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.msg-search {
    width: 100%;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 7px 10px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    outline: none;
    transition: border-color 0.15s;
}
.msg-search::placeholder { color: var(--text-3); }
.msg-search:focus { border-color: var(--border-hi); }

.msg-conv-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-hi) transparent;
}
.msg-conv-list::-webkit-scrollbar { width: 4px; }
.msg-conv-list::-webkit-scrollbar-track { background: transparent; }
.msg-conv-list::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 2px; }

.msg-conv-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-3);
    font-size: 0.82rem;
    line-height: 1.6;
}

.msg-conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(30,38,54,0.5);
    cursor: pointer;
    transition: background 0.12s;
    position: relative;
}
.msg-conv-item:hover { background: var(--bg-hover); }
.msg-conv-item.active {
    background: var(--bg-hover);
    border-left: 2px solid var(--accent);
}
.msg-conv-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--bg-2);
    border: 1px solid var(--border-hi);
    flex-shrink: 0;
    object-fit: cover;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
    overflow: hidden;
}
.msg-conv-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.msg-conv-info { flex: 1; min-width: 0; }
.msg-conv-name {
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.msg-conv-preview {
    font-size: 0.78rem;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.msg-conv-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}
.msg-conv-time {
    font-size: 0.72rem;
    color: var(--text-3);
}
.msg-unread-badge {
    background: var(--accent);
    color: #000;
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 0.68rem;
    font-weight: 700;
    font-family: var(--font-ui);
    min-width: 18px;
    text-align: center;
}

/* ── Chat area ── */
.msg-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 0 8px 8px 0;
    overflow: hidden;
    min-width: 0;
}

.msg-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    flex-shrink: 0;
}
.msg-chat-header-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border-hi);
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-ui);
    font-weight: 700;
    color: var(--accent);
    overflow: hidden;
}
.msg-chat-header-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.msg-chat-header-name {
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 1px;
}
.msg-chat-header-status {
    font-size: 0.75rem;
    color: var(--text-3);
    margin-left: auto;
    font-family: var(--font-mono);
}

.msg-chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-3);
}
.msg-chat-empty i { font-size: 2rem; }
.msg-chat-empty p {
    font-size: 0.85rem;
    color: var(--text-3);
    letter-spacing: 1px;
    text-transform: uppercase;
    font-family: var(--font-ui);
}

/* ── Messages ── */
.msg-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-hi) transparent;
}
.msg-messages::-webkit-scrollbar { width: 4px; }
.msg-messages::-webkit-scrollbar-track { background: transparent; }
.msg-messages::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 2px; }

.msg-date-divider {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-3);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: 8px 0;
    position: relative;
}
.msg-date-divider::before,
.msg-date-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: var(--border);
}
.msg-date-divider::before { left: 0; }
.msg-date-divider::after { right: 0; }

.msg-bubble-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    max-width: 75%;
}
.msg-bubble-row.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.msg-bubble-row.received { align-self: flex-start; }

.msg-bubble-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border-hi);
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    overflow: hidden;
    margin-bottom: 2px;
}
.msg-bubble-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.msg-bubble-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.msg-bubble {
    padding: 9px 14px;
    border-radius: 14px;
    line-height: 1.5;
    font-size: 0.88rem;
    word-break: break-word;
    max-width: 100%;
}
.msg-bubble-row.sent .msg-bubble {
    background: var(--accent-dim);
    border: 1px solid rgba(0,255,136,0.15);
    color: var(--text);
    border-radius: 14px 14px 4px 14px;
}
.msg-bubble-row.received .msg-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 14px 14px 14px 4px;
}

.msg-bubble-time {
    font-size: 0.68rem;
    color: var(--text-3);
    padding: 0 4px;
}
.msg-bubble-row.sent .msg-bubble-time { text-align: right; }

/* ── Input area ── */
.msg-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    flex-shrink: 0;
}
.msg-input {
    flex: 1;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.88rem;
    resize: none;
    outline: none;
    max-height: 120px;
    min-height: 42px;
    line-height: 1.5;
    transition: border-color 0.15s;
    overflow-y: auto;
}
.msg-input::placeholder { color: var(--text-3); }
.msg-input:focus { border-color: var(--border-hi); }
.msg-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.msg-send-btn {
    width: 42px; height: 42px;
    flex-shrink: 0;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: #000;
    font-size: 1rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.15s, transform 0.1s;
}
.msg-send-btn:hover:not(:disabled) { opacity: 0.85; }
.msg-send-btn:active:not(:disabled) { transform: scale(0.95); }
.msg-send-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── New conversation modal ── */
.msg-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.msg-modal-overlay.visible {
    opacity: 1;
    pointer-events: all;
}
.msg-modal {
    background: var(--bg-card);
    border: 1px solid var(--border-hi);
    border-radius: 10px;
    padding: 28px;
    width: 380px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.msg-modal-title {
    font-family: var(--font-ui);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text);
}
.msg-modal-label {
    font-size: 0.8rem;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}
.msg-modal-input {
    width: 100%;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.15s;
}
.msg-modal-input:focus { border-color: var(--accent); }
.msg-modal-error {
    font-size: 0.8rem;
    color: var(--danger);
    min-height: 16px;
}
.msg-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.msg-btn {
    padding: 9px 18px;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s;
}
.msg-btn:hover { opacity: 0.85; }
.msg-btn-primary { background: var(--accent); color: #000; }
.msg-btn-ghost {
    background: transparent;
    color: var(--text-2);
    border: 1px solid var(--border-hi);
}

/* ── Footer ── */
footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
}
