/**
 * Chatbot styles for the Statistical Model Suggester application
 */

/* Chat icon */
.chat-icon-container {
    position: fixed;
    bottom: 82px;
    right: 20px;
    z-index: 1000;
}

#chat-icon {
    width: 52px;
    height: 52px;
    padding: 0;
    background-color: #0f766e;
    border: 0;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(16, 42, 67, 0.22);
    transition: transform 0.3s, background-color 0.3s;
}

#chat-icon:hover {
    transform: translateY(-2px);
    background-color: #0b625c;
}

#chat-icon i {
    color: white;
    font-size: 24px;
}

/* Chat window */
#chat-window {
    position: fixed;
    bottom: 145px;
    right: 20px;
    width: min(380px, calc(100vw - 32px));
    height: min(540px, calc(100vh - 180px));
    background-color: white;
    border: 1px solid #dce5eb;
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(16, 42, 67, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
    transform: scale(0.9);
    opacity: 0;
    pointer-events: none;
    transform-origin: bottom right;
    transition: transform 0.3s, opacity 0.3s;
}

#chat-window.show {
    transform: scale(1);
    opacity: 1;
    pointer-events: all;
}

/* Chat header */
.chat-header {
    background: linear-gradient(125deg, #102a43, #124b55);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    color: white;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

#close-chat {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
}

/* Chat message container */
#chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Message styling */
.message {
    display: flex;
    margin-bottom: 10px;
}

.user-message {
    justify-content: flex-end;
}

.bot-message {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.user-message .message-bubble {
    background-color: #0f766e;
    color: white;
    border-top-right-radius: 4px;
}

.bot-message .message-bubble {
    background-color: #edf3f6;
    color: #172b3a;
    border-top-left-radius: 4px;
}

/* Typing indicator */
.typing-indicator .message-bubble {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    min-width: 60px;
}

.typing-indicator .message-bubble span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #aaa;
    border-radius: 50%;
    margin: 0 3px;
    animation: typing 1.4s infinite;
}

.typing-indicator .message-bubble span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator .message-bubble span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0); }
}

/* Input area */
.chat-input {
    display: flex;
    padding: 15px;
    border-top: 1px solid #e5e5e5;
    background-color: #f9f9f9;
}

#user-message {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
}

#user-message:focus {
    border-color: #0d9488;
}

#send-message {
    background-color: #0f766e;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-left: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s;
}

#send-message:hover {
    background-color: #0b625c;
}

/* Responsive styles */
@media (max-width: 768px) {
    #chat-window {
        right: 16px;
        bottom: 140px;
    }
    
    .chat-icon-container {
        right: 16px;
        bottom: 78px;
    }
}

@media (max-width: 576px) {
    #chat-window {
        right: 16px;
        bottom: calc(128px + env(safe-area-inset-bottom, 0px));
        width: min(330px, calc(100vw - 48px));
        height: min(440px, 62dvh);
        border-radius: 14px;
    }

    .chat-icon-container {
        right: 16px;
        bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    }

    #chat-icon {
        width: 46px;
        height: 46px;
    }

    #chat-icon i {
        font-size: 21px;
    }

    .chat-header {
        padding: 11px 12px;
    }

    .chat-header h3 {
        font-size: 15px;
    }

    #chat-messages {
        padding: 10px;
        gap: 8px;
    }

    .message {
        margin-bottom: 6px;
    }

    .message-bubble {
        max-width: 88%;
        padding: 8px 10px;
        font-size: 13px;
    }

    .chat-input {
        padding: 10px;
    }

    #user-message {
        min-width: 0;
        padding: 8px 11px;
        font-size: 13px;
    }

    #send-message {
        width: 36px;
        height: 36px;
        margin-left: 8px;
        flex: 0 0 36px;
    }
}
