/* ══════════════════════════════════════════
   WINEIA CHAT WIDGET — PREMIUM DESIGN
   ══════════════════════════════════════════ */

#wineia-window,
#wineia-launcher,
#wineia-popup,
#wineia-typing {
  --wc-dark:     #1A0A0E;
  --wc-mid:      #2D1117;
  --wc-bordeaux: #722F37;
  --wc-deep:     #4A0E1A;
  --wc-gold:     #C9A84C;
  --wc-cream:    #FAF7F2;
  --wc-text-dark: #1A0A0E;
  --wc-text-light: #FAF7F2;
}

/* ── LAUNCHER ── */
#wineia-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: white !important;
  box-shadow: 0 4px 24px rgba(114,47,55,0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: transform 0.2s, box-shadow 0.2s;
  animation: wineia-bounce 0.6s ease;
}
#wineia-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 32px rgba(114,47,55,0.7);
}
#wineia-launcher img {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  min-height: 32px !important;
  max-width: 32px !important;
  max-height: 32px !important;
  object-fit: contain !important;
  background: transparent !important;
  padding: 2px !important;
  display: block;
}
#wineia-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--wc-gold);
  color: var(--wc-dark);
  font-size: 11px;
  font-weight: bold;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: wineia-pulse 1.5s infinite;
}

/* ── POPUP D'ACCUEIL ── */
#wineia-popup {
  position: fixed;
  bottom: 96px;
  right: 24px;
  background: var(--wc-cream);
  border: 1.5px solid var(--wc-gold);
  border-radius: 16px 16px 4px 16px;
  padding: 12px 16px;
  max-width: 240px;
  font-size: 14px;
  color: var(--wc-text-dark);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  z-index: 9998;
  display: none;
  align-items: center;
  gap: 8px;
  animation: wineia-popin 0.3s ease;
  font-family: system-ui, -apple-system, sans-serif;
}
#wineia-popup-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--wc-bordeaux);
  font-size: 14px;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
}

/* ── FENÊTRE PRINCIPALE ── */
#wineia-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  height: 560px;
  background: linear-gradient(160deg, var(--wc-dark) 0%, var(--wc-mid) 100%);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4), 0 0 0 1px rgba(201,168,76,0.12);
  display: none;
  flex-direction: column;
  z-index: 9997;
  overflow: hidden;
  animation: wineia-slidein 0.3s ease;
  font-family: system-ui, -apple-system, sans-serif;
}
#wineia-window.open {
  display: flex;
}

/* ── HEADER ── */
#wineia-header {
  background: var(--wc-deep);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(201,168,76,0.2);
  flex-shrink: 0;
}
#wineia-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
#wineia-avatar {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  min-height: 36px !important;
  max-width: 36px !important;
  max-height: 36px !important;
  object-fit: contain !important;
  background: white !important;
  padding: 4px !important;
  border-radius: 50% !important;
  border: 2px solid var(--wc-gold) !important;
  box-shadow: 0 0 0 1.5px var(--wc-gold) !important;
  display: block;
  flex-shrink: 0;
}
#wineia-header-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
#wineia-header-name {
  color: white;
  font-weight: 600;
  font-size: 15px;
  display: block;
  line-height: 1.2;
}
#wineia-header-sub {
  color: var(--wc-gold);
  font-size: 12px;
  display: block;
  line-height: 1.2;
}
#wineia-online-dot {
  width: 8px;
  height: 8px;
  background: #4CAF50;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(76,175,80,0.6);
  animation: wineia-online 2s infinite;
  flex-shrink: 0;
}
#wineia-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.55);
  font-size: 18px;
  cursor: pointer;
  transition: color 0.2s, transform 0.15s;
  padding: 0;
  line-height: 1;
}
#wineia-close:hover {
  color: white;
  transform: scale(1.15);
}

/* ── ZONE DE MESSAGES ── */
#wineia-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
#wineia-messages::-webkit-scrollbar { width: 4px; }
#wineia-messages::-webkit-scrollbar-track { background: transparent; }
#wineia-messages::-webkit-scrollbar-thumb {
  background: rgba(201,168,76,0.3);
  border-radius: 4px;
}

