/* --- PÄÄSÄILIÖ --- */
#pm-chat-container {
    position: fixed; 
    bottom: 20px; /* Laskettu alemmas, jotta kelluu samassa tasossa napin kanssa */
    right: 20px;
    width: 350px; 
    height: 500px; 
    background: white;
    border-radius: 15px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    display: none; 
    flex-direction: column; 
    overflow: hidden; 
    z-index: 2147483647 !important;
}

/* Piilotetaan avausnappi, kun chatti on auki */
#pm-chat-container.active ~ #pm-chat-toggle {
    display: none !important;
}

#pm-chat-container.active { display: flex; }

/* --- HEADER --- */
#pm-chat-header {
    height: 60px !important;
    padding: 0 15px !important;
    color: white !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
}

.pm-chat-header-info { display: flex !important; align-items: center !important; gap: 10px !important; }
.pm-bot-avatar { 
    width: 38px !important; 
    height: 38px !important; 
    border-radius: 50% !important; 
    object-fit: cover !important; 
    flex-shrink: 0 !important;
    border: 1px solid rgba(255,255,255,0.2);
}
.pm-chat-bot-name { font-weight: bold !important; font-size: 14px !important; white-space: nowrap; }

.pm-chat-header-actions { display: flex !important; align-items: center !important; gap: 5px !important; }

/* Tyhjennyksen ja sulkemisen painikkeet */
#pm-chat-clear, #pm-chat-close {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    margin: 0 !important;
    color: white !important;
    opacity: 0.8;
}

#pm-chat-clear svg { width: 18px !important; height: 18px !important; pointer-events: none; }
#pm-chat-close { font-size: 26px !important; font-weight: normal !important; }
#pm-chat-clear:hover, #pm-chat-close:hover { opacity: 1; }

/* --- VIESTIALUE --- */
#pm-chat-body { flex: 1; padding: 15px; overflow-y: auto; background: #f4f7f9; }
.chat-msg { margin-bottom: 12px; padding: 10px 12px; border-radius: 10px; font-size: 14px; max-width: 85%; }
.user { background: #dcf8ff; align-self: flex-end; margin-left: auto; color: #333; }
.assistant { background: white; border: 1px solid #eee; align-self: flex-start; color: #333; }

/* --- FOOTER --- */
#pm-chat-footer { padding: 10px; display: flex; border-top: 1px solid #eee; background: white; align-items: center; }
#pm-chat-input { flex: 1; border: 1px solid #ddd; padding: 10px; border-radius: 20px; font-size: 16px; outline: none; }
#pm-chat-send { margin-left: 8px; border: none; color: white; padding: 10px 20px; border-radius: 20px; font-weight: bold; cursor: pointer; }

/* --- AVAUSPAINIKE --- */
#pm-chat-toggle {
    all: unset !important; position: fixed !important; bottom: 20px !important; right: 20px !important;
    width: 60px !important; height: 60px !important; border-radius: 50% !important;
    cursor: pointer !important; box-shadow: 0 4px 15px rgba(0,0,0,0.4) !important;
    z-index: 2147483646 !important; display: flex !important; align-items: center !important; justify-content: center !important;
}

/* --- MOBIILI (KELLUVA VERSIO) --- */
@media (max-width: 600px) {
    #pm-chat-container.active {
        /* Ikkuna ei peitä koko ruutua, vaan jättää marginaalit */
        width: calc(100% - 30px) !important; 
        height: 70% !important; 
        bottom: 15px !important; 
        right: 15px !important; 
        border-radius: 15px !important; /* Pidetään pyöreät kulmat */
    }
    #pm-chat-header { height: 55px !important; }
    #pm-chat-footer { padding-bottom: 15px; } 
}