/* ═══════════════════════════════════════════════════════════════
   IMPULSE MESSENGER — Acid Liquid Glass Design System v2
   With Auth Screens & Real Messaging
   ═══════════════════════════════════════════════════════════════ */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --acid-cyan: #00f0ff;
    --acid-magenta: #ff006e;
    --acid-violet: #b400ff;
    --acid-lime: #39ff14;
    --acid-pink: #ff61d8;
    --acid-orange: #ff6a00;
    --acid-yellow: #f5ff00;
    --acid-blue: #4d4dff;

    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-bg-hover: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hi: rgba(255, 255, 255, 0.15);
    --glass-blur: 18px;
    --glass-blur-lg: 28px;

    --surface-dark: #08080e;
    --surface-msg: rgba(255, 255, 255, 0.05);
    --surface-msg-own: linear-gradient(135deg, rgba(0, 240, 255, 0.15), rgba(180, 0, 255, 0.12));

    --text-primary: #f0f0f8;
    --text-secondary: rgba(240, 240, 248, 0.55);
    --text-tertiary: rgba(240, 240, 248, 0.3);

    --sidebar-w: 360px;
    --header-h: 60px;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 50px;
    --ease-spring: cubic-bezier(.175, .885, .32, 1.275);
    --ease-out: cubic-bezier(.25, .46, .45, .94);
    --speed: .25s;
}

html {
    font-size: 15px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--surface-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* ── Background Orbs ── */
.bg-orbs {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: .35;
    animation: orbFloat 20s ease-in-out infinite alternate;
}

.orb-1 {
    width: 600px;
    height: 600px;
    background: var(--acid-violet);
    top: -10%;
    left: -10%;
    animation-duration: 25s;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: var(--acid-cyan);
    top: 60%;
    right: -5%;
    animation-duration: 22s;
    animation-delay: -5s;
}

.orb-3 {
    width: 400px;
    height: 400px;
    background: var(--acid-magenta);
    bottom: -15%;
    left: 30%;
    animation-duration: 28s;
    animation-delay: -10s;
}

.orb-4 {
    width: 350px;
    height: 350px;
    background: var(--acid-lime);
    top: 20%;
    right: 25%;
    animation-duration: 30s;
    animation-delay: -3s;
    opacity: .2;
}

.orb-5 {
    width: 300px;
    height: 300px;
    background: var(--acid-orange);
    bottom: 30%;
    left: 10%;
    animation-duration: 18s;
    animation-delay: -8s;
    opacity: .18;
}

@keyframes orbFloat {
    0% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(60px, -40px) scale(1.1);
    }

    66% {
        transform: translate(-30px, 50px) scale(.95);
    }

    100% {
        transform: translate(40px, -20px) scale(1.05);
    }
}

/* ═══════════════════  AUTH & SETUP SCREENS  ═══════════════════ */
.screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.glass-card {
    background: rgba(14, 14, 24, 0.85);
    backdrop-filter: blur(var(--glass-blur-lg));
    border: 1px solid var(--glass-border-hi);
    border-radius: var(--radius-xl);
    padding: 40px 36px;
    max-width: 420px;
    width: 100%;
    position: relative;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--acid-cyan), var(--acid-violet), transparent);
    opacity: .5;
}

.glass-card h1 {
    text-align: center;
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--acid-cyan), var(--acid-violet), var(--acid-magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.auth-sub {
    text-align: center;
    color: var(--text-tertiary);
    font-size: .85rem;
    margin-bottom: 20px;
}

.auth-logo {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-pulse {
    position: absolute;
    inset: -15px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 240, 255, 0.15), rgba(180, 0, 255, 0.1), transparent 70%);
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: .6;
    }

    50% {
        transform: scale(1.2);
        opacity: .3;
    }
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    gap: 4px;
    margin: 20px 0 16px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.04);
    padding: 4px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: .88rem;
    font-weight: 500;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--speed);
}

.auth-tab.active {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(180, 0, 255, 0.15));
    color: var(--acid-cyan);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.1);
}

