/* ═══════════════════════════════════════════════════════════
   WP Chat AI – Chat Widget Styles
   ═══════════════════════════════════════════════════════════ */

:root {
    --wpcai-primary: #0ea5e9;
    --wpcai-primary-dark: #0284c7;
    --wpcai-primary-light: #e0f2fe;
    --wpcai-bg: #ffffff;
    --wpcai-surface: #f8fafc;
    --wpcai-border: #e2e8f0;
    --wpcai-text: #1e293b;
    --wpcai-text-secondary: #64748b;
    --wpcai-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    --wpcai-radius: 16px;
    --wpcai-radius-sm: 12px;
    --wpcai-transition: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Toggle Button ──────────────────────────────────────── */
.wpcai-toggle {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--wpcai-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(14, 165, 233, 0.4);
    transition: all 0.3s var(--wpcai-transition);
    outline: none;
}

.wpcai-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(14, 165, 233, 0.55);
}

.wpcai-toggle:active {
    transform: scale(0.95);
}

.wpcai-toggle.bottom-right {
    right: 24px;
}

.wpcai-toggle.bottom-left {
    left: 24px;
}

.wpcai-toggle svg {
    width: 28px !important;
    height: 28px !important;
    color: #ffffff !important;
    fill: #ffffff !important;
    display: inline-block !important;
    visibility: visible !important;
    overflow: visible !important;
    max-width: none !important;
    max-height: none !important;
    transition: transform 0.3s var(--wpcai-transition);
}

.wpcai-toggle.is-open svg.wpcai-icon-chat {
    display: none !important;
}

.wpcai-toggle.is-open svg.wpcai-icon-close {
    display: inline-block !important;
}

.wpcai-toggle:not(.is-open) svg.wpcai-icon-close {
    display: none !important;
}

/* Pulse animation on load */
.wpcai-toggle::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--wpcai-primary);
    animation: wpcaiPulse 2s ease-out 1s 3;
    opacity: 0;
    pointer-events: none;
}

@keyframes wpcaiPulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

/* ── Chat Panel ─────────────────────────────────────────── */
.wpcai-panel {
    position: fixed;
    bottom: 100px;
    z-index: 999998;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 140px);
    background: var(--wpcai-bg);
    border-radius: var(--wpcai-radius);
    box-shadow: var(--wpcai-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.85) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s var(--wpcai-transition);
    transform-origin: bottom right;
    border: 1px solid var(--wpcai-border);
}

.wpcai-panel.bottom-right {
    right: 24px;
    transform-origin: bottom right;
}

.wpcai-panel.bottom-left {
    left: 24px;
    transform-origin: bottom left;
}

.wpcai-panel.is-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ── Header ─────────────────────────────────────────────── */
.wpcai-header {
    background: linear-gradient(135deg, var(--wpcai-primary), var(--wpcai-primary-dark));
    color: #fff;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.wpcai-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wpcai-header-avatar svg {
    width: 22px !important;
    height: 22px !important;
    fill: #fff !important;
    display: inline-block !important;
    visibility: visible !important;
    overflow: visible !important;
    max-width: none !important;
    max-height: none !important;
}

.wpcai-header-info {
    flex: 1;
    min-width: 0;
}

.wpcai-header-title {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
}

.wpcai-header-subtitle {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 2px;
}

.wpcai-header-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    margin-right: 4px;
    animation: wpcaiStatusPulse 2s ease-in-out infinite;
}

@keyframes wpcaiStatusPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ── Messages Area ──────────────────────────────────────── */
.wpcai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: var(--wpcai-surface);
}

.wpcai-messages::-webkit-scrollbar {
    width: 5px;
}

.wpcai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.wpcai-messages::-webkit-scrollbar-thumb {
    background: var(--wpcai-border);
    border-radius: 10px;
}

/* ── Message Bubbles ────────────────────────────────────── */
.wpcai-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: wpcaiFadeIn 0.3s var(--wpcai-transition);
}

@keyframes wpcaiFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wpcai-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.wpcai-msg.bot {
    align-self: flex-start;
}

.wpcai-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.wpcai-msg.user .wpcai-msg-avatar {
    background: var(--wpcai-primary-light);
    color: var(--wpcai-primary);
}

.wpcai-msg.bot .wpcai-msg-avatar {
    background: linear-gradient(135deg, var(--wpcai-primary), var(--wpcai-primary-dark));
    color: #fff;
}

.wpcai-msg-avatar svg {
    width: 16px !important;
    height: 16px !important;
    fill: currentColor !important;
    display: inline-block !important;
    visibility: visible !important;
    overflow: visible !important;
    max-width: none !important;
    max-height: none !important;
}

