/* assets/css/chat_widget.css */

/* CONTAINER */
#chat-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    /* High Z-Index */
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    pointer-events: none;
    /* Allow clicking through container area */
}

/* TOGGLE BUTTON */
#chat-widget-toggle {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #198754, #146c43);
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    /* Changed from grab for better feel, logic handles text selection */
    color: white;
    font-size: 24px;
    pointer-events: auto;
    /* Enable clicks */
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    z-index: 2;
}

#chat-widget-toggle:active {
    transform: scale(0.95);
}

#chat-widget-toggle:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* CHAT WINDOW */
#chat-widget-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    display: none;
    /* JS toggles this */
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
    border: 1px solid rgba(0, 0, 0, 0.1);

    /* Animation State */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
}

#chat-widget-window.open {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* HEADER */
.chat-header {
    background: #198754;
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 0 5px;
}

/* BODY */
.chat-body {
    flex: 1;
    background: #f8f9fa;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* MESSAGES */
.chat-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.chat-message.bot {
    background: white;
    color: #212529;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.chat-message.user {
    background: #d1e7dd;
    color: #0f5132;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

/* MENU OPTIONS */
.chat-options {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    /* Align right for cleaner look */
    gap: 8px;
    margin-top: 5px;
}

.chat-option-btn {
    background: transparent;
    border: 1px solid #198754;
    color: #198754;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: right;
    max-width: 90%;
}

.chat-option-btn:hover {
    background: #198754;
    color: white;
}

/* FOOTER */
.chat-footer {
    padding: 12px;
    background: white;
    border-top: 1px solid #eee;
    text-align: center;
}

.btn-cs {
    background: #25d366;
    color: white;
    text-decoration: none;
    padding: 8px 20px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s;
}

.btn-cs:hover {
    opacity: 0.9;
    color: white;
}

/* TYPING */
.typing-indicator {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #adb5bd;
    border-radius: 50%;
    animation: typing 1s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* === MOBILE RESPONSIVENESS === */
@media (max-width: 480px) {
    #chat-widget-window {
        /* Force Fullscreen/Bottom Sheet */
        position: fixed !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 85vh !important;
        max-height: 85vh !important;
        border-radius: 20px 20px 0 0 !important;
        transform: translateY(100%);
        box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.2) !important;
    }

    #chat-widget-window.open {
        transform: translateY(0) !important;
    }

    /* Keep toggle button accessible but behind window if needed? 
       Actually standard UI is to hide toggle or keep it visible. 
       We keep it visible at bottom right. */
    #chat-widget-container {
        /* Ensure container respects viewport */
        right: 20px !important;
        bottom: 20px !important;
        left: auto !important;
        top: auto !important;
    }
}