/*
 * ===================================================================
 * Chat Widget Stylesheet (v3 - Sandboxed)
 *
 * All styles are now scoped within #allma-chat-container
 * to prevent conflicts when embedded on a host website.
 * ===================================================================
 */

/* --- SANDBOXING PREFIX --- */
#allma-chat-container #chat-launcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: #007bff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 9998;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
#allma-chat-container #chat-launcher:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}
#allma-chat-container #chat-launcher svg {
    width: 32px;
    height: 32px;
    fill: white;
}


/* --- SANDBOXING PREFIX --- */
#allma-chat-container #allma-chat-widget {
    position: fixed;
    bottom: 90px;
    right: 20px;

    width: 50vw;
    height: 80vh;
    min-width: 380px;
    max-width: 1200px;
    max-height: 900px;

    max-height: calc(100vh - 110px);
    z-index: 9999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;

    box-shadow: 0 8px 16px rgba(0,0,0,0.1), 0 20px 40px rgba(0,0,0,0.15);
    border-radius: 16px;
}
#allma-chat-container #allma-chat-widget.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}


/* --- All subsequent rules are sandboxed --- */
#allma-chat-container .quikchat-base {
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
}

#allma-chat-container .quikchat-title-area {
    background: #ffffff;
    color: #111827;
    padding: 16px 20px;
    font-weight: 600;
    font-size: 1.15rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
#allma-chat-container .chat-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.2s;
}
#allma-chat-container .chat-close-btn:hover {
    opacity: 1;
}
#allma-chat-container .chat-close-btn svg {
    width: 18px;
    height: 18px;
    fill: #333;
}

#allma-chat-container .quikchat-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #f9fafb;
}

#allma-chat-container .quikchat-message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

#allma-chat-container .quikchat-user-label {
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 4px;
}
#allma-chat-container .message-time {
    font-weight: normal;
    margin-left: 8px;
    color: #9ca3af;
}

#allma-chat-container .quikchat-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 85%;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#allma-chat-container .quikchat-message-content p {
    margin-top: 0;
    margin-bottom: 0;
}
#allma-chat-container .quikchat-message-content p:not(:last-child) {
    margin-bottom: 0.75em;
}
#allma-chat-container .quikchat-message-content strong {
    font-weight: 600;
    color: inherit;
}

#allma-chat-container .typing-indicator-content {
    display: flex;
    align-items: center;
    padding: 8px 0;
}
#allma-chat-container .typing-indicator-content span {
    height: 8px;
    width: 8px;
    margin: 0 2px;
    background-color: #9ca3af;
    border-radius: 50%;
    display: inline-block;
    animation: allma-chat-typing-dot-bounce 1.4s infinite ease-in-out both;
}
#allma-chat-container .typing-indicator-content span:nth-child(1) { animation-delay: -0.32s; }
#allma-chat-container .typing-indicator-content span:nth-child(2) { animation-delay: -0.16s; }

@keyframes allma-chat-typing-dot-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1.0); }
}

#allma-chat-container .left-multiline, 
#allma-chat-container .left-singleline {
    align-items: flex-start;
}
#allma-chat-container .left-multiline .quikchat-user-label, 
#allma-chat-container .left-singleline .quikchat-user-label {
    text-align: left;
}
#allma-chat-container .left-multiline .quikchat-message-content, 
#allma-chat-container .left-singleline .quikchat-message-content {
    background: #e5e7eb;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    /* MODIFIED: Fix alignment for assistant messages */
    text-align: left;
}

#allma-chat-container .right-multiline, 
#allma-chat-container .right-singleline {
    align-items: flex-end;
}
#allma-chat-container .right-multiline .quikchat-user-label, 
#allma-chat-container .right-singleline .quikchat-user-label {
    text-align: right;
}
#allma-chat-container .right-multiline .quikchat-message-content, 
#allma-chat-container .right-singleline .quikchat-message-content {
    background: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

#allma-chat-container .quikchat-message-content a {
    color: #0056b3;
    font-weight: 500;
    text-decoration: underline;
    transition: color 0.2s ease;
}
#allma-chat-container .quikchat-message-content a:hover {
    color: #003d82;
    text-decoration: none;
}
#allma-chat-container .right-multiline .quikchat-message-content a,
#allma-chat-container .right-singleline .quikchat-message-content a {
    color: #ffffff;
    font-weight: 600;
    opacity: 0.9;
    transition: opacity 0.2s ease;
}
#allma-chat-container .right-multiline .quikchat-message-content a:hover,
#allma-chat-container .right-singleline .quikchat-message-content a:hover {
    opacity: 1;
}

#allma-chat-container .quikchat-input-area {
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

#allma-chat-container .quikchat-input-textbox {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 0.95rem;
    line-height: 1.4;
    resize: none;
    overflow-y: hidden;
    min-height: 22px;
    max-height: 100px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
#allma-chat-container .quikchat-input-textbox:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

#allma-chat-container .quikchat-input-send-btn {
    background: #007bff;
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.2s;
}
#allma-chat-container .quikchat-input-send-btn:hover {
    background: #0056b3;
}
#allma-chat-container .quikchat-input-send-btn:disabled {
    background: #a0c7f0;
    cursor: not-allowed;
}
#allma-chat-container .quikchat-input-send-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
    margin-left: -2px;
}

@media (max-width: 600px) {
    #allma-chat-container #allma-chat-widget {
        bottom: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        min-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        top: auto;
    }
    #allma-chat-container .quikchat-base {
        border-radius: 0;
    }
    #allma-chat-container #allma-chat-widget.active {
        transform: translateY(100%);
    }
    #allma-chat-container #allma-chat-widget.active.visible {
        transform: translateY(0);
    }
}