/**
 * WooCommerce Smart AI Chatbot Frontend Styling
 */

:root {
    --wc-bot-primary: #2563eb;
    --wc-bot-primary-hover: #1d4ed8;
    --wc-bot-bg: #ffffff;
    --wc-bot-surface: #f8fafc;
    --wc-bot-text-main: #0f172a;
    --wc-bot-text-muted: #64748b;
    --wc-bot-border: #e2e8f0;
    --wc-bot-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --wc-bot-radius: 18px;
    --wc-bot-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Base Wrapper */
.wc-chatbot-wrapper {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
    font-family: var(--wc-bot-font);
    box-sizing: border-box;
}

.wc-chatbot-wrapper *,
.wc-chatbot-wrapper *::before,
.wc-chatbot-wrapper *::after {
    box-sizing: border-box;
}

.wc-chat-right {
    right: 24px;
}

.wc-chat-left {
    left: 24px;
}

/* Floating Launcher Button */
.wc-chatbot-launcher-btn {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wc-bot-primary), #3b82f6);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
    outline: none;
    padding: 0;
}

.wc-chatbot-launcher-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.45);
}

.wc-chatbot-launcher-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wc-chatbot-launcher-btn .wc-icon-close {
    display: none;
}

.wc-chatbot-launcher-btn.is-active .wc-icon-chat {
    display: none;
}

.wc-chatbot-launcher-btn.is-active .wc-icon-close {
    display: block;
}

.wc-chatbot-badge-pulse {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background-color: #10b981;
    border: 2.5px solid #ffffff;
    animation: wcPulse 2s infinite;
}

@keyframes wcPulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Chat Window Container */
.wc-chatbot-window {
    position: absolute;
    bottom: 76px;
    right: 0;
    left: auto;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: var(--wc-bot-radius);
    box-shadow: var(--wc-bot-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, 0.8);
    transform: scale(0.92) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
    transform-origin: bottom right;
}

.wc-chat-right .wc-chatbot-window {
    right: 0;
    left: auto;
    transform-origin: bottom right;
}

.wc-chat-left .wc-chatbot-window {
    left: 0;
    right: auto;
    transform-origin: bottom left;
}

.wc-chatbot-window.is-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.wc-chatbot-header {
    background: linear-gradient(135deg, var(--wc-bot-primary) 0%, #1d4ed8 100%);
    color: #ffffff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.wc-chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wc-chatbot-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.wc-chatbot-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.wc-chatbot-default-avatar {
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wc-status-indicator {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 11px;
    height: 11px;
    background-color: #22c55e;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

.wc-chatbot-header-text .wc-chatbot-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    color: #ffffff;
}

.wc-chatbot-header-text .wc-chatbot-subtitle {
    margin: 3px 0 0;
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    gap: 5px;
}

.wc-dot-online {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #4ade80;
    border-radius: 50%;
}

.wc-chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.wc-chatbot-icon-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.wc-chatbot-icon-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

/* Messages Area */
.wc-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
    scroll-behavior: smooth;
}

/* Scrollbar */
.wc-chatbot-messages::-webkit-scrollbar {
    width: 5px;
}
.wc-chatbot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Message Bubbles */
.wc-chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    font-size: 13.5px;
    line-height: 1.45;
    animation: wcFadeInUp 0.22s ease-out;
}

@keyframes wcFadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.wc-chat-msg-user {
    align-self: flex-end;
}

.wc-chat-msg-user .wc-msg-bubble {
    background: var(--wc-bot-primary);
    color: #ffffff;
    border-radius: 16px 16px 2px 16px;
    padding: 10px 14px;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
}

.wc-chat-msg-bot {
    align-self: flex-start;
}

.wc-chat-msg-bot .wc-msg-bubble {
    background: #ffffff;
    color: var(--wc-bot-text-main);
    border: 1px solid var(--wc-bot-border);
    border-radius: 16px 16px 16px 2px;
    padding: 11px 14px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
}

.wc-msg-bubble p {
    margin: 0 0 6px;
}
.wc-msg-bubble p:last-child {
    margin-bottom: 0;
}

.wc-msg-bubble strong {
    font-weight: 600;
}

