/* ═══════════════════════════════════════════════════════════════
   XES — chat styles
   Shared by lobby and room (chat drawer).
   Includes: message bubbles, chat strip input, emoji picker.
   ═══════════════════════════════════════════════════════════════ */


/* ── Message bubbles ── */
.chat-message {
    display: flex;
    flex-direction: row;
    pointer-events: auto;
    padding: 2px 0;
}
.chat-message.mine   { justify-content: flex-end; }
.chat-message.theirs { justify-content: flex-start; }
.chat-message.system { justify-content: center; }

.message-content {
    max-width: 72%;
    padding: 8px 12px;
    border-radius: 16px;
    font-size: 0.84rem;
    line-height: 1.4;
    word-break: break-word;
}

/* Own messages: flat text on the right, marked by a faint full-width band
   (a translucent take on the old deep-blue 'mine' bubble) rather than a
   contained bubble. Partner messages are flat text too — matches global. */
.chat-message.mine {
    /* Faint deep-blue, concentrated on the right and fading to nothing by the
       left edge — no bubble, no rounded corners. The 5px right padding insets
       the content off the gradient's strong edge. */
    background: linear-gradient(to left, rgba(28, 72, 112, 0.3), transparent);
    padding-right: 5px;
}
.chat-message.mine .message-content {
    background: none;
    color: var(--text-primary);
    text-align: right;
    border-radius: 0;
    padding: 3px 4px;
    max-width: 82%;
}

.chat-message.theirs .message-content {
    background: none;
    color: var(--text-primary);
    border-radius: 0;
    padding: 3px 4px;
    max-width: 82%;
}

.chat-message.system .message-content {
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-style: italic;
    padding: 2px 8px;
    max-width: 100%;
}
/* Coloured intro lines: the icebreaker reads ice-blue; the new/guest/level
   identity line reads peach. Everything else stays muted. */