/* Form */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: .78rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    height: 44px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0 14px;
    color: var(--text-primary);
    font-size: .9rem;
    font-family: inherit;
    outline: none;
    transition: all var(--speed);
}

.form-group input::placeholder {
    color: var(--text-tertiary);
}

.form-group input:focus {
    border-color: var(--acid-cyan);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1);
}

.username-input {
    display: flex;
    align-items: center;
    gap: 0;
}

.at-sign {
    height: 44px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    background: rgba(0, 240, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-right: none;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    color: var(--acid-cyan);
    font-weight: 600;
    font-size: .95rem;
}

.username-input input {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.username-hint {
    font-size: .72rem;
    color: var(--text-tertiary);
    margin-top: 4px;
    display: block;
}

.username-hint.error {
    color: var(--acid-magenta);
}

.username-hint.success {
    color: var(--acid-lime);
}

.btn-primary {
    width: 100%;
    height: 48px;
    border: none;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--acid-cyan), var(--acid-violet));
    color: #fff;
    font-size: .95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--speed);
    margin-top: 8px;
    box-shadow: 0 4px 20px rgba(0, 240, 255, 0.2);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 25px rgba(0, 240, 255, 0.3);
}

.btn-primary:active {
    transform: scale(.98);
}

.btn-primary:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    height: 44px;
    padding: 0 24px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    font-size: .9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--speed);
}

.btn-secondary:hover {
    background: var(--glass-bg-hover);
    color: var(--text-primary);
}

.auth-hint {
    text-align: center;
    font-size: .78rem;
    color: var(--text-tertiary);
    margin-top: 12px;
}

.auth-hint a {
    color: var(--acid-cyan);
    text-decoration: none;
}

.auth-hint.error {
    color: var(--acid-magenta);
}

/* ═══════════════════  APP ═══════════════════ */
.app {
    position: relative;
    z-index: 1;
    display: flex;
    height: 100vh;
    background: rgba(8, 8, 14, 0.6);
    backdrop-filter: blur(4px);
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur-lg));
    border-right: 1px solid var(--glass-border);
    position: relative;
    z-index: 10;
    transition: transform var(--speed) var(--ease-out);
}

.sidebar-header {
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    border-bottom: 1px solid var(--glass-border);
}

.search-box {
    flex: 1;
    position: relative;
}

.search-box input {
    width: 100%;
    height: 38px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    padding: 0 14px 0 36px;
    color: var(--text-primary);
    font-size: .87rem;
    outline: none;
    transition: all var(--speed);
}

.search-box input::placeholder {
    color: var(--text-tertiary);
}

.search-box input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--acid-cyan);
    box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--speed);
    position: relative;
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--glass-bg-hover);
    color: var(--text-primary);
}

.icon-btn:active {
    transform: scale(.92);
}

/* New Chat Button */
.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.12), rgba(180, 0, 255, 0.08));
    border: 1px solid rgba(0, 240, 255, 0.2);
    border-radius: var(--radius-md);
    color: var(--acid-cyan);
    font-size: .88rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--speed);
}

.new-chat-btn:hover {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(180, 0, 255, 0.15));
    transform: translateY(-1px);
}

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
    list-style: none;
    padding: 4px 0;
}

.chat-list::-webkit-scrollbar {
    width: 4px;
}

.chat-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.empty-chats {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 8px;
    text-align: center;
}

.empty-chats p {
    color: var(--text-secondary);
    font-size: .95rem;
}

.empty-chats span {
    color: var(--text-tertiary);
    font-size: .8rem;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: all var(--speed);
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.chat-item:hover {
    background: var(--glass-bg-hover);
}

.chat-item.active {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.08), rgba(180, 0, 255, 0.06));
    border-left: 3px solid var(--acid-cyan);
}

.chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
}

.chat-avatar .online-dot {
    position: absolute;
    bottom: 8px;
    left: 50px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--acid-lime);
    border: 2px solid var(--surface-dark);
    box-shadow: 0 0 6px var(--acid-lime);
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-info-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 3px;
}

