/* =============================================================
   RETICEO Chat AI Widget
   © 2026 RETICEO — Groupe KA Technologies
   ============================================================= */

/* ── CSS custom properties ── */
:root {
  --chat-navy:       #060f1e;
  --chat-navy-mid:   #0e2041;
  --chat-navy-light: #142a55;
  --chat-gold:       #d4973a;
  --chat-gold-dim:   rgba(212, 151, 58, .18);
  --chat-white:      #ffffff;
  --chat-ink:        rgba(255,255,255,.95);
  --chat-ink-dim:    rgba(255,255,255,.58);
  --chat-bubble-u:   #1a3a6e;          /* user bubble */
  --chat-bubble-b:   #112244;           /* bot bubble — opaque pour lisibilité */
  --chat-border:     rgba(255,255,255,.10);
  --chat-radius:     18px;
  --chat-radius-sm:  10px;
  --chat-shadow:     0 24px 64px rgba(0,0,0,.55), 0 4px 12px rgba(0,0,0,.3);
  --chat-btn-size:   60px;
  --chat-width:      400px;
  --chat-height:     580px;
  --chat-z:          9999;
  --chat-transition: .25s cubic-bezier(.4,0,.2,1);
}

/* ── FAB (Floating Action Button) ── */
#reticeo-chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: var(--chat-z);
  width: var(--chat-btn-size);
  height: var(--chat-btn-size);
  border-radius: 50%;
  background: linear-gradient(135deg, #1a4080 0%, #0e2041 100%);
  border: 2px solid var(--chat-gold);
  box-shadow: 0 6px 24px rgba(212,151,58,.35), 0 2px 8px rgba(0,0,0,.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--chat-transition), box-shadow var(--chat-transition);
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

#reticeo-chat-fab:hover {
  transform: scale(1.10) translateY(-2px);
  box-shadow: 0 10px 32px rgba(212,151,58,.5), 0 4px 12px rgba(0,0,0,.4);
}

#reticeo-chat-fab:active {
  transform: scale(.96);
}

#reticeo-chat-fab .chat-fab-icon {
  font-size: 1.45rem;
  color: var(--chat-gold);
  transition: opacity var(--chat-transition);
  position: absolute;
}

#reticeo-chat-fab .chat-fab-icon--close {
  opacity: 0;
  transform: rotate(-90deg);
  transition: opacity var(--chat-transition), transform var(--chat-transition);
}

#reticeo-chat-fab.is-open .chat-fab-icon--chat {
  opacity: 0;
}

#reticeo-chat-fab.is-open .chat-fab-icon--close {
  opacity: 1;
  transform: rotate(0deg);
}

/* notification dot */
#reticeo-chat-fab .chat-fab-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 12px;
  height: 12px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: chatPulse 2s infinite;
}

@keyframes chatPulse {
  0%,100% { transform: scale(1); opacity:1; }
  50%      { transform: scale(1.3); opacity:.7; }
}

/* ── Panel (fenêtre de chat) ── */
#reticeo-chat-panel {
  position: fixed;
  bottom: calc(var(--chat-btn-size) + 40px);
  right: 28px;
  z-index: var(--chat-z);
  width: var(--chat-width);
  height: var(--chat-height);
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 120px);
  background: linear-gradient(160deg, #0a1628 0%, #060f1e 100%);
  border: 1px solid var(--chat-border);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* animation d'entrée */
  transform: translateY(16px) scale(.97);
  opacity: 0;
  pointer-events: none;
  transition: transform var(--chat-transition), opacity var(--chat-transition);
}

#reticeo-chat-panel.is-visible {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ── Header du panel ── */
.chat-header {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: 1rem 1.2rem;
  background: linear-gradient(135deg, #0e2041 0%, #0a1628 100%);
  border-bottom: 1px solid var(--chat-border);
  flex-shrink: 0;
}

.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a4080, #0e2041);
  border: 2px solid var(--chat-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-header-avatar i {
  font-size: 1.1rem;
  color: var(--chat-gold);
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-header-name {
  font-size: .92rem;
  font-weight: 700;
  color: var(--chat-white);
  letter-spacing: .01em;
  line-height: 1.2;
}

.chat-header-status {
  font-size: .72rem;
  color: #4ade80;
  display: flex;
  align-items: center;
  gap: .3rem;
  margin-top: .15rem;
}

.chat-header-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
}

.chat-header-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--chat-border);
  color: var(--chat-ink-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--chat-transition), color var(--chat-transition);
  flex-shrink: 0;
}

.chat-header-close:hover {
  background: rgba(255,255,255,.1);
  color: var(--chat-white);
}

/* ── Zone messages ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1rem .5rem;
  display: flex;
  flex-direction: column;
  gap: .7rem;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 5px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.15);
  border-radius: 10px;
}

/* ── Bulles ── */
.chat-msg {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  animation: chatMsgIn .22s ease both;
}

@keyframes chatMsgIn {
  from { opacity:0; transform:translateY(8px); }
  to   { opacity:1; transform:translateY(0); }
}

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

