/* ============================================
   Xacta Chatbot - v1.0
   Bilingual (AR/EN) widget with rich responses
   ============================================ */

#xacta-chat-widget {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 99999;
    font-family: 'Segoe UI', 'Tahoma', Arial, sans-serif;
}

/* ====== Toggle button (always visible) ====== */
#xacta-chat-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6B2FA0 0%, #4A1D7A 100%);
    border: none;
    cursor: pointer;
    font-size: 28px;
    box-shadow: 0 6px 24px rgba(107, 47, 160, 0.45);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}
#xacta-chat-toggle:hover {
    transform: scale(1.08) rotate(8deg);
    box-shadow: 0 8px 32px rgba(107, 47, 160, 0.6);
}
.xacta-toggle-icon-close { font-size: 32px; line-height: 1; }
.xacta-notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    background: #00d97e;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 0 rgba(0, 217, 126, 0.7);
    animation: xacta-pulse 2s infinite;
}
@keyframes xacta-pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 217, 126, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(0, 217, 126, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 217, 126, 0); }
}

/* ====== Chat box ====== */
#xacta-chat-box {
    width: 380px;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
    background: #fff;
    margin-bottom: 15px;
    animation: xacta-slide-up 0.3s ease;
}
@keyframes xacta-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ====== Header ====== */
#xacta-chat-header {
    background: linear-gradient(135deg, #6B2FA0 0%, #4A1D7A 100%);
    color: white;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
#xacta-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
#xacta-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}
#xacta-chat-title { font-weight: 700; font-size: 14px; }
#xacta-chat-status { font-size: 11px; opacity: 0.85; color: #b3ffcb; }
#xacta-chat-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    opacity: 0.85;
    transition: opacity 0.2s;
}
#xacta-chat-close:hover { opacity: 1; }

/* ====== Messages area ====== */
#xacta-chat-messages {
    height: 380px;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fb;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#xacta-chat-messages::-webkit-scrollbar { width: 6px; }
#xacta-chat-messages::-webkit-scrollbar-track { background: transparent; }
#xacta-chat-messages::-webkit-scrollbar-thumb {
    background: #c4b5d9;
    border-radius: 6px;
}

/* ====== Message bubble ====== */
.xacta-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.6;
    white-space: pre-line;
    word-wrap: break-word;
    animation: xacta-fade-in 0.25s ease;
}
@keyframes xacta-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.xacta-msg.bot {
    background: #ffffff;
    border: 1px solid #e6e6ee;
    align-self: flex-start;
    border-radius: 14px 14px 14px 4px;
    color: #2c2c3a;
}
.xacta-msg.user {
    background: linear-gradient(135deg, #6B2FA0 0%, #4A1D7A 100%);
    color: white;
    align-self: flex-end;
    border-radius: 14px 14px 4px 14px;
}
.xacta-msg.typing {
    color: #888;
    font-style: italic;
    background: #f0eff5;
    border: 1px dashed #d4c8e0;
}
.xacta-msg.typing .xacta-typing-dots {
    display: inline-block;
    margin-left: 6px;
}
.xacta-msg.typing .xacta-typing-dots span {
    display: inline-block;
    width: 5px;
    height: 5px;
    background: #6B2FA0;
    border-radius: 50%;
    margin: 0 1px;
    animation: xacta-typing 1.2s infinite;
}
.xacta-msg.typing .xacta-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.xacta-msg.typing .xacta-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes xacta-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ====== Quick-reply suggestion chips ====== */
/*
 * Appear after greeting / fallback responses.
 * Clicking a chip sends it as a user message and removes all chip rows.
 */
.xacta-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 10px;
    align-self: flex-start;
    max-width: 100%;
    animation: xacta-fade-in 0.3s ease;
}
.xacta-suggestion-chip {
    display: inline-flex;
    align-items: center;
    background: #f3eefa;
    border: 1.5px solid #c4a0e0;
    color: #4A1D7A;
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: background 0.18s, color 0.18s, border-color 0.18s,
                transform 0.15s, box-shadow 0.18s;
    line-height: 1.3;
}
.xacta-suggestion-chip:hover {
    background: #6B2FA0;
    color: #fff;
    border-color: #6B2FA0;
    transform: translateY(-2px);
    box-shadow: 0 5px 14px rgba(107, 47, 160, 0.28);
}
.xacta-suggestion-chip:active {
    transform: translateY(0);
    box-shadow: none;
}

/* ====== Action links (CTA buttons under bot reply) ====== */
.xacta-msg-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    align-self: flex-start;
    max-width: 85%;
}
.xacta-msg-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #fff;
    border: 1.5px solid #6B2FA0;
    color: #6B2FA0;
    padding: 6px 12px;
    border-radius: 18px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}
.xacta-msg-link:hover {
    background: #6B2FA0;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(107, 47, 160, 0.25);
}
.xacta-msg-link::after { content: "↗"; font-size: 11px; }

/* ====== Input area ====== */
#xacta-chat-input-area {
    display: flex;
    border-top: 1px solid #eee;
    background: #fff;
    padding: 10px;
    gap: 8px;
    align-items: center;
}
#xacta-chat-input {
    flex: 1;
    border: 1.5px solid #e0e0eb;
    border-radius: 25px;
    padding: 10px 16px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}
#xacta-chat-input:focus {
    border-color: #6B2FA0;
    box-shadow: 0 0 0 3px rgba(107, 47, 160, 0.1);
}
#xacta-chat-send {
    background: linear-gradient(135deg, #6B2FA0 0%, #4A1D7A 100%);
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}
#xacta-chat-send:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(107, 47, 160, 0.4);
}
#xacta-chat-send:active { transform: scale(0.95); }

