/* WhatsApp Style Chat Widget */
#konnection-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: "Roboto", sans-serif;
}

/* Chat Button */
.konnection-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #075e54;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease-in-out;
    position: relative;
}

/* Icona chat e chiusura */
.chat-icon {
    display: block;
    font-size: 26px;
      max-width: 100px !important;
    transition: opacity 0.3s ease-in-out;
}
.close-icon {
    display: none;
    font-size: 26px;
     max-width: 100px !important;
    transition: opacity 0.3s ease-in-out;
}

/* Effetto di cambio icona quando la chat è aperta */
.konnection-chat-open .chat-icon {
    display: none;
}
.konnection-chat-open .close-icon {
    display: block;
}

/* Quando la chat è chiusa */
.konnection-chat-closed #konnection-chat-container {
    display: none !important;
}

/* Chat Container */
#konnection-chat-container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: #efe7dd;
    border-radius: 15px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease-in-out;
}

/* Quando la chat è aperta */
.konnection-chat-open #konnection-chat-container {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

/* Chat Header */
.chat-header {
    padding: 15px;
    background: #075e54;
    color: white;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
}

.chat-header h3 {
    color: white;
    margin: 0;
    padding: 0;
}

/* Chat Messages */
#konnection-chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    background: #efe7dd;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

#konnection-chat-messages::-webkit-scrollbar {
    width: 6px;
}

#konnection-chat-messages::-webkit-scrollbar-thumb {
    background: #bbb;
    border-radius: 3px;
}

/* Input Area */
.chat-input-container {
    padding: 12px;
    border-top: 1px solid #ddd;
    background: #ffffff;
    display: flex;
    align-items: center;
}

#konnection-chat-input {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 20px;
    background: #f2f2f2;
    font-size: 14px;
    outline: none;
    resize: none;
    min-height: 24px;
    max-height: 80px;
}

/* Pulsante di invio */
#konnection-chat-send {
    min-width: 45px;
    min-height: 45px;
    background: #075e54;
    color: white;
    border: none;
    border-radius: 50%;
    margin-left: 8px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

#konnection-chat-send:hover {
    background: #128C7E;
}

/* Message Bubbles */
.message {
    padding: 10px 14px;
    border-radius: 15px;
    max-width: 75%;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    display: inline-block;
    position: relative;
    margin-bottom: 6px;
}

/* User Messages */
.user-message {
    background: #dcf8c6;
    color: black;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
    margin-left: auto;
}

.user-message:after {
    content: "";
    position: absolute;
    right: -5px;
    top: 10px;
    border-width: 8px;
    border-style: solid;
    border-color: transparent transparent transparent #dcf8c6;
}

/* Bot Messages */
.bot-message {
    background: white;
    color: black;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
    margin-right: auto;
}

.bot-message:after {
    content: "";
    position: absolute;
    left: -5px;
    top: 10px;
    border-width: 8px;
    border-style: solid;
    border-color: transparent #ffffff transparent transparent;
}

/* Media Queries migliorati per tutti i dispositivi mobili */
@media (max-width: 767px) {
    #konnection-chat-container {
        width: 300px;
        height: 450px;
    }
}

@media (max-width: 480px) {
    #konnection-chat-widget {
        bottom: 10px;
        right: 10px;
    }
    
    #konnection-chat-container {
        width: calc(100vw - 20px);
        max-width: 350px;
        height: 400px;
        right: 0;
    }
    
    .konnection-chat-button {
        width: 50px;
        height: 50px;
    }
}

/* Per schermi molto piccoli */
@media (max-width: 360px) {
    #konnection-chat-container {
        width: calc(100vw - 20px);
        height: 80vh;
        max-height: 500px;
        bottom: 70px;
    }
    
    .chat-input-container {
        padding: 8px;
    }
    
    #konnection-chat-input {
        padding: 8px;
    }
    
    #konnection-chat-send {
        min-width: 40px;
        min-height: 40px;
    }
}

/* Fix per dispositivi iOS */
@supports (-webkit-touch-callout: none) {
    #konnection-chat-container {
        /* Previene problemi con il viewheight su iOS */
        height: 450px;
    }
}