/* =====================================================
   CASI — Le Griot · Widget IA narratif
   Earth tones + motif kente + design conteur
   ===================================================== */

/* ── Variables locales ────────────────────────────────── */
.griot-widget {
  --g-sand:    #FDF3E3;
  --g-earth:   #C4622D;
  --g-mahog:   #6B2D0E;
  --g-gold:    #D4A017;
  --g-sage:    #4A7C59;
  --g-ink:     #1A1208;
  --g-stone:   #7A6550;
  --g-border:  rgba(196,98,45,.18);
  --g-r:       16px;
  --g-shadow:  0 20px 60px rgba(26,18,8,.22), 0 4px 16px rgba(196,98,45,.12);
}

/* ── FAB Griot ────────────────────────────────────────── */
.griot-fab {
  position: fixed;
  right: 24px;
  bottom: 164px;
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--g-mahog);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 11px 18px 11px 14px;
  cursor: pointer;
  box-shadow: 0 6px 28px rgba(107,45,14,.38), 0 2px 8px rgba(107,45,14,.2);
  transition: transform .22s cubic-bezier(.22,1,.36,1), box-shadow .22s ease;
  font-family: var(--font-ui, sans-serif);
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .04em;
  white-space: nowrap;
}
.griot-fab:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 36px rgba(107,45,14,.42), 0 4px 12px rgba(107,45,14,.22);
}
.griot-fab:active { transform: translateY(0); }
.griot-fab__icon {
  width: 28px; height: 28px;
  flex-shrink: 0;
  animation: griot-float 3.5s ease-in-out infinite;
}
.griot-fab__label { line-height: 1; }

@keyframes griot-float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-3px); }
}

/* ── Overlay ──────────────────────────────────────────── */
.griot-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 401;
  background: rgba(26,18,8,.35);
  backdrop-filter: blur(2px);
}
.griot-overlay.open { display: block; }

/* ── Panel ────────────────────────────────────────────── */
.griot-panel {
  position: fixed;
  right: 20px;
  bottom: 80px;
  z-index: 402;
  width: min(400px, calc(100vw - 40px));
  max-height: min(600px, calc(100vh - 140px));
  background: var(--g-sand);
  border-radius: var(--g-r);
  box-shadow: var(--g-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(.97);
  pointer-events: none;
  transition: opacity .28s cubic-bezier(.22,1,.36,1), transform .28s cubic-bezier(.22,1,.36,1);
}
.griot-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Bandeau kente en haut du panel */
.griot-panel::before {
  content: '';
  display: block;
  height: 7px;
  flex-shrink: 0;
  background: repeating-linear-gradient(
    90deg,
    var(--g-gold)  0px, var(--g-gold)  12px,
    var(--g-earth) 12px, var(--g-earth) 22px,
    var(--g-sage)  22px, var(--g-sage)  30px,
    var(--g-ink)   30px, var(--g-ink)   34px,
    var(--g-gold)  34px, var(--g-gold)  46px,
    var(--g-earth) 46px, var(--g-earth) 52px
  );
}

/* ── Header ───────────────────────────────────────────── */
.griot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--g-border);
  background: var(--g-sand);
  flex-shrink: 0;
}
.griot-header__ident {
  display: flex;
  align-items: center;
  gap: 11px;
}
.griot-avatar {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--g-earth), var(--g-mahog));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.griot-titre {
  font-family: var(--font-display, serif);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--g-ink);
  margin: 0;
  letter-spacing: .02em;
}
.griot-sous-titre {
  font-family: var(--font-ui, sans-serif);
  font-size: .72rem;
  color: var(--g-stone);
  margin: 0;
  letter-spacing: .04em;
}
.griot-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  color: var(--g-stone);
  line-height: 1;
  transition: background .15s, color .15s;
}
.griot-close:hover {
  background: rgba(196,98,45,.1);
  color: var(--g-earth);
}

/* ── Zone messages ────────────────────────────────────── */
.griot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.griot-messages::-webkit-scrollbar { width: 4px; }
.griot-messages::-webkit-scrollbar-thumb { background: var(--g-border); border-radius: 4px; }

