/**
 * MaxStore AI Chatbot Styles
 */

/* CSS Variables */
:root {
    --maxstore-ai-accent: #d62c2c;
    --maxstore-ai-accent-hover: #b82424;
    --maxstore-ai-bg: #ffffff;
    --maxstore-ai-bg-dark: #303030;
    --maxstore-ai-text: #333333;
    --maxstore-ai-text-light: #767676;
    --maxstore-ai-border: #e5e5e5;
    --maxstore-ai-shadow: 0 5px 40px rgba(0,0,0,0.16);
    --maxstore-ai-radius: 16px;
}

/* Reset & Base */
.maxstore-ai-chatbot,
.maxstore-ai-chatbot * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.maxstore-ai-chatbot {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 2147483647 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Toggle Button */
.maxstore-ai-toggle {
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    background: var(--maxstore-ai-accent) !important;
    background-color: #d62c2c !important;
    border: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 5px 40px rgba(0,0,0,0.16) !important;
    transition: all 0.3s ease !important;
    position: relative !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.maxstore-ai-toggle:hover {
    background: var(--maxstore-ai-accent-hover);
    transform: scale(1.05);
}

.maxstore-ai-toggle svg {
    width: 28px;
    height: 28px;
    color: #ffffff;
    transition: all 0.3s ease;
}

.maxstore-ai-toggle .maxstore-ai-icon-close {
    display: none;
}

.maxstore-ai-chatbot.is-open .maxstore-ai-toggle .maxstore-ai-icon-chat {
    display: none;
}

.maxstore-ai-chatbot.is-open .maxstore-ai-toggle .maxstore-ai-icon-close {
    display: block;
}

.maxstore-ai-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 22px;
    height: 22px;
    background: #ff4444;
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat Window */
.maxstore-ai-window {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: var(--maxstore-ai-bg);
    border-radius: var(--maxstore-ai-radius);
    box-shadow: var(--maxstore-ai-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
}

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

/* Header */
.maxstore-ai-header {
    background: var(--maxstore-ai-bg-dark);
    color: #ffffff;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.maxstore-ai-avatar {
    width: 40px;
    height: 40px;
    background: var(--maxstore-ai-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.maxstore-ai-avatar svg {
    width: 24px;
    height: 24px;
    color: #ffffff;
}

.maxstore-ai-header-text {
    display: flex;
    flex-direction: column;
}

.maxstore-ai-title {
    font-weight: 600;
    font-size: 16px;
}

.maxstore-ai-subtitle {
    font-size: 12px;
    opacity: 0.8;
}

.maxstore-ai-close {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.maxstore-ai-close:hover {
    background: rgba(255,255,255,0.1);
}

.maxstore-ai-close svg {
    width: 20px;
    height: 20px;
    color: #ffffff;
}

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

.maxstore-ai-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.maxstore-ai-message-bot {
    align-self: flex-start;
}

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

.maxstore-ai-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
}

.maxstore-ai-message-bot .maxstore-ai-message-content {
    background: #f0f0f0;
    color: var(--maxstore-ai-text);
    border-bottom-left-radius: 4px;
}

.maxstore-ai-message-user .maxstore-ai-message-content {
    background: var(--maxstore-ai-accent);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

/* Typing Indicator */
.maxstore-ai-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #f0f0f0;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.maxstore-ai-typing span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

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

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

/* Products Grid */
.maxstore-ai-products {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 12px;
}

.maxstore-ai-product {
    background: #fff;
    border: 1px solid var(--maxstore-ai-border);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.maxstore-ai-product:hover {
    border-color: var(--maxstore-ai-accent);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.maxstore-ai-product-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: #f5f5f5;
}

.maxstore-ai-product-info {
    padding: 10px;
}

.maxstore-ai-product-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--maxstore-ai-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.maxstore-ai-product-price {
    font-size: 14px;
    font-weight: 700;
    color: var(--maxstore-ai-accent);
}

.maxstore-ai-product-price del {
    color: var(--maxstore-ai-text-light);
    font-weight: 400;
    font-size: 12px;
}

/* View All Link */
.maxstore-ai-view-all {
    display: block;
    text-align: center;
    padding: 12px;
    background: var(--maxstore-ai-accent);
    color: #fff;
    text-decoration: none;
    border-radius: 10px;
    margin-top: 12px;
    font-weight: 500;
    transition: background 0.2s;
}

.maxstore-ai-view-all:hover {
    background: var(--maxstore-ai-accent-hover);
    color: #fff;
}

/* Suggestions */
.maxstore-ai-suggestions {
    padding: 8px 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    border-top: 1px solid var(--maxstore-ai-border);
}

.maxstore-ai-suggestion {
    background: #f5f5f5;
    border: 1px solid var(--maxstore-ai-border);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--maxstore-ai-text);
}

.maxstore-ai-suggestion:hover {
    background: var(--maxstore-ai-accent);
    color: #fff;
    border-color: var(--maxstore-ai-accent);
}

/* Input Area */
.maxstore-ai-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--maxstore-ai-border);
    background: #fafafa;
}

.maxstore-ai-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.maxstore-ai-input {
    flex: 1;
    border: 1px solid var(--maxstore-ai-border);
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: #fff;
}

.maxstore-ai-input:focus {
    border-color: var(--maxstore-ai-accent);
}

.maxstore-ai-send {
    width: 44px;
    height: 44px;
    background: var(--maxstore-ai-accent);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.maxstore-ai-send:hover {
    background: var(--maxstore-ai-accent-hover);
    transform: scale(1.05);
}

.maxstore-ai-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.maxstore-ai-send svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .maxstore-ai-chatbot {
        bottom: 10px !important;
        right: 10px !important;
    }

    .maxstore-ai-toggle {
        width: 54px;
        height: 54px;
    }

    .maxstore-ai-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        bottom: 65px;
        right: 0;
        border-radius: 12px;
    }

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

/* Scrollbar */
.maxstore-ai-messages::-webkit-scrollbar {
    width: 6px;
}

.maxstore-ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.maxstore-ai-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.maxstore-ai-messages::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* Animation for new messages */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.maxstore-ai-message {
    animation: slideIn 0.3s ease;
}

/* Sale Badge */
.maxstore-ai-product-sale {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--maxstore-ai-accent);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.maxstore-ai-product-image-wrap {
    position: relative;
}

/* Error message */
.maxstore-ai-error {
    background: #fff3f3;
    color: #d62c2c;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    border: 1px solid #ffcccc;
}
