/* ═══════════════════════════════════════════════
   El Callejon AI Chat — Style iMessage iOS
   ═══════════════════════════════════════════════ */

:root {
    --ec-bg:          #ffffff;
    --ec-bg-msgs:     #ffffff;
    --ec-bg-input:    #faf8f5;
    --ec-border:      #c6c6c8;
    --ec-blue:        #9a6607;
    --ec-blue-dark:   #0062cc;
    --ec-gray-bubble: #e9e9eb;
    --ec-text:        #000000;
    --ec-text-2:      #3c3c43;
    --ec-text-3:      #948577;
    --ec-text-white:  #ffffff;
    --ec-green:       #34c759;
    --ec-radius:      22px;
    --ec-shadow:      0 8px 32px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.08);
    --ec-font:        -apple-system, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
    --ec-w:           370px;
    --ec-h:           580px;
    --ec-z:           999999;
}

#ecai-widget *, .ecai-inline-trigger * {
    box-sizing: border-box; margin: 0; padding: 0;
}

/* ═══ WIDGET FLOTTANT ═══ */
#ecai-widget {
    position: fixed; bottom: 24px; right: 24px;
    z-index: var(--ec-z); font-family: var(--ec-font);
}

/* Bulle iOS — fond bleu iMessage */
#ecai-bubble {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--ec-blue); border: none;
    box-shadow: 0 4px 16px rgba(154,102,7,0.4), 0 1px 4px rgba(0,0,0,0.12);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: #fff; position: relative;
    transition: transform 0.2s cubic-bezier(.34,1.56,.64,1), box-shadow 0.2s;
}
#ecai-bubble:hover { transform: scale(1.08); box-shadow: 0 6px 22px rgba(154,102,7,0.5); }
#ecai-bubble.is-open { background: var(--ec-blue-dark); }
#ecai-bubble svg { width: 24px; height: 24px; }

.ecai-bubble-notif {
    position: absolute; top: -2px; right: -2px;
    width: 18px; height: 18px; background: #ff3b30;
    color: #fff; font-size: 11px; font-weight: 700;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-family: var(--ec-font); border: 2px solid #fff;
}

/* ═══ PANNEAU ═══ */
#ecai-panel {
    position: absolute; bottom: 82px; right: 0;
    width: var(--ec-w); max-height: var(--ec-h);
    background: var(--ec-bg); border-radius: var(--ec-radius);
    box-shadow: var(--ec-shadow); border: 0.5px solid rgba(0,0,0,0.12);
    display: flex; flex-direction: column; overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0.88) translateY(10px); opacity: 0;
    transition: transform 0.3s cubic-bezier(.34,1.56,.64,1), opacity 0.22s ease;
    pointer-events: none;
}
#ecai-panel:not([hidden]) { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; display: flex; }
#ecai-panel[hidden] { display: flex !important; pointer-events: none; }

/* ═══ SHORTCODE INLINE ═══ */
.ecai-inline-trigger { display: inline-block; font-family: var(--ec-font); position: relative; }

.ecai-inline-btn {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--ec-blue); color: #fff; border: none;
    border-radius: 980px; padding: 13px 22px;
    font-family: var(--ec-font); font-size: 15px; font-weight: 500;
    cursor: pointer; letter-spacing: -0.01em;
    box-shadow: 0 2px 12px rgba(154,102,7,0.35);
    transition: transform 0.2s, box-shadow 0.2s, background 0.15s;
}
.ecai-inline-btn:hover { transform: translateY(-1px); background: var(--ec-blue-dark); box-shadow: 0 4px 18px rgba(154,102,7,0.45); }
.ecai-inline-btn svg { width: 17px; height: 17px; flex-shrink: 0; }

