/* ===== Assistant Takacim =====
 * Charte reprise de takacim.com.tn : or #bd9d51, crème #fbf5df, chocolat #31261d,
 * titres Cinzel, textes éditoriaux Cormorant Garamond, signature Great Vibes, texte Poppins.
 */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600&family=Cormorant+Garamond:ital,wght@0,500;1,500&family=Great+Vibes&family=Poppins:wght@400;500;600&display=swap');

#takacim-assistant {
  --ta-gold: #bd9d51;
  --ta-gold-dark: #a47e2d;
  --ta-gold-light: #e7d6b4;
  --ta-choco: #31261d;
  --ta-brown: #4b3a26;
  --ta-cream: #fbf5df;
  --ta-ivory: #fffdf6;
  --ta-line: #eadcb8;
  --ta-shadow: 0 18px 50px rgba(49, 38, 29, 0.28);
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1050;
  color: var(--ta-brown);
  font-family: 'Poppins', -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

#takacim-assistant *,
#takacim-assistant *::before,
#takacim-assistant *::after {
  box-sizing: border-box;
}

/* --- Monogramme (rappel du logo) --- */
.ta-monogram {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding-top: 4px;
  border: 1px solid var(--ta-gold);
  border-radius: 50%;
  background: var(--ta-cream);
  color: var(--ta-gold-dark);
  font-family: 'Great Vibes', 'Brush Script MT', cursive;
  font-size: 1.75rem;
  line-height: 1;
  box-shadow: inset 0 0 0 3px var(--ta-cream), inset 0 0 0 4px rgba(189, 157, 81, 0.45);
}

/* --- Bouton flottant --- */
.ta-launcher {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 1.4rem 0.45rem 0.45rem;
  border: 1px solid var(--ta-gold);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--ta-brown), var(--ta-choco));
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  box-shadow: var(--ta-shadow);
  cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s;
}

.ta-launcher::before {
  content: "";
  position: absolute;
  inset: -1px;
  border: 1px solid var(--ta-gold);
  border-radius: inherit;
  animation: ta-ring 2.8s ease-out infinite;
  pointer-events: none;
}

.ta-launcher:hover {
  transform: translateY(-3px);
  box-shadow: 0 22px 55px rgba(49, 38, 29, 0.35);
}

.ta-launcher:focus-visible,
.ta-close:focus-visible,
.ta-foot button:focus-visible {
  outline: 2px solid var(--ta-gold);
  outline-offset: 3px;
}

.ta-launcher-text small {
  display: block;
  color: var(--ta-gold-light);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.85rem;
  font-style: italic;
  font-weight: 500;
  line-height: 1.1;
}

#takacim-assistant.is-open .ta-launcher {
  display: none;
}

@keyframes ta-ring {
  0% { opacity: 0.8; transform: scale(1); }
  70%, 100% { opacity: 0; transform: scale(1.12, 1.35); }
}

/* --- Fenêtre --- */
.ta-panel {
  display: flex;
  flex-direction: column;
  width: 390px;
  max-width: calc(100vw - 48px);
  height: 620px;
  max-height: calc(100vh - 48px);
  overflow: hidden;
  background: var(--ta-ivory);
  border: 1px solid var(--ta-line);
  border-radius: 18px;
  box-shadow: var(--ta-shadow);
  transform-origin: bottom right;
  animation: ta-open 0.3s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.ta-panel[hidden] {
  display: none;
}

@keyframes ta-open {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
}

.ta-head {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1rem 1.1rem;
  background: linear-gradient(135deg, var(--ta-brown), var(--ta-choco));
  color: #fff;
}

.ta-head-text {
  flex: 1;
  min-width: 0;
}

/* Clé de sol du logo Takacim, dans un médaillon crème pour ressortir sur le fond chocolat */
.ta-monogram--clef {
  width: 46px;
  height: 46px;
  padding: 0;
  border-width: 2px;
}

.ta-monogram--clef img {
  display: block;
  width: 18px;
  height: auto;
}

/* Nom écrit comme le logo : grand T + petites capitales (les minuscules de Cinzel) */
.ta-wordmark {
  display: inline-block;
  color: var(--ta-gold);
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
  text-transform: none;
}

.ta-head small {
  display: block;
  color: var(--ta-gold-light);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.95rem;
  font-style: italic;
}

.ta-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(189, 157, 81, 0.45);
  border-radius: 50%;
  background: transparent;
  color: var(--ta-gold-light);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.ta-close:hover {
  background: var(--ta-gold);
  color: var(--ta-choco);
}

/* Filet doré avec losange, comme les séparateurs du site */
.ta-ornament {
  position: relative;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--ta-gold) 20%, var(--ta-gold) 80%, transparent);
}

.ta-ornament span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 9px;
  height: 9px;
  border: 1px solid var(--ta-gold);
  background: var(--ta-ivory);
  transform: translate(-50%, -50%) rotate(45deg);
}

