.ah-assistant-container {
    width: 100%;
    max-width: 100%;
    height: 80vh;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    overflow-x: hidden; /* blokujemy poziome scrollowanie całego chat */
}

.ah-assistant-window {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.ah-assistant-header {
    background: var(--ah-assistant-primary, #0073aa);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ah-assistant-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.ah-assistant-new-chat {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.ah-assistant-new-chat:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ah-assistant-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden; /* blokujemy poziome scrollowanie w liście wiadomości */
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f5f5f5;
    box-sizing: border-box;
}

.ah-message {
    display: flex;
    gap: 12px;
    max-width: 80%;
    animation: messageSlideIn 0.3s ease-out;
    box-sizing: border-box;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ah-message.ah-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ah-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
}

.ah-message-avatar img.ah-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.ah-message.ah-bot .ah-message-avatar {
    background: var(--ah-assistant-primary, #0073aa);
    color: white;
}

.ah-message.ah-user .ah-message-avatar {
    background: #e0e0e0;
    color: #333;
}

.ah-message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    line-height: 1.4;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 70vw;
    box-sizing: border-box;
    word-wrap: break-word;
}

.ah-message-text {
    /* zwykły tekst */
}

/* Delegujemy scrollbar na wewnętrzny kontener produktów */
.ah-products-wrapper {
    background: #f0f4ff; /* delikatne jasnoniebieskie tło */
    padding: 10px 14px;
    border-radius: 10px;
    box-shadow: inset 0 0 8px rgba(0, 115, 170, 0.15);
    overflow-x: auto; /* pojemnik pozwala przewijać poziomo produkty, jeśli będzie konieczne */
    overflow-y: auto;
    box-sizing: border-box;
}

/* Scrollbary dla produktów */
.ah-products-wrapper::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.ah-products-wrapper::-webkit-scrollbar-thumb {
    background-color: var(--ah-assistant-primary, #0073aa);
    border-radius: 3px;
}

.ah-products-wrapper::-webkit-scrollbar-track {
    background: #e6f0ff;
}

.ah-products-wrapper ul.products {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 10px !important;
    padding: 0 !important;
    margin: 0 !important;
    list-style: none;
}

.ah-products-wrapper ul.products li.product {
    flex: 0 0 auto !important;
    width: 200px !important;
    height: auto !important;
    margin: 0 !important;
}

.ah-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.ah-product-card {
    display: flex;
    flex-direction: column;
    border: 1px solid #ddd;
    padding: 8px;
    border-radius: 8px;
    background: #fff;
    text-align: center;
    transition: box-shadow 0.3s ease-in-out;
}

.ah-product-card:hover {
    box-shadow: 0 0 10px var(--ah-assistant-primary, #0073aa);
}

.ah-product-image {
    width: 100%;
    height: 100px;
    object-fit: contain;
    border-radius: 6px;
    margin-bottom: 8px;
}

.ah-product-name {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 6px 0;
    color: #333;
    min-height: 38px;
}

.ah-product-price {
    font-weight: 700;
    font-size: 13px;
    color: var(--ah-assistant-primary, #0073aa);
    margin-bottom: 8px;
}

.ah-product-actions {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.ah-product-btn {
    flex: 1 1 auto;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.3s ease;
}

.ah-add-to-cart {
    background-color: var(--ah-assistant-primary, #0073aa);
    color: white;
}

.ah-add-to-cart:hover:not(:disabled) {
    background-color: #005a99;
}

.ah-add-to-cart:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ah-view-product {
    background-color: #f0f0f0;
    color: #333;
}

.ah-view-product:hover {
    background-color: #ddd;
}

.ah-assistant-input-wrapper {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: white;
    border-top: 1px solid #ddd;
}

.ah-assistant-input {
    flex-grow: 1;
    font-size: 14px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #ccc;
    resize: none;
    font-family: inherit;
    max-height: 120px;
}

.ah-assistant-input:focus {
    border-color: var(--ah-assistant-primary, #0073aa);
    outline: none;
}

.ah-assistant-send {
    width: 44px;
    height: 44px;
    background: var(--ah-assistant-primary, #0073aa);
    color: white;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
}

.ah-assistant-send:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-1px);
}

.ah-assistant-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 768px) {
    .ah-assistant-container {
        height: 90vh;
        overflow-x: hidden; /* zapobiega przewijaniu poziomemu na mob */
    }

    /* Maksymalna szerokość wiadomości */
    .ah-message.ah-bot,
    .ah-message.ah-user {
        max-width: 70vw;
        word-wrap: break-word;
        box-sizing: border-box;
    }

    .ah-message-content {
        max-width: 100%;
        overflow-wrap: break-word;
        box-sizing: border-box;
    }

    /* Kontener produktów: dopuszczalne przewijanie poziome wewnątrz */
    .ah-products-wrapper {
        max-width: 100%;
        overflow-x: auto;
        padding-right: 8px;
        box-sizing: border-box;
    }

    /* Produkty w linii z przewijaniem poziomym */
    .ah-products-wrapper ul.products {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 10px !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .ah-products-wrapper ul.products li.product {
        flex: 0 0 auto !important;
        width: 200px !important;
        height: auto !important;
        margin: 0 !important;
    }

    /* Dod. dopasowania dla listy produktów */
    .ah-products-grid {
        grid-template-columns: 1fr;
        gap: 8px;
        margin-top: 8px;
    }

    .ah-product-image {
        height: 80px;
    }

    .ah-product-name {
        font-size: 13px;
        min-height: 32px;
    }

    .ah-product-price {
        font-size: 12px;
        margin-bottom: 6px;
    }

    .ah-product-btn {
        font-size: 11px;
        padding: 5px 8px;
    }
}

/* Scrollbar dla wiadomości i produktów */
.ah-assistant-messages::-webkit-scrollbar,
.ah-products-wrapper::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.ah-assistant-messages::-webkit-scrollbar-thumb,
.ah-products-wrapper::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.ah-assistant-messages::-webkit-scrollbar-thumb:hover,
.ah-products-wrapper::-webkit-scrollbar-thumb:hover {
    background: #555;
}
