/* AI Chat Assistant Widget Styles */

:root {
    --aica-primary: #6366f1;
    --aica-primary-hover: #4f46e5;
    --aica-bg: #ffffff;
    --aica-text: #1f2937;
    --aica-border: #e5e7eb;
    --aica-user-msg: #6366f1;
    --aica-ai-msg: #f3f4f6;
    --aica-shadow: rgba(0, 0, 0, 0.1);
}

/* Chat Button */
button.aica-chat-button {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    left: auto !important;
    top: auto !important;
    width: 60px !important;
    height: 60px !important;
    background: linear-gradient(135deg, var(--aica-primary), var(--aica-primary-hover)) !important;
    border: none !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    box-shadow: 0 4px 12px var(--aica-shadow) !important;
    transition: transform 0.3s ease, box-shadow 0.3s ease !important;
    z-index: 99999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
}

button.aica-chat-button:hover {
    transform: scale(1.1) !important;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4) !important;
}

.aica-chat-button svg {
    width: 28px;
    height: 28px;
    fill: white;
}

.aica-chat-button.active {
    transform: rotate(90deg);
}

/* Chat Window */
.aica-chat-window {
    position: fixed !important;
    bottom: 90px !important;
    right: 20px !important;
    left: auto !important;
    top: auto !important;
    width: 400px !important;
    max-width: calc(100vw - 40px) !important;
    height: 600px !important;
    max-height: calc(100vh - 120px) !important;
    background: var(--aica-bg) !important;
    border-radius: 16px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15) !important;
    display: none !important;
    flex-direction: column !important;
    z-index: 99998 !important;
    overflow: hidden !important;
    animation: slideUp 0.3s ease-out !important;
    direction: rtl;
    text-align: right;
}

.aica-chat-window.visible {
    display: flex !important;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.aica-chat-header {
    background: linear-gradient(135deg, var(--aica-primary), var(--aica-primary-hover));
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.aica-header-content {
    flex: 1;
}

.aica-chat-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.aica-chat-header p {
    margin: 4px 0 0;
    font-size: 13px;
    opacity: 0.9;
}

.aica-header-logo {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.aica-header-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.aica-close-btn {
    --btn-padding: 0;
    --btn-brd-width: 0;
    background: rgba(255, 255, 255, 0.2);
    border: none !important;
    color: white;
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    border-radius: 4px !important;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px !important;
    line-height: 1 !important;
    flex-shrink: 0;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
}

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

/* Chat Messages */
.aica-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fafafa;
    scroll-behavior: smooth;
}

.aica-message {
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.aica-message.user {
    flex-direction: row;
}

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

.aica-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin: 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.aica-message.user .aica-message-avatar {
    background: var(--aica-user-msg);
    color: white;
}

.aica-message.ai .aica-message-avatar {
    background: var(--aica-primary);
    color: white;
}

.aica-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 14px;
}

.aica-message.user .aica-message-content {
    background: var(--aica-user-msg);
    color: white;
    border-bottom-left-radius: 4px;
}

.aica-message.ai .aica-message-content {
    background: white;
    color: var(--aica-text);
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Product Cards */
.aica-products-container {
    position: relative;
    margin-top: 12px;
    max-width: 100%;
}

.aica-products-grid {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
    padding: 4px 0;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

.aica-products-grid.dragging {
    scroll-behavior: auto;
    scroll-snap-type: none;
}

.aica-products-grid::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.aica-product-card {
    background: white;
    border: 1px solid var(--aica-border);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    min-width: 200px;
    max-width: 200px;
    flex-shrink: 0;
    scroll-snap-align: start;
}

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

.aica-product-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.aica-product-info {
    padding: 12px;
}

.aica-product-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--aica-text);
    margin: 0 0 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

.aica-product-attrs {
    font-size: 12px;
    color: #6b7280;
    margin: 0 0 8px;
}

.aica-product-btn {
    width: 100%;
    padding: 8px;
    background: var(--aica-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

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

/* Carousel Navigation */
.aica-carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: white;
    border: 1px solid var(--aica-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s, border-color 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.aica-carousel-nav:hover {
    background: var(--aica-primary);
    border-color: var(--aica-primary);
}

.aica-carousel-nav:hover svg {
    fill: white;
}

.aica-carousel-nav svg {
    width: 16px;
    height: 16px;
    fill: #6b7280;
    transition: fill 0.2s;
}

.aica-carousel-nav.prev {
    left: -16px;
}

.aica-carousel-nav.next {
    right: -16px;
}

.aica-carousel-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.aica-carousel-nav:disabled:hover {
    background: white;
    border-color: var(--aica-border);
}

.aica-carousel-nav:disabled:hover svg {
    fill: #6b7280;
}

/* Typing Indicator */
.aica-typing {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    width: fit-content;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.aica-typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    margin: 0 3px;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Chat Input */
.aica-chat-input {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid var(--aica-border);
    display: flex;
    gap: 12px;
}

.aica-chat-input input {
    flex: 1;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
    outline: none !important;
    transition: border-color 0.2s;
    background: #f8fafc !important;
    min-height: 44px !important;
    box-shadow: none !important;
}

.aica-chat-input input:focus {
    border-color: var(--aica-primary);
}

.aica-send-btn {
    --btn-padding: 0;
    --btn-brd-width: 0;
    background: var(--aica-primary);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 12px !important;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.aica-send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: scale(1);
}

.aica-send-btn img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .aica-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        right: 10px;
        bottom: 80px;
    }

    .aica-chat-button {
        bottom: 15px;
        right: 15px;
    }
}

/* Order Display */
.aica-order-card {
    background: white;
    border: 1px solid var(--aica-border);
    border-radius: 12px;
    padding: 16px;
    margin-top: 12px;
}

.aica-order-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--aica-border);
}

.aica-order-number {
    font-weight: 600;
    color: var(--aica-text);
}

.aica-order-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: #dbeafe;
    color: #1e40af;
}

.aica-order-items {
    margin: 12px 0;
}

.aica-order-item {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}

.aica-order-item img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 8px;
}

.aica-order-total {
    font-size: 16px;
    font-weight: 700;
    color: var(--aica-primary);
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--aica-border);
}