/**
 * Aria Chatbot — Widget Styles
 *
 * All selectors scoped to #ce-chatbot-* / .ce-chat-* to prevent collisions.
 * Brand tokens match base.css :root variables.
 *
 * @package Commerce_Elite
 */

/* ── Variables ─────────────────────────────────────────────────────────────── */
#ce-chatbot-root {
    --cb-primary:       #4a0e0e;
    --cb-primary-dark:  #2c2222;
    --cb-surface:       #fdfbf7;
    --cb-surface-dark:  #f6f4f0;
    --cb-text:          #2c2222;
    --cb-text-light:    #6b4f4f;
    --cb-text-muted:    #a89999;
    --cb-border:        #e8e0de;
    --cb-white:         #ffffff;
    --cb-success:       #00a32a;
    --cb-font:          'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --cb-font-serif:    'Playfair Display', Georgia, serif;
    --cb-shadow:        0 8px 40px rgba(44, 34, 34, 0.18);
    --cb-radius:        16px;
    --cb-radius-sm:     8px;
    --cb-z:             999990;
}

/* ── Toggle button ─────────────────────────────────────────────────────────── */
#ce-chatbot-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-dark) 100%);
    box-shadow: 0 4px 20px rgba(74, 14, 14, 0.40);
    cursor: pointer;
    z-index: var(--cb-z);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    border: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}
#ce-chatbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(74, 14, 14, 0.50);
}
#ce-chatbot-toggle.ce-is-open {
    transform: scale(0.92);
}

.ce-toggle-icon {
    width: 28px;
    height: 28px;
    color: #fdfbf7;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ce-toggle-icon svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.ce-toggle-icon-close {
    display: none;
}
#ce-chatbot-toggle.ce-is-open .ce-toggle-icon-chat {
    display: none;
}
#ce-chatbot-toggle.ce-is-open .ce-toggle-icon-close {
    display: flex;
}

/* Notification dot */
.ce-toggle-dot {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 14px;
    height: 14px;
    background: #d63638;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
}
.ce-toggle-dot.ce-visible {
    display: block;
    animation: ce-pulse 2s infinite;
}
@keyframes ce-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%       { transform: scale(1.2); opacity: 0.8; }
}

/* ── Proactive bubble ──────────────────────────────────────────────────────── */
#ce-chatbot-bubble {
    position: fixed;
    bottom: 96px;
    right: 24px;
    max-width: 260px;
    background: var(--cb-white);
    border: 1px solid var(--cb-border);
    border-radius: var(--cb-radius);
    padding: 14px 16px 14px 14px;
    box-shadow: var(--cb-shadow);
    z-index: var(--cb-z);
    display: none;
    font-family: var(--cb-font);
    animation: ce-slide-up 0.3s ease;
    cursor: pointer;
}
#ce-chatbot-bubble.ce-visible {
    display: block;
}
.ce-bubble-agent {
    font-size: 11px;
    font-weight: 600;
    color: var(--cb-primary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ce-bubble-text {
    font-size: 13px;
    color: var(--cb-text);
    line-height: 1.45;
    margin: 0;
}
.ce-bubble-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--cb-text-muted);
    line-height: 1;
    padding: 0;
}
.ce-bubble-close:hover {
    color: var(--cb-text);
}
/* Tail pointing to toggle */
#ce-chatbot-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 26px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--cb-white);
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.06));
}

/* ── Chat window ───────────────────────────────────────────────────────────── */
#ce-chatbot-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 360px;
    height: 540px;
    background: var(--cb-white);
    border-radius: var(--cb-radius);
    box-shadow: var(--cb-shadow);
    z-index: var(--cb-z);
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--cb-font);
    border: 1px solid var(--cb-border);
    animation: ce-slide-up 0.3s ease;
}
#ce-chatbot-window.ce-visible {
    display: flex;
}

