* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --accent: #6d5ff7;
    --accent-light: #a78bfa;
    --bg-glass: rgba(255, 255, 255, 0.06);
    --border-glass: rgba(255, 255, 255, 0.14);
    --text-muted: rgba(255, 255, 255, 0.6);
    --radius: 14px;
    --radius-sm: 8px;
    --radius-pill: 999px;
}

body {
    font-family: 'Inter', Arial, sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: #fff;
    min-height: 100vh;
}

/* App Shell */
#app {
    max-width: 600px;
    margin: 50px auto;
    padding: 1.5rem;
    background: var(--bg-glass);
    backdrop-filter: blur(18px);
    border: 0.5px solid var(--border-glass);
    border-radius: var(--radius);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

/* ==================== LOGIN ==================== */
.login_container {
    max-width: 380px;
    margin: 30px auto;
    padding: 1.75rem 1.5rem;
    background: var(--bg-glass);
    backdrop-filter: blur(18px);
    border: 0.5px solid var(--border-glass);
    border-radius: var(--radius);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.login_container h2 {
    text-align: center;
    margin-bottom: 1.25rem;
    font-size: 20px;
}

.login_container input {
    display: block;
    width: 100%;
    margin-bottom: 12px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.07);
    border: 0.5px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 14px;
}

.login_container input:focus,
.login_container input:hover {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.1);
}

.login_container button {
    width: 100%;
    padding: 11px;
    margin-top: 8px;
    border-radius: var(--radius-sm);
}

#errorMessage {
    color: red;
    text-align: center;
    margin-top: 15px;
    font-size: 14px;
}

/* ==================== CHAT ==================== */
#chat {
    max-width: 1100px;
    margin: 40px auto;
    height: calc(100vh - 100px);
    background: var(--bg-glass);
    backdrop-filter: blur(18px);
    border: 0.5px solid var(--border-glass);
    border-radius: var(--radius);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: none;           /* Controlled by JS with .hidden */
    flex-direction: column;
}

.chat_header {
    padding: 16px;
    border-bottom: 0.5px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat_header h1 {
    font-size: 18px;
}

h1 {
    font-size: 50px;
    color: var(--accent-light);
    text-shadow: 0 0 6px var(--accent-light);
    text-align: center;
}

p {
    text-align: center;
    color: var(--text-muted);
    margin-top: 8px;
}

#currentUser {
    font-size: 14px;
    color: var(--text-muted);
}

/* Messages Container */
#messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message Styling */
/* Fix bubble shape */
.message {
    max-width: 75%;
    padding: 11px 16px;
    border-radius: var(--radius);
    border-bottom-left-radius: var(--radius-sm);
    background: var(--bg-glass);
    border: 0.5px solid var(--border-glass);
    font-size: 14.5px;
    line-height: 1.45;
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border: none;
    border-radius: var(--radius);
    border-bottom-right-radius: var(--radius-sm);
    color: white;
}

/* Status dots — used everywhere */
.dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}
.dot.green  { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.dot.yellow { background: #eab308; box-shadow: 0 0 6px #eab308; }
.dot.red    { background: #ef4444; box-shadow: 0 0 6px #ef4444; }

/* User list items */
.user-item {
    padding: 9px 16px;
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 14px;
}
.user-item:hover { background: rgba(255,255,255,0.07); }

.user-name { flex: 1; }
.user-name.self { font-weight: 700; color: var(--accent-light); }

.user-status-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: capitalize;
}

/* Status picker in header */
.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.status-picker {
    display: flex;
    gap: 6px;
}

.status-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-size: 12px;
    border-radius: var(--radius-pill);
    background: rgba(255,255,255,0.07);
    border: 0.5px solid var(--border-glass);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.status-btn:hover,
.status-btn.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-color: rgba(255,255,255,0.3);
}

/* System messages */
.system_message {
    text-align: center;
    font-size: 12.5px;
    color: var(--text-muted);
    padding: 2px 0;
    font-style: italic;
}

.message_time {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 8px;
}

.message_text {
    margin-top: 3px;
    word-break: break-word;
}

/* Input Area */
.message_row {
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.25);
    border-top: 0.5px solid var(--border-glass);
    display: flex;
    gap: 10px;
}

.message_row input {
    flex: 1;
    background: rgba(255, 255, 255, 0.08);
    border: 0.5px solid var(--border-glass);
    border-radius: var(--radius-pill);
    padding: 12px 18px;
    color: #fff;
    font-size: 15px;
    outline: none;
}

.message_row input:focus {
    border-color: var(--accent);
}

.message_row button {
    padding: 0 26px;
    font-size: 14px;
    font-weight: 500;
}

/* User List Sidebar */
#chat {
    display: none;   /* Changed to flex for sidebar */
}

.chat-wrapper {
    display: flex;
    width: 100%;
    height: 100%;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Sidebar */
.user-list-sidebar {
    width: 240px;
    border-left: 0.5px solid var(--border-glass);
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.user-list-header {
    padding: 16px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--accent-light);
    border-bottom: 0.5px solid var(--border-glass);
}

.user-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.user-item {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14.5px;
}

.user-item:hover {
    background: rgba(255,255,255,0.08);
}

.user-item .status {
    width: 9px;
    height: 9px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 6px #22c55e;
}

.user-item.offline .status {
    background: #64748b;
    box-shadow: none;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
}

#footer {
    text-align: center;
    padding: 20px;
    font-size: 13px;
    color: var(--text-muted);
}

