/* Chatbot Container */
.woo-ai-chatbot {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* CSS Custom Properties */
    --primary-color: #E91E63;
    --secondary-color: #F48FB1;
    --text-color: #333333;
    --background-color: #ffffff;
    --border-color: #e0e0e0;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    --border-radius: 16px;
}

.woo-ai-chatbot.bottom-right {
    bottom: 20px;
    right: 20px;
}

.woo-ai-chatbot.bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Chatbot Trigger Button */
.chatbot-trigger {
    width: 60px;
    height: 60px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    color: white;
}

.chatbot-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.chatbot-trigger.active {
    transform: scale(0.9);
}

/* Chatbot Window */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 500px;
    background: var(--background-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transform: translateY(20px) scale(0.9);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.woo-ai-chatbot.bottom-left .chatbot-window {
    left: 0;
    right: auto;
}

.chatbot-window.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* Chatbot Header */
.chatbot-header {
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

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

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

.chatbot-title {
    font-weight: 600;
    font-size: 16px;
    line-height: 1.2;
}

.chatbot-subtitle {
    font-size: 12px;
    opacity: 0.8;
    line-height: 1.2;
}

.chatbot-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.clear-chat-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.2s;
}

.clear-chat-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.close-chat-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
}

.close-chat-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

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

.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

/* Messages */
.message {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 85%;
}

.user-message {
    align-self: flex-end;
}

.assistant-message {
    align-self: flex-start;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.user-message .message-content {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 6px;
}

.assistant-message .message-content {
    background: #f5f5f5;
    color: var(--text-color);
    border-bottom-left-radius: 6px;
}

.message-time {
    font-size: 11px;
    color: #888;
    padding: 0 16px;
}

.user-message .message-time {
    text-align: right;
}

/* Product Recommendations */
.product-recommendations {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.recommendations-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 0 4px;
}

.recommendations-header svg {
    color: var(--primary-color);
}

.recommendations-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
}

.product-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.product-image {
    width: 100%;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-name {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 6px 0;
    color: var(--text-color);
    line-height: 1.3;
}

.product-description {
    font-size: 12px;
    color: #666;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.product-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 12px;
}

.product-actions {
    display: flex;
    gap: 8px;
}

.product-view-btn,
.product-add-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.product-view-btn {
    background: var(--secondary-color);
    color: white;
}

.product-view-btn:hover {
    background: var(--primary-color);
}

.product-add-btn {
    background: var(--primary-color);
    color: white;
}

.product-add-btn:hover {
    background: #C2185B;
}

.product-add-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.product-add-btn.added {
    background: #4CAF50;
    cursor: default;
}

/* Order Tracking Form */
.order-tracking-form {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px;
    margin-top: 8px;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-color);
}

.order-id-input,
.order-email-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}

.order-id-input:focus,
.order-email-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(233, 30, 99, 0.1);
}

.track-order-btn {
    width: 100%;
    padding: 10px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.track-order-btn:hover {
    background: #C2185B;
}

/* Order Info */
.order-info {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px;
    margin-top: 8px;
}

.order-info h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: var(--text-color);
}

.order-status {
    margin-bottom: 12px;
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
}

.status-processing {
    background: #FFF3E0;
    color: #F57C00;
}

.status-completed {
    background: #E8F5E8;
    color: #2E7D32;
}

.status-shipped {
    background: #E3F2FD;
    color: #1976D2;
}

.status-pending {
    background: #FFF8E1;
    color: #F9A825;
}

.tracking-message {
    font-size: 14px;
    color: var(--text-color);
    margin-bottom: 12px;
    line-height: 1.4;
}

.order-details {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 12px;
}

.detail-row span:first-child {
    color: #666;
}

.detail-row span:last-child {
    font-weight: 500;
    color: var(--text-color);
}

/* Input Area */
.chatbot-input-area {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: white;
}

.typing-message .typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #f5f5f5;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    width: fit-content;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

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

.input-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(233, 30, 99, 0.1);
}

.send-btn {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-btn:hover {
    background: #C2185B;
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

/* Responsive Design */
@media (max-width: 480px) {
    .chatbot-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        bottom: 80px;
        left: 20px !important;
        right: 20px !important;
    }
    
    .woo-ai-chatbot.bottom-left .chatbot-window,
    .woo-ai-chatbot.bottom-right .chatbot-window {
        left: 20px;
        right: 20px;
    }
    
    .product-actions {
        flex-direction: column;
    }
    
    .product-view-btn,
    .product-add-btn {
        flex: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .woo-ai-chatbot {
        --background-color: #1a1a1a;
        --text-color: #ffffff;
        --border-color: #333333;
    }
    
    .assistant-message .message-content {
        background: #2a2a2a;
        color: #ffffff;
    }
    
    .product-card {
        background: #2a2a2a;
        border-color: #333333;
    }
    
    .order-tracking-form,
    .order-info {
        background: #2a2a2a;
    }
    
    .order-id-input,
    .order-email-input,
    .chat-input {
        background: #333333;
        color: #ffffff;
        border-color: #444444;
    }
}

/* Accessibility */
.woo-ai-chatbot button:focus,
.woo-ai-chatbot input:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.woo-ai-chatbot * {
    box-sizing: border-box;
}

/* Animation for new messages */
.message {
    animation: messageSlideIn 0.3s ease-out;
}

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

/* Product card animation */
.product-card {
    animation: cardFadeIn 0.4s ease-out;
}

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