/* EZ-AD Chatbot Widget — themed with the shared design-system tokens. */

#ezad-chatbot {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: var(--ezad-z-modal);
    font-family: var(--ezad-font);
}
body.ezad-rtl #ezad-chatbot {
    right: auto;
    left: 20px;
}

/* Floating launcher */
.ezad-chatbot-launcher {
    width: 58px;
    height: 58px;
    border: none;
    border-radius: var(--ezad-radius-full);
    background: linear-gradient(135deg, var(--ezad-primary) 0%, var(--ezad-secondary) 100%);
    color: #fff;
    box-shadow: var(--ezad-shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: transform var(--ezad-transition), box-shadow var(--ezad-transition);
}
.ezad-chatbot-launcher:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: var(--ezad-shadow-xl);
}
.ezad-chatbot-launcher .dashicons {
    width: 26px;
    height: 26px;
    font-size: 26px;
    line-height: 26px;
    color: #fff;
}
.ezad-chatbot-launcher img {
    width: 30px;
    height: 30px;
    object-fit: contain;
    border-radius: var(--ezad-radius-sm);
}
.ezad-chatbot-launcher::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: var(--ezad-radius-full);
    background: var(--ezad-primary);
    opacity: 0;
    z-index: -1;
    animation: ezad-pulse-ring 1.8s ease-out infinite;
}
.ezad-chatbot-launcher.ezad-chatbot-open::after {
    display: none;
}

/* Panel */
.ezad-chatbot-panel {
    position: absolute;
    bottom: 74px;
    right: 0;
    width: min(380px, calc(100vw - 32px));
    height: min(540px, calc(100vh - 120px));
    background: var(--ezad-surface);
    border-radius: var(--ezad-radius-lg);
    border: 1px solid var(--ezad-border-light);
    box-shadow: var(--ezad-shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(14px) scale(0.97);
    pointer-events: none;
    transition: opacity var(--ezad-transition), transform var(--ezad-transition);
}
body.ezad-rtl .ezad-chatbot-panel {
    right: auto;
    left: 0;
}
.ezad-chatbot-panel.ezad-chatbot-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Header */
.ezad-chatbot-header {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 18px 16px 14px;
    background: linear-gradient(135deg, var(--ezad-primary) 0%, var(--ezad-secondary) 100%);
    color: #fff;
    text-align: center;
}
.ezad-chatbot-logo {
    width: 150px;
    height: auto;
    border-radius: var(--ezad-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    background: transparent;
}
.ezad-chatbot-logo img {
    width: 150px;
    height: auto;
    object-fit: contain;
}
.ezad-chatbot-title {
    flex: none;
    min-width: 0;
    margin-top: 6px;
}
.ezad-chatbot-title strong {
    display: block;
    font-size: var(--ezad-font-size);
    letter-spacing: -0.01em;
    line-height: 1.3;
    color: #fff;
}
.ezad-chatbot-title span {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: var(--ezad-font-size-xs);
    color: rgba(255, 255, 255, 0.85);
}
.ezad-chatbot-status {
    width: 8px;
    height: 8px;
    border-radius: var(--ezad-radius-full);
    background: var(--ezad-success);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}
.ezad-chatbot-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-radius: var(--ezad-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--ezad-transition);
}
.ezad-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.28);
}
body.ezad-rtl .ezad-chatbot-close {
    right: auto;
    left: 10px;
}
body.ezad-rtl .ezad-chatbot-close .dashicons {
    transform: scaleX(-1);
}