.chat-message.system.ice .message-content         { color: #9bdcff; }
.chat-message.system.intro-peach .message-content { color: #ff9a52; }

/* Post-call rating notifications — opt-in via .rating-msg span passed in
   from rate.js. Bigger, not italic, semantic colour. Keeps subtle system
   lines (mic on/off, etc.) at the default look. */
.chat-message.system .rating-msg {
    font-size: 0.85rem;
    font-style: normal;
    font-weight: 500;
    line-height: 1.45;
    display: inline-block;
    padding: 4px 2px;
}
.chat-message.system .rating-msg.positive { color: #4ade80; }
.chat-message.system .rating-msg.negative { color: #fbbf24; }
.chat-message.system .rating-msg a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.chat-message.system .rating-msg a:hover { opacity: 0.85; }

/* Links inside any chat bubble — white + subtle underline so they read
   cleanly against the deep blue (mine) and coral (theirs) bubbles. The
   existing .chat-message.system .rating-msg a rule overrides via higher
   specificity for the post-call rating system lines. */
.chat-message a {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.15s;
}
.chat-message a:hover { color: var(--primary); }

.message-content.emoji-only {
    background: transparent;
    font-size: 4.6rem;
    line-height: 1.1;
    padding: 2px 4px;
}

.message-image {
    max-width: 100%;
    max-height: 200px;
    border-radius: 10px;
    display: block;
    cursor: pointer;
}

/* ── Music file shared P2P during a call ──────────────────────────────────
   "Rainbow" player — markup + look nicked from the therob.lol html5 skin,
   adapted to sit in the dark chat bubble. Custom controls drive a hidden
   <audio> (see chat.js _wireAudioPlayer). ── */
.message-audio {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 240px;
    max-width: 300px;
}
.chat-message.mine .message-audio { margin-left: auto; }   /* follow right-aligned own messages */
.message-audio-name {
    font-size: 0.82rem;
    font-weight: 600;
    /* inherits the bubble's --text-primary; truncate long names with an ellipsis */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.snd-rainbow .snd-controls {
    display: flex;
    align-items: center;
    height: 40px;
    padding: 7px 12px;
    box-sizing: border-box;
    border-radius: 9px;
    background: linear-gradient(45deg, #ff6b6b, #ffd93d, #6bcf7f, #4ecdc4, #4e89ae, #a77dc2);
    background-size: 300% 300%;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}
/* The signature animated rainbow — only while it's actually playing. */
.snd-rainbow.playing .snd-controls { animation: snd-rainbow-shift 4s ease-in-out infinite; }
@keyframes snd-rainbow-shift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.snd-rainbow .snd-play-btn {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin: 0 8px 0 0;
    padding: 0;
    border: none;
    background: none;
    color: #1a1a1a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
}
.snd-rainbow .snd-play-btn:hover { transform: scale(1.12); color: #000; }
.snd-rainbow .snd-play-btn .ico-pause { display: none; }
.snd-rainbow.playing .snd-play-btn .ico-play  { display: none; }
.snd-rainbow.playing .snd-play-btn .ico-pause { display: block; }
.snd-rainbow .snd-progress {
    flex: 1;
    height: 6px;
    margin: 0 8px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    position: relative;
    touch-action: none;
}
.snd-rainbow .snd-progress-bar {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    background: #1a1a1a;
    transition: width 0.1s linear;
}
.snd-rainbow .snd-progress-handle {
    position: absolute;
    top: 50%;
    left: 0;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #1a1a1a;
    transform: translate(-50%, -50%);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transition: opacity 0.15s ease;
}
.snd-rainbow .snd-progress:hover .snd-progress-handle,
.snd-rainbow .snd-progress.seeking .snd-progress-handle { opacity: 1; }
.snd-rainbow .snd-time {
    flex: 0 0 auto;
    min-width: 38px;
    text-align: right;
    font-size: 11px;
    font-weight: 600;
    color: #1a1a1a;
    font-variant-numeric: tabular-nums;
}
.snd-rainbow .snd-audio { display: none; }

/* ── Full-size image lightbox ── */
.chat-lightbox {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    cursor: zoom-out;
    animation: chat-lightbox-fade 0.15s ease-out;
}
.chat-lightbox.hidden { display: none; }
@keyframes chat-lightbox-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.chat-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    cursor: default;
}
.chat-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s;
}
.chat-lightbox-close:hover { background: rgba(255, 255, 255, 0.22); }

/* ── Chat strip (text input row) ── */
.chat-strip {
    position: relative;
    height: 52px;
    background: rgba(255,255,255,0.02);
    border-top: 1px solid rgba(255,255,255,0.07);
    display: flex;
    align-items: center;
    padding: 0 8px;
    gap: 5px;
    flex-shrink: 0;
}

.chat-text-input {
    flex: 1;
    min-width: 0;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: "Exo 2", sans-serif;
    outline: none;
    transition: border-color 0.18s;
}
.chat-text-input:focus { border-color: rgba(255,255,255,0.22); background: rgba(255,255,255,0.07); }
.chat-text-input::placeholder { color: rgba(255,255,255,0.34); }
.chat-text-input.drag-over {
    border-color: rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.08);
}

.chat-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.09);
    color: var(--text-secondary);
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.14s, border-color 0.14s, color 0.14s;
    flex-shrink: 0;
}
.chat-icon-btn:hover { background: rgba(255,255,255,0.10); border-color: rgba(255,255,255,0.16); color: var(--text-primary); }
/* Toggled-on state for the admin stats button (📊). */
.chat-icon-btn.active {
    background: rgba(74, 222, 128, 0.25);
    color: #fff;
    border-color: rgba(74, 222, 128, 0.5);
}

/* Emoji picker — plain white outline smiley (SVG), not the colour glyph. */
.chat-emoji-btn { color: #fff; }
.chat-emoji-btn svg { width: 23px; height: 23px; display: block; }

/* Send button — white arrow on a subtle dark fill, no teal. */
.chat-send-btn { color: var(--text-primary); }
.chat-send-btn:hover { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.2); color: #fff; }

/* ── Unread badge (used by both pages, positioned by page-specific CSS) ── */
.unread-badge {
    background: var(--danger);
    color: #fff;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0 5px;
}

/* ── Emoji picker (anchored above chat strip) ── */
.emoji-picker {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 48px;
    width: 300px;
    max-height: 200px;
    overflow-y: auto;
    background: var(--dark-panel);
    border: 1px solid var(--dark-border);
    border-radius: var(--radius);
    padding: 10px;
    z-index: 500;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}

.emoji-item {
    background: none;
    border: none;
    font-size: calc(1.2rem + 2px);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.15s;
    line-height: 1;
}
.emoji-item:hover { background: rgba(255,255,255,0.1); }

/* Bio messages — italic, slightly muted */
/* Partner bio intro — "in their own words:" label (regular font, like the
   bio text) over a literal ASCII box. No background, no rounded box. */
.bio-intro { text-align: left; max-width: 94%; }
/* Partner avatar + label share one line above the bio box. */
.bio-intro-head { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.bio-intro-avatar { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; overflow: hidden; background: #161a26; }
.bio-intro-avatar .av-img { width: 100%; height: 100%; display: block; }
.bio-intro-label {
    font-family: "Exo 2", sans-serif;
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.bio-intro-box {
    font-family: 'Space Mono', ui-monospace, monospace;
    font-size: 0.72rem;
    line-height: 1.25;
    color: var(--text-primary);
    margin: 0;
    white-space: pre;
    /* No overflow scroller — the column count is measured to fit, so the box
       never exceeds the chat column (a few words = small box; lots = full). */
    overflow: visible;
}

/* Flag emoji shown on partner connect — large, centered, no bubble */
.message-content.flag {
    background: transparent;
    font-size: 3.6rem;
    line-height: 1;
    padding: 6px 0;
    text-align: center;
    text-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    animation: jamFlagPop 0.5s ease-out;
}

@keyframes jamFlagPop {
    0%   { transform: scale(0.4); opacity: 0; }
    60%  { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); }
}

/* Star/crown rank — gold stars (the 👑 emoji is self-colored). Sits inline
   right after a username (chat, profile) or leading the partner-hint pill. */
.av-rank {
    color: #ffd24a;
    letter-spacing: 1px;
    font-size: 0.82em;
    white-space: nowrap;
    vertical-align: baseline;
}
/* Daily-call streak pill — 🔥 + day count, orange. Orthogonal to rank. */
.av-streak {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    font-size: 0.72em;
    font-weight: 700;
    color: #ffb86b;
    background: rgba(255, 138, 0, 0.14);
    border: 1px solid rgba(255, 138, 0, 0.35);
    border-radius: 999px;
    padding: 0 5px;
    line-height: 1.5;
    white-space: nowrap;
    vertical-align: middle;
}
/* Profile-only "X to next level" progress bar under the level row. */
.level-progress { margin-top: 6px; max-width: 220px; }
.level-progress-track {
    height: 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}
.level-progress-track span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary, #22d3ee), #ffd24a);
}
.level-progress-label {
    margin-top: 4px;
    font-size: 0.7rem;
    color: var(--text-secondary, #9aa0aa);
}
/* Profile achievement badges — earned only (no locked/greyed placeholders). */
.profile-achievements { margin-top: 10px; }
.ach-head {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.78rem; color: var(--text-secondary, #9aa0aa); margin-bottom: 6px;
}
.ach-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.ach {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px; border-radius: 999px;
    font-size: 0.72rem; border: 1px solid transparent;
}
.ach.earned {
    background: rgba(34, 211, 238, 0.12); color: #a5f3fc;
    border-color: rgba(34, 211, 238, 0.3);
}
.ach-emoji { font-size: 0.85rem; line-height: 1; }
.ach-best { margin-top: 8px; font-size: 0.74rem; color: #ffb86b; }



/* ── Typing indicator (in-call peer chat — Signal-style) ──────────────────
   Appended last in #chat-messages-user when the partner is typing; removed
   on their next message, on stop, or via a safety timeout. */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
    margin: 4px 0 6px;
    padding: 9px 13px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--dark-border);
    border-radius: 14px 14px 14px 4px;
}
.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typing-bounce 1.3s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.18s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.36s; }
@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0);    opacity: 0.45; }
    30%           { transform: translateY(-4px); opacity: 1; }
}