.chat-name {
    font-weight: 600;
    font-size: .93rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: .72rem;
    color: var(--text-tertiary);
    white-space: nowrap;
    margin-left: 8px;
}

.chat-preview {
    font-size: .82rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: linear-gradient(135deg, var(--acid-cyan), var(--acid-violet));
    color: #000;
    font-weight: 700;
    font-size: .7rem;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    flex-shrink: 0;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.sidebar-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--glass-border);
}

.supabase-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .72rem;
    color: var(--text-tertiary);
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.supabase-badge strong {
    color: var(--acid-lime);
}

.footer-branding {
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-tertiary);
    margin-top: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    opacity: 0.7;
}

/* ═══════════════════  CHAT AREA  ═══════════════════ */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: 0;
}

.chat-header {
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur-lg));
    border-bottom: 1px solid var(--glass-border);
    position: relative;
    z-index: 5;
}

.chat-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--acid-cyan), var(--acid-violet), transparent);
    opacity: .3;
}

.back-btn {
    display: none;
}

.chat-header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    flex-shrink: 0;
    display: none;
}

.chat-header-avatar.visible {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
}

.chat-header-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.chat-header-name {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header-status {
    font-size: .75rem;
    color: var(--text-tertiary);
}

.chat-header-status.online {
    color: var(--acid-lime);
}

.chat-header-actions {
    display: flex;
    gap: 2px;
}

/* ── Messages ── */
.messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 20px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
    width: 5px;
}

.messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

.welcome-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    text-align: center;
    animation: fadeInUp .6s var(--ease-spring);
}

.welcome-logo {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-state h2 {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--acid-cyan), var(--acid-violet), var(--acid-magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-state p {
    color: var(--text-secondary);
    font-size: .9rem;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.date-separator {
    text-align: center;
    margin: 12px 0;
}

.date-separator span {
    display: inline-block;
    padding: 4px 14px;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-full);
    font-size: .72rem;
    color: var(--text-tertiary);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Message bubble */
.message {
    display: flex;
    gap: 8px;
    max-width: 70%;
    animation: msgIn .35s var(--ease-spring);
    position: relative;
}

.message.own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.other {
    align-self: flex-start;
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.msg-bubble {
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    position: relative;
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    cursor: default;
    transition: all var(--speed);
}

.msg-bubble::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, transparent 50%);
    pointer-events: none;
}

.message.other .msg-bubble {
    background: var(--surface-msg);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
}

.msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    margin-top: auto;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.msg-avatar:hover {
    transform: scale(1.15);
}

.avatar-emoji-selector {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    margin-top: 8px;
}

.avatar-emoji-item {
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 10px;
    transition: all 0.2s;
}

.avatar-emoji-item:hover {
    background: var(--glass-bg-hover);
    transform: scale(1.1);
}

.avatar-emoji-item.selected {
    background: rgba(0, 240, 255, 0.1);
    border: 1px solid var(--acid-cyan);
}

.avatar-emoji-item.none {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    border: 1px dashed var(--glass-border);
}

.message.own .msg-bubble {
    background: var(--surface-msg-own);
    border-color: rgba(0, 240, 255, 0.12);
    border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.05);
}

.msg-sender {
    font-size: .78rem;
    font-weight: 600;
    margin-bottom: 3px;
    color: var(--acid-cyan);
}

.msg-text {
    font-size: .9rem;
    line-height: 1.5;
    word-break: break-word;
}

.msg-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
    margin-top: 4px;
}

.msg-time {
    font-size: .68rem;
    color: var(--text-tertiary);
}

.msg-status {
    font-size: .72rem;
}

.msg-status.sent {
    color: var(--text-tertiary);
}

.msg-status.read {
    color: var(--acid-cyan);
}

/* Media in messages */
.msg-media {
    border-radius: var(--radius-md);
    overflow: hidden;
    margin: 6px 0;
    max-width: 320px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    cursor: pointer;
}

.msg-media img,
.msg-media video {
    display: block;
    width: 100%;
    max-height: 300px;
    object-fit: cover;
}

/* Voice message */
.msg-voice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    min-width: 200px;
}

