/* css/webchat.css */

#channel-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
}

#channel-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #0044cc;
    border: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

#channel-chat-button:hover { transform: scale(1.1); }

#channel-chat-container {
    display: none;
    flex-direction: column;
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 360px;
    height: 550px;
    max-height: 80vh;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    overflow: hidden;
    z-index: 99999;
    border: 1px solid rgba(0,0,0,0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#channel-chat-container.show { display: flex; }

#channel-chat-header {
    background: linear-gradient(135deg, #0044cc, #002a80);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.header-actions { display: flex; gap: 12px; }
.header-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.header-btn:hover { background: rgba(255,255,255,0.3); }

#channel-chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #eef2f6;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.channel-message {
    padding: 10px 16px;
    border-radius: 16px;
    max-width: 85%;
    font-size: 15px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    
    /* ESSA LINHA É OBRIGATÓRIA PARA A FORMATAÇÃO FUNCIONAR */
    white-space: pre-wrap; 
}

.channel-sent { background: #0044cc; color: white; align-self: flex-end; border-bottom-right-radius: 2px; }
.channel-received { background: #ffffff; color: #333; align-self: flex-start; border-bottom-left-radius: 2px; }

.chat-media-img {
    display: block;
    max-width: 100%;
    max-height: 150px;
    width: auto;
    height: auto;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    border: 1px solid rgba(0,0,0,0.1);
    background-color: #f0f0f0;
    transition: opacity 0.2s;
}
.chat-media-img:hover { opacity: 0.9; }

#channel-chat-input-area {
    background: white;
    border-top: 1px solid #eee;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px; 
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}

#channel-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    outline: none;
    font-size: 15px;
    background: #f8f9fa;
    min-height: 45px;
}

#channel-chat-attach {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: #555;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
#channel-chat-attach:hover { background: #f0f0f0; color: #0044cc; }

#channel-chat-send {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: #0044cc;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,68,204,0.3);
}

#channel-chat-login-screen {
    position: absolute;
    top: 70px;
    left: 0;
    width: 100%;
    height: calc(100% - 70px);
    background: #eef2f6;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    padding: 20px;
}
.login-card {
    background: white;
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 280px;
    text-align: center;
}
#login-name-input {
    width: 100%;
    padding: 12px;
    margin: 15px 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    text-align: center;
}
#login-start-btn {
    width: 100%;
    padding: 12px;
    background: #0044cc;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

@media (max-width: 480px) {
    #channel-chat-widget { bottom: 15px; right: 15px; }
    #channel-chat-container { width: 100% !important; height: 100dvh !important; max-height: none; bottom: 0; right: 0; border-radius: 0; }
    #channel-chat-header { padding-top: max(15px, env(safe-area-inset-top)); }
    #channel-chat-input-area { position: sticky; bottom: 0; }
}