/* ============================================
   SpaceChat — futuristic glassmorphism theme
============================================ */
:root {
    --bg-0: #05060f;
    --bg-1: #0a0d22;
    --bg-2: #11153a;
    --neon-blue: #4d8bff;
    --neon-purple: #a855f7;
    --neon-cyan: #22e1ff;
    --text: #e8ecff;
    --text-dim: #9aa3c7;
    --danger: #ff5577;
    --glass-bg: rgba(20, 24, 60, 0.45);
    --glass-border: rgba(120, 140, 255, 0.18);
    --glow-blue: 0 0 20px rgba(77, 139, 255, 0.55);
    --glow-purple: 0 0 24px rgba(168, 85, 247, 0.55);
    --glow-cyan: 0 0 18px rgba(34, 225, 255, 0.45);
    --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--text);
    background: radial-gradient(ellipse at top, var(--bg-2) 0%, var(--bg-1) 40%, var(--bg-0) 100%);
    background-attachment: fixed;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== Animated stars ===== */
.stars, .stars2, .stars3 {
    position: fixed; inset: 0;
    background-image:
        radial-gradient(1px 1px at 20% 30%, #fff, transparent),
        radial-gradient(1px 1px at 70% 80%, #fff, transparent),
        radial-gradient(2px 2px at 40% 60%, #cfe, transparent),
        radial-gradient(1px 1px at 85% 15%, #fff, transparent),
        radial-gradient(1px 1px at 10% 90%, #fff, transparent),
        radial-gradient(1.5px 1.5px at 55% 25%, #bcf, transparent);
    background-size: 600px 600px;
    pointer-events: none;
    animation: drift 120s linear infinite;
    opacity: 0.6;
    z-index: 0;
}
.stars2 { background-size: 900px 900px; animation-duration: 200s; opacity: 0.4; }
.stars3 { background-size: 1200px 1200px; animation-duration: 300s; opacity: 0.25; }
@keyframes drift {
    from { transform: translate3d(0,0,0); }
    to { transform: translate3d(-600px, -600px, 0); }
}

/* ===== Floating particles ===== */
.particles { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
.particle {
    position: absolute; bottom: -10px;
    width: 4px; height: 4px; border-radius: 50%;
    background: var(--neon-cyan);
    box-shadow: 0 0 12px var(--neon-cyan);
    animation: rise linear infinite;
    opacity: 0.7;
}
.particle:nth-child(3n) { background: var(--neon-purple); box-shadow: 0 0 12px var(--neon-purple); }
.particle:nth-child(3n+1) { background: var(--neon-blue); box-shadow: 0 0 12px var(--neon-blue); }
@keyframes rise {
    0%   { transform: translateY(0) scale(1); opacity: 0; }
    10%  { opacity: 0.8; }
    100% { transform: translateY(-110vh) scale(0.4); opacity: 0; }
}

/* ===== Glass surface ===== */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: 0 8px 40px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.05);
}

/* ===== Logo ===== */
.logo-orb {
    width: 38px; height: 38px; border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--neon-cyan), var(--neon-blue) 50%, var(--neon-purple) 100%);
    box-shadow: var(--glow-purple), var(--glow-cyan);
    animation: pulse 3s ease-in-out infinite;
    display: inline-block;
}
.logo-orb.sm { width: 26px; height: 26px; }
@keyframes pulse {
    0%,100% { transform: scale(1); filter: brightness(1); }
    50%     { transform: scale(1.08); filter: brightness(1.25); }
}

/* ============================================
   LOGIN PAGE
============================================ */
.login-body { display: flex; align-items: center; justify-content: center; }
.login-wrap {
    position: relative; z-index: 2;
    width: 100%; max-width: 460px; padding: 24px;
}
.login-card { padding: 40px 32px; text-align: center; animation: floatIn .6s ease-out; }
@keyframes floatIn {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.logo-big { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 8px; }
.logo-big h1 { font-size: 36px; letter-spacing: -0.5px; font-weight: 800; }
.accent {
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-blue), var(--neon-purple));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { color: var(--text-dim); margin: 8px 0 28px; font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-form label { font-size: 12px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--text-dim); }
.login-form input {
    background: rgba(10,12,30,0.7);
    border: 1px solid var(--glass-border);
    color: var(--text);
    padding: 14px 16px; border-radius: 12px; font-size: 15px;
    outline: none; transition: all .25s;
}
.login-form input:focus {
    border-color: var(--neon-blue);
    box-shadow: var(--glow-blue);
}
.error {
    background: rgba(255, 85, 119, 0.12);
    border: 1px solid rgba(255, 85, 119, 0.4);
    color: #ffb3c2; padding: 10px 12px; border-radius: 10px; font-size: 13px;
}
.login-foot { margin-top: 20px; font-size: 12px; color: var(--text-dim); }

/* ===== Glow button ===== */
.btn-glow {
    border: none; cursor: pointer;
    background: linear-gradient(135deg, var(--neon-blue), var(--neon-purple));
    color: #fff; font-weight: 600; letter-spacing: 0.3px;
    padding: 14px 22px; border-radius: 12px; font-size: 15px;
    box-shadow: var(--glow-blue);
    transition: transform .2s ease, box-shadow .25s ease, filter .2s;
    position: relative; overflow: hidden;
}
.btn-glow:hover { transform: translateY(-2px); box-shadow: var(--glow-purple), var(--glow-blue); filter: brightness(1.1); }
.btn-glow:active { transform: translateY(0); }

/* ============================================
   CHAT PAGE
============================================ */
.chat-body { display: flex; flex-direction: column; }
.topbar {
    position: relative; z-index: 5;
    margin: 12px 12px 0; padding: 10px 18px;
    display: flex; align-items: center; gap: 16px;
    border-radius: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }
.brand-name { letter-spacing: -0.3px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 14px; }
.status-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: #22e17a; box-shadow: 0 0 10px #22e17a;
}
.me-name { color: var(--text); font-weight: 600; }
.logout-btn {
    color: var(--text-dim); text-decoration: none;
    padding: 6px 12px; border-radius: 10px;
    border: 1px solid var(--glass-border);
    transition: all .2s;
}
.logout-btn:hover { color: var(--danger); border-color: var(--danger); box-shadow: 0 0 12px rgba(255,85,119,0.4); }
.menu-toggle {
    display: none; background: transparent; border: 1px solid var(--glass-border);
    color: var(--text); padding: 6px 12px; border-radius: 10px; cursor: pointer; font-size: 18px;
}

.layout {
    flex: 1;
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 12px; padding: 12px;
    height: calc(100vh - 76px);
    position: relative; z-index: 2;
}

/* ===== Sidebar ===== */
.sidebar { padding: 18px; overflow-y: auto; }
.sidebar-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
}
.sidebar-head h3 { font-size: 12px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--text-dim); }
.count-pill {
    background: rgba(34, 225, 255, 0.12);
    color: var(--neon-cyan); font-size: 12px;
    padding: 2px 9px; border-radius: 999px;
    border: 1px solid rgba(34,225,255,0.3);
}
.user-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.user-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 10px;
    transition: background .2s, transform .2s;
    animation: fadeSlide .3s ease;
}
.user-item:hover { background: rgba(120,140,255,0.08); transform: translateX(2px); }
.user-item.me { background: rgba(77,139,255,0.12); border: 1px solid rgba(77,139,255,0.3); }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: #fff;
    background: linear-gradient(135deg, var(--neon-blue), var(--neon-purple));
    box-shadow: 0 0 10px rgba(77,139,255,0.4);
    flex-shrink: 0;
}
.avatar.c2 { background: linear-gradient(135deg, var(--neon-cyan), var(--neon-blue)); }
.avatar.c3 { background: linear-gradient(135deg, var(--neon-purple), #ff5fb6); }
.avatar.c4 { background: linear-gradient(135deg, #22e17a, var(--neon-cyan)); }
.user-name { font-size: 14px; }
.user-presence {
    margin-left: auto; width: 8px; height: 8px; border-radius: 50%;
    background: #22e17a; box-shadow: 0 0 8px #22e17a;
}
@keyframes fadeSlide {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ===== Chat main ===== */
.chat-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.channel-head {
    padding: 14px 20px; display: flex; align-items: center; gap: 14px;
}
.hash {
    font-size: 26px; color: var(--neon-cyan);
    text-shadow: 0 0 14px var(--neon-cyan);
}
.channel-name { font-weight: 700; font-size: 16px; }
.channel-sub { font-size: 12px; color: var(--text-dim); }

.messages {
    flex: 1; overflow-y: auto;
    padding: 18px 22px;
    background: rgba(10,12,30,0.35);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
    scroll-behavior: smooth;
    display: flex; flex-direction: column; gap: 14px;
}
.messages::-webkit-scrollbar, .sidebar::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb {
    background: rgba(120,140,255,0.25); border-radius: 4px;
}
.messages::-webkit-scrollbar-thumb:hover { background: rgba(120,140,255,0.45); }

.msg {
    display: flex; gap: 12px; align-items: flex-start;
    animation: msgIn .35s ease;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.msg-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.msg-meta { display: flex; gap: 8px; align-items: baseline; }
.msg-name { font-weight: 700; font-size: 14px; color: var(--text); }
.msg-name.is-me { color: var(--neon-cyan); }
.msg-time { font-size: 11px; color: var(--text-dim); }
.msg-bubble {
    background: linear-gradient(135deg, rgba(77,139,255,0.12), rgba(168,85,247,0.10));
    border: 1px solid rgba(120,140,255,0.18);
    padding: 10px 14px; border-radius: 14px;
    line-height: 1.5; font-size: 14.5px;
    word-wrap: break-word; overflow-wrap: anywhere;
    max-width: 100%;
    transition: border-color .25s, box-shadow .25s;
}
.msg:hover .msg-bubble { border-color: rgba(120,140,255,0.35); box-shadow: 0 0 14px rgba(77,139,255,0.15); }
.msg.is-me .msg-bubble {
    background: linear-gradient(135deg, rgba(34,225,255,0.18), rgba(77,139,255,0.18));
    border-color: rgba(34,225,255,0.35);
}

.system-msg {
    text-align: center; font-size: 12.5px; color: var(--text-dim);
    padding: 6px 14px; border-radius: 999px;
    background: rgba(120,140,255,0.08);
    border: 1px dashed var(--glass-border);
    align-self: center;
    animation: msgIn .35s ease;
}

/* ===== Typing indicator ===== */
.typing-bar {
    height: 18px; padding: 0 8px;
    font-size: 12.5px; color: var(--text-dim);
    display: flex; align-items: center; gap: 8px;
}
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots span {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--neon-cyan); box-shadow: 0 0 6px var(--neon-cyan);
    animation: bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
    0%,80%,100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-5px); opacity: 1; }
}

/* ===== Composer ===== */
.composer {
    position: relative;
    padding: 10px 12px; display: flex; align-items: center; gap: 10px;
    border-radius: 14px;
}
.composer input {
    flex: 1; background: transparent; border: none; outline: none;
    color: var(--text); font-size: 15px; padding: 12px 8px;
}
.composer input::placeholder { color: var(--text-dim); }
.emoji-btn {
    background: rgba(120,140,255,0.1);
    border: 1px solid var(--glass-border);
    color: var(--text); width: 40px; height: 40px;
    border-radius: 12px; cursor: pointer; font-size: 18px;
    transition: all .2s;
}
.emoji-btn:hover { background: rgba(168,85,247,0.18); box-shadow: var(--glow-purple); }
.emoji-pop {
    position: absolute; bottom: 60px; left: 8px;
    background: rgba(15,18,40,0.95);
    border: 1px solid var(--glass-border);
    border-radius: 12px; padding: 10px;
    display: none; flex-wrap: wrap; gap: 4px;
    width: 240px; box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    backdrop-filter: blur(12px);
    z-index: 10;
}
.emoji-pop.open { display: flex; animation: floatIn .2s ease; }
.emoji-pop button {
    background: transparent; border: none; cursor: pointer;
    font-size: 20px; padding: 4px 6px; border-radius: 6px;
    transition: background .15s, transform .15s;
}
.emoji-pop button:hover { background: rgba(120,140,255,0.2); transform: scale(1.2); }
.send-btn { padding: 10px 20px; font-size: 14px; }

/* ===== Loader ===== */
.loader { display: flex; gap: 6px; justify-content: center; padding: 40px; }
.loader span {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--neon-blue); box-shadow: var(--glow-blue);
    animation: bounce 1.2s infinite;
}
.loader span:nth-child(2) { animation-delay: .15s; background: var(--neon-cyan); box-shadow: var(--glow-cyan); }
.loader span:nth-child(3) { animation-delay: .3s; background: var(--neon-purple); box-shadow: var(--glow-purple); }

/* ============================================
   RESPONSIVE
============================================ */
@media (max-width: 768px) {
    .layout { grid-template-columns: 1fr; height: calc(100vh - 70px); }
    .sidebar {
        position: fixed; top: 70px; left: 12px; right: 12px; bottom: 12px;
        z-index: 20; transform: translateX(-110%); transition: transform .3s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .menu-toggle { display: inline-flex; }
    .topbar { margin: 8px 8px 0; padding: 8px 14px; }
    .layout { padding: 8px; }
    .brand-name { font-size: 16px; }
    .me-name { display: none; }
    .channel-head { padding: 10px 14px; }
    .messages { padding: 14px; }
}