#currentUser {
    font-size: 14px;
    color: var(--text-muted);
    text-align: right;
    margin-top: 8px;
    color: var(--accent-light);
}

.system_message {
    text-align: center;
    font-size: 12.5px;
    color: var(--text-muted);
    padding: 2px 0;
    font-style: italic;
}

/* ── Message header / delete btn ── */
.msg-header {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.delete-msg-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    opacity: 0.4;
    padding: 0 2px;
    transition: opacity 0.2s;
    margin-left: auto;
}
.delete-msg-btn:hover { opacity: 1; }

/* ── Media in messages ── */
.msg-media {
    max-width: 300px;
    max-height: 250px;
    border-radius: 10px;
    margin-top: 8px;
    display: block;
    cursor: pointer;
    object-fit: cover;
}
video.msg-media { cursor: default; }

/* ── Reaction bar ── */
.msg-footer {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.reaction-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.reaction-chip {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,0.1);
    border: 0.5px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}
.reaction-chip:hover  { background: rgba(255,255,255,0.18); }
.reaction-chip.reacted{ background: rgba(109,95,247,0.4); border-color: var(--accent); }

.add-reaction-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    opacity: 0.4;
    padding: 0 2px;
    transition: opacity 0.2s;
}
.add-reaction-btn:hover { opacity: 1; }

/* ── Emoji picker ── */
.emoji-picker {
    position: fixed;
    z-index: 999;
    background: #1e1b3a;
    border: 0.5px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
}
.emoji-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.15s;
}
.emoji-btn:hover { background: rgba(255,255,255,0.1); }

/* ── File upload ── */
.upload-btn {
    cursor: pointer;
    font-size: 20px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.upload-btn:hover { opacity: 1; }

.file-preview-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--accent-light);
    background: rgba(109,95,247,0.15);
    border-radius: 999px;
    padding: 4px 10px;
    max-width: 220px;
    overflow: hidden;
    white-space: nowrap;
}
.file-preview-bar button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    padding: 0;
}

/* ── Admin button ── */
.admin-btn {
    font-size: 12px;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    background: rgba(109,95,247,0.25);
    border: 0.5px solid var(--accent);
    color: var(--accent-light);
    cursor: pointer;
    transition: background 0.2s;
}
.admin-btn:hover { background: rgba(109,95,247,0.45); }

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-overlay[hidden] { display: none; }

.modal {
    background: #1a1730;
    border: 0.5px solid var(--border-glass);
    border-radius: var(--radius);
    width: min(700px, 95vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 0.5px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 { font-size: 18px; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
}
.modal-close:hover { color: #fff; }

.modal-body {
    overflow-y: auto;
    padding: 16px 20px;
}

/* ── Admin table ── */
#adminTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
#adminTable th {
    text-align: left;
    padding: 8px 10px;
    color: var(--text-muted);
    border-bottom: 0.5px solid var(--border-glass);
    font-weight: 500;
}
#adminTable td {
    padding: 10px;
    border-bottom: 0.5px solid rgba(255,255,255,0.05);
    vertical-align: middle;
}
#adminTable select {
    background: rgba(255,255,255,0.07);
    border: 0.5px solid var(--border-glass);
    border-radius: 6px;
    color: #fff;
    padding: 4px 8px;
    font-size: 13px;
}

.ban-btn {
    padding: 4px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    background: rgba(239,68,68,0.2);
    border: 0.5px solid #ef4444;
    color: #fca5a5;
    transition: background 0.2s;
}
.ban-btn:hover { background: rgba(239,68,68,0.4); }
.ban-btn.unban {
    background: rgba(34,197,94,0.15);
    border-color: #22c55e;
    color: #86efac;
}
.ban-btn.unban:hover { background: rgba(34,197,94,0.3); }

.banned-label { color: #ef4444; font-size: 12px; font-weight: 600; }

/* ── Role badges ── */
.role-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.role-badge.admin    { background: rgba(239,68,68,0.2);  color: #fca5a5; border: 0.5px solid #ef4444; }
.role-badge.mod      { background: rgba(234,179,8,0.2);  color: #fde68a; border: 0.5px solid #eab308; }
.role-badge.standard { background: rgba(255,255,255,0.07); color: var(--text-muted); border: 0.5px solid var(--border-glass); }

/* ── Lightbox ── */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
.lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: var(--radius);
    object-fit: contain;
}
.lightbox span {
    position: absolute;
    top: 20px;
    right: 24px;
    font-size: 28px;
    color: #fff;
    cursor: pointer;
    opacity: 0.7;
}
.lightbox span:hover { opacity: 1; }

/* ── Logout button ── */
.logout-btn {
    font-size: 12px;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    background: rgba(239, 68, 68, 0.15);
    border: 0.5px solid #ef4444;
    color: #fca5a5;
    cursor: pointer;
    transition: background 0.2s;
}

.logout-btn:hover { background: rgba(239, 68, 68, 0.35); }

/* ── Admin table select fix ── */
#adminTable select {
    background: #1e1b3a;
    border: 0.5px solid var(--border-glass);
    border-radius: 6px;
    color: #fff;
    padding: 4px 8px;
    font-size: 13px;
}

#adminTable select option {
    background: #1e1b3a;
    color: #fff;
}