/* ============================================================
   Agent IA Public — Widget LesMarchesIvoire
   Style autonome, pas de dependance CSS externe
   ============================================================ */

/* FAB */
.ap-fab {
    position: fixed; bottom: 24px; right: 24px; z-index: 9999;
    width: 56px; height: 56px; border-radius: 50%;
    background: linear-gradient(135deg, #16a34a, #059669);
    color: #fff; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 16px rgba(22,163,74,0.35);
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}
.ap-fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(22,163,74,0.45); }
.ap-fab.open { background: #dc2626; }
.ap-fab.open:hover { background: #b91c1c; }

/* PANEL */
.ap-panel {
    position: fixed; bottom: 90px; right: 24px; z-index: 9998;
    width: 380px; max-width: calc(100vw - 32px); height: 520px; max-height: calc(100vh - 130px);
    background: #fff; border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.18);
    display: flex; flex-direction: column; overflow: hidden;
    transform: scale(0.8) translateY(20px); opacity: 0; pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}
.ap-panel.visible { transform: scale(1) translateY(0); opacity: 1; pointer-events: auto; }

/* HEADER */
.ap-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; background: linear-gradient(135deg, #16a34a, #059669);
    color: #fff; font-size: 14px; font-weight: 600; flex-shrink: 0;
}
.ap-header-left { display: flex; align-items: center; gap: 8px; }
.ap-close {
    background: none; border: none; color: #fff; font-size: 22px;
    cursor: pointer; padding: 0 4px; line-height: 1;
}

/* MESSAGES */
.ap-messages {
    flex: 1; overflow-y: auto; padding: 16px; display: flex;
    flex-direction: column; gap: 10px;
}
.ap-msg {
    max-width: 85%; padding: 10px 14px; border-radius: 12px;
    font-size: 13px; line-height: 1.5; word-wrap: break-word;
    animation: apFadeIn 0.2s ease;
}
@keyframes apFadeIn { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:translateY(0); } }
.ap-user {
    align-self: flex-end; background: #16a34a; color: #fff;
    border-bottom-right-radius: 4px;
}
.ap-bot {
    align-self: flex-start; background: #f3f4f6; color: #1f2937;
    border-bottom-left-radius: 4px;
}
.ap-arrow { color: #16a34a; font-weight: 700; }
.ap-warn { color: #f59e0b; }
.ap-tip { color: #8b5cf6; }

/* LOADING */
.ap-loading .ap-dot {
    display: inline-block; width: 6px; height: 6px; border-radius: 50%;
    background: #9ca3af; margin: 0 2px;
    animation: apBounce 1.2s infinite ease-in-out;
}
.ap-loading .ap-dot:nth-child(1) { animation-delay: 0s; }
.ap-loading .ap-dot:nth-child(2) { animation-delay: 0.2s; }
.ap-loading .ap-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes apBounce { 0%,80%,100%{transform:scale(0);opacity:0.4} 40%{transform:scale(1);opacity:1} }

/* ACTIONS */
.ap-actions { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.ap-action-btn {
    display: inline-block; padding: 5px 12px; font-size: 11px; font-weight: 600;
    background: #16a34a; color: #fff !important; text-decoration: none;
    border-radius: 16px; transition: background 0.15s; white-space: nowrap;
}
.ap-action-btn:hover { background: #15803d; }
.ap-action-btn.ap-alt { background: #6366f1; }
.ap-action-btn.ap-alt:hover { background: #4f46e5; }

/* SUGGESTIONS */
.ap-suggestions {
    display: flex; gap: 6px; padding: 8px 12px;
    overflow-x: auto; flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.ap-suggestions::-webkit-scrollbar { display: none; }
.ap-sug {
    flex-shrink: 0; padding: 5px 12px; font-size: 11px; font-weight: 500;
    background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0;
    border-radius: 16px; cursor: pointer; white-space: nowrap;
    transition: all 0.15s;
    font-family: inherit;
}
.ap-sug:hover { background: #16a34a; color: #fff; border-color: #16a34a; }

/* INPUT */
.ap-input-area {
    display: flex; gap: 6px; padding: 10px 12px;
    border-top: 1px solid #e5e7eb; background: #fff; flex-shrink: 0;
}
.ap-input-area input {
    flex: 1; padding: 8px 12px; border: 1.5px solid #e5e7eb;
    border-radius: 10px; font-size: 13px; outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
}
.ap-input-area input:focus { border-color: #16a34a; }
.ap-input-area button {
    padding: 8px 16px; background: #16a34a; color: #fff;
    border: none; border-radius: 10px; font-size: 12px; font-weight: 600;
    cursor: pointer; transition: background 0.15s; white-space: nowrap;
    font-family: inherit;
}
.ap-input-area button:hover { background: #15803d; }

/* SCROLLBAR */
.ap-messages::-webkit-scrollbar { width: 4px; }
.ap-messages::-webkit-scrollbar-track { background: transparent; }
.ap-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

/* RESPONSIVE */
@media (max-width: 480px) {
    .ap-panel { right: 8px; bottom: 80px; width: calc(100vw - 16px); height: calc(100vh - 100px); border-radius: 12px; }
    .ap-fab { bottom: 16px; right: 16px; width: 50px; height: 50px; }
}
