/* ═══════════════════════════════════════════════════════════
   niniwapp · style.css  — liquid glass edition
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=JetBrains+Mono&display=swap');

:root {
    --bg:      #06060f;
    --cyan:    #39ff14;
    --purple:  #f5e642;
    --pink:    #ff6bcd;
    --green:   #00ff88;
    --yellow:  #ffd93d;
    --text:    #e8e8f5;
    --muted:   rgba(232,232,245,0.42);

    /* ── Liquid glass tokens ── */
    --glass-bg:       rgba(255,255,255,0.07);
    --glass-border:   rgba(255,255,255,0.22);
    --glass-blur:     8px;
    --glass-shadow:
        0 8px 32px rgba(0,0,0,0.35),
        inset 0 1px 0 rgba(255,255,255,0.32),
        inset 0 -1px 0 rgba(255,255,255,0.08),
        inset 0 0 4px 2px rgba(255,255,255,0.06);
}

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

body {
    font-family: 'Syne', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}


/* ══════════════════════════════════════════════════════════
   Liquid glass – mixin pattern réutilisé partout
   (::before  = highlight top edge, ::after = left edge)
   ══════════════════════════════════════════════════════════ */
.glass {
    background:         var(--glass-bg);
    backdrop-filter:    blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border:             1px solid var(--glass-border);
    box-shadow:         var(--glass-shadow);
    position:           relative;
    overflow:           hidden;
}
.glass::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.72), transparent);
    pointer-events: none;
    z-index: 1;
}
.glass::after {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 1px; height: 100%;
    background: linear-gradient(180deg,
        rgba(255,255,255,0.72),
        rgba(255,255,255,0.12),
        rgba(255,255,255,0.28));
    pointer-events: none;
    z-index: 1;
}


/* ── Background blobs ────────────────────────────────────── */
/* Plus opaques → ils transpercent le glass */
.blob {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(80px);
    opacity: 0.22;
    animation: blobFloat 14s ease-in-out infinite;
}
.blob-1 { width: 520px; height: 520px; background: var(--cyan);   top: -160px;  left: -130px; animation-delay: 0s; }
.blob-2 { width: 440px; height: 440px; background: var(--purple); bottom: -90px; right: -110px; animation-delay: -5s; }
.blob-3 { width: 360px; height: 360px; background: var(--pink);   top: 38%;  left: 22%;  animation-delay: -9s; }
.blob-4 { width: 300px; height: 300px; background: var(--yellow); top: 18%;  right: 8%;  animation-delay: -3s; opacity: 0.12; }

@keyframes blobFloat {
    0%,100% { transform: translate(0, 0) scale(1); }
    30%     { transform: translate(28px, -38px) scale(1.08); }
    65%     { transform: translate(-22px, 20px) scale(0.93); }
}


/* ── Fireworks canvas ────────────────────────────────────── */
#fireworks {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999;
}


/* ══════════════════════════════════════════════════════════
   Login overlay
   ══════════════════════════════════════════════════════════ */
#login-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    background: rgba(6,6,15,0.45);
    backdrop-filter: blur(4px);
}

.login-card {
    /* Liquid glass — un peu plus opaque pour lisibilité du form */
    background: rgba(255,255,255,0.10);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255,255,255,0.26);
    box-shadow:
        0 24px 64px rgba(0,0,0,0.45),
        inset 0 1px 0 rgba(255,255,255,0.45),
        inset 0 -1px 0 rgba(255,255,255,0.08),
        inset 0 0 4px 2px rgba(255,255,255,0.08);
    border-radius: 26px;
    padding: 40px 36px 32px;
    width: 360px;
    position: relative;
    overflow: hidden;
    z-index: 2;
    display: flex;
    flex-direction: column;
}
/* top-edge highlight */
.login-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.8), transparent);
    pointer-events: none;
}
/* left-edge highlight */
.login-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 1px; height: 100%;
    background: linear-gradient(180deg,
        rgba(255,255,255,0.8),
        rgba(255,255,255,0.1),
        rgba(255,255,255,0.32));
    pointer-events: none;
}