.wpcai-msg-bubble {
    padding: 10px 14px;
    border-radius: var(--wpcai-radius-sm);
    font-size: 14px;
    line-height: 1.55;
    color: var(--wpcai-text);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.wpcai-msg.user .wpcai-msg-bubble {
    background: var(--wpcai-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.wpcai-msg.bot .wpcai-msg-bubble {
    background: var(--wpcai-bg);
    border: 1px solid var(--wpcai-border);
    border-bottom-left-radius: 4px;
}

.wpcai-msg-bubble p {
    margin: 0 0 8px 0;
}

.wpcai-msg-bubble p:last-child {
    margin-bottom: 0;
}

.wpcai-msg-bubble a {
    color: var(--wpcai-primary);
    text-decoration: underline;
}

.wpcai-msg.user .wpcai-msg-bubble a {
    color: #fff;
}

.wpcai-msg-bubble ul,
.wpcai-msg-bubble ol {
    margin: 4px 0;
    padding-left: 18px;
}

.wpcai-msg-bubble li {
    margin-bottom: 2px;
}

.wpcai-msg-bubble strong {
    font-weight: 600;
}

.wpcai-msg-bubble code {
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 4px;
    border-radius: 4px;
    font-size: 13px;
}

/* ── Typing Indicator ───────────────────────────────────── */
.wpcai-typing {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    align-items: center;
}

.wpcai-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--wpcai-text-secondary);
    animation: wpcaiTyping 1.4s ease-in-out infinite;
}

.wpcai-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.wpcai-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes wpcaiTyping {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ── Search Results Cards ───────────────────────────────── */
.wpcai-search-header {
    font-size: 13px;
    color: var(--wpcai-text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.wpcai-search-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wpcai-result-card {
    display: flex;
    gap: 10px;
    padding: 10px;
    background: var(--wpcai-bg);
    border: 1px solid var(--wpcai-border);
    border-radius: 10px;
    text-decoration: none;
    color: var(--wpcai-text);
    transition: all 0.2s ease;
    cursor: pointer;
}

.wpcai-result-card:hover {
    border-color: var(--wpcai-primary);
    box-shadow: 0 2px 12px rgba(14, 165, 233, 0.12);
    transform: translateY(-1px);
}

.wpcai-result-thumb {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--wpcai-surface);
}

.wpcai-result-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wpcai-result-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wpcai-result-excerpt {
    font-size: 11px;
    color: var(--wpcai-text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.wpcai-result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.wpcai-result-price {
    font-size: 12px;
    font-weight: 700;
    color: var(--wpcai-primary);
}

.wpcai-result-type {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--wpcai-primary-light);
    color: var(--wpcai-primary);
    font-weight: 600;
}

/* ── Input Area ─────────────────────────────────────────── */
.wpcai-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--wpcai-border);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: var(--wpcai-bg);
    flex-shrink: 0;
}

.wpcai-input {
    flex: 1;
    border: 1.5px solid var(--wpcai-border);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 100px;
    min-height: 40px;
    line-height: 1.4;
    transition: border-color 0.2s ease;
    color: var(--wpcai-text);
    background: var(--wpcai-surface);
}

.wpcai-input:focus {
    border-color: var(--wpcai-primary);
}

.wpcai-input::placeholder {
    color: var(--wpcai-text-secondary);
}

.wpcai-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--wpcai-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    outline: none;
}

.wpcai-send-btn:hover {
    background: var(--wpcai-primary-dark);
}

.wpcai-send-btn:active {
    transform: scale(0.92);
}

.wpcai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wpcai-send-btn svg {
    width: 18px !important;
    height: 18px !important;
    color: #fff !important;
    fill: #fff !important;
    display: inline-block !important;
    visibility: visible !important;
    overflow: visible !important;
    max-width: none !important;
    max-height: none !important;
}

/* ── Powered by ─────────────────────────────────────────── */
.wpcai-powered {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: var(--wpcai-text-secondary);
    background: var(--wpcai-bg);
    border-top: 1px solid var(--wpcai-border);
}

/* ── Mobile Responsive ──────────────────────────────────── */
@media (max-width: 480px) {
    .wpcai-panel {
        width: calc(100vw - 16px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 8px !important;
        left: 8px !important;
        border-radius: 16px;
    }

    .wpcai-toggle {
        bottom: 16px;
    }

    .wpcai-toggle.bottom-right {
        right: 16px;
    }

    .wpcai-toggle.bottom-left {
        left: 16px;
    }
}