/* Container holds everything together */
.proey-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 250px;
    height: 350px;
    z-index: 200001; /* Extremely high to stay above modal overlays */
    pointer-events: none; /* Allow clicks to pass through unless clicking Proey himself */
    transition: opacity 0.5s ease, transform 0.5s ease;
    opacity: 0;
    transform: translateY(100px);
}

.proey-container.hidden {
    visibility: hidden !important;
    pointer-events: none;
}

.proey-container.visible {
    opacity: 1;
    transform: translateY(0);
}

.proey-part {
    position: absolute;
    transition: transform 0.3s ease-in-out; 
    pointer-events: auto;
}

/* ASSEMBLE THE PARTS */
.proey-torso { top: 70px; left: 50px; width: 150px; z-index: 3; }
.proey-head-container { top: 15px; left: 55px; width: 160px; z-index: 4; transition: all 0.5s ease; }
.proey-head-base { width: 90%; }

.proey-eye { width: 35px; top: 55px; position: absolute; }
.proey-left-eye { left:35px; width:25px; height:25px }
.proey-right-eye { right:40px; width:25px; height:25px  }

.proey-left-arm { top: 160px; left: 25px; width: 40px; z-index: 5; transform-origin: top center; transition: transform 0.3s ease; }
.proey-right-arm { top: 160px; left: 185px; width: 40px; z-index: 5; transform-origin: top center; transition: transform 0.3s ease; }
.proey-left-leg { top: 280px; left: 60px; width: 50px; z-index: 2; transition: opacity 0.3s ease; }
.proey-right-leg { top: 280px; left: 140px; width: 50px; z-index: 1; transition: opacity 0.3s ease; }

/* IDLE ANIMATION */
@keyframes proey-breathe {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

@keyframes head-bob {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-3px) rotate(1deg); }
}

.proey-torso, .proey-left-arm, .proey-right-arm { animation: proey-breathe 3s infinite ease-in-out; }
.proey-head-container { animation: head-bob 3s infinite ease-in-out; }

/* POINTING */
.proey-pointing .proey-left-arm {
    transform: rotate(120deg); 
}

/* SPEECH BUBBLE */
.proey-speech-bubble {
    position: fixed; /* Changed to fixed to match container */
    bottom: 360px;
    right: 20px;
    width: 300px;
    background: white;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    border: 2px solid #6A5ACD;
    z-index: 200002; /* Top-most */
    display: none;
    max-height: 200px;
    overflow-y: auto;
}

.proey-speech-bubble.visible {
    display: block;
    animation: pop-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop-in {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.proey-speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -15px;
    right: 50px;
    border-width: 15px 15px 0;
    border-style: solid;
    border-color: white transparent transparent;
}

.proey-speech-bubble::before {
    content: '';
    position: absolute;
    bottom: -18px;
    right: 48px;
    border-width: 17px 17px 0;
    border-style: solid;
    border-color: #6A5ACD transparent transparent;
}

.proey-inspecting * {
    cursor: help !important;
}

.proey-toggle-btn {
    position: fixed;
    top: 15px;
    right: 310px; /* Positions it in the top bar area visually */
    z-index: 200000; /* Punch through Radzen dialog backdrop */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, color 0.2s, background-color 0.2s;
    background: white; 
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    outline: none;
    padding: 0;
}

.proey-toggle-btn:hover {
    transform: scale(1.1);
    background-color: #f8fafc;
}

.proey-toggle-btn.active {
    color: #6A5ACD;
    border-color: #6A5ACD;
    background-color: #f5f3ff;
    box-shadow: 0 0 10px rgba(106, 90, 205, 0.3);
}