/* --- Conversation --- */
.ta-messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.7rem;
  overflow-y: auto;
  padding: 1.3rem 1.1rem 1rem;
  background:
    radial-gradient(circle at 100% 0, rgba(189, 157, 81, 0.08), transparent 45%),
    var(--ta-ivory);
  scrollbar-color: var(--ta-gold-light) transparent;
  scrollbar-width: thin;
}

.ta-msg {
  max-width: 85%;
  padding: 0.7rem 0.95rem;
  border-radius: 16px;
  font-size: 0.87rem;
  line-height: 1.5;
  animation: ta-in 0.25s ease-out;
}

.ta-msg--bot {
  align-self: flex-start;
  background: #fff;
  color: var(--ta-brown);
  border: 1px solid var(--ta-line);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(75, 58, 38, 0.05);
}

.ta-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--ta-gold), var(--ta-gold-dark));
  color: #fff;
  border-bottom-right-radius: 4px;
}

@keyframes ta-in {
  from { opacity: 0; transform: translateY(6px); }
}

/* Points d'attente */
.ta-typing {
  display: flex;
  gap: 5px;
  padding: 0.85rem 1rem;
}

.ta-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ta-gold);
  animation: ta-bounce 1.2s ease-in-out infinite;
}

.ta-typing span:nth-child(2) { animation-delay: 0.15s; }
.ta-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ta-bounce {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* --- Choix --- */
.ta-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  max-height: 40%;
  overflow-y: auto;
  padding: 0 1.1rem 1rem;
  background: var(--ta-ivory);
}

.ta-options:empty {
  display: none;
}

.ta-option,
.ta-more {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--ta-gold);
  border-radius: 999px;
  background: #fff;
  color: var(--ta-brown);
  font: inherit;
  font-size: 0.83rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  animation: ta-in 0.3s ease-out both;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
}

.ta-option:hover,
.ta-option:focus-visible {
  border-color: var(--ta-gold-dark);
  background: var(--ta-gold);
  color: #fff;
  text-decoration: none;
  outline: none;
  transform: translateY(-1px);
}

.ta-more {
  width: 100%;
  justify-content: center;
  border-color: var(--ta-choco);
  background: var(--ta-choco);
  color: var(--ta-gold-light);
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ta-more:hover,
.ta-more:focus-visible {
  background: var(--ta-brown);
  color: var(--ta-gold);
  text-decoration: none;
  outline: none;
}

.ta-count {
  min-width: 1.5em;
  padding: 0.05em 0.45em;
  border-radius: 999px;
  background: var(--ta-cream);
  color: var(--ta-gold-dark);
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
}

.ta-option:hover .ta-count,
.ta-option:focus-visible .ta-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* --- Produits proposés --- */
.ta-products {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  animation: ta-in 0.3s ease-out;
}

.ta-product {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--ta-line);
  border-radius: 12px;
  color: var(--ta-brown);
  text-decoration: none;
  transition: box-shadow 0.25s, transform 0.25s, border-color 0.25s;
}

.ta-product:hover {
  border-color: var(--ta-gold);
  box-shadow: 0 8px 22px rgba(49, 38, 29, 0.14);
  color: var(--ta-brown);
  text-decoration: none;
  transform: translateY(-2px);
}

.ta-product img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: linear-gradient(135deg, #f2e1c7, #d9b58d);
  transition: transform 0.4s;
}

.ta-product:hover img {
  transform: scale(1.04);
}

.ta-product-name {
  position: relative;
  padding: 0.55rem 0.6rem 0;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.35;
}

.ta-product-price {
  margin-top: auto;
  padding: 0.2rem 0.6rem 0.6rem;
  color: var(--ta-gold-dark);
  font-size: 0.8rem;
  font-weight: 600;
}

/* --- Bas de fenêtre --- */
.ta-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.1rem;
  border-top: 1px solid var(--ta-line);
  background: var(--ta-cream);
}

.ta-foot button {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.2rem;
  border: 0;
  background: none;
  color: var(--ta-brown);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s;
}

.ta-foot button:hover:not(:disabled) {
  color: var(--ta-gold-dark);
}

.ta-foot button:disabled {
  opacity: 0.35;
  cursor: default;
}

.ta-signature {
  color: var(--ta-gold);
  font-family: 'Great Vibes', 'Brush Script MT', cursive;
  font-size: 1.15rem;
  line-height: 1;
}

/* --- Mobile : la fenêtre prend tout l'écran --- */
@media (max-width: 575px) {
  #takacim-assistant {
    right: 14px;
    bottom: 14px;
  }

  #takacim-assistant.is-open {
    inset: 0;
  }

  .ta-launcher {
    padding-right: 1.1rem;
    font-size: 0.85rem;
  }

  .ta-panel {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  .ta-signature {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #takacim-assistant *,
  #takacim-assistant *::before {
    animation: none !important;
    transition: none !important;
  }
}
