/* ==============================================
   iOS Native Room View
   ============================================== */

/* ─── Room Panel ─── */
.ios-room {
    display: none;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-dark, #0a0a0c);
    z-index: 999;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.ios-room.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

/* ─── Top Nav (TikTok: semi-transparent floating) ─── */
.ios-room-nav {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    padding: max(env(safe-area-inset-top, 54px), 54px) 16px 10px;
    gap: 12px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
}

.ios-room-back,
.ios-room-share {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #fff;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ios-room-back:active,
.ios-room-share:active {
    background: rgba(255, 255, 255, 0.15);
}

.ios-room-nav-center {
    flex: 1;
    text-align: center;
}

.ios-room-title {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ios-room-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 4px;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.5);
}

.ios-live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ff3b30;
    animation: iosLivePulse 1.5s infinite;
}

@keyframes iosLivePulse {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.5);
    }

    50% {
        opacity: 0.7;
        box-shadow: 0 0 0 6px rgba(255, 59, 48, 0);
    }
}

.ios-room-timer {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* ─── Character Stage ─── */
.ios-room-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px;
    min-height: 0;
}

.ios-speaker-ring {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(0, 210, 211, 0.15), rgba(255, 179, 64, 0.15));
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.ios-speaker-ring::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(0, 210, 211, 0.2);
    transition: all 0.3s ease;
}

.ios-speaker-ring.speaking {
    background: linear-gradient(135deg, rgba(0, 210, 211, 0.3), rgba(255, 179, 64, 0.3));
    box-shadow: 0 0 40px rgba(0, 210, 211, 0.25), 0 0 80px rgba(255, 179, 64, 0.15);
}

.ios-speaker-ring.speaking::before {
    border-color: rgba(0, 210, 211, 0.5);
    animation: iosSpeakerPulse 2s infinite;
}

@keyframes iosSpeakerPulse {

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

    50% {
        transform: scale(1.08);
        opacity: 0.6;
    }
}

.ios-speaker-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.1);
}

.ios-speaker-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    text-align: center;
}

/* Cast row (small avatars) */
.ios-room-cast {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
}

.ios-cast-avatar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.ios-cast-avatar.speaking,
.participant.speaking .ios-cast-avatar {
    opacity: 1;
}

/* Override web app's golden rectangular frame on speaking participant */
body.ios-mvp .participant.speaking {
    transform: none !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

body.ios-mvp .participant.speaking::after {
    display: none !important;
}

body.ios-mvp .participant.speaking .ios-cast-avatar img {
    border-color: rgba(0, 210, 211, 0.6);
    box-shadow: 0 0 12px rgba(0, 210, 211, 0.3);
}

.ios-cast-avatar img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.ios-cast-avatar span {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
    max-width: 56px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── Waveform Visualizer (inside stage, below cast) ─── */
.ios-room-waveform {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3.5px;
    height: 36px;
    margin-top: 20px;
    padding: 0;
}

.ios-room-waveform .v-bar {
    width: 3.5px;
    background: linear-gradient(to top, rgba(0, 210, 211, 0.6), rgba(232, 184, 73, 0.9));
    border-radius: 3px;
    height: 6px;
    transition: height 0.12s ease-out;
}

.ios-room-waveform.is-speaking {
    filter: drop-shadow(0 0 8px rgba(0, 210, 211, 0.3));
}

.ios-room-waveform.is-speaking .v-bar {
    animation: iosWave 0.55s ease-in-out infinite alternate;
}

.ios-room-waveform.is-speaking .v-bar:nth-child(1) { animation-delay: 0s; }
.ios-room-waveform.is-speaking .v-bar:nth-child(2) { animation-delay: 0.07s; }
.ios-room-waveform.is-speaking .v-bar:nth-child(3) { animation-delay: 0.14s; }
.ios-room-waveform.is-speaking .v-bar:nth-child(4) { animation-delay: 0.21s; }
.ios-room-waveform.is-speaking .v-bar:nth-child(5) { animation-delay: 0.28s; }
.ios-room-waveform.is-speaking .v-bar:nth-child(6) { animation-delay: 0.21s; }
.ios-room-waveform.is-speaking .v-bar:nth-child(7) { animation-delay: 0.14s; }
.ios-room-waveform.is-speaking .v-bar:nth-child(8) { animation-delay: 0.07s; }
.ios-room-waveform.is-speaking .v-bar:nth-child(9) { animation-delay: 0s; }

@keyframes iosWave {
    from {
        height: 4px;
    }

    to {
        height: 22px;
    }
}

/* ─── Subtitle Area ─── */
.ios-room-subtitle {
    padding: 8px 20px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ios-subtitle-text {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.85);
    text-align: center;
    line-height: 1.5;
    font-weight: 500;
    max-width: 100%;
}

/* ─── Messages (TikTok: bottom-left floating chat) ─── */
.ios-room .ios-room-messages {
    position: absolute;
    left: 0;
    bottom: 100px;
    width: 70%;
    max-height: 40vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 16px;
    z-index: 5;
    mask-image: linear-gradient(transparent 0%, black 20%, black 100%);
    -webkit-mask-image: linear-gradient(transparent 0%, black 20%, black 100%);
}

/* Full-screen chat mode (when subtitles ON) */
.ios-room-messages.fullscreen-chat {
    position: absolute;
    top: 100px;
    left: 0;
    right: 0;
    bottom: 80px;
    width: 100%;
    max-height: none;
    background: rgba(0, 0, 0, 0.85);
    padding: 16px;
    mask-image: none;
    -webkit-mask-image: none;
}

/* TikTok-style right-side action column */
.tiktok-action-col {
    position: absolute;
    right: 12px;
    bottom: 160px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.tiktok-action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.tiktok-action-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.tiktok-action-btn:active {
    transform: scale(0.88);
}

.tiktok-action-btn.active {
    background: rgba(255, 59, 92, 0.2);
}

.tiktok-action-btn.active i.fa-heart {
    color: #ff3b5c;
}

.tiktok-action-label {
    font-size: 0.7rem;
    color: #fff;
    font-weight: 600;
    text-align: center;
}

/* ─── Bottom Controls (TikTok: transparent floating bar) ─── */
.ios-room-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 100%);
}

.ios-control-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
}

