/**
 * Frontend Chat Widget CSS for WP AI Support Bot
 * Premium Glassmorphism & Micro-animations
 */

#wp-ai-bot-container {
    position: fixed;
    bottom: 30px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    display: flex;
    flex-direction: column-reverse; /* Stack elements bottom-to-top */
    align-items: flex-end;
    pointer-events: none; /* Let clicks pass through empty space */
}

/* Position Alignments */
.wp-ai-bot-right {
    right: 30px;
    align-items: flex-end !important;
}

.wp-ai-bot-left {
    left: 30px;
    align-items: flex-start !important;
}

.wp-ai-bot-left #wp-ai-bot-launcher {
    align-self: flex-start;
}

.wp-ai-bot-left #wp-ai-bot-window {
    left: 0;
    right: auto;
}

/* Interactive elements need pointer-events restored */
#wp-ai-bot-launcher,
#wp-ai-bot-window {
    pointer-events: auto;
}

/* ── 1. Floating Launcher Button ── */
#wp-ai-bot-launcher {
    border: none;
    cursor: pointer;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--wp-ai-bot-primary, #6366f1);
    color: #ffffff;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.15), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

#wp-ai-bot-launcher:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
}

#wp-ai-bot-launcher:active {
    transform: scale(0.95);
}

/* Launcher Shape classes */
#wp-ai-bot-launcher.rounded-full { border-radius: 50%; }
#wp-ai-bot-launcher.rounded-xl { border-radius: 16px; }
#wp-ai-bot-launcher.rounded-none { border-radius: 0; }

#wp-ai-bot-launcher svg {
    width: 28px;
    height: 28px;
    transition: transform 0.3s ease;
}

.wp-ai-bot-pulse::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    border: 2px solid var(--wp-ai-bot-primary, #6366f1);
    opacity: 0.8;
    animation: wp-ai-bot-pulse-animation 2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
    pointer-events: none;
    box-sizing: border-box;
}

@keyframes wp-ai-bot-pulse-animation {
    0% { transform: scale(1); opacity: 0.8; }
    50% { opacity: 0; }
    100% { transform: scale(1.35); opacity: 0; }
}

.wp-ai-bot-unread-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background-color: #ef4444;
    border: 2px solid #ffffff;
    border-radius: 50%;
    display: none;
}

/* ── 2. Chat Window ── */
#wp-ai-bot-window {
    width: 370px;
    height: 520px;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 16px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: bottom right;
    animation: wp-ai-bot-open-anim 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wp-ai-bot-left #wp-ai-bot-window {
    transform-origin: bottom left;
}

