/* 3D round table. Every layout rule is scoped so the 2D view is unchanged.
   The facilitator role is the one exception: it exists in the shared markup and
   stays hidden until the 3D class is on the container. */

.character-role {
    display: none;
}

#pbl-roundtable-container.roundtable-3d {
    padding: 0;
    background: #f7f8fa;
    --glow-color: #4c94e0;
    isolation: isolate;
    position: relative;
    overflow: hidden;
}

#pbl-roundtable-container.roundtable-3d .roundtable-3d-canvas {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

#pbl-roundtable-container.roundtable-3d .pbl-environment {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: block;
    height: 100%;
    width: 100%;
    pointer-events: none;
    padding: 0;
    gap: 0;
}

#pbl-roundtable-container.roundtable-3d .virtual-table,
#pbl-roundtable-container.roundtable-3d .icon-wrapper,
#pbl-roundtable-container.roundtable-3d .person-icon {
    display: none;
}

#pbl-roundtable-container.roundtable-3d .pbl-session-recording-notice-wrapper,
#pbl-roundtable-container.roundtable-3d .roundtable-live-call-status {
    z-index: 40;
}

#pbl-roundtable-container.roundtable-3d .character-rig {
    position: absolute;
    width: 0;
    height: 0;
    margin: 0;
    transform: none;
    pointer-events: none;
}

#pbl-roundtable-container.roundtable-3d .character {
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    display: block;
    opacity: 1;
    transform: none;
    pointer-events: none;
}

#pbl-roundtable-container.roundtable-3d .character-name,
#pbl-roundtable-container.roundtable-3d .speech-bubble,
#pbl-roundtable-container.roundtable-3d .typing-indicator {
    pointer-events: auto;
}

#pbl-roundtable-container.roundtable-3d .character-name {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -100%);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: max-content;
    margin: 0;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(195, 206, 218, 0.85);
    color: #5f6368;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(32, 48, 72, 0.08);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, color 0.35s ease;
}

#pbl-roundtable-container.roundtable-3d .character.is-self .character-name,
#pbl-roundtable-container.roundtable-3d .character.user-character .character-name,
#pbl-roundtable-container.roundtable-3d .character.roundtable-name-visible .character-name {
    opacity: 1;
    pointer-events: auto;
}

#pbl-roundtable-container.roundtable-3d .character-name::before {
    content: none;
}

#pbl-roundtable-container.roundtable-3d .character-role,
#pbl-roundtable-container.roundtable-3d .character-sub {
    display: inline;
    font-size: 0.83em;
    font-weight: 500;
    color: #5f6368;
}

#pbl-roundtable-container.roundtable-3d .character-role::before {
    content: '· ';
}

#pbl-roundtable-container.roundtable-3d .character.active.roundtable-name-visible .character-name,
#pbl-roundtable-container.roundtable-3d .character.active.is-self .character-name,
#pbl-roundtable-container.roundtable-3d .character.active.user-character .character-name {
    background: #fff;
    color: #3c4043;
    font-weight: 600;
    box-shadow: 0 1px 6px rgba(32, 48, 72, 0.12);
}

#pbl-roundtable-container.roundtable-3d .character.is-offline.is-self .character-name,
#pbl-roundtable-container.roundtable-3d .character.is-offline.user-character .character-name,
#pbl-roundtable-container.roundtable-3d .character.is-offline.roundtable-name-visible .character-name {
    opacity: 0.72;
}

#pbl-roundtable-container.roundtable-3d .character.is-offline .character-name::after {
    display: inline;
    margin: 0 0 0 2px;
    padding: 1px 6px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #6b7280;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

#pbl-roundtable-container.roundtable-3d .speech-bubble,
#pbl-roundtable-container.roundtable-3d #rig-facilitator .speech-bubble {
    position: absolute;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
    margin: 0;
    width: max-content;
    max-width: 360px;
    background: #fff;
    border: none;
    border-radius: 14px;
    box-shadow:
        0 0 0 1px color-mix(in srgb, var(--c, var(--primary-color)) 18%, transparent),
        0 0 14px color-mix(in srgb, var(--c, var(--primary-color)) 20%, transparent),
        0 10px 24px rgba(20, 40, 35, 0.1);
    transform: none;
    z-index: 5;
}

#pbl-roundtable-container.roundtable-3d .character.user-character .speech-bubble {
    background: #fff;
    border: none;
}

/* 2D draws the active speaker at 1.1x and its bubble at 1.05x. The 3D module pins `transform` inline,
   so the same size uses `scale` (placeFloating reads it) and the pop-in uses `translate`. */
