/* WooCommerce AI Chatbot Frontend Styles */

/* Chat Widget Container */
#woo-ai-chatbot-widget {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Position variants */
#woo-ai-chatbot-widget.position-bottom-right {
    bottom: 20px;
    right: 20px;
}

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

#woo-ai-chatbot-widget.position-top-right {
    top: 20px;
    right: 20px;
}

#woo-ai-chatbot-widget.position-top-left {
    top: 20px;
    left: 20px;
}

/* Chat Toggle Button */
.woo-ai-chat-toggle {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 30px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
    position: relative;
    overflow: hidden;
}

.woo-ai-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

.woo-ai-chat-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.4);
}

.woo-ai-chat-toggle .icon {
    transition: all 0.3s ease;
}

.woo-ai-chat-toggle.active .icon-chat {
    transform: rotate(180deg) scale(0);
}

.woo-ai-chat-toggle.active .icon-close {
    transform: rotate(0deg) scale(1);
}

.woo-ai-chat-toggle .icon-close {
    position: absolute;
    transform: rotate(-180deg) scale(0);
}

/* Notification Badge */
.woo-ai-chat-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #ff4757;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Chat Window */
.woo-ai-chat-window {
    width: 450px;
    height: 650px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.2);
    position: absolute;
    bottom: 80px;
    right: 0;
    transform: scale(0) translateY(20px);
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    opacity: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.woo-ai-chat-window.open {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Adjust position for different placements */
#woo-ai-chatbot-widget.position-bottom-left .woo-ai-chat-window {
    bottom: 80px;
    left: 0;
    transform-origin: bottom left;
}

#woo-ai-chatbot-widget.position-top-right .woo-ai-chat-window {
    top: 80px;
    right: 0;
    transform-origin: top right;
}

#woo-ai-chatbot-widget.position-top-left .woo-ai-chat-window {
    top: 80px;
    left: 0;
    transform-origin: top left;
}

/* Chat Header */
.woo-ai-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.woo-ai-chat-header .title {
    font-weight: 600;
    font-size: 18px;
    letter-spacing: 0.3px;
}

.woo-ai-chat-header .status {
    font-size: 13px;
    opacity: 0.9;
    margin-top: 2px;
}

.woo-ai-chat-header .actions {
    display: flex;
    gap: 8px;
}

.woo-ai-chat-header .btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.woo-ai-chat-header .btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Chat Messages */
.woo-ai-chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    scroll-behavior: smooth;
    background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
}

.woo-ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.woo-ai-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.woo-ai-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.woo-ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Message Bubbles */
.woo-ai-message {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: fadeInUp 0.3s ease;
}

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

.woo-ai-message.user {
    flex-direction: row-reverse;
}

.woo-ai-message .avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.woo-ai-message.bot .avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.woo-ai-message.user .avatar {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
}

.woo-ai-message .content {
    max-width: 75%;
    word-wrap: break-word;
}

.woo-ai-message .bubble {
    padding: 14px 18px;
    border-radius: 20px;
    position: relative;
    line-height: 1.5;
    font-size: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.woo-ai-message.bot .bubble {
    background: #ffffff;
    color: #2c3e50;
    border-bottom-left-radius: 6px;
    border: 1px solid #e9ecef;
}

.woo-ai-message.user .bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.woo-ai-message .timestamp {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 4px;
    text-align: center;
}

/* Typing Indicator */
.woo-ai-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    margin-bottom: 16px;
    max-width: 70%;
}

.woo-ai-typing .dots {
    display: flex;
    gap: 4px;
}

.woo-ai-typing .dot {
    width: 6px;
    height: 6px;
    background: #6c757d;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.woo-ai-typing .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.woo-ai-typing .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}

/* Product Cards */
.woo-ai-products {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.woo-ai-product-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.woo-ai-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    text-decoration: none;
    color: inherit;
}

.woo-ai-product-card .image {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
}

.woo-ai-product-card .image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.woo-ai-product-card:hover .image img {
    transform: scale(1.05);
}

.woo-ai-product-card .badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #ff4757;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: bold;
}

.woo-ai-product-card .info {
    padding: 12px;
}