.voice-play {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--acid-cyan), var(--acid-violet));
    border: none;
    cursor: pointer;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform .2s;
    font-size: .9rem;
}

.voice-play:hover {
    transform: scale(1.1);
}

.voice-waves {
    flex: 1;
    height: 30px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.voice-waves .bar {
    width: 3px;
    border-radius: 2px;
    background: linear-gradient(to top, var(--acid-cyan), var(--acid-violet));
    opacity: .6;
}

.voice-duration {
    font-size: .72rem;
    color: var(--text-tertiary);
    white-space: nowrap;
}

/* File message */
.msg-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    cursor: pointer;
}

.file-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--acid-orange), var(--acid-magenta));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: .85rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    font-size: .72rem;
    color: var(--text-tertiary);
}

/* Reactions */
.msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.reaction-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    font-size: .78rem;
    cursor: pointer;
    transition: all var(--speed);
    backdrop-filter: blur(8px);
}

.reaction-chip:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.1);
}

.reaction-chip.own {
    border-color: rgba(0, 240, 255, 0.3);
    background: rgba(0, 240, 255, 0.1);
}

.reaction-chip .count {
    font-size: .7rem;
    color: var(--text-secondary);
}

/* ── Typing ── */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 4px 20px 8px;
    font-size: .8rem;
    color: var(--text-tertiary);
}

.typing-indicator.visible {
    display: flex;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--acid-cyan);
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: .2s;
}

.typing-dot:nth-child(3) {
    animation-delay: .4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: .3;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ── Input Area ── */
.input-area {
    padding: 8px 14px 10px;
    position: relative;
    z-index: 5;
    display: none;
}

.input-area.visible {
    display: block;
}

.glass-bar {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(var(--glass-blur-lg));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    position: relative;
    overflow: hidden;
    transition: all var(--speed);
}

.glass-bar::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0%, transparent 40%);
    border-radius: inherit;
    pointer-events: none;
}

.glass-bar:focus-within {
    border-color: rgba(0, 240, 255, 0.25);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.08);
}

.input-wrapper {
    flex: 1;
}

.input-wrapper textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: .9rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 120px;
    min-height: 24px;
    padding: 8px 4px;
    line-height: 1.4;
}

.input-wrapper textarea::placeholder {
    color: var(--text-tertiary);
}

.send-btn {
    color: var(--acid-cyan);
}

.send-btn:hover {
    color: #fff;
    background: rgba(0, 240, 255, 0.2);
}

.mic-btn:hover {
    color: var(--acid-magenta);
}

.attach-btn:hover {
    color: var(--acid-violet);
}

.emoji-btn:hover {
    color: var(--acid-yellow);
}

/* Recording Bar */
.recording-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(255, 0, 110, 0.08);
    border: 1px solid rgba(255, 0, 110, 0.2);
    border-radius: var(--radius-xl);
    margin-top: 6px;
}

.recording-bar.hidden {
    display: none;
}

.rec-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--acid-magenta);
    animation: recPulse 1s ease-in-out infinite;
}

@keyframes recPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.3);
        opacity: .5;
    }
}

.rec-timer {
    font-size: .85rem;
    color: var(--acid-magenta);
    font-weight: 600;
    min-width: 40px;
}

.rec-waves {
    flex: 1;
    height: 24px;
    display: flex;
    align-items: center;
    gap: 2px;
    overflow: hidden;
}

.rec-waves .bar {
    width: 3px;
    border-radius: 2px;
    background: var(--acid-magenta);
    opacity: .5;
    transition: height .1s;
}

.rec-cancel {
    color: var(--text-secondary);
}

.rec-cancel:hover {
    color: var(--acid-magenta);
}

.rec-send {
    color: var(--acid-cyan);
}

.rec-send:hover {
    color: #fff;
    background: rgba(0, 240, 255, 0.2);
}

/* ── Emoji Panel ── */
.emoji-panel {
    position: absolute;
    bottom: 80px;
    left: 14px;
    right: 14px;
    max-width: 420px;
    display: none;
    flex-direction: column;
    background: rgba(14, 14, 24, 0.95);
    backdrop-filter: blur(var(--glass-blur-lg));
    border: 1px solid var(--glass-border-hi);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 20;
    animation: popUp .25s var(--ease-spring);
    max-height: 300px;
    overflow: hidden;
}