@keyframes ce-slide-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.ce-chat-header {
    background: linear-gradient(135deg, var(--cb-primary) 0%, var(--cb-primary-dark) 100%);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.ce-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ce-chat-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(253, 251, 247, 0.3);
    flex-shrink: 0;
}
.ce-chat-header-avatar-initial {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(253, 251, 247, 0.15);
    border: 2px solid rgba(253, 251, 247, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--cb-font-serif);
    font-size: 17px;
    font-weight: 700;
    color: #fdfbf7;
    flex-shrink: 0;
}
.ce-chat-header-text {
    display: flex;
    flex-direction: column;
}
.ce-chat-header-name {
    font-size: 15px;
    font-weight: 600;
    color: #fdfbf7;
    line-height: 1.2;
}
.ce-chat-header-sub {
    font-size: 11px;
    color: rgba(253, 251, 247, 0.7);
    margin-top: 1px;
}
.ce-chat-header-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.ce-lang-btn {
    background: rgba(253, 251, 247, 0.12);
    border: 1px solid rgba(253, 251, 247, 0.25);
    border-radius: 4px;
    color: rgba(253, 251, 247, 0.65);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 3px 7px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    line-height: 1;
    font-family: var(--cb-font);
}
.ce-lang-btn:hover {
    color: #fdfbf7;
    background: rgba(253, 251, 247, 0.2);
}
.ce-lang-btn.ce-lang-active {
    background: var(--cb-primary);
    border-color: var(--cb-primary);
    color: #fdfbf7;
}
.ce-chat-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(253, 251, 247, 0.8);
    font-size: 22px;
    line-height: 1;
    padding: 0;
    transition: color 0.15s;
}
.ce-chat-close-btn:hover {
    color: #fdfbf7;
}

/* ── Messages area ─────────────────────────────────────────────────────────── */
.ce-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: var(--cb-surface);
}
.ce-chat-messages::-webkit-scrollbar {
    width: 4px;
}
.ce-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.ce-chat-messages::-webkit-scrollbar-thumb {
    background: var(--cb-border);
    border-radius: 2px;
}

/* ── Message bubbles ───────────────────────────────────────────────────────── */
.ce-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 88%;
    animation: ce-msg-in 0.2s ease;
}
@keyframes ce-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.ce-msg-agent {
    align-self: flex-start;
}
.ce-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ce-msg-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--cb-primary);
    color: #fdfbf7;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: var(--cb-font-serif);
}
.ce-msg-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.ce-msg-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.ce-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
}
.ce-msg-agent .ce-msg-bubble {
    background: var(--cb-white);
    color: var(--cb-text);
    border: 1px solid var(--cb-border);
    border-bottom-left-radius: 4px;
}
.ce-msg-user .ce-msg-bubble {
    background: var(--cb-primary);
    color: #fdfbf7;
    border-bottom-right-radius: 4px;
}
.ce-msg-time {
    font-size: 10px;
    color: var(--cb-text-muted);
    padding: 0 4px;
}
.ce-msg-user .ce-msg-time {
    text-align: right;
}

/* ── Typing indicator ──────────────────────────────────────────────────────── */
.ce-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 0 4px;
}
.ce-typing-dots {
    background: var(--cb-white);
    border: 1px solid var(--cb-border);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: 10px 14px;
    display: flex;
    gap: 4px;
    align-items: center;
}
.ce-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--cb-text-muted);
    border-radius: 50%;
    animation: ce-dot-bounce 1.2s infinite ease-in-out;
}
.ce-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ce-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes ce-dot-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
    40%           { transform: scale(1);   opacity: 1;   }
}

/* ── WhatsApp button ───────────────────────────────────────────────────────── */
.ce-chat-wa-strip {
    background: #f0fdf4;
    border-top: 1px solid #bbf7d0;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.ce-chat-wa-strip a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: #25D366;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none;
    transition: background 0.15s;
}
.ce-chat-wa-strip a:hover {
    background: #128c7e;
    color: #fff;
}
.ce-chat-wa-strip a svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}
.ce-chat-wa-label {
    font-size: 12px;
    color: #166534;
}

