/* ─── Caillou Chat Widget ─── */
/* Floating chat bubble & panel for the Caillou AI Sales Agent */

/* Reset & Container */
#caillou-widget * { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Floating Bubble ─── */
#caillou-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    z-index: 9999;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none;
    outline: none;
}
#caillou-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(59, 130, 246, 0.5);
}
#caillou-bubble svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; }

/* Unread badge */
#caillou-bubble .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* Greeting tooltip */
#caillou-greeting {
    position: fixed;
    bottom: 92px;
    right: 24px;
    max-width: 280px;
    background: #fff;
    border-radius: 12px;
    padding: 14px 18px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.12);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: #334155;
    line-height: 1.5;
    z-index: 9998;
    animation: caillou-fadeInUp 0.4s ease;
}
#caillou-greeting::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 30px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #fff;
}

/* ─── Chat Panel ─── */
#caillou-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 48px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    animation: caillou-slideUp 0.3s ease;
}

/* Header */
#caillou-panel .caillou-header {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
#caillou-panel .caillou-header .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.4);
}
#caillou-panel .caillou-header .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    display: block;
}
#caillou-panel .caillou-header .info { flex: 1; }
#caillou-panel .caillou-header .info h4 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}
#caillou-panel .caillou-header .info p {
    font-size: 12px;
    opacity: 0.85;
    margin: 2px 0 0;
}
#caillou-panel .caillou-header .close-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
#caillou-panel .caillou-header .close-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* Messages area */
#caillou-panel .caillou-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}
#caillou-panel .caillou-messages::-webkit-scrollbar { width: 4px; }
#caillou-panel .caillou-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* Message row with avatar */
.caillou-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: caillou-fadeIn 0.2s ease;
}
.caillou-msg-row.bot { align-self: flex-start; }
.caillou-msg-row.user { align-self: flex-end; flex-direction: row-reverse; }
.caillou-msg-row .msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
}
.caillou-msg-row .msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    display: block;
}
.caillou-msg-row .msg-avatar.user-avatar {
    background: #3b82f6;
    display: flex;
    align-items: center;
    justify-content: center;
}
.caillou-msg-row .msg-avatar.user-avatar svg {
    width: 16px;
    height: 16px;
    color: #fff;
}

/* Message bubbles */
.caillou-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}
.caillou-msg.bot {
    background: #fff;
    color: #334155;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}
.caillou-msg.user {
    background: #3b82f6;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.caillou-msg.bot a {
    color: #3b82f6;
    text-decoration: underline;
}

/* Quick actions */
.caillou-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
    align-self: flex-start;
}
.caillou-actions button {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #2563eb;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.caillou-actions button:hover {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

/* Action link buttons from AI */
.caillou-action-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
.caillou-action-links a {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #16a34a;
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 12px;
    text-decoration: none;
    transition: all 0.2s;
}
.caillou-action-links a:hover {
    background: #16a34a;
    color: #fff;
}

/* Typing indicator */
.caillou-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
}
.caillou-typing span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: caillou-bounce 1.4s infinite ease-in-out both;
}
.caillou-typing span:nth-child(1) { animation-delay: -0.32s; }
.caillou-typing span:nth-child(2) { animation-delay: -0.16s; }
.caillou-typing span:nth-child(3) { animation-delay: 0s; }

/* ─── Input Area ─── */
#caillou-panel .caillou-input {
    padding: 12px 16px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #fff;
    flex-shrink: 0;
}
#caillou-panel .caillou-input textarea {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    min-height: 40px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s;
}
#caillou-panel .caillou-input textarea:focus {
    border-color: #3b82f6;
}
#caillou-panel .caillou-input textarea::placeholder {
    color: #94a3b8;
}

/* Send button */
#caillou-panel .caillou-input .send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #3b82f6;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
#caillou-panel .caillou-input .send-btn:hover { background: #2563eb; }
#caillou-panel .caillou-input .send-btn:disabled { background: #94a3b8; cursor: not-allowed; }
#caillou-panel .caillou-input .send-btn svg { width: 18px; height: 18px; }

/* Mic button */
#caillou-panel .caillou-input .mic-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
#caillou-panel .caillou-input .mic-btn:hover { background: #e2e8f0; }
#caillou-panel .caillou-input .mic-btn.recording {
    background: #fef2f2;
    color: #ef4444;
    border-color: #fca5a5;
    animation: caillou-pulse 1.5s infinite;
}
#caillou-panel .caillou-input .mic-btn svg { width: 18px; height: 18px; }



/* ─── Animations ─── */
@keyframes caillou-slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes caillou-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes caillou-fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes caillou-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}
@keyframes caillou-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ─── Responsive ─── */
@media (max-width: 480px) {
    #caillou-panel {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    #caillou-bubble { bottom: 16px; right: 16px; }
    #caillou-greeting { bottom: 84px; right: 16px; max-width: 240px; }
}