.chat-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg,#1a4080,#0e2041);
  border: 1.5px solid var(--chat-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.chat-msg-avatar i {
  font-size: .72rem;
  color: var(--chat-gold);
}

.chat-msg-bubble {
  max-width: 82%;
  padding: .82rem 1.05rem;
  border-radius: 16px;
  font-size: .88rem;
  line-height: 1.7;
  position: relative;
}

.chat-msg--bot .chat-msg-bubble {
  background: var(--chat-bubble-b);
  border: 1px solid rgba(255,255,255,.15);
  color: var(--chat-ink);
  border-bottom-left-radius: 4px;
}

.chat-msg--user .chat-msg-bubble {
  background: linear-gradient(135deg, #1a4a8a 0%, #1e3a7a 100%);
  border: 1px solid rgba(99,141,207,.3);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* markdown-like dans les bulles */
.chat-msg-bubble strong {
  color: #ffffff;
  font-weight: 700;
}

.chat-msg-bubble em {
  color: var(--chat-gold);
  font-style: italic;
}

.chat-msg-bubble ul, .chat-msg-bubble ol {
  margin: .4rem 0 .4rem 1.2rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.chat-msg-bubble li {
  line-height: 1.6;
  color: inherit;
}

.chat-msg-bubble p {
  margin: 0 0 .5rem;
  color: inherit;
}

.chat-msg-bubble p:last-child {
  margin-bottom: 0;
}

/* lien CTA dans la bulle */
.chat-msg-link {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin-top: .6rem;
  padding: .38rem .85rem;
  background: var(--chat-gold-dim);
  border: 1px solid rgba(212,151,58,.35);
  border-radius: 20px;
  font-size: .76rem;
  font-weight: 600;
  color: var(--chat-gold);
  text-decoration: none;
  letter-spacing: .02em;
  transition: background var(--chat-transition), border-color var(--chat-transition);
}

.chat-msg-link:hover {
  background: rgba(212,151,58,.28);
  border-color: rgba(212,151,58,.6);
}

.chat-msg-link i {
  font-size: .7rem;
}

/* timestamp */
.chat-msg-time {
  font-size: .65rem;
  color: var(--chat-ink-dim);
  margin-top: .2rem;
  padding: 0 .3rem;
}

/* ── Typing indicator ── */
.chat-typing {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.chat-typing-dots {
  display: flex;
  gap: 4px;
  padding: .6rem .8rem;
  background: var(--chat-bubble-b);
  border: 1px solid var(--chat-border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.chat-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-gold);
  animation: chatDot 1.4s infinite both;
}

.chat-typing-dots span:nth-child(2) { animation-delay: .2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes chatDot {
  0%,80%,100% { transform: scale(.7); opacity:.5; }
  40%          { transform: scale(1);  opacity:1; }
}

/* ── Suggestions ── */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  padding: .5rem .9rem .3rem;
}

.chat-suggestion-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .35rem .8rem;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  font-size: .76rem;
  color: var(--chat-ink);
  cursor: pointer;
  transition: background var(--chat-transition), border-color var(--chat-transition), color var(--chat-transition);
  white-space: nowrap;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.chat-suggestion-btn:hover {
  background: var(--chat-gold-dim);
  border-color: rgba(212,151,58,.4);
  color: var(--chat-gold);
}

/* ── Zone de saisie ── */
.chat-input-area {
  padding: .75rem 1rem;
  border-top: 1px solid var(--chat-border);
  display: flex;
  gap: .6rem;
  align-items: flex-end;
  background: rgba(6,15,30,.5);
  flex-shrink: 0;
}

.chat-input-wrap {
  flex: 1;
  position: relative;
}

.chat-input {
  width: 100%;
  min-height: 40px;
  max-height: 120px;
  padding: .6rem .9rem;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--chat-border);
  border-radius: 22px;
  color: var(--chat-white);
  font-size: .84rem;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.5;
  box-sizing: border-box;
  transition: border-color var(--chat-transition), background var(--chat-transition);
  scrollbar-width: none;
}

.chat-input::-webkit-scrollbar { display: none; }

.chat-input::placeholder { color: var(--chat-ink-dim); }

.chat-input:focus {
  border-color: rgba(212,151,58,.5);
  background: rgba(255,255,255,.1);
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-gold) 0%, #c2832a 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--chat-transition), box-shadow var(--chat-transition), opacity var(--chat-transition);
  box-shadow: 0 3px 10px rgba(212,151,58,.4);
}

.chat-send-btn:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 5px 15px rgba(212,151,58,.55);
}

.chat-send-btn:active:not(:disabled) {
  transform: scale(.94);
}

.chat-send-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.chat-send-btn i {
  color: #fff;
  font-size: .9rem;
}

/* ── Footer du panel ── */
.chat-panel-footer {
  padding: .4rem .9rem .55rem;
  text-align: center;
  font-size: .65rem;
  color: var(--chat-ink-dim);
  border-top: 1px solid var(--chat-border);
  flex-shrink: 0;
  background: rgba(6,15,30,.3);
}

.chat-panel-footer a {
  color: var(--chat-gold);
  text-decoration: none;
}

/* ── Welcome card ── */
.chat-welcome {
  background: linear-gradient(135deg, rgba(26,64,128,.5) 0%, rgba(14,32,65,.5) 100%);
  border: 1px solid rgba(212,151,58,.25);
  border-radius: var(--chat-radius-sm);
  padding: 1.1rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-bottom: .3rem;
}

.chat-welcome-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--chat-white);
}

.chat-welcome-sub {
  font-size: .82rem;
  color: rgba(255,255,255,.92);
  line-height: 1.65;
}

/* ── Responsive mobile ── */
@media (max-width: 480px) {
  :root {
    --chat-width: calc(100vw - 16px);
    --chat-height: 70vh;
  }

  #reticeo-chat-panel {
    right: 8px;
    bottom: calc(var(--chat-btn-size) + 12px);
  }

  #reticeo-chat-fab {
    bottom: 16px;
    right: 16px;
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  #reticeo-chat-panel,
  #reticeo-chat-fab,
  .chat-msg,
  .chat-typing-dots span {
    animation: none !important;
    transition: none !important;
  }
}