.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand-icon { font-size: 2.4rem; margin-bottom: 10px; }
.login-brand-name {
    font-size: 2.1rem;
    font-weight: 800;
    letter-spacing: 3px;
    background: linear-gradient(135deg, #39ff14, #f5e642);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: logoPulse 3s ease-in-out infinite;
}
.login-brand-sub { margin-top: 6px; font-size: 0.82rem; color: var(--muted); }

@keyframes logoPulse {
    0%,100% { filter: drop-shadow(0 0 6px rgba(57,255,20,0.3)); }
    50%      { filter: drop-shadow(0 0 20px rgba(245,230,66,0.55)); }
}

.login-card input[type="text"] {
    width: 100%;
    /* small glass input */
    background: rgba(255,255,255,0.10);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,0.25);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.25),
        inset 0 0 4px rgba(255,255,255,0.06);
    color: var(--text);
    padding: 13px 16px;
    border-radius: 14px;
    font-family: 'Syne', sans-serif;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 16px;
}
.login-card input[type="text"]::placeholder { color: rgba(232,232,245,0.38); }
.login-card input[type="text"]:focus {
    border-color: rgba(57,255,20,0.55);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.3),
        0 0 0 3px rgba(57,255,20,0.12);
}

.section-label {
    font-size: 0.76rem;
    color: var(--muted);
    margin-bottom: 9px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.preset-avatar {
    cursor: pointer;
    padding: 11px 8px;
    /* mini glass tile */
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,0.18);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.28),
        0 4px 12px rgba(0,0,0,0.2);
    border-radius: 13px;
    font-size: 1.4rem;
    text-align: center;
    transition: all 0.2s;
    user-select: none;
    position: relative;
    overflow: hidden;
}
.preset-avatar::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
    pointer-events: none;
}
.preset-avatar:hover {
    border-color: rgba(57,255,20,0.5);
    background: rgba(57,255,20,0.12);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.35),
        0 0 16px rgba(57,255,20,0.18);
}
.preset-avatar.selected {
    border-color: rgba(57,255,20,0.7);
    background: rgba(57,255,20,0.15);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.4),
        0 0 20px rgba(57,255,20,0.28);
}

.upload-avatar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px;
    background: rgba(245,230,66,0.10);
    backdrop-filter: blur(6px);
    border: 1px dashed rgba(245,230,66,0.4);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
    border-radius: 13px;
    color: rgba(232,232,245,0.85);
    text-align: center;
    cursor: pointer;
    font-size: 0.83rem;
    font-family: 'Syne', sans-serif;
    transition: all 0.2s;
    margin-bottom: 10px;
}
.upload-avatar-btn:hover {
    background: rgba(245,230,66,0.18);
    border-color: var(--purple);
}

#avatarPreview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    padding: 8px 12px;
    background: rgba(0,255,136,0.08);
    border: 1px solid rgba(0,255,136,0.25);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
    border-radius: 12px;
}
.avatar-preview-img {
    width: 44px; height: 44px;
    border-radius: 10px;
    object-fit: cover;
    border: 1.5px solid rgba(57,255,20,0.6);
}
.avatar-preview-ok { font-size: 0.8rem; color: var(--green); }

.join-btn {
    width: 100%;
    margin-top: 16px;
    padding: 15px;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Syne', sans-serif;
    /* glass button */
    background: rgba(255,255,255,0.10);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.28);
    box-shadow:
        0 8px 24px rgba(0,0,0,0.25),
        inset 0 1px 0 rgba(255,255,255,0.45),
        inset 0 -1px 0 rgba(255,255,255,0.08);
    border-radius: 14px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}
.join-btn::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.7), transparent);
    pointer-events: none;
}
.join-btn:hover {
    background: rgba(255,255,255,0.16);
    box-shadow:
        0 12px 32px rgba(0,0,0,0.3),
        inset 0 1px 0 rgba(255,255,255,0.5),
        0 0 30px rgba(57,255,20,0.14);
    transform: translateY(-1px);
}

.login-footer {
    text-align: center;
    font-size: 0.71rem;
    color: rgba(232,232,245,0.22);
    margin-top: 16px;
    letter-spacing: 1px;
    text-transform: uppercase;
}


/* ══════════════════════════════════════════════════════════
   App principal
   ══════════════════════════════════════════════════════════ */