/* Messages */
.ezad-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--ezad-bg);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ezad-chatbot-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: var(--ezad-radius);
    font-size: var(--ezad-font-size-sm);
    line-height: 1.5;
    box-shadow: var(--ezad-shadow-sm);
    word-wrap: break-word;
    white-space: pre-line;
    animation: ezad-fade-in 0.25s ease-out;
}
.ezad-chatbot-msg-bot {
    align-self: flex-start;
    background: var(--ezad-surface);
    color: var(--ezad-text);
    border: 1px solid var(--ezad-border-light);
    border-top-left-radius: var(--ezad-radius-sm);
}
body.ezad-rtl .ezad-chatbot-msg-bot {
    border-radius: var(--ezad-radius);
    border-top-right-radius: var(--ezad-radius-sm);
    border-top-left-radius: var(--ezad-radius);
}
.ezad-chatbot-msg-user {
    align-self: flex-end;
    background: var(--ezad-primary);
    color: #fff;
    border-top-right-radius: var(--ezad-radius-sm);
}
body.ezad-rtl .ezad-chatbot-msg-user {
    align-self: flex-start;
    border-radius: var(--ezad-radius);
    border-top-right-radius: var(--ezad-radius);
    border-top-left-radius: var(--ezad-radius-sm);
}
body.ezad-rtl .ezad-chatbot-msg-bot {
    align-self: flex-end;
}
.ezad-chatbot-msg a.ezad-chatbot-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 12px;
    border-radius: var(--ezad-radius-sm);
    background: var(--ezad-primary-light);
    color: var(--ezad-primary);
    font-weight: 600;
    font-size: var(--ezad-font-size-xs);
    text-decoration: none;
    transition: background var(--ezad-transition);
}
.ezad-chatbot-msg a.ezad-chatbot-cta:hover {
    background: var(--ezad-primary);
    color: #fff;
}

/* Quick chips */
.ezad-chatbot-chips {
    padding: 10px 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    background: var(--ezad-bg);
    border-top: 1px solid var(--ezad-border-light);
}
.ezad-chatbot-chip {
    padding: 7px 12px;
    border: 1px solid var(--ezad-border);
    background: var(--ezad-surface);
    color: var(--ezad-text-secondary);
    border-radius: var(--ezad-radius-full);
    font-size: var(--ezad-font-size-xs);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--ezad-transition);
}
.ezad-chatbot-chip:hover {
    border-color: var(--ezad-primary);
    color: var(--ezad-primary);
    background: var(--ezad-primary-light);
}

/* Input */
.ezad-chatbot-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: var(--ezad-surface);
    border-top: 1px solid var(--ezad-border-light);
}
.ezad-chatbot-input {
    flex: 1;
    border: 1px solid var(--ezad-border);
    border-radius: var(--ezad-radius-full);
    padding: 10px 16px;
    font-size: var(--ezad-font-size-sm);
    font-family: inherit;
    color: var(--ezad-text);
    background: var(--ezad-bg);
    min-height: 42px;
    transition: all var(--ezad-transition);
}
.ezad-chatbot-input:focus {
    outline: none;
    border-color: var(--ezad-primary);
    box-shadow: var(--ezad-ring-primary);
    background: var(--ezad-surface);
}
.ezad-chatbot-input::placeholder {
    color: var(--ezad-text-muted);
}
.ezad-chatbot-send {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: none;
    border-radius: var(--ezad-radius-full);
    background: var(--ezad-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--ezad-transition), transform var(--ezad-transition);
}
.ezad-chatbot-send:hover {
    background: var(--ezad-primary-hover);
    transform: scale(1.05);
}
.ezad-chatbot-send .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    line-height: 20px;
    color: #fff;
}
body.ezad-rtl .ezad-chatbot-send .dashicons {
    transform: scaleX(-1);
}

/* Typing indicator */
.ezad-chatbot-typing {
    display: inline-flex;
    gap: 4px;
    padding: 12px 14px;
}
.ezad-chatbot-typing span {
    width: 7px;
    height: 7px;
    border-radius: var(--ezad-radius-full);
    background: var(--ezad-text-muted);
    animation: ezad-dot-blink 1.2s ease-in-out infinite;
}
.ezad-chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.ezad-chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }

@media (max-width: 480px) {
    #ezad-chatbot { bottom: 14px; right: 14px; }
    body.ezad-rtl #ezad-chatbot { right: auto; left: 14px; }
    .ezad-chatbot-panel {
        bottom: 68px;
        width: calc(100vw - 24px);
        height: min(480px, calc(100vh - 110px));
    }
}