/**
 * 2026 Genisoft Web
 *
 * NOTICE OF LICENSE
 *
 * Commercial License - PrestaShop AI Chatbot Module
 *
 * @author    Genisoft Web <contact@genisoft.fr>
 * @copyright 2026 Genisoft Web
 * @license   Commercial License
 */

:host {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --bg-chat: #ffffff;
    --bg-bubble-bot: #f1f5f9;
    --border-color: #e2e8f0;
    --shadow-soft: 0 10px 30px -5px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-family: var(--font-family);
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: inherit;
    margin: 0;
    padding: 0;
}

/* Floating Trigger Button */
.aichatbot-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
    z-index: 2147483646;
}

.aichatbot-trigger:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.5);
}

.aichatbot-trigger:active {
    transform: scale(0.95);
}

.aichatbot-trigger svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
    transition: transform 0.2s ease;
}

.aichatbot-trigger .icon-close {
    display: none;
}

.aichatbot-trigger.is-open .icon-chat {
    display: none;
}

.aichatbot-trigger.is-open .icon-close {
    display: block;
}

/* Unread Badge */
.aichatbot-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 14px;
    height: 14px;
    background-color: #22c55e;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

/* Chat Window Container */
.aichatbot-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 390px;
    height: 620px;
    max-height: calc(100vh - 120px);
    background: var(--bg-chat);
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 2147483647;
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.aichatbot-window.is-open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* Header */
.aichatbot-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.aichatbot-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.aichatbot-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
}

.aichatbot-online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 11px;
    height: 11px;
    background: #22c55e;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

.aichatbot-title-group h3 {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.aichatbot-title-group span {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
}

.aichatbot-header-actions {
    display: flex;
    gap: 8px;
}

.aichatbot-header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.aichatbot-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Chat Messages Body */
.aichatbot-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background-color: #f8fafc;
    scroll-behavior: smooth;
}

.aichatbot-body::-webkit-scrollbar {
    width: 5px;
}

.aichatbot-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Messages */
.aichatbot-msg {
    display: flex;
    flex-direction: column;
    max-width: 86%;
    animation: aichatbot-fade-in 0.2s ease;
}

@keyframes aichatbot-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.aichatbot-msg.is-bot {
    align-self: flex-start;
}

.aichatbot-msg.is-user {
    align-self: flex-end;
}

.aichatbot-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.aichatbot-msg.is-bot .aichatbot-bubble {
    background: var(--bg-bubble-bot);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.aichatbot-msg.is-user .aichatbot-bubble {
    background: var(--primary-color);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.aichatbot-bubble a {
    color: var(--primary-color);
    text-decoration: underline;
    font-weight: 600;
}

.aichatbot-msg.is-user .aichatbot-bubble a {
    color: #ffffff;
}

.aichatbot-msg-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

.aichatbot-msg.is-user .aichatbot-msg-time {
    text-align: right;
}

/* Quick Action Chips */
.aichatbot-quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.aichatbot-chip {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.aichatbot-chip:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--primary-light);
    transform: translateY(-1px);
}

/* Product Cards Carousel */
.aichatbot-cards {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 8px 2px 12px 2px;
    scroll-snap-type: x mandatory;
}

.aichatbot-cards::-webkit-scrollbar {
    height: 4px;
}

.aichatbot-cards::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.aichatbot-card {
    flex: 0 0 210px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    scroll-snap-align: start;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.aichatbot-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.09);
}

.aichatbot-card-img-wrapper {
    position: relative;
    width: 100%;
    height: 130px;
    background: #f8fafc;
    overflow: hidden;
}

.aichatbot-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.aichatbot-card-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.aichatbot-card-badge.is-stock {
    background: #dcfce7;
    color: #15803d;
}

.aichatbot-card-badge.is-out {
    background: #fef3c7;
    color: #b45309;
}

.aichatbot-card-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: space-between;
}

.aichatbot-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.3;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.aichatbot-card-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.aichatbot-card-btn {
    display: block;
    text-align: center;
    background: var(--primary-color);
    color: #ffffff !important;
    text-decoration: none !important;
    font-size: 12px;
    font-weight: 600;
    padding: 8px 10px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.aichatbot-card-btn:hover {
    background: var(--primary-hover);
}

/* In-Chat Form (Tracking) */
.aichatbot-form-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.aichatbot-form-card h4 {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
}

.aichatbot-form-input {
    width: 100%;
    padding: 9px 12px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.aichatbot-form-input:focus {
    border-color: var(--primary-color);
}

.aichatbot-form-submit {
    background: var(--primary-color);
    color: #ffffff;
    border: none;
    padding: 9px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.aichatbot-form-submit:hover {
    background: var(--primary-hover);
}

/* Typing indicator */
.aichatbot-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-bubble-bot);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.aichatbot-dot {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: aichatbot-bounce 1.3s infinite ease-in-out;
}

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

@keyframes aichatbot-bounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Footer / Input Bar */
.aichatbot-footer {
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    padding: 12px 16px 8px 16px;
}

.aichatbot-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f1f5f9;
    border-radius: 24px;
    padding: 4px 6px 4px 16px;
    border: 1px solid transparent;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.aichatbot-input-group:focus-within {
    border-color: var(--primary-color);
    background: #ffffff;
}

.aichatbot-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--text-main);
    outline: none;
    font-family: inherit;
    padding: 6px 0;
}

.aichatbot-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease;
}

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

.aichatbot-send-btn:active {
    transform: scale(0.95);
}

.aichatbot-send-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

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

/* Responsive Mobile Rules */
@media (max-width: 480px) {
    .aichatbot-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .aichatbot-trigger {
        bottom: 16px;
        right: 16px;
    }
}