#pbl-roundtable-container.roundtable-3d .speech-bubble.visible {
    scale: 1.155;
    transform-origin: 0 0;
    animation: roundtable-3d-bubble-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes roundtable-3d-bubble-in {
    from {
        opacity: 0;
        translate: 0 8px;
    }
}

#pbl-roundtable-container.roundtable-3d .speech-bubble.with-avatar {
    padding-left: 86px;
    min-height: 78px;
    box-sizing: border-box;
}

#pbl-roundtable-container.roundtable-3d .roundtable-bubble-person {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    position: absolute;
    left: 12px;
    top: 50%;
    width: 64px;
    transform: translateY(-50%);
    pointer-events: none;
}

#pbl-roundtable-container.roundtable-3d .roundtable-bubble-avatar {
    position: static;
    left: auto;
    top: auto;
    transform: none;
}

#pbl-roundtable-container.roundtable-3d .roundtable-bubble-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 64px;
    color: #3c4043;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
    overflow-wrap: anywhere;
}

#pbl-roundtable-container.roundtable-3d .speech-bubble::after,
#pbl-roundtable-container.roundtable-3d #rig-facilitator .speech-bubble::after {
    top: auto;
    bottom: -9px;
    left: var(--tail, 50%);
    transform: translateX(-50%);
    border-width: 9px 9px 0;
    border-style: solid;
    border-color: #fff transparent transparent transparent;
    display: block;
}

#pbl-roundtable-container.roundtable-3d .speech-bubble.no-tail::after,
#pbl-roundtable-container.roundtable-3d .speech-bubble.roundtable-3d-caption::after {
    display: none;
}

#pbl-roundtable-container.roundtable-3d .typing-indicator,
#pbl-roundtable-container.roundtable-3d #rig-facilitator .typing-indicator {
    position: absolute;
    top: auto;
    bottom: auto;
    left: auto;
    margin: 0;
    transform: none;
    padding: 10px 14px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

#pbl-roundtable-container.roundtable-3d .typing-indicator span:not(.generation-retry-note) {
    background: var(--c, var(--primary-color));
}

#pbl-roundtable-container.roundtable-3d .roundtable-3d-case-tag {
    position: absolute;
    z-index: 30;
    transform: translate(-50%, -100%) translateY(4px);
    padding: 4px 12px;
    border-radius: 999px;
    background: #fff;
    color: var(--text-color);
    box-shadow: 0 0 0 2px var(--glow-color), 0 6px 18px rgba(0, 0, 0, 0.12);
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    white-space: nowrap;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#pbl-roundtable-container.roundtable-3d .roundtable-3d-case-tag.show {
    opacity: 1;
    transform: translate(-50%, -100%);
}

#pbl-roundtable-container.roundtable-3d .roundtable-3d-hint {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(6px);
    font-size: 11px;
    color: #5f6368;
    white-space: nowrap;
    pointer-events: none;
}

/* Speech bubbles live in .pbl-environment, so the camera buttons sit below it */
#pbl-roundtable-container.roundtable-3d .roundtable-3d-camera {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1;
    display: flex;
    gap: 0;
    border: 1px solid #d5dbe1;
    border-radius: 999px;
    overflow: hidden;
    background: #fff;
}

#pbl-roundtable-container.roundtable-3d .roundtable-3d-camera button {
    border: 0;
    background: transparent;
    color: #5f6368;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    cursor: pointer;
}

#pbl-roundtable-container.roundtable-3d .roundtable-3d-camera button.on {
    background: var(--primary-color);
    color: #fff;
}

#pbl-roundtable-container.roundtable-3d .roundtable-3d-zoom {
    position: absolute;
    top: 52px;
    right: 8px;
    bottom: 14px;
    z-index: 3;
    width: 22px;
    display: flex;
    justify-content: center;
}

#pbl-roundtable-container.roundtable-3d .roundtable-3d-zoom input {
    writing-mode: vertical-lr;
    direction: rtl;
    appearance: none;
    width: 14px;
    height: 100%;
    margin: 0;
    background: transparent;
    cursor: pointer;
}

#pbl-roundtable-container.roundtable-3d .roundtable-3d-zoom input::-webkit-slider-runnable-track {
    width: 3px;
    background: rgba(96, 112, 132, 0.22);
    border: 0;
    border-radius: 999px;
}

#pbl-roundtable-container.roundtable-3d .roundtable-3d-zoom input::-webkit-slider-thumb {
    appearance: none;
    box-sizing: border-box;
    width: 12px;
    height: 12px;
    margin-left: -4px;
    border: 0;
    border-radius: 50%;
    background: rgba(96, 112, 132, 0.38);
}

