/* ==============================================
   LIVE ROOM - CHAT & LYRICS SYSTEM
   ============================================== */

/* Messages Container - Apple Music Lyrics Style */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 30vh 32px 25vh;
    /* Large vertical padding to center first/last items */
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* Fade mask at top and bottom */
    mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 85%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 85%, transparent 100%);
}

.messages-container::-webkit-scrollbar {
    display: none;
}

/* Live Lyrics Line - Apple Music Style */
.live-lyrics-line {
    text-align: left;
    padding: 16px 24px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    filter: blur(2px);
    opacity: 0.4;
    transform: scale(0.92);
}

.live-lyrics-line:hover {
    filter: blur(0);
    opacity: 0.6;
    background: rgba(255, 255, 255, 0.03);
}

.live-lyrics-line.active {
    filter: blur(0);
    opacity: 1;
    transform: scale(1);
    background: linear-gradient(135deg, rgba(243, 194, 106, 0.12) 0%, rgba(243, 194, 106, 0.03) 100%);
    border-left: 4px solid var(--gold);
    padding-left: 20px;
}

.live-lyrics-line.user-line {
    filter: blur(0);
    opacity: 1;
    text-align: right;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15) 0%, rgba(236, 72, 153, 0.08) 100%);
    border-left: none;
    border-right: 4px solid var(--purple);
    padding-right: 20px;
    padding-left: 24px;
}

.live-lyrics-meta {
    display: block;
    font-size: 0.85rem;
    color: var(--gold);
    margin-bottom: 8px;
    font-weight: 600;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.live-lyrics-meta .avatar-img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    overflow: hidden;
}

.live-lyrics-line.user-line .live-lyrics-meta {
    color: var(--purple);
}

.live-lyrics-text {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
}

.live-lyrics-line.active .live-lyrics-text {
    color: #fff;
    text-shadow: 0 0 30px rgba(243, 194, 106, 0.4);
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 16px;
    max-width: 85%;
    animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message .avatar {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.message .bubble {
    padding: 16px 20px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    position: relative;
    transition: all 0.3s ease;
}

.message.user .bubble {
    background: linear-gradient(135deg, var(--purple) 0%, var(--pink) 100%);
    border: none;
    box-shadow: 0 10px 20px rgba(168, 85, 247, 0.2);
}

.message .sender {
    font-size: 0.8rem;
    color: var(--gold);
    margin-bottom: 6px;
    font-weight: 700;
}

.message .content {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
}

/* Live Mode Sentence Highlighting (Apple Podcast Style) */
.message .content .sentence {
    display: inline;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    padding: 2px 4px;
    border-radius: 6px;
    margin: 0 1px;
}

.message .content .sentence.active {
    color: var(--gold);
    text-shadow: 0 0 20px rgba(243, 194, 106, 0.5);
    background: rgba(243, 194, 106, 0.1);
    font-weight: 600;
}

/* Text Toggle Logic */
.messages-container.hidden-text .bubble,
.messages-container.hidden-text .live-lyrics-line {
    opacity: 0 !important;
    filter: blur(8px);
    pointer-events: none;
    transform: scale(0.95);
}

.messages-container.hidden-text .message.user .bubble {
    opacity: 1;
    filter: none;
}

/* ==============================================
   PREMIUM FLOATING CONTROLS
   ============================================== */

.live-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 20px 32px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.6) 50%, transparent 100%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    z-index: 200;
}

.mic-hint {
    background: rgba(243, 194, 106, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(243, 194, 106, 0.2);
    color: var(--gold);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    animation: fadeInDown 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    pointer-events: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Current Subtitle in Control Bar */
.live-current-subtitle {
    width: 100%;
    max-width: 600px;
    min-height: 44px;
    padding: 10px 20px;
    margin-bottom: 12px;
    background: rgba(243, 194, 106, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(243, 194, 106, 0.2);
    border-radius: 16px;
    color: var(--gold);
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
    display: none;
    /* Injected via JS when active */
    animation: slideUpFade 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.live-current-subtitle:empty {
    display: none !important;
}

/* AI Avatar Overlay — Premium Podcast Studio Mode */
.live-avatar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(243, 194, 106, 0.03) 0%, transparent 60%);
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.live-avatar-overlay.hidden {
    opacity: 0;
    transform: scale(0.92);
    display: none !important;
}

/* Inner Box Container — Matches Replay Mode .album-art */
.live-album-art {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1/1;
    background: linear-gradient(135deg, #333, #111);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    align-content: center;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 16px;
    gap: 16px;
    pointer-events: auto;
}

/* Individual Avatar Card */
.live-avatar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    gap: 12px;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
}

.live-avatar-item .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    background-color: rgba(20, 20, 30, 0.95);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(255, 255, 255, 0.06);
    border: 3px solid rgba(255, 255, 255, 0.08);
    animation: avatarBreathing 4s ease-in-out infinite;
    transition: border-color 0.4s ease, box-shadow 0.6s ease, transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Character Name Label */
.live-avatar-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    letter-spacing: 0.02em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.3s ease;
    pointer-events: none;
}

/* Speaking State — Golden Glow + Ring Pulse + Bounce-In Scale */
.live-avatar-item.speaking .avatar-img {
    border-color: rgba(243, 194, 106, 0.7);
    box-shadow:
        0 0 0 4px rgba(243, 194, 106, 0.25),
        0 0 30px rgba(243, 194, 106, 0.2),
        0 0 60px rgba(243, 194, 106, 0.08),
        0 20px 50px rgba(0, 0, 0, 0.5);
    animation: speakingPulse 2s ease-in-out infinite, speakingBounceIn 0.6s ease-out forwards;
}

.live-avatar-item.speaking .live-avatar-name {
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 0 12px rgba(243, 194, 106, 0.3), 0 2px 8px rgba(0, 0, 0, 0.6);
}

/* Non-speaking Avatars — Dim when at least one is speaking */
.live-album-art:has(.live-avatar-item.speaking) .live-avatar-item:not(.speaking) {
    opacity: 0.5;
    transform: scale(0.95);
}

.live-album-art:has(.live-avatar-item.speaking) .live-avatar-item:not(.speaking) .avatar-img {
    border-color: rgba(255, 255, 255, 0.04);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    animation: none;
}

.live-album-art:has(.live-avatar-item.speaking) .live-avatar-item:not(.speaking) .live-avatar-name {
    color: rgba(255, 255, 255, 0.3);
}

/* Subtle Breathing Animation (idle) */
@keyframes avatarBreathing {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.015);
    }
}

/* Speaking Pulse Animation */
@keyframes speakingPulse {

    0%,
    100% {
        box-shadow:
            0 0 0 4px rgba(243, 194, 106, 0.25),
            0 0 30px rgba(243, 194, 106, 0.2),
            0 0 60px rgba(243, 194, 106, 0.08),
            0 20px 50px rgba(0, 0, 0, 0.5);
    }

    50% {
        box-shadow:
            0 0 0 6px rgba(243, 194, 106, 0.35),
            0 0 40px rgba(243, 194, 106, 0.25),
            0 0 80px rgba(243, 194, 106, 0.12),
            0 20px 50px rgba(0, 0, 0, 0.5);
    }
}

/* Bounce-In Scale for Speaker Activation */
@keyframes speakingBounceIn {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }

    100% {
        transform: scale(1.04);
    }
}

/* Hover state on avatars */
.live-avatar-item:hover .avatar-img {
    border-color: rgba(255, 255, 255, 0.25);
    transform: scale(1.04);
}

.live-avatar-item:hover .live-avatar-name {
    color: #fff;
}