#app {
    position: relative;
    z-index: 2;
    flex-direction: column;
    height: 100vh;
    max-width: 620px;
    margin: auto;
    /* glass container — très léger, les blobs transparaissent */
    background: rgba(255,255,255,0.04);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-left:  1px solid rgba(255,255,255,0.14);
    border-right: 1px solid rgba(255,255,255,0.06);
    overflow: hidden;
}


/* ── Header ──────────────────────────────────────────────── */
.glass-header {
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(255,255,255,0.18);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.35),
        inset 0 0 4px 2px rgba(255,255,255,0.05),
        0 4px 20px rgba(0,0,0,0.2);
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}
/* top-edge */
.glass-header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.7), transparent);
    pointer-events: none;
}

.app-logo { display: flex; align-items: center; gap: 12px; }

.header-avatar {
    width: 38px; height: 38px;
    border-radius: 11px;
    background: rgba(255,255,255,0.09);
    border: 1px solid rgba(255,255,255,0.22);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.3),
        0 4px 12px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    overflow: hidden;
    flex-shrink: 0;
    isolation: isolate; /* force le clipping du border-radius sur l'img */
}
.header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 0; /* le parent gère le clip */
}

.header-text { display: flex; flex-direction: column; gap: 1px; }

.app-logo-text {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #39ff14, #f5e642);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: logoPulse 3s ease-in-out infinite;
    line-height: 1;
}
.header-pseudo {
    font-size: 0.72rem;
    color: var(--muted);
    font-family: 'JetBrains Mono', monospace;
    line-height: 1;
}

.header-right { display: flex; align-items: center; gap: 8px; }

.online-dot {
    width: 8px; height: 8px;
    background: var(--green);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--green);
    animation: onlinePulse 2s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes onlinePulse {
    0%,100% { opacity: 1; transform: scale(1); }
    50%     { opacity: 0.5; transform: scale(0.8); }
}
.online-label { font-size: 0.72rem; color: var(--green); }

.logout-btn {
    background: rgba(255,68,68,0.10);
    backdrop-filter: blur(6px);
    color: #ff8080;
    border: 1px solid rgba(255,68,68,0.28);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.18),
        0 4px 12px rgba(0,0,0,0.15);
    padding: 5px 11px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: 'Syne', sans-serif;
    transition: all 0.2s;
}
.logout-btn:hover { background: rgba(255,68,68,0.18); }


/* ── Zone messages ───────────────────────────────────────── */
#messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.12) transparent;
}
#messages::-webkit-scrollbar       { width: 4px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }


/* ── Message row : liquid glass ──────────────────────────── */
.message-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 14px;
    /* glass row */
    background: rgba(255,255,255,0.055);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.14);
    box-shadow:
        0 4px 16px rgba(0,0,0,0.18),
        inset 0 1px 0 rgba(255,255,255,0.25),
        inset 0 0 4px rgba(255,255,255,0.04);
    transition: background 0.18s, box-shadow 0.18s;
    animation: msgIn 0.22s ease;
    position: relative;
    overflow: hidden;
}
/* top-edge highlight */
.message-row::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    pointer-events: none;
}
.message-row:hover {
    background: rgba(255,255,255,0.09);
    box-shadow:
        0 6px 20px rgba(0,0,0,0.22),
        inset 0 1px 0 rgba(255,255,255,0.32),
        inset 0 0 4px rgba(255,255,255,0.06);
}

.message-row.mine {
    background: rgba(57,255,20,0.09);
    border-color: rgba(57,255,20,0.22);
    box-shadow:
        0 4px 16px rgba(0,0,0,0.18),
        inset 0 1px 0 rgba(57,255,20,0.3),
        inset 0 0 4px rgba(57,255,20,0.06);
    flex-direction: row-reverse;
}
.message-row.mine::before {
    background: linear-gradient(90deg, transparent, rgba(57,255,20,0.4), transparent);
}
.message-row.mine .msg-name { color: var(--purple); }
.message-row.mine .msg-sep  { color: rgba(245,230,66,0.4); }
.message-row.mine .msg-body { text-align: right; }

@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.msg-avatar-wrap {
    flex-shrink: 0;
    width: 34px; height: 34px;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: rgba(255,255,255,0.09);
    border: 1px solid rgba(255,255,255,0.22);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.3),
        0 4px 10px rgba(0,0,0,0.2);
    margin-top: 1px;
}
.msg-avatar-wrap img { width: 100%; height: 100%; object-fit: cover; }

