/* ─── AimToServe Chatbot ───────────────────────────────────────────────────
   Brand palette:
     Teal (primary):   #1a6b7a
     Teal dark:        #145a67
     Orange (accent):  #c8622a
     Orange dark:      #b0551f
     Gold (highlight): #8a7a2a
     Off-white:        #f5f5f0
   ─────────────────────────────────────────────────────────────────────── */

#ats-chat-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

/* ── Bubble ─────────────────────────────────────────────────────────────── */

#ats-chat-bubble {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: #1a6b7a;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 16px rgba(26, 107, 122, 0.45);
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    margin-left: auto;
}

#ats-chat-bubble:hover {
    background: #145a67;
    transform: scale(1.07);
    box-shadow: 0 6px 22px rgba(26, 107, 122, 0.55);
}

#ats-chat-bubble:active {
    transform: scale(0.96);
}

/* ── Chat Window ────────────────────────────────────────────────────────── */

#ats-chat-window {
    display: none;
    flex-direction: column;
    width: 360px;
    max-width: calc(100vw - 48px);
    height: 480px;
    max-height: calc(100vh - 100px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    margin-bottom: 14px;
    animation: atsChatFadeIn 0.2s ease;
}

#ats-chat-window.ats-open {
    display: flex;
}

@keyframes atsChatFadeIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

/* ── Header ─────────────────────────────────────────────────────────────── */

#ats-chat-header {
    background: #1a6b7a;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

#ats-chat-title {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
}

#ats-chat-close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.75);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    transition: color 0.15s;
}

#ats-chat-close:hover {
    color: #fff;
}

/* ── Messages ───────────────────────────────────────────────────────────── */

#ats-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f5f5f0;
    scroll-behavior: smooth;
}

#ats-chat-messages::-webkit-scrollbar { width: 4px; }
#ats-chat-messages::-webkit-scrollbar-track { background: transparent; }
#ats-chat-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

.ats-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
    animation: atsMsgPop 0.18s ease;
}

@keyframes atsMsgPop {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0);   }
}

.ats-msg.bot {
    background: #fff;
    color: #222;
    border: 1px solid #e0e0d8;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.ats-msg.user {
    background: #1a6b7a;
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

/* Typing indicator */
.ats-typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid #e0e0d8;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: 56px;
}

.ats-typing-dot {
    width: 7px;
    height: 7px;
    background: #1a6b7a;
    border-radius: 50%;
    opacity: 0.5;
    animation: atsTypingBounce 1.2s ease-in-out infinite;
}

.ats-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ats-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes atsTypingBounce {
    0%, 80%, 100% { transform: translateY(0);    opacity: 0.4; }
    40%           { transform: translateY(-6px); opacity: 1;   }
}

/* ── Input Area ─────────────────────────────────────────────────────────── */

#ats-chat-input-area {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border-top: 1px solid #e0e0d8;
    background: #fff;
    gap: 8px;
    flex-shrink: 0;
}

#ats-chat-input {
    flex: 1;
    border: 1px solid #ccc;
    border-radius: 22px;
    padding: 9px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #fafaf7;
    color: #222;
    font-family: inherit;
}

#ats-chat-input:focus {
    border-color: #1a6b7a;
    box-shadow: 0 0 0 3px rgba(26, 107, 122, 0.12);
}

#ats-chat-input::placeholder {
    color: #aaa;
}

#ats-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #c8622a;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.15s ease;
}

#ats-chat-send:hover {
    background: #b0551f;
    transform: scale(1.06);
}

#ats-chat-send:active {
    transform: scale(0.95);
}

#ats-chat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* ── Error State ────────────────────────────────────────────────────────── */

.ats-msg.error {
    background: #fff3f0;
    color: #b94a00;
    border: 1px solid #f5c6b0;
    font-size: 13px;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
    #ats-chat-wrapper {
        bottom: 16px;
        right: 16px;
    }

    #ats-chat-window {
        width: calc(100vw - 32px);
        height: 72vh;
        max-height: 520px;
    }
}