.ecai-inline-trigger .ecai-panel-inline {
    position: absolute; top: calc(100% + 10px); left: 0;
    width: var(--ec-w); max-height: var(--ec-h);
    background: var(--ec-bg); border-radius: var(--ec-radius);
    box-shadow: var(--ec-shadow); border: 0.5px solid rgba(0,0,0,0.12);
    display: flex; flex-direction: column; overflow: hidden;
    transform-origin: top left;
    transform: scale(0.92) translateY(-6px); opacity: 0;
    transition: transform 0.28s cubic-bezier(.34,1.56,.64,1), opacity 0.22s ease;
    pointer-events: none; z-index: var(--ec-z);
}
.ecai-inline-trigger .ecai-panel-inline:not([hidden]) { transform: scale(1) translateY(0); opacity: 1; pointer-events: all; display: flex; }
.ecai-inline-trigger .ecai-panel-inline[hidden] { display: flex !important; pointer-events: none; }

/* ═══ HEADER — barre iMessage ═══ */
.ecai-header {
    background: #faf8f5;
    border-bottom: 0.5px solid var(--ec-border);
    padding: 12px 16px 11px;
    display: flex; align-items: center; gap: 11px; flex-shrink: 0;
}

.ecai-header-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.ecai-header-info { flex: 1; }
.ecai-agent-name {
    font-size: 15px; font-weight: 600; color: var(--ec-text);
    letter-spacing: -0.01em;
}
.ecai-agent-status {
    font-size: 11px; color: var(--ec-text-3);
    display: flex; align-items: center; gap: 4px; margin-top: 1px;
}
.ecai-status-dot {
    width: 6px; height: 6px; background: var(--ec-green);
    border-radius: 50%; flex-shrink: 0;
    animation: ecai-blink 2.5s ease-in-out infinite;
}
@keyframes ecai-blink { 0%,100% { opacity:1; } 50% { opacity:.3; } }

.ecai-close-btn {
    background: #f5f1ea; border: none; cursor: pointer; color: var(--ec-text-2);
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.ecai-close-btn:hover { background: #ece4d8; }
.ecai-close-btn svg { width: 14px; height: 14px; }

/* ═══ MESSAGES ═══ */
.ecai-messages {
    flex: 1; overflow-y: auto; padding: 18px 14px 10px;
    display: flex; flex-direction: column; gap: 8px;
    background: var(--ec-bg-msgs);
    scrollbar-width: none;
}
.ecai-messages::-webkit-scrollbar { display: none; }

.ecai-msg {
    display: flex; align-items: flex-end; gap: 6px;
    animation: ecai-msg-in 0.22s ease forwards;
    margin-bottom: 2px;
}
@keyframes ecai-msg-in { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:translateY(0); } }

.ecai-msg--user { justify-content: flex-end; }
.ecai-msg--ai   { justify-content: flex-start; }

/* Avatar IA petit cercle */
.ecai-msg-avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; flex-shrink: 0;
    margin-bottom: 0;
}

/* Bulles iMessage */
.ecai-msg-bubble {
    max-width: 75%;
    padding: 9px 14px;
    font-family: var(--ec-font);
    font-size: 15px;
    line-height: 1.45;
    word-break: break-word;
    position: relative;
}

/* Bulle IA — grise */
.ecai-msg--ai .ecai-msg-bubble {
    background: var(--ec-gray-bubble);
    color: var(--ec-text);
    border-radius: 18px 18px 18px 4px;
}

/* Bulle utilisateur — bleue iMessage */
.ecai-msg--user .ecai-msg-bubble {
    background: var(--ec-blue);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
}

/* Timestamp discret */
.ecai-msg-time {
    font-size: 10px;
    color: var(--ec-text-3);
    text-align: center;
    margin: 6px 0 4px;
    font-family: var(--ec-font);
    letter-spacing: 0.01em;
}

