/* --- V3.1 UI Update: Alvariini Brand Colors --- */

/* 1. CHAT-IKKUNA */
#pm-v55-container {
    display: none;
    position: fixed;
    bottom: 85px;
    right: 25px;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 50px rgba(0,0,0,0.4);
    flex-direction: column;
    overflow: hidden;
    z-index: 2147483647 !important; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#pm-v55-container.active { display: flex; }

/* 2. AVAUSPAINIKE */
#pm-v55-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #8A253F; /* Alvariini Brand Color */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2147483646;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    transition: transform 0.2s;
}
#pm-v55-toggle:active { transform: scale(0.95); }
#pm-v55-toggle img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
#pm-v55-toggle svg { width: 30px; height: 30px; stroke: white; fill: none; stroke-width: 2.5; }

/* 3. HEADER */
#pm-v55-header {
    height: 60px;
    padding: 0 15px;
    background-color: #8A253F; /* Alvariini Brand Color */
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.pm-v55-avatar { 
    width: 38px; height: 38px; 
    border-radius: 50%; object-fit: cover; 
    border: 1px solid rgba(255,255,255,0.3);
    margin-right: 10px;
}

#pm-v55-header-actions { display: flex; align-items: center; }

#pm-v55-close-btn, #pm-v55-clear-btn { 
    background: transparent !important; 
    border: none !important; 
    box-shadow: none !important;
    color: white !important; 
    cursor: pointer !important; 
    padding: 0 !important; 
    margin-left: 15px !important;
    display: flex !important; 
    align-items: center !important;
    justify-content: center !important;
    min-width: auto !important;
    width: auto !important;
    height: auto !important;
    opacity: 0.9;
}
#pm-v55-close-btn:hover, #pm-v55-clear-btn:hover { opacity: 1; }
#pm-v55-close-btn svg, #pm-v55-clear-btn svg { width: 24px !important; height: 24px !important; fill: white !important; }

/* 4. VIESTIALUE */
#pm-v55-body {
    flex: 1; 
    padding: 15px; 
    overflow-y: auto; 
    background: #f4f7f9; 
    display: flex; 
    flex-direction: column;
    scroll-behavior: smooth;
}

.pm-v55-msg {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 12px;
    font-size: 15px;
    line-height: 1.5;
    max-width: 85%;
    word-wrap: break-word;
}
/* KÄYTTÄJÄN VIESTIKUPLA - VÄRI VAIHDETTU */
.pm-v55-user { background: #8A253F; color: white; align-self: flex-end; border-bottom-right-radius: 2px; }
.pm-v55-bot { background: white; border: 1px solid #e0e0e0; align-self: flex-start; color: #333; border-bottom-left-radius: 2px; }

.pm-v55-bot p { margin: 0 0 10px 0; }
.pm-v55-bot p:last-child { margin-bottom: 0; }
.pm-v55-bot strong, .pm-v55-bot b { font-weight: 700; color: #000; }
.pm-v55-bot ul { margin: 5px 0 10px 20px; padding: 0; list-style-type: disc; }
.pm-v55-bot li { margin-bottom: 5px; }

/* LINKKIEN VÄRI VAIHDETTU */
.pm-v55-bot a { color: #8A253F; text-decoration: underline; font-weight: 600; }

/* 5. INPUT JA NAPPI */
#pm-v55-inputbar {
    padding: 10px; 
    background: white; 
    border-top: 1px solid #eee; 
    display: flex; 
    align-items: center; 
    flex-shrink: 0;
}
#pm-v55-input { 
    flex: 1; 
    padding: 12px; 
    border: 1px solid #ddd; 
    border-radius: 25px; 
    outline: none; 
    font-size: 16px;
}
/* KIRJOITUSKENTÄN REUNUS AKTIIVISENA */
#pm-v55-input:focus { border-color: #8A253F; }

#pm-v55-send-btn { 
    margin-left: 10px; 
    background: #8A253F; /* Alvariini Brand Color */
    color: white; 
    border: none; 
    width: 45px; 
    height: 45px; 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
    padding: 0; 
    flex-shrink: 0;
}

/* 6. DISCLAIMER */
#pm-v55-disclaimer {
    font-size: 11px;
    color: #999;
    text-align: center;
    padding: 5px 10px 8px 10px;
    background: white;
    flex-shrink: 0;
    line-height: 1.3;
}

/* 7. TYPING */
#pm-v55-typing {
    padding: 15px; display: none; background: white; 
    border-radius: 10px; width: fit-content; margin-bottom: 10px;
    border: 1px solid #eee; align-items: center; gap: 10px;
}
.pm-typing-dots { display: flex; gap: 4px; }
.pm-typing-dot {
    width: 6px; height: 6px; background-color: #888;
    border-radius: 50%; animation: pm-bounce 1.4s infinite ease-in-out both;
}
.pm-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.pm-typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes pm-bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* 8. MOBIILI: KELLUVA IKKUNA */
@media (max-width: 600px) {
    #pm-v55-container {
        width: 94% !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        border-radius: 16px !important;
        box-shadow: 0 10px 40px rgba(0,0,0,0.5) !important;
        position: fixed !important;
        bottom: auto !important;
        margin: 0 !important;
        z-index: 999999999 !important; 
    }
    #pm-v55-header { padding-top: 5px; min-height: 55px; border-radius: 16px 16px 0 0; }
    
    #pm-v55-disclaimer { 
        padding-bottom: max(8px, env(safe-area-inset-bottom)); 
        border-radius: 0 0 16px 16px; 
    }
    body.pm-chat-open #pm-v55-toggle { display: none !important; }
}