.msg-body {
    flex: 1;
    min-width: 0;
    align-self: center;
    line-height: 1.7;
    word-break: break-word;
    /* Pas de display:flex ici — les spans enfants restent inline naturellement */
}
/* Forcer inline sur chaque span pour garantir la même ligne */
.msg-name,
.msg-sep,
.msg-text {
    display: inline;
}
.msg-name {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--cyan);
}
.msg-sep {
    font-size: 0.85rem;
    color: rgba(57,255,20,0.35);
    margin: 0 3px;
    font-weight: 300;
}
.msg-text {
    font-size: 0.95rem;
    color: var(--text);
}


/* ── Emoji picker ────────────────────────────────────────── */
#emoji-picker {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    grid-template-columns: repeat(5, 1fr);
    background: rgba(255,255,255,0.10);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.24);
    box-shadow:
        0 16px 48px rgba(0,0,0,0.35),
        inset 0 1px 0 rgba(255,255,255,0.4),
        inset 0 0 4px rgba(255,255,255,0.06);
    border-radius: 16px;
    padding: 10px;
    z-index: 20;
    display: none;
    gap: 3px;
    overflow: hidden;
}
#emoji-picker::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.7), transparent);
}
#emoji-picker span {
    cursor: pointer;
    padding: 9px;
    border-radius: 9px;
    text-align: center;
    font-size: 1.15rem;
    transition: background 0.15s;
    user-select: none;
    position: relative;
    z-index: 1;
}
#emoji-picker span:hover {
    background: rgba(255,255,255,0.14);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.22);
}


/* ── Barre de saisie ─────────────────────────────────────── */
#input-area {
    padding: 12px 14px;
    display: flex;
    gap: 9px;
    align-items: center;
    background: rgba(255,255,255,0.07);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid rgba(255,255,255,0.18);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.3),
        inset 0 0 4px rgba(255,255,255,0.04);
    flex-shrink: 0;
    position: relative;
    overflow: visible;
}
/* top-edge highlight */
#input-area::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
    pointer-events: none;
}

#input-area input[type="text"] {
    flex: 1;
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,0.22);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.22),
        inset 0 0 4px rgba(255,255,255,0.04),
        0 4px 12px rgba(0,0,0,0.15);
    color: var(--text);
    padding: 12px 16px;
    border-radius: 13px;
    font-family: 'Syne', sans-serif;
    font-size: 0.93rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 0;
}
#input-area input[type="text"]::placeholder { color: rgba(232,232,245,0.35); }
#input-area input[type="text"]:focus {
    border-color: rgba(57,255,20,0.5);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.28),
        0 0 0 3px rgba(57,255,20,0.10),
        0 4px 12px rgba(0,0,0,0.15);
}

.icon-btn, .send-btn {
    flex-shrink: 0;
    width: 46px; height: 46px;
    padding: 0;
    border-radius: 13px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: 'Syne', sans-serif;
    transition: all 0.18s;
    /* glass button */
    background: rgba(255,255,255,0.09);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.22);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.32),
        inset 0 0 4px rgba(255,255,255,0.06),
        0 4px 14px rgba(0,0,0,0.2);
    color: var(--text);
    position: relative;
    overflow: hidden;
}
.icon-btn::before, .send-btn::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
    pointer-events: none;
}
.icon-btn:hover {
    background: rgba(255,255,255,0.14);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.4),
        0 6px 18px rgba(0,0,0,0.22);
}

.send-btn {
    background: rgba(57,255,20,0.14);
    border-color: rgba(57,255,20,0.38);
    box-shadow:
        inset 0 1px 0 rgba(57,255,20,0.4),
        inset 0 0 4px rgba(57,255,20,0.08),
        0 4px 14px rgba(0,0,0,0.2);
    color: var(--cyan);
}
.send-btn::before {
    background: linear-gradient(90deg, transparent, rgba(57,255,20,0.5), transparent);
}
.send-btn:hover {
    background: rgba(57,255,20,0.22);
    box-shadow:
        inset 0 1px 0 rgba(57,255,20,0.5),
        0 0 24px rgba(57,255,20,0.22),
        0 6px 18px rgba(0,0,0,0.22);
    transform: scale(1.05);
}