#pbl-roundtable-container.roundtable-3d .roundtable-3d-zoom input:hover::-webkit-slider-thumb {
    background: rgba(96, 112, 132, 0.62);
}

#pbl-roundtable-container.roundtable-3d .roundtable-3d-zoom input::-moz-range-track {
    width: 3px;
    background: rgba(96, 112, 132, 0.22);
    border: 0;
    border-radius: 999px;
}

#pbl-roundtable-container.roundtable-3d .roundtable-3d-zoom input::-moz-range-thumb {
    box-sizing: border-box;
    width: 12px;
    height: 12px;
    border: 0;
    border-radius: 50%;
    background: rgba(96, 112, 132, 0.38);
}

.roundtable-view-toggle {
    display: inline-flex;
    align-items: stretch;
    height: 28px;
    border: 1px solid #d5dbe1;
    border-radius: 999px;
    overflow: hidden;
    background: #fff;
    margin-right: 8px;
}

.roundtable-view-toggle button {
    border: 0;
    background: transparent;
    color: #5f6368;
    font-size: 12px;
    font-weight: 700;
    padding: 0 10px;
    cursor: pointer;
    line-height: 26px;
}

.roundtable-view-toggle button[aria-pressed="true"] {
    background: var(--primary-color);
    color: #fff;
}

.roundtable-view-toggle button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

@media (max-width: 767px) {
    #pbl-roundtable-container.roundtable-3d {
        height: 60vh !important;
        min-height: 320px !important;
        max-height: none !important;
        padding: 0 !important;
        overflow: hidden !important;
    }

    #pbl-roundtable-container.roundtable-3d .roundtable-3d-canvas {
        touch-action: pan-y;
    }

    #pbl-roundtable-container.roundtable-3d .pbl-environment {
        position: absolute !important;
        display: block !important;
        height: 100% !important;
        flex-direction: initial !important;
        pointer-events: none !important;
    }

    #pbl-roundtable-container.roundtable-3d .character-rig {
        position: absolute !important;
        top: auto;
        left: auto;
        width: 0 !important;
        height: 0 !important;
        min-height: 0 !important;
        margin: 0 !important;
        display: block !important;
        transform: none !important;
        opacity: 1 !important;
    }

    #pbl-roundtable-container.roundtable-3d .character {
        position: absolute !important;
        display: block !important;
        flex-direction: initial !important;
        width: 0 !important;
        height: 0 !important;
        gap: 0 !important;
        transform: none !important;
        opacity: 1 !important;
    }

    #pbl-roundtable-container.roundtable-3d .character-name {
        width: max-content !important;
        max-width: 120px;
        font-size: 11px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #pbl-roundtable-container.roundtable-3d .character-role,
    #pbl-roundtable-container.roundtable-3d .character-sub {
        display: none !important;
    }

    #pbl-roundtable-container.roundtable-3d .speech-bubble,
    #pbl-roundtable-container.roundtable-3d .speech-bubble.visible,
    #pbl-roundtable-container.roundtable-3d #rig-facilitator .speech-bubble,
    #pbl-roundtable-container.roundtable-3d #rig-facilitator .speech-bubble.visible {
        position: absolute !important;
        order: initial !important;
        flex: none !important;
        display: block !important;
        width: max-content !important;
        max-width: min(360px, calc(100% - 28px)) !important;
        margin: 0 !important;
        transform: none !important;
        scale: none;
    }

    #pbl-roundtable-container.roundtable-3d .speech-bubble:not(.visible),
    #pbl-roundtable-container.roundtable-3d #rig-facilitator .speech-bubble:not(.visible) {
        display: none !important;
    }

    #pbl-roundtable-container.roundtable-3d .speech-bubble.roundtable-3d-caption,
    #pbl-roundtable-container.roundtable-3d #rig-facilitator .speech-bubble.roundtable-3d-caption {
        width: calc(100vw - 28px);
        max-width: calc(100% - 28px) !important;
        max-height: 40% !important;
        overflow: auto !important;
    }

    #pbl-roundtable-container.roundtable-3d .typing-indicator,
    #pbl-roundtable-container.roundtable-3d #rig-facilitator .typing-indicator {
        position: absolute !important;
        top: auto !important;
        left: auto !important;
        margin: 0 !important;
        transform: none !important;
    }

    #pbl-roundtable-container.roundtable-3d .roundtable-3d-camera,
    #pbl-roundtable-container.roundtable-3d .roundtable-3d-zoom,
    #pbl-roundtable-container.roundtable-3d .roundtable-3d-hint,
    #pbl-roundtable-container.roundtable-3d .roundtable-3d-case-tag {
        display: none !important;
    }
}