.wineia-separator {
  text-align: center;
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  margin: 4px 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── BULLES ── */
.wineia-msg {
  display: flex;
  align-items: flex-end !important;
  gap: 8px !important;
}
.wineia-msg-bot  { flex-direction: row; }
.wineia-msg-user {
  flex-direction: row !important;
  justify-content: flex-end !important;
  align-items: flex-end !important;
}

.wineia-msg-avatar {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  max-width: 28px !important;
  max-height: 28px !important;
  object-fit: contain !important;
  background: white !important;
  padding: 4px !important;
  border-radius: 50% !important;
  box-shadow: 0 0 0 1.5px var(--wc-gold) !important;
  flex-shrink: 0 !important;
  display: block;
}
#wineia-typing .wineia-msg-avatar {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  max-width: 28px !important;
  background: white !important;
  padding: 4px !important;
  border-radius: 50% !important;
  box-shadow: 0 0 0 1.5px var(--wc-gold) !important;
  flex-shrink: 0 !important;
}
.wineia-msg-avatar,
#wineia-avatar,
#wineia-launcher img {
  image-rendering: auto;
}
img[src$=".svg"] {
  width: 100%;
  height: 100%;
}
.wineia-user-avatar {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  border-radius: 50% !important;
  background: var(--wc-bordeaux) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: white !important;
  font-size: 13px !important;
  flex-shrink: 0 !important;
  order: 2 !important;
}
.wineia-msg-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0 !important;
  max-width: calc(100% - 44px) !important;
}
.wineia-msg-bot .wineia-msg-content  { align-items: flex-start; }
.wineia-msg-user .wineia-msg-content {
  order: 1 !important;
  align-items: flex-end !important;
}

.wineia-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
  max-width: 100% !important;
}
.wineia-msg-bot .wineia-msg-bubble {
  background: var(--wc-cream);
  color: var(--wc-text-dark);
  border-bottom-left-radius: 4px;
}
.wineia-msg-user .wineia-msg-bubble {
  background: var(--wc-bordeaux);
  color: white;
  border-bottom-right-radius: 4px;
}
.wineia-msg-time {
  font-size: 10px;
  color: rgba(255,255,255,0.3);
}

/* ── TYPING INDICATOR ── */
#wineia-typing {
  display: none;
  align-items: flex-end;
  gap: 8px;
  padding: 0 16px 12px;
  flex-shrink: 0;
}
#wineia-typing-bubble {
  background: var(--wc-cream);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
#wineia-typing-bubble div {
  display: flex;
  flex-direction: row;
  gap: 5px;
  align-items: center;
}
#wineia-typing-bubble span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--wc-gold);
  display: inline-block;
  animation: wineia-dots 1.2s infinite;
}
#wineia-typing-bubble span:nth-child(1) { animation-delay: 0s; }
#wineia-typing-bubble span:nth-child(2) { animation-delay: 0.2s; }
#wineia-typing-bubble span:nth-child(3) { animation-delay: 0.4s; }
#wineia-typing-bubble p {
  margin: 0;
  font-size: 11px;
  color: rgba(0,0,0,0.4);
  font-style: italic;
}

/* ── ZONE DE SAISIE ── */
#wineia-input-area {
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.2);
  flex-shrink: 0;
  align-items: center;
}
#wineia-input {
  flex: 1;
  background: white;
  border: 1.5px solid rgba(114,47,55,0.3);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--wc-text-dark);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: system-ui, -apple-system, sans-serif;
}
#wineia-input::placeholder { color: #a08880; }
#wineia-input:focus {
  border-color: var(--wc-gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.15);
}
#wineia-send {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  background: var(--wc-bordeaux);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 3px 12px rgba(114,47,55,0.42);
}
#wineia-send:hover {
  background: var(--wc-deep);
  transform: scale(1.06);
  box-shadow: 0 5px 18px rgba(74,14,26,0.55);
}
#wineia-send:active { transform: scale(0.94); }

/* ── ANIMATIONS ── */
@keyframes wineia-bounce {
  0%   { transform: scale(0); opacity: 0; }
  70%  { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes wineia-pulse {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.2); }
}
@keyframes wineia-popin {
  from { transform: scale(0.8) translateY(8px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);   opacity: 1; }
}
@keyframes wineia-slidein {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes wineia-dots {
  0%,60%,100% { transform: translateY(0); }
  30%         { transform: translateY(-6px); }
}
@keyframes wineia-online {
  0%,100% { opacity: 1;   }
  50%     { opacity: 0.4; }
}

/* ── RESPONSIVE MOBILE ── */
@media (max-width: 480px) {
  #wineia-window {
    width: calc(100vw - 32px) !important;
    height: 70vh !important;
    max-height: 500px !important;
    bottom: 80px !important;
    right: 16px !important;
    left: 16px !important;
    border-radius: 16px !important;
  }
  #wineia-launcher {
    bottom: 16px !important;
    right: 16px !important;
  }
  #wineia-popup {
    right: 16px;
    bottom: 88px;
    max-width: calc(100vw - 32px);
  }
}

/* ── FOND BLANC FORCÉ SUR TOUS LES AVATARS SOFIA ── */
.wineia-msg-avatar,
#wineia-avatar,
#wineia-launcher img,
#wineia-typing .wineia-msg-avatar {
  background: white !important;
  padding: 4px !important;
  object-fit: contain !important;
}