.wc-msg-time {
    font-size: 10px;
    color: var(--wc-bot-text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

.wc-chat-msg-user .wc-msg-time {
    text-align: right;
}

/* Quick Action Suggestion Chips */
.wc-chatbot-quick-chips {
    padding: 8px 14px;
    background: #ffffff;
    border-top: 1px solid var(--wc-bot-border);
    display: flex;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}
.wc-chatbot-quick-chips::-webkit-scrollbar {
    display: none;
}

.wc-chip-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #334155;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.wc-chip-btn:hover {
    background: var(--wc-bot-primary);
    color: #ffffff;
    border-color: var(--wc-bot-primary);
    transform: translateY(-1px);
}

/* Typing Indicator */
.wc-chatbot-typing-indicator {
    padding: 8px 16px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wc-typing-bubbles {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #ffffff;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--wc-bot-border);
}

.wc-typing-bubbles span {
    width: 6px;
    height: 6px;
    background-color: #94a3b8;
    border-radius: 50%;
    animation: wcTypingDot 1.4s infinite ease-in-out both;
}

.wc-typing-bubbles span:nth-child(1) { animation-delay: -0.32s; }
.wc-typing-bubbles span:nth-child(2) { animation-delay: -0.16s; }

@keyframes wcTypingDot {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Input Bar */
.wc-chatbot-input-bar {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: #ffffff;
    border-top: 1px solid var(--wc-bot-border);
    gap: 8px;
}

.wc-chatbot-input-field {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 24px;
    padding: 9px 16px;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f8fafc;
}

.wc-chatbot-input-field:focus {
    border-color: var(--wc-bot-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    background: #ffffff;
}

.wc-chatbot-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--wc-bot-primary);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.15s;
    flex-shrink: 0;
}

.wc-chatbot-send-btn:hover {
    background: var(--wc-bot-primary-hover);
    transform: scale(1.05);
}

.wc-chatbot-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

/* Footer Brand */
.wc-chatbot-footer-brand {
    text-align: center;
    font-size: 10.5px;
    color: var(--wc-bot-text-muted);
    padding: 5px 0 7px;
    background: #ffffff;
}

/* --- RICH PAYLOADS: PRODUCT CARDS --- */
.wc-chat-products-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
    width: 100%;
}

.wc-product-card {
    display: flex;
    gap: 10px;
    background: #ffffff;
    border: 1px solid var(--wc-bot-border);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    transition: transform 0.15s, box-shadow 0.15s;
}

.wc-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.wc-product-thumb {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
    background: #f1f5f9;
    flex-shrink: 0;
}

.wc-product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.wc-product-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--wc-bot-text-main);
    text-decoration: none;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wc-product-title:hover {
    color: var(--wc-bot-primary);
}

.wc-product-price {
    font-size: 13px;
    font-weight: 700;
    color: #059669;
    margin: 3px 0;
}

.wc-product-actions {
    display: flex;
    gap: 6px;
    margin-top: 5px;
}

.wc-btn-add-cart {
    background: var(--wc-bot-primary);
    color: #ffffff;
    border: none;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.wc-btn-add-cart:hover {
    background: var(--wc-bot-primary-hover);
}

.wc-btn-view-product {
    background: #f1f5f9;
    color: #475569;
    text-decoration: none;
    padding: 5px 9px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
}

.wc-btn-view-product:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* --- RICH PAYLOADS: ORDER STATUS CARD --- */
.wc-order-card {
    background: #ffffff;
    border: 1px solid var(--wc-bot-border);
    border-radius: 12px;
    padding: 12px;
    margin-top: 8px;
    width: 100%;
}

.wc-order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.wc-order-num {
    font-size: 14px;
    font-weight: 700;
    color: var(--wc-bot-text-main);
}

.wc-status-badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}

.wc-status-completed { background: #dcfce7; color: #15803d; }
.wc-status-processing { background: #e0f2fe; color: #0369a1; }
.wc-status-on-hold { background: #fef3c7; color: #b45309; }
.wc-status-pending { background: #fef9c3; color: #854d0e; }
.wc-status-cancelled { background: #fee2e2; color: #b91c1c; }

.wc-order-meta {
    font-size: 12px;
    color: var(--wc-bot-text-muted);
    line-height: 1.5;
}

.wc-order-items-summary {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--wc-bot-border);
    font-size: 12px;
}

.wc-order-item-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.wc-order-total-row {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #f1f5f9;
    color: var(--wc-bot-text-main);
}

.wc-order-btn-link {
    display: inline-block;
    margin-top: 10px;
    width: 100%;
    text-align: center;
    background: #f1f5f9;
    color: #334155;
    text-decoration: none;
    padding: 7px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.wc-order-btn-link:hover {
    background: var(--wc-bot-primary);
    color: #ffffff;
}

/* --- RICH PAYLOADS: ORDER LIST --- */
.wc-order-list-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.wc-order-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--wc-bot-border);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 12.5px;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}

.wc-order-list-item:hover {
    background: #f1f5f9;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .wc-chatbot-wrapper {
        bottom: 16px;
    }
    .wc-chat-right {
        right: 16px;
    }
    .wc-chat-left {
        left: 16px;
    }
    .wc-chatbot-window {
        position: fixed;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        top: 0;
        bottom: 0;
        right: 0;
        left: 0;
        border-radius: 0;
        transform-origin: bottom center;
    }
}
