/* ================= Floating button ================= */
#aiChatButton {
    position: fixed;
    right: 15px;
    bottom: 10px;
    width: 46px;
    height: 46px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #D45060, #D45060);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    z-index: 9999;
    box-shadow: 0 8px 25px rgba(185, 14, 80, .30);
    transition: all .2s ease;
}

#aiChatButton:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(185, 14, 80, .40);
}

/* ================= Chat box ================= */
#aiChatBox {
    position: fixed;
    right: 25px;
    bottom: 70px;
    width: 312px;
    height: 452px;
    max-height: calc(100vh - 90px);   /* small screens-il top cut aavilla */
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .20);
    z-index: 9999;
    overflow: hidden;
    display: none;
    flex-direction: column;
}

/* jQuery .toggle() sets inline display:block, so force flex when shown */
#aiChatBox[style*="display: block"],
#aiChatBox[style*="display:block"] {
    display: flex !important;
}

/* ================= Header ================= */
.chat-header {
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--theme-color, #b90e50), var(--theme-color-dark, #a00c45));
    color: #fff;
    padding: 15px 18px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#closeChat {
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    opacity: .85;
}

#closeChat:hover {
    opacity: 1;
}

/* ================= Messages ================= */
.chat-body {
    flex: 1 1 auto;
    min-height: 0;            /* body shrink cheythu box-ukulle scroll aavan */
    overflow-y: auto;
    padding: 15px;
    background: #fafafa;
}

.ai-message {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 13px;
    margin-bottom: 10px;
    font-size: 13px;
    line-height: 1.5;
    color: #333;
    word-break: break-word;   /* long equipment names overflow aavilla */
}

.user-message {
    display: inline-block;
    background: #f7eef1;
    color: var(--theme-color, #b90e50);
    border: 1px solid rgba(185, 14, 80, .15);
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    word-break: break-word;
}

/* ================= Quick actions ================= */
.chat-actions {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #eee;
}

.ai-action {
    border: 1px solid var(--theme-color, #b90e50);
    color: var(--theme-color, #b90e50);
    background: #fff;
    border-radius: 20px;
    font-size: 11px;
    padding: 5px 10px;
    cursor: pointer;
    transition: all .2s ease;
}

.ai-action:hover {
    background: var(--theme-color, #b90e50);
    color: #fff;
}

/* ================= Footer ================= */
.chat-footer {
    flex-shrink: 0;
    padding: 12px;
    background: #fff;
    border-top: 1px solid #eee;
}

.chat-footer input {
    font-size: 13px;
    border-radius: 9px;
}

.chat-footer input:focus {
    border-color: var(--theme-color, #b90e50);
    box-shadow: 0 0 0 3px rgba(185, 14, 80, .10);
}

.chat-footer button {
    width: 100%;
    border: none;
    border-radius: 9px;
    font-weight: 600;
}

/* ================= Mobile ================= */
@media (max-width: 576px) {
    #aiChatBox {
        right: 12px;
        bottom: 85px;
        width: calc(100% - 24px);
        height: 500px;
    }

    #aiChatButton {
        right: 15px;
        bottom: 15px;
    }
}