.ios-lang-select-inline {
    height: 32px;
    padding: 0 8px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    font-size: 0.75rem;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    flex-shrink: 0;
}

.ios-ctrl-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
    position: relative;
}

.ios-ctrl-btn span {
    display: none;
}

/* Like badge (count inside button) — must override .ios-ctrl-btn span { display:none } */
.ios-ctrl-btn .ios-like-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff3b5c;
    color: #fff;
    font-size: 0.55rem;
    min-width: 14px;
    height: 14px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    padding: 0 3px;
}

.ios-ctrl-btn .ios-like-badge:empty {
    display: none !important;
}

.ios-ctrl-btn.active i.fa-heart {
    color: #ff3b5c;
}

.ios-ctrl-btn:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.2);
}

.ios-ctrl-btn.active {
    background: rgba(255, 255, 255, 0.2);
}

/* Mic recording animation */
.ios-ctrl-btn.recording {
    background: rgba(255, 59, 48, 0.3);
    animation: mic-pulse 1.2s ease-in-out infinite;
}

.ios-ctrl-btn.recording i {
    color: #ff3b30;
}

@keyframes mic-pulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.4);
    }

    50% {
        transform: scale(1.1);
        box-shadow: 0 0 12px 4px rgba(255, 59, 48, 0.3);
    }
}

/* Like badge: click-through so parent button gets clicks */
.ios-like-badge {
    pointer-events: none;
}

/* Heart pop animation */
.ios-ctrl-btn.like-pop {
    animation: heart-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes heart-pop {
    0% {
        transform: scale(1);
    }

    30% {
        transform: scale(1.35);
    }

    60% {
        transform: scale(0.9);
    }

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

.ios-ctrl-btn.active i.fa-heart {
    color: #ff3b5c;
    text-shadow: 0 0 8px rgba(255, 59, 92, 0.5);
}

/* Audio muted button */
.ios-ctrl-btn.muted {
    opacity: 0.5;
}

.ios-ctrl-stop {
    background: rgba(255, 59, 48, 0.15);
    color: #ff3b30;
    border-color: rgba(255, 59, 48, 0.2);
}

.ios-ctrl-stop:active {
    background: rgba(255, 59, 48, 0.3);
}

/* Language selector */
.ios-lang-select {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.82rem;
    margin-bottom: 8px;
    -webkit-appearance: none;
    appearance: none;
}

/* Input row */
.ios-input-row {
    display: flex;
    gap: 8px;
}

.ios-chat-input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 0.9rem;
    outline: none;
}

.ios-chat-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.ios-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gold, #e8b849);
    border: none;
    color: #000;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ios-send-btn:active {
    transform: scale(0.92);
}

/* ─── Tab bar hidden in room ─── */
.mvp-tab-bar.hidden {
    display: none !important;
}