.emoji-panel.visible {
    display: flex;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 10px;
    overflow-y: auto;
    max-height: 280px;
}

.emoji-grid::-webkit-scrollbar {
    width: 4px;
}

.emoji-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.emoji-grid button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    font-size: 1.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all .15s;
}

.emoji-grid button:hover {
    background: var(--glass-bg-hover);
    transform: scale(1.2);
}

@keyframes popUp {
    from {
        opacity: 0;
        transform: translateY(10px) scale(.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Reaction Picker */
.reaction-picker {
    position: absolute;
    display: none;
    gap: 4px;
    padding: 6px 10px;
    background: rgba(14, 14, 24, 0.95);
    backdrop-filter: blur(var(--glass-blur-lg));
    border: 1px solid var(--glass-border-hi);
    border-radius: var(--radius-full);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 30;
    animation: popUp .2s var(--ease-spring);
}

.reaction-picker.visible {
    display: flex;
}

.reaction-option {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 50%;
    transition: all .15s;
}

.reaction-option:hover {
    background: var(--glass-bg-hover);
    transform: scale(1.3);
}

/* ═══════════════════  MODAL ═══════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    max-width: 400px;
    width: 100%;
    padding: 30px;
}

.modal h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 4px;
    background: linear-gradient(135deg, var(--acid-cyan), var(--acid-violet));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal p {
    color: var(--text-secondary);
    font-size: .85rem;
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* Group Member Selection */
.group-member-selection {
    max-height: 200px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    margin-top: 10px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.selection-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--speed);
    border: 1px solid transparent;
}

.selection-item:hover {
    background: var(--glass-bg-hover);
}

.selection-item.selected {
    background: rgba(0, 240, 255, 0.1);
    border-color: rgba(0, 240, 255, 0.3);
}

.selection-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 600;
}

.selection-info {
    flex: 1;
}

.selection-name {
    font-size: .85rem;
    font-weight: 500;
}

.selection-check {
    width: 18px;
    height: 18px;
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--speed);
}

.selected .selection-check {
    background: var(--acid-cyan);
    border-color: var(--acid-cyan);
}

/* Button Loaders */
.btn-loader {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.empty-selection-hint {
    color: var(--text-tertiary);
    font-size: .8rem;
    text-align: center;
    padding: 20px;
}

/* Info Modal Styling */
.add-member-zone {
    padding: 16px;
    background: rgba(0, 240, 255, 0.05);
    border-radius: var(--radius-md);
    margin-top: 10px;
    border: 1px dashed rgba(0, 240, 255, 0.2);
}

.add-member-zone .btn-primary {
    margin-top: 10px;
}

.info-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 24px;
}

.info-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.info-body {
    margin: 20px 0;
    max-height: 300px;
    overflow-y: auto;
}

.member-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: 8px;
}

.member-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    font-weight: 600;
    flex-shrink: 0;
}

.member-info {
    flex: 1;
    min-width: 0;
}