/* Carte confirmation résa */
.ecai-resa-card {
    background: #fff;
    border: 1px solid #f5f1ea;
    border-radius: 14px;
    padding: 12px 14px;
    margin-top: 4px;
    font-size: 13px;
    color: var(--ec-text);
    max-width: 80%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.ecai-resa-card h4 {
    font-size: 13px; font-weight: 600; margin-bottom: 8px;
    display: flex; align-items: center; gap: 6px; color: var(--ec-text);
}
.ecai-resa-row {
    display: flex; justify-content: space-between;
    padding: 4px 0; border-bottom: 0.5px solid #f5f1ea;
    font-size: 12px; gap: 10px;
}
.ecai-resa-row:last-child { border-bottom: none; }
.ecai-resa-row span:first-child { color: var(--ec-text-3); }
.ecai-resa-row span:last-child  { color: var(--ec-text); font-weight: 500; text-align: right; }

/* Typing dots iMessage */
.ecai-typing {
    display: flex; align-items: center; gap: 4px;
    padding: 11px 14px;
    background: var(--ec-gray-bubble);
    border-radius: 18px 18px 18px 4px;
    width: fit-content;
}
.ecai-typing span {
    display: block; width: 8px; height: 8px;
    background: var(--ec-text-3); border-radius: 50%;
    animation: ecai-dot 1.3s ease-in-out infinite;
}
.ecai-typing span:nth-child(2) { animation-delay: .15s; }
.ecai-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes ecai-dot { 0%,60%,100% { transform:scale(.7); opacity:.5; } 30% { transform:scale(1); opacity:1; } }

/* ═══ CHIPS ═══ */
.ecai-suggestions { padding: 12px 14px 14px; display: flex; gap: 8px; flex-wrap: wrap; flex-shrink: 0; border-top: 0.5px solid #c6c6c8; background: #fff; }
.ecai-chip { background: rgba(154,102,7,0.07); border: 1px solid rgba(154,102,7,0.22); color: #9a6607; font-family: var(--ec-font); font-size: 13px; font-weight: 500; padding: 9px 16px; border-radius: 980px; cursor: pointer; transition: all .15s; white-space: nowrap; line-height: 1.3; }
.ecai-chip:hover { background: #9a6607; color: #fff; border-color: #9a6607; }

/* ═══ SAISIE — iMessage input ═══ */
.ecai-input-area {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 8px 12px 10px;
    background: #faf8f5;
    border-top: 0.5px solid var(--ec-border);
    flex-shrink: 0;
}

#ecai-input, .ecai-input {
    flex: 1;
    background: #fff;
    border: 1px solid var(--ec-border);
    border-radius: 20px;
    color: var(--ec-text);
    font-family: var(--ec-font);
    font-size: 15px;
    padding: 9px 14px;
    resize: none; outline: none;
    max-height: 100px; overflow-y: auto; scrollbar-width: none;
    line-height: 1.4;
    transition: border-color .15s;
}
#ecai-input::-webkit-scrollbar, .ecai-input::-webkit-scrollbar { display: none; }
#ecai-input::placeholder, .ecai-input::placeholder { color: var(--ec-text-3); }
#ecai-input:focus, .ecai-input:focus { border-color: #9a6607; }

/* Bouton envoi — rond bleu iMessage */
#ecai-send, .ecai-send {
    width: 34px; height: 34px;
    background: var(--ec-blue); border: none; border-radius: 50%;
    cursor: pointer; color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: transform .15s, background .15s;
    margin-bottom: 1px;
}
#ecai-send:hover, .ecai-send:hover { transform: scale(1.08); background: var(--ec-blue-dark); }
#ecai-send:disabled, .ecai-send:disabled { background: #ddd2c2; cursor: not-allowed; transform: none; }
#ecai-send svg, .ecai-send svg { width: 15px; height: 15px; }

/* RESPONSIVE */
@media (max-width: 420px) {
    :root { --ec-w: calc(100vw - 24px); }
    #ecai-widget { right: 12px; bottom: 12px; }
}

/* FOCUS */
#ecai-bubble:focus-visible, #ecai-send:focus-visible, .ecai-send:focus-visible,
.ecai-chip:focus-visible, .ecai-close-btn:focus-visible, .ecai-inline-btn:focus-visible {
    outline: 2px solid var(--ec-blue); outline-offset: 2px;
}

/* ============================================================
   LANCEUR : Emma detouree, a la place de la pastille ronde.
   Le bouton n'a plus de fond ni de forme : c'est l'image
   qui porte toute la presence visuelle.
   ============================================================ */
.ecai-bubble {
	all: unset !important;
	position: fixed !important;
	right: 18px !important;
	bottom: 0 !important;
	z-index: 99998 !important;
	display: flex !important;
	align-items: flex-end !important;
	gap: 8px !important;
	cursor: pointer !important;
	background: none !important;
	border: 0 !important;
	box-shadow: none !important;
	padding: 0 !important;
	transition: transform .25s ease !important;
}
.ecai-bubble:hover { transform: translateY(-4px) !important; }

.ecai-bubble-emma {
	width: 160px !important;
	height: auto !important;
	display: block !important;
	filter: drop-shadow(0 6px 16px rgba(44, 36, 32, 0.22)) !important;
	pointer-events: none !important;
}

.ecai-bubble-accroche {
	background: #ffffff !important;
	color: #2c2420 !important;
	border: 1px solid #ece4d8 !important;
	border-left: 3px solid #9a6607 !important;
	border-radius: 14px 14px 2px 14px !important;
	padding: 10px 14px !important;
	font-size: 14px !important;
	line-height: 1.35 !important;
	max-width: 190px !important;
	margin-bottom: 46px !important;
	box-shadow: 0 4px 14px rgba(44, 36, 32, 0.12) !important;
	opacity: 0;
	transform: translateY(6px);
	animation: ecai-accroche-entree .45s ease 3.5s forwards;
}
@keyframes ecai-accroche-entree { to { opacity: 1; transform: translateY(0); } }

/* Croix de masquage : discrete, mais toujours atteignable */
.ecai-bubble-masquer {
	all: unset !important;
	position: fixed !important;
	right: 12px !important;
	bottom: 178px !important;
	z-index: 99999 !important;
	width: 26px !important;
	height: 26px !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	border-radius: 50% !important;
	background: rgba(255, 255, 255, 0.92) !important;
	border: 1px solid #ece4d8 !important;
	color: #6f6255 !important;
	font-size: 16px !important;
	line-height: 1 !important;
	cursor: pointer !important;
	box-shadow: 0 2px 8px rgba(44, 36, 32, 0.14) !important;
}
.ecai-bubble-masquer:hover { color: #9a6607 !important; }

/* Panneau ouvert : on efface le lanceur */
.ecai-bubble[aria-expanded="true"] { display: none !important; }
.ecai-bubble[aria-expanded="true"] ~ .ecai-bubble-masquer { display: none !important; }

/* Ecrans etroits : Emma retrecit et l'accroche disparait */
@media (max-width: 600px) {
	.ecai-bubble { right: 10px !important; gap: 0 !important; }
	.ecai-bubble-emma { width: 100px !important; }
	.ecai-bubble-accroche { display: none !important; }
	.ecai-bubble-masquer { bottom: 116px !important; right: 6px !important; }
}
@media (max-width: 380px) {
	.ecai-bubble-emma { width: 84px !important; }
	.ecai-bubble-masquer { bottom: 98px !important; }
}
/* Respect de la preference systeme */
@media (prefers-reduced-motion: reduce) {
	.ecai-bubble-accroche { animation: none; opacity: 1; transform: none; }
	.ecai-bubble { transition: none !important; }
}


/* ============================================================
   LANCEUR - AJUSTEMENTS
   L'accroche debordait a droite : on ancre le bloc sur son bord
   droit et on empile accroche puis portrait, plutot que de les
   poser cote a cote sur une ligne qui sort de l'ecran.
   ============================================================ */
.ecai-bubble {
	flex-direction: column !important;
	align-items: flex-end !important;
	gap: 0 !important;
	max-width: calc(100vw - 36px) !important;
}
.ecai-bubble-accroche {
	margin-bottom: -6px !important;
	margin-right: 24px !important;
	max-width: min(230px, calc(100vw - 60px)) !important;
	text-align: left !important;
	position: relative !important;
	z-index: 2 !important;
}
/* Le portrait ne doit jamais deborder non plus */
.ecai-bubble-emma { max-width: calc(100vw - 36px) !important; }