.woo-ai-product-card .name {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.woo-ai-product-card .price {
    font-weight: 600;
    color: #28a745;
    font-size: 14px;
}

.woo-ai-product-card .price .original {
    text-decoration: line-through;
    color: #6c757d;
    font-weight: normal;
    font-size: 12px;
    margin-right: 4px;
}

.woo-ai-product-card .rating {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 11px;
    color: #6c757d;
}

.woo-ai-product-card .stars {
    color: #ffc107;
}

/* Suggestions - Hidden */
.woo-ai-suggestions {
    display: none !important;
}

.woo-ai-suggestion {
    display: none !important;
}

/* Chat Input */
.woo-ai-chat-input {
    padding: 20px 24px;
    border-top: 1px solid #e9ecef;
    background: white;
    border-radius: 0 0 20px 20px;
}

.woo-ai-input-group {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: #f8f9fa;
    border-radius: 26px;
    padding: 10px 16px;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
}

.woo-ai-input-group:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
    background: white;
}

.woo-ai-input-group textarea {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    resize: none;
    font-size: 15px;
    line-height: 1.5;
    max-height: 100px;
    min-height: 24px;
    font-family: inherit;
    color: #2c3e50;
}

.woo-ai-input-group textarea::placeholder {
    color: #6c757d;
}

.woo-ai-send-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    font-size: 18px;
}

.woo-ai-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.woo-ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Inline Chat Mode */
.woo-ai-chatbot-inline {
    border: 1px solid #e9ecef;
    border-radius: 16px;
    overflow: hidden;
    background: white;
}

.woo-ai-chatbot-inline .woo-ai-chat-window {
    position: static;
    width: 100%;
    height: 100%;
    transform: none;
    opacity: 1;
    box-shadow: none;
    border-radius: 0;
}

/* Error Messages */
.woo-ai-error {
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    margin-top: 8px;
}

/* Loading States */
.woo-ai-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #6c757d;
    font-size: 13px;
}

.woo-ai-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Theme Variations */

/* Dark Theme */
.woo-ai-chatbot-theme-dark .woo-ai-chat-window {
    background: #2c3e50;
    color: #ecf0f1;
}

.woo-ai-chatbot-theme-dark .woo-ai-chat-messages {
    background: #2c3e50;
}

.woo-ai-chatbot-theme-dark .woo-ai-message.bot .bubble {
    background: #34495e;
    color: #ecf0f1;
}

.woo-ai-chatbot-theme-dark .woo-ai-chat-input {
    background: #34495e;
    border-color: #4a5f7a;
}

.woo-ai-chatbot-theme-dark .woo-ai-input-group {
    background: #2c3e50;
    border-color: #4a5f7a;
}

/* Light Theme */
.woo-ai-chatbot-theme-light .woo-ai-chat-toggle {
    background: #ffffff;
    color: #495057;
    border: 2px solid #dee2e6;
}

.woo-ai-chatbot-theme-light .woo-ai-chat-header {
    background: #ffffff;
    color: #495057;
    border-bottom: 1px solid #dee2e6;
}

/* Electro Theme Match */
.woo-ai-chatbot-theme-electro .woo-ai-chat-toggle {
    background: #efba01;
}

.woo-ai-chatbot-theme-electro .woo-ai-chat-header {
    background: #2c3e50;
}

.woo-ai-chatbot-theme-electro .woo-ai-send-btn {
    background: #efba01;
}

.woo-ai-chatbot-theme-electro .woo-ai-suggestion:hover {
    background: #efba01;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #woo-ai-chatbot-widget {
        bottom: 10px;
        right: 10px;
        left: 10px;
        width: auto;
    }

    .woo-ai-chat-window {
        width: 100%;
        height: 80vh;
        bottom: 80px;
        right: 0;
        left: 0;
        border-radius: 16px 16px 0 0;
    }

    .woo-ai-products {
        grid-template-columns: repeat(2, 1fr);
    }

    .woo-ai-chat-toggle {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .woo-ai-chat-window {
        height: 100vh;
        border-radius: 0;
        bottom: 0;
    }

    .woo-ai-chat-header {
        border-radius: 0;
    }

    .woo-ai-products {
        grid-template-columns: 1fr;
    }
}

/* Accessibility */
.woo-ai-chat-toggle:focus,
.woo-ai-send-btn:focus,
.woo-ai-suggestion:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Print styles */
@media print {
    #woo-ai-chatbot-widget {
        display: none !important;
    }
}