.member-name {
    font-size: .9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.member-role {
    font-size: .7rem;
    padding: 2px 6px;
    background: rgba(0, 240, 255, 0.1);
    color: var(--acid-cyan);
    border-radius: 4px;
    font-weight: 600;
}

.kick-btn {
    padding: 4px 8px;
    background: rgba(255, 0, 110, 0.1);
    color: var(--acid-magenta);
    border: none;
    border-radius: 4px;
    font-size: .75rem;
    cursor: pointer;
    transition: all var(--speed);
}

.kick-btn:hover {
    background: var(--acid-magenta);
    color: #fff;
}

/* Message Context Menu */
.context-menu {
    position: fixed;
    z-index: 2000;
    min-width: 180px;
    padding: 6px;
    border-radius: 12px;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
}

.context-item {
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.context-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.context-item.danger {
    color: var(--acid-magenta);
}

.context-item.danger:hover {
    background: rgba(255, 60, 60, 0.15);
    color: #ff4d4d;
}

.ctx-item {
    padding: 10px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ctx-item:hover {
    background: var(--glass-bg-hover);
}

.ctx-item.danger {
    color: #ff4d4d;
}

.ctx-item.danger:hover {
    background: rgba(255, 60, 60, 0.15);
}

.btn-primary.danger {
    background: linear-gradient(135deg, #ff4d4d, #f44336);
    box-shadow: 0 4px 15px rgba(244, 67, 54, 0.3);
}

.btn-primary.danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(244, 67, 54, 0.4);
}

/* Profiles & Avatars Hover */
.avatar:hover,
.member-avatar:hover {
    transform: scale(1.05);
    cursor: pointer;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

.avatar,
.member-avatar {
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ═══════════════════  NAV MENU ═══════════════════ */
.nav-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--speed);
}

.nav-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.nav-menu {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    z-index: 101;
    background: rgba(14, 14, 24, 0.97);
    backdrop-filter: blur(var(--glass-blur-lg));
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform var(--speed) var(--ease-out);
}

.nav-menu.visible {
    transform: translateX(0);
}

.nav-user {
    padding: 20px 16px;
    display: flex;
    gap: 12px;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

.nav-user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--acid-cyan), var(--acid-violet));
}

.nav-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-user-info strong {
    font-size: .95rem;
}

.nav-user-info span {
    font-size: .78rem;
    color: var(--text-secondary);
}

.nav-links {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: .9rem;
    border-radius: var(--radius-md);
    transition: all var(--speed);
}

.nav-link:hover {
    background: var(--glass-bg-hover);
}

.nav-link svg {
    color: var(--text-secondary);
}

.nav-footer {
    padding: 16px;
    border-top: 1px solid var(--glass-border);
}

.nav-version {
    font-size: .72rem;
    color: var(--text-tertiary);
}

/* ── Discovery & Groups ── */
.discovery-item {
    background: rgba(0, 240, 255, 0.05);
    border: 1px dashed var(--acid-cyan) !important;
    margin: 8px 12px;
    border-radius: var(--radius-md);
}

.discovery-item:hover {
    background: rgba(0, 240, 255, 0.1);
}

/* ── Call Overlay ── */
.call-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(8, 8, 14, 0.9);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.call-card {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 60px;
    box-shadow: 0 0 100px rgba(0, 240, 255, 0.15);
}

.call-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--surface-msg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 800;
    color: #fff;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    position: relative;
}

.call-avatar::after {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 2px solid var(--acid-cyan);
    opacity: 0.5;
    animation: ringPulse 2s infinite;
}

@keyframes ringPulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.call-actions {
    margin-top: 30px;
}

.call-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.3s;
}

.call-btn.hangup {
    background: #ff3b30;
    box-shadow: 0 10px 30px rgba(255, 59, 48, 0.3);
}

.call-btn.hangup:hover {
    transform: scale(1.1);
    background: #ff453a;
}

.call-btn.accept {
    background: #34c759;
    box-shadow: 0 10px 30px rgba(52, 199, 89, 0.3);
}

.call-btn.accept:hover {
    transform: scale(1.1);
    background: #30d158;
}

.call-btn svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* ═══════════════════  MOBILE ═══════════════════ */
@media (max-width: 768px) {
    :root {
        --sidebar-w: 100vw;
    }

    .sidebar {
        position: fixed;
        inset: 0;
        z-index: 50;
    }

    .sidebar.hidden {
        transform: translateX(-100%);
    }

    .chat-area {
        width: 100vw;
    }

    .back-btn {
        display: inline-flex;
    }

    .message {
        max-width: 85%;
    }
}

@media (max-width: 480px) {
    .emoji-grid {
        grid-template-columns: repeat(6, 1fr);
    }

    .glass-card {
        padding: 24px 20px;
    }
}

::selection {
    background: rgba(0, 240, 255, 0.25);
}

:focus-visible {
    outline: 2px solid var(--acid-cyan);
    outline-offset: 2px;
}