/* ── Bulles de message ────────────────────────────────── */
.griot-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: griot-msg-in .22s cubic-bezier(.22,1,.36,1) both;
}
@keyframes griot-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.griot-msg--griot { align-self: flex-start; }
.griot-msg--user  { align-self: flex-end; }

.griot-msg__text {
  padding: 11px 15px;
  border-radius: 14px;
  font-family: var(--font-ui, sans-serif);
  font-size: .88rem;
  line-height: 1.6;
}
.griot-msg--griot .griot-msg__text {
  background: #fff;
  color: var(--g-ink);
  border: 1px solid var(--g-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(26,18,8,.06);
}
.griot-msg--user .griot-msg__text {
  background: var(--g-earth);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Parsing Markdown basique (gras, italique) */
.griot-msg__text strong, .griot-msg__text b { font-weight: 700; }
.griot-msg__text em, .griot-msg__text i     { font-style: italic; color: var(--g-stone); }

/* Cursor clignotant pendant le streaming */
.griot-msg--streaming .griot-msg__text::after {
  content: '▋';
  color: var(--g-earth);
  animation: griot-cursor .8s step-end infinite;
  margin-left: 2px;
}
@keyframes griot-cursor {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Chips voyage ─────────────────────────────────────── */
.griot-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 4px 0 8px;
  align-self: flex-start;
}
.griot-chip {
  background: rgba(212,160,23,.12);
  border: 1px solid rgba(212,160,23,.4);
  color: var(--g-mahog);
  border-radius: 999px;
  padding: 6px 13px;
  font-family: var(--font-ui, sans-serif);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
  white-space: nowrap;
}
.griot-chip:hover {
  background: rgba(196,98,45,.14);
  border-color: var(--g-earth);
  transform: translateY(-1px);
}

/* ── Mini card plat embarquée dans la réponse ─────────── */
.griot-plat-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--g-border);
  border-radius: 10px;
  padding: 9px 11px;
  margin: 6px 0;
  box-shadow: 0 2px 8px rgba(26,18,8,.06);
}
.griot-plat-card img {
  width: 48px; height: 48px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
}
.griot-plat-card__info {
  flex: 1;
  min-width: 0;
}
.griot-plat-card__info strong {
  display: block;
  font-family: var(--font-display, serif);
  font-size: .9rem;
  color: var(--g-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.griot-plat-card__info span {
  font-size: .78rem;
  color: var(--g-earth);
  font-weight: 700;
}
.griot-plat-card__btn {
  background: var(--g-earth);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 6px 13px;
  font-family: var(--font-ui, sans-serif);
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
  flex-shrink: 0;
}
.griot-plat-card__btn:hover { background: var(--g-mahog); }

/* ── Formulaire de saisie ─────────────────────────────── */
.griot-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--g-border);
  background: var(--g-sand);
  flex-shrink: 0;
}
.griot-input {
  flex: 1;
  border: 1px solid var(--g-border);
  border-radius: 999px;
  padding: 10px 16px;
  font-family: var(--font-ui, sans-serif);
  font-size: .88rem;
  background: #fff;
  color: var(--g-ink);
  outline: none;
  transition: border-color .15s;
}
.griot-input::placeholder { color: var(--g-stone); }
.griot-input:focus { border-color: var(--g-earth); }

.griot-send {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--g-earth);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.griot-send:hover { background: var(--g-mahog); transform: scale(1.06); }
.griot-send:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ── Typing indicator ─────────────────────────────────── */
.griot-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 11px 15px;
}
.griot-typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--g-stone);
  animation: griot-dot .9s ease-in-out infinite;
}
.griot-typing span:nth-child(2) { animation-delay: .18s; }
.griot-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes griot-dot {
  0%, 80%, 100% { transform: scale(.7); opacity: .4; }
  40%           { transform: scale(1);  opacity: 1; }
}

/* ── Responsive mobile ────────────────────────────────── */
@media (max-width: 480px) {
  .griot-panel {
    right: 0; left: 0;
    bottom: 0;
    width: 100%;
    max-height: 75vh;
    border-radius: 20px 20px 0 0;
  }
  .griot-fab { right: 16px; bottom: 150px; }
}

/* ── Prefers reduced motion ───────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .griot-fab__icon { animation: none; }
  .griot-panel { transition: opacity .15s; }
  .griot-msg    { animation: none; }
}
