@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; }

body {
    background-color: #0f172a;
    color: #f8fafc;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.screen {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #1e293b;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    overflow: hidden;
}

.hidden { display: none !important; }

/* ===== JOIN SCREEN ===== */
#login-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #0f172a, #1e293b);
}

.glass-panel {
    background: rgba(255,255,255,0.05);
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    width: 320px;
}

.join-icon { font-size: 2.5em; color: #3b82f6; margin-bottom: 15px; }
.glass-panel h2 { margin-bottom: 8px; font-weight: 600; font-size: 1.3em; }
.glass-panel > p { margin-bottom: 20px; color: #94a3b8; font-size: 0.9em; }

.glass-panel input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 12px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    background: #0f172a;
    color: white;
    outline: none;
    font-size: 0.95em;
    transition: border-color 0.2s;
}
.glass-panel input:focus { border-color: #3b82f6; }

.glass-panel button {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: none;
    background: #3b82f6;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
    font-size: 1em;
    margin-top: 4px;
}
.glass-panel button:hover { background: #2563eb; }

#error-msg { color: #ef4444; margin-top: 12px; font-size: 0.85em; }

/* Admin hint inside login */
.admin-hint {
    color: #a78bfa;
    font-size: 0.8em;
    margin-bottom: 10px;
    margin-top: 4px;
    text-align: left;
}
.admin-hint i { margin-right: 5px; }

/* ===== HEADER ===== */
header {
    padding: 14px 20px;
    background: #0f172a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
}

.current-user-info { display: flex; align-items: center; gap: 12px; }
.current-user-info img {
    width: 42px; height: 42px;
    border-radius: 50%; object-fit: cover; background: #1e293b;
}
.current-user-info h3 { font-size: 1em; font-weight: 600; }
.status { font-size: 0.75em; color: #10b981; }
.status i { font-size: 0.6em; margin-right: 3px; }

.icon-btn {
    background: none; border: none; color: #64748b;
    font-size: 1.1em; cursor: pointer; transition: 0.2s;
    padding: 6px; border-radius: 6px;
}
.icon-btn:hover { color: #ef4444; background: rgba(239,68,68,0.1); }

/* ===== ADMIN BADGES ===== */
.admin-badge {
    font-size: 0.6em;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: white;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    vertical-align: middle;
    margin-left: 5px;
}

.admin-badge-msg {
    font-size: 0.65em;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: white;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 700;
    letter-spacing: 0.04em;
    vertical-align: middle;
    margin-left: 4px;
}

/* ===== MESSAGES ===== */
main {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.msg-wrapper {
    display: flex;
    gap: 8px;
    max-width: 84%;
    transition: background 0.3s;
    border-radius: 12px;
    padding: 2px;
}

.msg-wrapper.me { align-self: flex-end; flex-direction: row-reverse; }
.msg-wrapper.them { align-self: flex-start; }

/* highlight handled via inline styles in JS */

/* ===== AVATAR ===== */
.msg-avatar {
    width: 32px; height: 32px;
    border-radius: 50%; object-fit: cover;
    background: #334155; flex-shrink: 0;
    align-self: flex-end;
}

.admin-avatar {
    border: 2px solid #a855f7;
    box-shadow: 0 0 8px #a855f7;
}

/* ===== BUBBLE ===== */
.bubble {
    padding: 10px 13px;
    border-radius: 16px;
    word-break: break-word;
    min-width: 60px;
}

.me .bubble { border-bottom-right-radius: 4px; }
.them .bubble { border-bottom-left-radius: 4px; }

.msg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.msg-username { font-size: 0.75em; font-weight: 600; color: rgba(255,255,255,0.85); }
.msg-time { font-size: 0.68em; color: rgba(255,255,255,0.4); white-space: nowrap; }
.msg-text { font-size: 0.92em; line-height: 1.45; color: #f1f5f9; }

/* ===== REPLY QUOTE IN BUBBLE ===== */
.reply-quote {
    background: rgba(0,0,0,0.2);
    border-left: 3px solid rgba(255,255,255,0.35);
    border-radius: 6px;
    padding: 5px 9px;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.reply-quote-user { font-size: 0.72em; font-weight: 600; color: rgba(255,255,255,0.8); }
.reply-quote-text {
    font-size: 0.78em; color: rgba(255,255,255,0.5);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px;
}

/* ===== MESSAGE ACTIONS ===== */
.msg-actions {
    display: flex;
    gap: 4px;
    margin-top: 7px;
    justify-content: flex-end;
}

.action-btn {
    background: none; border: none;
    color: rgba(255,255,255,0.35);
    font-size: 0.72em; cursor: pointer;
    padding: 3px 6px; border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}
.action-btn:hover { color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.1); }
.action-btn.delete-btn:hover { color: #f87171; background: rgba(239,68,68,0.15); }
.action-btn.reply-btn:hover { color: #93c5fd; background: rgba(59,130,246,0.15); }
.action-btn.highlight-btn { color: rgba(251,191,36,0.35); }
.action-btn.highlight-btn:hover,
.action-btn.highlight-btn.active { color: #fbbf24; background: rgba(251,191,36,0.12); }

/* ===== REPLY BAR ===== */
#reply-bar {
    background: #162032;
    border-top: 1px solid #2d3f55;
    padding: 8px 16px;
    flex-shrink: 0;
}

.reply-bar-inner { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.reply-bar-content { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.reply-bar-content > i { color: #3b82f6; font-size: 0.85em; flex-shrink: 0; }
.reply-bar-user { display: block; font-size: 0.75em; font-weight: 600; color: #60a5fa; }
.reply-bar-text {
    display: block; font-size: 0.78em; color: #64748b;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px;
}
.cancel-reply {
    background: none; border: none; color: #64748b;
    cursor: pointer; font-size: 0.9em;
    padding: 4px 6px; border-radius: 4px; transition: 0.2s;
}
.cancel-reply:hover { color: #f8fafc; background: rgba(255,255,255,0.08); }

/* ===== FOOTER ===== */
footer {
    padding: 12px 14px;
    background: #0f172a;
    display: flex;
    gap: 10px;
    border-top: 1px solid #334155;
    flex-shrink: 0;
    align-items: center;
}

footer input {
    flex: 1; padding: 11px 18px;
    border-radius: 24px;
    border: 1px solid #334155;
    background: #1e293b; color: white;
    outline: none; font-size: 0.93em;
    transition: border-color 0.2s;
}
footer input:focus { border-color: #3b82f6; }

footer button {
    width: 44px; height: 44px;
    border-radius: 50%; border: none;
    background: #3b82f6; color: white;
    cursor: pointer; transition: 0.25s;
    font-size: 0.95em; flex-shrink: 0;
}
footer button:hover { background: #2563eb; transform: scale(1.07); }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }
