.ai-widget-wrap {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Pre-Chat Form */
.ai-prechat-form {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #f8fafc;
    overflow-y: auto;
}

.ai-prechat-content {
    width: 100%;
    max-width: 280px;
    text-align: center;
}

.ai-prechat-icon {
    margin-bottom: 12px;
}

.ai-prechat-title {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 6px;
}

.ai-prechat-desc {
    font-size: 13px;
    color: #64748b;
    margin: 0 0 16px;
}

.ai-prechat-field {
    margin-bottom: 10px;
}

.ai-prechat-field input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
    background: #fff;
}

.ai-prechat-field input:focus {
    border-color: #93c5fd;
}

.ai-prechat-field input::placeholder {
    color: #94a3b8;
}

.ai-prechat-submit {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.2s;
    margin-top: 4px;
}

.ai-prechat-submit:hover {
    opacity: 0.9;
}

.ai-dir-rtl .ai-widget-wrap,
.ai-dir-rtl.ai-widget-wrap {
    right: auto;
    left: 24px;
}

.ai-dir-rtl .ai-chat-window {
    left: 0;
    right: auto;
}

.ai-dir-rtl .ai-unread-badge {
    right: auto;
    left: -4px;
}

.ai-widget-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
}

.ai-widget-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(0,0,0,0.3);
}

.ai-widget-toggle .ai-icon-close { display: none; }
.ai-widget-wrap.ai-open .ai-icon-chat { display: none !important; }
.ai-widget-wrap.ai-open .ai-icon-close { display: block !important; }

.ai-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 380px;
    max-height: 560px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: aiSlideUp 0.3s ease;
    border: 1px solid rgba(0,0,0,0.08);
}

.ai-dir-rtl .ai-chat-window {
    left: 0;
    right: auto;
    animation: aiSlideUpRtl 0.3s ease;
}

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

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

.ai-chat-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    flex-shrink: 0;
}

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

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

.ai-chat-title {
    font-weight: 600;
    font-size: 15px;
}

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

.ai-btn-icon {
    background: rgba(255,255,255,0.2) !important;
    border: 1px solid rgba(255,255,255,0.3) !important;
    color: #fff !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    padding: 0 !important;
    margin: 0 !important;
    outline: none !important;
    box-shadow: none !important;
}

.ai-btn-icon svg {
    width: 16px !important;
    height: 16px !important;
    stroke: #fff !important;
    fill: none !important;
    stroke-width: 2 !important;
    display: block !important;
}

.ai-btn-icon:hover {
    background: rgba(255,255,255,0.4) !important;
    border-color: rgba(255,255,255,0.5) !important;
    transform: scale(1.05);
}

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

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 280px;
    max-height: 340px;
    background: #f8fafc;
}

.ai-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
}

.ai-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-dir-rtl .ai-message-user {
    align-self: flex-start;
    flex-direction: row;
}

.ai-dir-rtl .ai-message-assistant {
    align-self: flex-end;
    flex-direction: row-reverse;
}

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

.ai-message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    white-space: pre-wrap;
    box-sizing: border-box;
}

.ai-message-user .ai-message-bubble {
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-dir-rtl .ai-message-user .ai-message-bubble {
    border-bottom-right-radius: 16px;
    border-bottom-left-radius: 4px;
}

.ai-dir-rtl .ai-message-assistant .ai-message-bubble {
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 4px;
}

.ai-message-assistant .ai-message-bubble {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.ai-message-user .ai-message-bubble {
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-dir-rtl .ai-message-user .ai-message-bubble {
    border-bottom-right-radius: 16px;
    border-bottom-left-radius: 4px;
}

.ai-dir-rtl .ai-message-assistant .ai-message-bubble {
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 4px;
}

.ai-message-assistant .ai-message-bubble {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.ai-message-time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    text-align: right;
}

.ai-dir-rtl .ai-message-time {
    text-align: left;
}

.ai-message-user .ai-message-time {
    text-align: left;
}

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

.ai-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
}

.ai-dir-rtl .ai-typing {
    align-self: flex-end;
}

.ai-typing-dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: aiTyping 1.4s ease-in-out infinite;
}

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

@keyframes aiTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.ai-suggestions {
    padding: 0 16px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: #f8fafc;
}

.ai-suggestion-chip {
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 12px;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.ai-suggestion-chip:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    color: #2563eb;
}

.ai-chat-footer {
    padding: 8px 12px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    flex-shrink: 0;
}

.ai-chat-form {
    display: flex;
    gap: 6px;
    align-items: center;
}

.ai-chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    font-family: inherit;
    resize: none;
    max-height: 50px;
    line-height: 1.3;
    outline: none;
    transition: border-color 0.2s;
    min-height: 32px;
}