/* ── Mic button ────────────────────────────────────────────────────────────── */
.ce-chat-mic-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: none;
    border: 1px solid var(--cb-border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s;
    outline: none;
    color: var(--cb-text-muted);
    padding: 0;
}
.ce-chat-mic-btn:hover {
    background: var(--cb-surface-dark);
    border-color: var(--cb-primary);
    color: var(--cb-primary);
}
.ce-chat-mic-btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.ce-chat-mic-btn.ce-mic-active {
    background: #fff0f0;
    border-color: #d63638;
    color: #d63638;
    animation: ce-mic-pulse 1.2s infinite ease-in-out;
}
@keyframes ce-mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(214, 54, 56, 0.35); }
    50%       { box-shadow: 0 0 0 6px rgba(214, 54, 56, 0); }
}

/* ── Toggle button avatar ──────────────────────────────────────────────────── */
.ce-chat-btn-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
#ce-chatbot-toggle.ce-is-open .ce-chat-btn-avatar {
    display: none;
}
#ce-chatbot-toggle:not(.ce-is-open) .ce-toggle-icon-close {
    display: none;
}

/* ── Input area ────────────────────────────────────────────────────────────── */
.ce-chat-input-wrap {
    padding: 12px 14px;
    border-top: 1px solid var(--cb-border);
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--cb-white);
    flex-shrink: 0;
}
.ce-chat-textarea {
    flex: 1;
    border: 1px solid var(--cb-border);
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 13.5px;
    font-family: var(--cb-font);
    color: var(--cb-text);
    resize: none;
    max-height: 100px;
    min-height: 38px;
    line-height: 1.45;
    outline: none;
    transition: border-color 0.15s;
    background: var(--cb-surface);
    overflow-y: auto;
}
.ce-chat-textarea:focus {
    border-color: var(--cb-primary);
    background: var(--cb-white);
}
.ce-chat-textarea::placeholder {
    color: var(--cb-text-muted);
}
.ce-chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--cb-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.15s;
    outline: none;
}
.ce-chat-send-btn:hover:not(:disabled) {
    background: var(--cb-primary-dark);
    transform: scale(1.05);
}
.ce-chat-send-btn:disabled {
    opacity: 0.45;
    cursor: default;
}
.ce-chat-send-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: #fdfbf7;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Verification forms ────────────────────────────────────────────────────── */
.ce-verify-form,
.ce-otp-form {
    background: var(--cb-surface);
    border: 1px solid var(--cb-border);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-self: flex-start;
    max-width: 88%;
    animation: ce-msg-in 0.2s ease;
}
.ce-otp-hint {
    font-size: 12px;
    color: var(--cb-text-light);
    margin: 0;
    line-height: 1.4;
}
.ce-otp-hint strong {
    color: var(--cb-text);
}
.ce-verify-email,
.ce-otp-input {
    border: 1px solid var(--cb-border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: var(--cb-font);
    color: var(--cb-text);
    background: var(--cb-white);
    outline: none;
    transition: border-color 0.15s;
}
.ce-verify-email:focus,
.ce-otp-input:focus {
    border-color: var(--cb-primary);
}
.ce-send-otp-btn,
.ce-verify-otp-btn {
    background: var(--cb-primary);
    color: #fdfbf7;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--cb-font);
    cursor: pointer;
    transition: background 0.15s;
    align-self: flex-start;
}
.ce-send-otp-btn:hover:not(:disabled),
.ce-verify-otp-btn:hover:not(:disabled) {
    background: var(--cb-primary-dark);
}
.ce-send-otp-btn:disabled,
.ce-verify-otp-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #ce-chatbot-toggle {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }
    #ce-chatbot-window {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
        animation: ce-slide-up-mobile 0.3s ease;
    }
    @keyframes ce-slide-up-mobile {
        from { opacity: 0; transform: translateY(30px); }
        to   { opacity: 1; transform: translateY(0); }
    }
    #ce-chatbot-bubble {
        right: 16px;
        max-width: calc(100vw - 80px);
    }
}