/* ====== Footer ====== */
#xacta-chat-footer {
    text-align: center;
    padding: 8px;
    font-size: 11px;
    color: #888;
    background: #fafafa;
    border-top: 1px solid #f0f0f0;
}

/* ====== Feature 3 — 👍 / 👎 Feedback row ====== */
.xacta-feedback-row {
    display: flex;
    gap: 6px;
    align-items: center;
    align-self: flex-start;
    margin-top: 2px;
    animation: xacta-fade-in 0.25s ease;
}
.xacta-feedback-btn {
    background: transparent;
    border: 1.5px solid #e0e0eb;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 14px;
    cursor: pointer;
    line-height: 1.4;
    transition: background 0.18s, border-color 0.18s, transform 0.15s;
    font-family: inherit;
}
.xacta-feedback-btn:hover {
    border-color: #6B2FA0;
    transform: scale(1.12);
}
.xacta-feedback-btn.up:hover   { background: #d1fae5; border-color: #059669; }
.xacta-feedback-btn.down:hover { background: #fee2e2; border-color: #dc2626; }
.xacta-feedback-thanks {
    font-size: 12px;
    color: #6B2FA0;
    font-style: italic;
}

/* ====== Feature 4 — Proactive Bubble ====== */
.xacta-proactive-bubble {
    position: absolute;
    bottom: 75px;
    right: 0;
    background: #fff;
    border: 1.5px solid #c4a0e0;
    border-radius: 14px 14px 4px 14px;
    padding: 10px 16px;
    font-size: 13.5px;
    color: #4A1D7A;
    white-space: nowrap;
    box-shadow: 0 6px 20px rgba(107, 47, 160, 0.22);
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px) scale(0.96);
    transition: opacity 0.35s ease, transform 0.35s ease;
    pointer-events: none;
    z-index: 1;
    font-family: inherit;
}
.xacta-proactive-bubble--show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.xacta-proactive-bubble:hover {
    background: #f3eefa;
    box-shadow: 0 8px 24px rgba(107, 47, 160, 0.32);
}

/* ====== Feature 8 — Autocomplete Dropdown ====== */
.xacta-autocomplete {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1.5px solid #c4a0e0;
    border-radius: 12px 12px 4px 4px;
    box-shadow: 0 -6px 20px rgba(107, 47, 160, 0.15);
    max-height: 210px;
    overflow-y: auto;
    z-index: 100;
    animation: xacta-fade-in 0.2s ease;
}
.xacta-autocomplete-item {
    padding: 9px 16px;
    font-size: 12.5px;
    color: #2c2c3a;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f8;
    transition: background 0.14s, color 0.14s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.xacta-autocomplete-item:last-child { border-bottom: none; border-radius: 0 0 4px 4px; }
.xacta-autocomplete-item:hover      { background: #f3eefa; color: #4A1D7A; }

/* ====== Mobile ====== */
@media (max-width: 480px) {
    #xacta-chat-widget { bottom: 15px; right: 15px; left: 15px; }
    #xacta-chat-box {
        width: 100%;
        max-width: none;
    }
    #xacta-chat-messages { height: 60vh; }
}

/* ====== Lead Capture Form (embedded in chat) ====== */
.xacta-lead-form {
    background: #fff;
    border: 1.5px solid #c4a0e0;
    border-radius: 14px;
    padding: 14px 16px 12px;
    margin: 6px 0;
    animation: xacta-fade-in 0.3s ease;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
}
.xacta-lead-form__title {
    font-size: 13.5px;
    font-weight: 700;
    color: #4A1D7A;
    margin-bottom: 10px;
}
.xacta-lead-form__field {
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
}
.xacta-lead-form__field label {
    font-size: 11.5px;
    color: #555;
    margin-bottom: 3px;
    font-weight: 600;
}
.xacta-lead-form__field input,
.xacta-lead-form__field select {
    border: 1.5px solid #d4b8ef;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 12.5px;
    font-family: inherit;
    color: #2c2c3a;
    background: #fafafa;
    outline: none;
    transition: border-color 0.18s, box-shadow 0.18s;
    width: 100%;
    box-sizing: border-box;
}
.xacta-lead-form__field input:focus,
.xacta-lead-form__field select:focus {
    border-color: #6B2FA0;
    box-shadow: 0 0 0 3px rgba(107, 47, 160, 0.12);
    background: #fff;
}
.xacta-lead-form__actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.xacta-lead-form__submit {
    flex: 1;
    background: linear-gradient(135deg, #6B2FA0, #4A1D7A);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.2s, transform 0.15s;
}
.xacta-lead-form__submit:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-1px);
}
.xacta-lead-form__submit:disabled {
    opacity: 0.55;
    cursor: default;
}
.xacta-lead-form__cancel {
    background: transparent;
    border: 1.5px solid #d4b8ef;
    border-radius: 20px;
    padding: 7px 14px;
    font-size: 12px;
    color: #6B2FA0;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.18s, border-color 0.18s;
}
.xacta-lead-form__cancel:hover {
    background: #f3eefa;
    border-color: #6B2FA0;
}
.xacta-lead-form__error {
    background: #fee2e2;
    color: #dc2626;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 11.5px;
    margin-bottom: 8px;
    animation: xacta-fade-in 0.2s ease;
}

/* ====== RTL support (when WordPress is in Arabic) ====== */
body.rtl #xacta-chat-widget,
[dir="rtl"] #xacta-chat-widget {
    right: auto;
    left: 25px;
}
body.rtl .xacta-msg.bot,
[dir="rtl"] .xacta-msg.bot {
    border-radius: 14px 14px 4px 14px;
    align-self: flex-start;
}
body.rtl .xacta-msg.user,
[dir="rtl"] .xacta-msg.user {
    border-radius: 14px 14px 14px 4px;
    align-self: flex-end;
}