.ai-chat-input:focus {
    border-color: #93c5fd;
}

.ai-chat-input::placeholder {
    color: #94a3b8;
}

.ai-chat-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.ai-chat-send:hover { opacity: 0.9; }
.ai-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

.ai-chat-footer-text {
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 6px;
}

.ai-feedback {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

.ai-feedback-btn {
    background: none;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-feedback-btn:hover {
    background: #f1f5f9;
}

@media (max-width: 480px) {
    .ai-chat-window {
        width: calc(100vw - 32px);
        right: -8px;
        bottom: 68px;
        max-height: 70vh;
    }

    .ai-dir-rtl .ai-chat-window {
        left: -8px;
        right: auto;
    }

    .ai-widget-wrap {
        bottom: 16px;
        right: 16px;
    }

    .ai-dir-rtl .ai-widget-wrap {
        right: auto;
        left: 16px;
    }
}

/* Product Cards */
.ai-products-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
    padding: 2px;
}

.ai-product-card {
    display: flex;
    gap: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px;
    transition: box-shadow 0.2s;
}

.ai-product-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.ai-product-img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: #e2e8f0;
}

.ai-product-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ai-product-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-product-price {
    font-size: 14px;
    font-weight: 700;
    color: #059669;
}

.ai-product-desc {
    font-size: 11px;
    color: #64748b;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ai-product-stock {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
}

.ai-stock-in {
    background: #d1fae5;
    color: #065f46;
}

.ai-stock-out {
    background: #fee2e2;
    color: #991b1b;
}

.ai-product-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.ai-product-view, .ai-product-cart {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-block;
}

.ai-product-view {
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #475569;
}

.ai-product-view:hover {
    border-color: #93c5fd;
    color: #2563eb;
}

.ai-product-cart {
    background: #2563eb;
    border: 1px solid #2563eb;
    color: #fff;
}

.ai-product-cart:hover {
    background: #1d4ed8;
}

.ai-product-bubble {
    padding: 8px !important;
    max-width: 340px !important;
    overflow: hidden;
    box-sizing: border-box;
}

.ai-product-bubble .ai-products-grid {
    max-width: 100%;
    overflow-x: hidden;
}

/* Order Card */
.ai-order-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
}

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

.ai-order-number {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
}

.ai-order-status {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
}

.ai-status-processing { background: #fef3c7; color: #92400e; }
.ai-status-completed  { background: #d1fae5; color: #065f46; }
.ai-status-pending    { background: #e0e7ff; color: #3730a3; }
.ai-status-cancelled  { background: #fee2e2; color: #991b1b; }
.ai-status-refunded   { background: #f3e8ff; color: #6b21a8; }
.ai-status-on-hold    { background: #fef9c3; color: #854d0e; }
.ai-status-failed     { background: #fee2e2; color: #991b1b; }

.ai-order-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.ai-order-detail {
    font-size: 12px;
    color: #475569;
}

.ai-order-detail span {
    font-weight: 600;
    color: #1e293b;
}

.ai-order-items-title {
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
    margin-top: 4px;
}

.ai-order-item {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 4px 0;
    border-bottom: 1px solid #f1f5f9;
}

.ai-order-item-name {
    color: #475569;
}

.ai-order-item-price {
    font-weight: 600;
    color: #1e293b;
}

.ai-order-bubble {
    padding: 8px !important;
    max-width: 340px !important;
    overflow: hidden;
    box-sizing: border-box;
}

/* Site Search Results */
.ai-site-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    padding: 2px;
}

.ai-site-result-card {
    display: flex;
    gap: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
    cursor: pointer;
}

.ai-site-result-card:hover {
    border-color: #93c5fd;
    box-shadow: 0 2px 8px rgba(37,99,235,0.1);
    background: #eff6ff;
}

.ai-site-result-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: #e2e8f0;
}

.ai-site-result-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ai-site-result-type {
    font-size: 10px;
    color: #64748b;
    font-weight: 500;
}

.ai-site-result-title {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-site-result-excerpt {
    font-size: 11px;
    color: #64748b;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ai-site-result-price {
    font-size: 13px;
    font-weight: 700;
    color: #059669;
    margin-top: 2px;
}

.ai-site-results-bubble {
    padding: 8px !important;
    max-width: 340px !important;
    overflow: hidden;
    box-sizing: border-box;
}

.ai-site-result-card {
    display: flex;
    gap: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
    cursor: pointer;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.ai-dir-rtl .ai-site-result-card {
    flex-direction: row-reverse;
}