@keyframes wp-ai-bot-open-anim {
    0% { opacity: 0; transform: scale(0.7) translateY(40px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Glassmorphism Styles */
.wp-ai-bot-glass #wp-ai-bot-window {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.wp-ai-bot-glass .wp-ai-bot-header {
    background: var(--wp-ai-bot-primary, #6366f1);
    opacity: 0.95;
    backdrop-filter: blur(4px);
}

/* Header */
.wp-ai-bot-header {
    background: var(--wp-ai-bot-primary, #6366f1);
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.wp-ai-bot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wp-ai-bot-avatar-container {
    position: relative;
    width: 40px;
    height: 40px;
}

.wp-ai-bot-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background-color: rgba(255,255,255,0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.wp-ai-bot-online-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background-color: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
    animation: wp-ai-bot-online-pulse 2s infinite;
}

@keyframes wp-ai-bot-online-pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.wp-ai-bot-title {
    margin: 0 !important;
    font-size: 14px;
    font-weight: 700;
    color: #ffffff !important;
    line-height: 1.2;
}

.wp-ai-bot-subtitle {
    margin: 2px 0 0 0 !important;
    font-size: 11px;
    color: #a5b4fc !important;
    line-height: 1;
}

#wp-ai-bot-close {
    background: transparent;
    border: none;
    color: #a5b4fc;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}

#wp-ai-bot-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

#wp-ai-bot-clear {
    background: transparent;
    border: none;
    color: #a5b4fc;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}

#wp-ai-bot-clear:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* Messages Area */
#wp-ai-bot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: #f8fafc;
}

.wp-ai-bot-glass #wp-ai-bot-messages {
    background-color: rgba(248, 250, 252, 0.4);
}

/* Custom Message Scrollbar */
#wp-ai-bot-messages::-webkit-scrollbar {
    width: 5px;
}
#wp-ai-bot-messages::-webkit-scrollbar-track {
    background: transparent;
}
#wp-ai-bot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
#wp-ai-bot-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Bubbles */
.wp-ai-bot-bubble {
    max-width: 82%;
    padding: 12px 16px;
    font-size: 13px;
    line-height: 1.5;
    animation: wp-ai-bot-message-fade 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes wp-ai-bot-message-fade {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

.wp-ai-bot-bubble.bot {
    background-color: #ffffff;
    color: #1e293b;
    align-self: flex-start;
    border-radius: 16px;
    border-bottom-left-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(226, 232, 240, 0.6);
}

.wp-ai-bot-glass .wp-ai-bot-bubble.bot {
    background-color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.wp-ai-bot-bubble.user {
    background-color: var(--wp-ai-bot-primary, #6366f1);
    color: #ffffff;
    align-self: flex-end;
    border-radius: 16px;
    border-bottom-right-radius: 2px;
    box-shadow: 0 3px 6px -1px rgba(99, 102, 241, 0.2);
}

.wp-ai-bot-bubble p {
    margin: 0 0 10px 0;
}

.wp-ai-bot-bubble p:last-child {
    margin-bottom: 0;
}

.wp-ai-bot-bubble strong {
    font-weight: 700;
}

.wp-ai-bot-bubble ul, .wp-ai-bot-bubble ol {
    margin: 6px 0 6px 20px !important;
    padding: 0 !important;
}

.wp-ai-bot-bubble li {
    margin-bottom: 4px;
}

/* ── 3. WooCommerce Product Card ── */
.wp-ai-bot-product-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px;
    margin-top: 8px;
    display: flex;
    gap: 12px;
    align-self: flex-start;
    max-width: 85%;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    animation: wp-ai-bot-message-fade 0.4s ease;
}

.wp-ai-bot-prod-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    background: #f1f5f9;
    flex-shrink: 0;
}

.wp-ai-bot-prod-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.wp-ai-bot-prod-title {
    font-weight: 600;
    font-size: 12px;
    color: #1e293b;
    margin: 0 0 4px 0 !important;
    line-height: 1.3;
}

.wp-ai-bot-prod-price {
    font-weight: 700;
    font-size: 13px;
    color: var(--wp-ai-bot-primary, #6366f1);
    margin: 0 0 8px 0 !important;
}

.wp-ai-bot-prod-btn {
    align-self: flex-start;
    display: inline-block;
    background-color: var(--wp-ai-bot-primary, #6366f1);
    color: #ffffff !important;
    font-size: 10px;
    font-weight: 700;
    text-decoration: none !important;
    padding: 5px 12px;
    border-radius: 6px;
    text-align: center;
    transition: background-color 0.2s, transform 0.1s;
}

.wp-ai-bot-prod-btn:hover {
    opacity: 0.95;
    transform: translateY(-1px);
}

.wp-ai-bot-prod-btn:active {
    transform: translateY(0);
}

/* ── 4. Typing Indicator Bubble ── */
.wp-ai-bot-typing-bubble {
    align-self: flex-start;
    background-color: #e2e8f0;
    padding: 12px 18px;
    border-radius: 16px;
    border-bottom-left-radius: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
    width: auto;
    animation: wp-ai-bot-message-fade 0.2s ease;
}

.wp-ai-bot-typing-bubble span {
    width: 6px;
    height: 6px;
    background: #64748b;
    border-radius: 50%;
    display: inline-block;
    animation: wp-ai-bot-typing-bounce 1.4s infinite ease-in-out both;
}

.wp-ai-bot-typing-bubble span:nth-child(1) { animation-delay: -0.32s; }
.wp-ai-bot-typing-bubble span:nth-child(2) { animation-delay: -0.16s; }

@keyframes wp-ai-bot-typing-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); translateY(-4px); }
}

/* ── 5. Input Area ── */
.wp-ai-bot-input-area {
    display: flex;
    border-top: 1px solid rgba(226, 232, 240, 0.8);
    padding: 12px 16px;
    background: #ffffff;
    align-items: flex-end;
    gap: 12px;
}

.wp-ai-bot-glass .wp-ai-bot-input-area {
    background: rgba(255, 255, 255, 0.8);
}

#wp-ai-bot-input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 13px;
    resize: none;
    max-height: 100px;
    height: 38px;
    line-height: 1.4;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: #f8fafc;
}

#wp-ai-bot-input:focus {
    border-color: var(--wp-ai-bot-primary, #6366f1);
    box-shadow: 0 0 0 1px var(--wp-ai-bot-primary, #6366f1);
    background-color: #ffffff;
}

#wp-ai-bot-send {
    background-color: var(--wp-ai-bot-primary, #6366f1);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: background-color 0.2s, transform 0.1s;
}

#wp-ai-bot-send:hover {
    opacity: 0.95;
    transform: scale(1.05);
}

#wp-ai-bot-send:active {
    transform: scale(0.95);
}

.wp-ai-bot-hidden {
    display: none !important;
}

/* ── 6. Mobile Responsiveness ── */
@media screen and (max-width: 480px) {
    #wp-ai-bot-container {
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #wp-ai-bot-launcher {
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 999999;
    }

    /* When active, show full screen window */
    #wp-ai-bot-window:not(.wp-ai-bot-hidden) {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        margin: 0 !important;
        border: none !important;
        z-index: 1000000;
    }

    #wp-ai-bot-launcher.wp-ai-bot-hidden-launcher {
        display: none !important;
    }
}

/* ── 7. Premium Icon Micro-animations ── */
.wp-ai-bot-antenna-dot {
    animation: wp-ai-bot-antenna-pulse-animation 2s infinite ease-in-out;
}

@keyframes wp-ai-bot-antenna-pulse-animation {
    0%, 100% {
        opacity: 0.5;
        color: inherit;
    }
    50% {
        opacity: 1;
        color: #f59e0b; /* Golden Amber pulse */
    }
}

#wp-ai-bot-launcher:hover .wp-ai-bot-icon-open {
    transform: scale(1.1) rotate(5deg);
}
