/* ============================================================
   Artemis Chat Widget — chat-widget.css
   ============================================================ */

#artemis-chat-container *,
#artemis-chat-container *::before,
#artemis-chat-container *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --ac-primary: #7c6ef4;
    --ac-bg: #ffffff;
    --ac-text: #222222;
    --ac-bubble-ai: #ffffff;
    --ac-bubble-ai-border: #e8e8f0;
    --ac-input-bg: #f8f8fc;
    --ac-border: #eeeeee;
}

#artemis-chat-container.ac-dark {
    --ac-bg: #1e1e2e;
    --ac-text: #f8f8f2;
    --ac-bubble-ai: #2a2a3e;
    --ac-bubble-ai-border: #333344;
    --ac-input-bg: #14141e;
    --ac-border: #333344;
}

/* ---- Float button ---- */
#artemis-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999998;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    transition: transform 0.2s, box-shadow 0.2s;
}

#artemis-chat-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0,0,0,0.32);
}

#artemis-chat-btn .ac-label {
    display: none;
}

/* ---- Chat window ---- */
#artemis-chat-container {
    position: fixed;
    bottom: 88px;
    right: 24px;
    z-index: 999999;
    width: 360px;
    max-height: 520px;
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--ac-bg);
    color: var(--ac-text);
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    transition: opacity 0.25s, transform 0.25s;
    transform-origin: bottom right;
}

#artemis-chat-container.ac-hidden {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
    pointer-events: none;
}

/* Header */
#ac-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: #fff;
    flex-shrink: 0;
}

#ac-header .ac-agent-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

#ac-header .ac-agent-name {
    font-weight: 600;
    font-size: 14px;
    flex: 1;
}

#ac-header .ac-status {
    font-size: 11px;
    opacity: 0.8;
}

#ac-end-chat {
    background: rgba(0,0,0,0.15);
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 4px;
    margin-right: 4px;
    font-weight: 500;
    display: none;
}
#ac-end-chat:hover { background: rgba(0,0,0,0.25); }

#ac-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
}
#ac-close:hover { color: #fff; }

/* Messages */
#ac-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--ac-input-bg);
}

#ac-messages::-webkit-scrollbar { width: 3px; }
#ac-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }

.ac-msg {
    display: flex;
    gap: 8px;
    animation: ac-fade-in 0.25s ease-out;
}

.ac-msg.ac-user {
    flex-direction: row;
    justify-content: flex-end;
}

.ac-msg-content {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.ac-msg.ac-user .ac-msg-content {
    align-items: flex-end;
}

.ac-bubble {
    width: fit-content;
    padding: 10px 16px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
    word-break: break-word; /* Ensure wrapping */
    margin-bottom: 2px;
}

.ac-bubble a {
    color: inherit;
    text-decoration: underline;
    font-weight: 500;
}

.ac-bubble a:hover {
    opacity: 0.8;
}

.ac-msg.ac-ai .ac-bubble {
    background: var(--ac-bubble-ai);
    color: var(--ac-text);
    border: 1px solid var(--ac-bubble-ai-border);
    border-bottom-left-radius: 4px;
}

.ac-msg.ac-user .ac-bubble {
    background: var(--ac-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
    margin-left: 12%;
}

.ac-timestamp {
    font-size: 10px;
    color: #999;
    margin-top: 2px;
    padding: 0 4px;
    opacity: 0.8;
}

.ac-msg.ac-user .ac-timestamp {
    text-align: right;
}

/* Toast */
.ac-toast {
    position: absolute;
    bottom: 80px;
    left: 20px;
    right: 20px;
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    z-index: 1000;
    transition: opacity 0.3s;
    pointer-events: none;
}

/* Modal */
.ac-modal-overlay {
    position: absolute;
    top:0; left:0; right:0; bottom:0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    backdrop-filter: blur(2px);
    border-radius: 12px;
}

.ac-modal {
    background: var(--ac-bg);
    color: var(--ac-text);
    padding: 24px;
    border-radius: 12px;
    width: 80%;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    text-align: center;
}

.ac-modal-text {
    font-size: 15px;
    margin-bottom: 20px;
    line-height: 1.4;
}

.ac-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.ac-modal-actions button {
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    min-width: 80px;
}

.ac-btn-confirm {
    color: #fff;
}

/* Hidden states */
.ac-toast.ac-hidden,
.ac-modal-overlay.ac-hidden {
    display: none !important;
}


/* Typing dots */
.ac-typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 2px;
    align-items: center;
}

.ac-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #aaa;
    animation: ac-bounce 1.2s ease-in-out infinite;
}
.ac-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ac-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Input area */
#ac-input-area {
    padding: 10px 12px;
    border-top: 1px solid var(--ac-border);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: var(--ac-bg);
    flex-shrink: 0;
}

#ac-input {
    flex: 1;
    border: 1px solid #e0e0e8;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    max-height: 80px;
    outline: none;
    background: var(--ac-input-bg);
    color: var(--ac-text);
    line-height: 1.5;
    transition: border-color 0.2s;
}
#ac-input:focus { border-color: var(--ac-primary); background: var(--ac-bg); }
#ac-input::placeholder { color: #888; }

#ac-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    color: #fff;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s;
}
#ac-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Powered by */
#ac-footer {
    text-align: center;
    font-size: 10px;
    color: #888;
    padding: 4px 12px 8px;
    background: var(--ac-bg);
    flex-shrink: 0;
}

/* Pre-chat Form */
#ac-lead-form {
    flex: 1;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--ac-bg);
    overflow-y: auto;
}

#ac-lead-form h3 {
    font-size: 16px;
    margin-bottom: 4px;
    color: var(--ac-primary);
}

.ac-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ac-form-group label {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.8;
}

.ac-form-group input {
    padding: 10px;
    border: 1px solid var(--ac-border);
    border-radius: 8px;
    background: var(--ac-input-bg);
    color: var(--ac-text);
    outline: none;
}
.ac-form-group input:focus { border-color: var(--ac-primary); }

.ac-gdpr-check {
    display: flex;
    gap: 10px;
    font-size: 12px;
    line-height: 1.4;
    margin-top: 4px;
}

.ac-gdpr-check input {
    margin-top: 2px;
    flex-shrink: 0;
}

#ac-start-btn {
    margin-top: 10px;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: var(--ac-primary);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}
#ac-start-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Mobile responsive */
@media (max-width: 400px) {
    #artemis-chat-container {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 76px;
    }
    #artemis-chat-btn {
        right: 16px;
        bottom: 16px;
    }
}

@keyframes ac-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes ac-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%            { transform: translateY(-5px); opacity: 1; }
}
