/* ============================================================
   ZENOCCAZ — CHATBOX WIDGET PREMIUM v4.0
   Design glassmorphism · cyberpunk automotive · ultra class
   ============================================================ */

/* ── Keyframes ── */
@keyframes zc-open {
  from { opacity:0; transform:translateY(24px) scale(0.95); }
  to   { opacity:1; transform:translateY(0) scale(1); }
}
@keyframes zc-close {
  from { opacity:1; transform:translateY(0) scale(1); }
  to   { opacity:0; transform:translateY(24px) scale(0.95); pointer-events:none; }
}
@keyframes zc-btn-in {
  from { opacity:0; transform:scale(0.5) rotate(-30deg); }
  to   { opacity:1; transform:scale(1) rotate(0deg); }
}
@keyframes zc-pulse-ring {
  0%   { transform:scale(1); opacity:.7; }
  100% { transform:scale(1.9); opacity:0; }
}
@keyframes zc-shimmer {
  0%   { background-position:-200% center; }
  100% { background-position:200% center; }
}
@keyframes zc-dot {
  0%,100% { transform:scale(1); opacity:1; }
  50%      { transform:scale(0.5); opacity:.4; }
}
@keyframes zc-msg-in-bot {
  from { opacity:0; transform:translateX(-14px) scale(0.96); }
  to   { opacity:1; transform:translateX(0) scale(1); }
}
@keyframes zc-msg-in-user {
  from { opacity:0; transform:translateX(14px) scale(0.96); }
  to   { opacity:1; transform:translateX(0) scale(1); }
}
@keyframes zc-scan {
  0%   { transform:translateY(-100%); }
  100% { transform:translateY(500%); }
}
@keyframes zc-glow-pulse {
  0%,100% { box-shadow: 0 0 20px rgba(16,185,129,0.3), 0 0 60px rgba(16,185,129,0.1); }
  50%      { box-shadow: 0 0 40px rgba(16,185,129,0.5), 0 0 80px rgba(16,185,129,0.2); }
}
@keyframes zc-typing {
  0%,80%,100% { transform:scale(0.8); opacity:.4; }
  40%          { transform:scale(1.1); opacity:1; }
}

/* ══════════════════════════════════════════
   BOUTON TOGGLE (bulle flottante)
══════════════════════════════════════════ */
#chat-toggle-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  z-index: 9998;
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow:
    0 8px 32px rgba(16,185,129,0.45),
    0 2px 8px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.2);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), box-shadow .3s;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: zc-btn-in .5s cubic-bezier(.34,1.56,.64,1) both;
  overflow: visible;
}

/* Scanline sur le bouton */
#chat-toggle-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.18) 0%, transparent 60%);
  pointer-events: none;
}

/* Double anneau pulsant */
#chat-toggle-btn::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(16,185,129,0.5);
  animation: zc-pulse-ring 2.4s ease-out infinite;
  pointer-events: none;
}

#chat-toggle-btn:hover {
  transform: scale(1.12) translateY(-3px);
  box-shadow:
    0 16px 48px rgba(16,185,129,0.6),
    0 4px 12px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.25);
}

#chat-toggle-btn svg {
  width: 28px;
  height: 28px;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* Badge "..." quand fermé */
#chat-widget.closed #chat-toggle-btn .zc-notif {
  display: flex;
}

.zc-notif {
  position: absolute;
  top: -4px; right: -4px;
  width: 22px; height: 22px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  border: 2px solid #0a0e1a;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  align-items: center;
  justify-content: center;
  display: none;
}

/* ══════════════════════════════════════════
   WIDGET CONTENEUR
══════════════════════════════════════════ */
#chat-widget {
  position: fixed;
  bottom: 104px;
  right: 28px;
  z-index: 9999;
  width: 380px;
  font-family: 'Inter', -apple-system, sans-serif;
}

/* État fermé */
#chat-widget.closed #chat-box {
  display: none;
}

/* ══════════════════════════════════════════
   CHAT BOX — conteneur principal
══════════════════════════════════════════ */
#chat-box {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 540px;
  background: linear-gradient(160deg, rgba(10,14,26,0.97) 0%, rgba(8,11,20,0.99) 100%);
  backdrop-filter: blur(32px) saturate(180%);
  border: 1px solid rgba(16,185,129,0.22);
  border-radius: 24px;
  overflow: hidden;
  box-shadow:
    0 32px 80px rgba(0,0,0,0.7),
    0 0 0 1px rgba(255,255,255,0.04),
    0 0 60px rgba(16,185,129,0.08);
  animation: zc-open .35s cubic-bezier(.4,0,.2,1) both;
  animation: zc-glow-pulse 4s ease-in-out infinite;
  position: relative;
}

/* Ligne dégradée en haut */
#chat-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    #10b981 25%,
    #3b82f6 50%,
    #a855f7 75%,
    transparent 100%
  );
  background-size: 200% auto;
  animation: zc-shimmer 4s linear infinite;
  z-index: 10;
}

/* Scanline déco en fond */
#chat-box::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 60px;
  background: linear-gradient(180deg, rgba(16,185,129,0.04) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

/* ══════════════════════════════════════════
   HEADER
══════════════════════════════════════════ */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  background: linear-gradient(90deg, rgba(16,185,129,0.07) 0%, rgba(59,130,246,0.04) 100%);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Avatar IA dans le header */
.zc-avatar {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(16,185,129,0.25), rgba(59,130,246,0.18));
  border: 1px solid rgba(16,185,129,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(16,185,129,0.25);
}

.zc-avatar svg {
  width: 22px; height: 22px;
  position: relative; z-index: 1;
}

/* Scanline sur l'avatar */
.zc-avatar::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 40%;
  background: linear-gradient(180deg, rgba(16,185,129,0.2) 0%, transparent 100%);
  animation: zc-scan 2s ease-in-out infinite;
}

.chat-header-info { flex: 1; }

.chat-header-info h3 {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 2px;
  background: linear-gradient(135deg, #fff, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -.2px;
}

.zc-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #94a3b8;
}

.zc-status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: zc-dot 1.8s ease-in-out infinite;
}

#chat-client-name {
  font-size: 11px !important;
  color: #f97316 !important;
  font-weight: 600 !important;
  margin: 1px 0 0 !important;
  display: none;
}

/* Groupe de boutons (resize + close) */
#chat-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Bouton fermer / resize */
#chat-close-btn,
#chat-resize-btn {
  width: 34px !important;
  height: 34px !important;
  border-radius: 10px !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  background: rgba(255,255,255,0.06) !important;
  color: #94a3b8 !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 14px !important;
  transition: all .2s !important;
  backdrop-filter: blur(6px) !important;
  font-family: inherit !important;
  padding: 0 !important;
}

#chat-close-btn:hover {
  background: rgba(239,68,68,0.15) !important;
  border-color: rgba(239,68,68,0.35) !important;
  color: #ef4444 !important;
  transform: rotate(90deg) scale(1.08) !important;
}

#chat-resize-btn:hover {
  background: rgba(59,130,246,0.15) !important;
  border-color: rgba(59,130,246,0.35) !important;
  color: #3b82f6 !important;
  transform: scale(1.08) !important;
}

/* ══════════════════════════════════════════
   ZONE MESSAGES
══════════════════════════════════════════ */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  position: relative;
  z-index: 1;
}

#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb {
  background: rgba(16,185,129,0.35);
  border-radius: 4px;
}

/* ── Messages ── */
.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  gap: 6px;
}

.chat-message.bot {
  align-self: flex-start;
  align-items: flex-start;
  animation: zc-msg-in-bot .3s cubic-bezier(.4,0,.2,1) both;
}

.chat-message.user {
  align-self: flex-end;
  align-items: flex-end;
  animation: zc-msg-in-user .3s cubic-bezier(.4,0,.2,1) both;
}

/* Bulle bot */
.chat-message.bot .chat-bubble {
  background: linear-gradient(135deg, rgba(16,185,129,0.1), rgba(59,130,246,0.07));
  border: 1px solid rgba(16,185,129,0.2);
  color: #e2e8f0;
  border-radius: 4px 18px 18px 18px;
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.65;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2), inset 0 1px 0 rgba(16,185,129,0.08);
  position: relative;
}

/* Bulle user */
.chat-message.user .chat-bubble {
  background: linear-gradient(135deg, #10b981, #059669);
  border: 1px solid rgba(16,185,129,0.4);
  color: #fff;
  border-radius: 18px 4px 18px 18px;
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.65;
  box-shadow: 0 4px 16px rgba(16,185,129,0.25), inset 0 1px 0 rgba(255,255,255,0.2);
}

/* ── Boutons choix (options) ── */
.chat-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 2px;
}

.chat-option {
  padding: 8px 16px;
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.28);
  border-radius: 20px;
  color: #10b981;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s cubic-bezier(.4,0,.2,1);
  white-space: nowrap;
  font-family: inherit;
  position: relative;
  overflow: hidden;
}

.chat-option::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(16,185,129,0.15), transparent);
  opacity: 0;
  transition: opacity .2s;
}

.chat-option:hover {
  background: rgba(16,185,129,0.18);
  border-color: rgba(16,185,129,0.55);
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 18px rgba(16,185,129,0.25);
  color: #fff;
}

.chat-option:hover::before { opacity: 1; }

.chat-option:active { transform: scale(.97); }

/* ══════════════════════════════════════════
   ZONE DE SAISIE
══════════════════════════════════════════ */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 14px 16px 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
  background: rgba(5,8,18,0.6);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

#chat-input {
  flex: 1;
  min-height: 40px;
  max-height: 100px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  color: #e2e8f0;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  line-height: 1.5;
  transition: border-color .2s, background .2s, box-shadow .2s;
  scrollbar-width: none;
}

#chat-input::-webkit-scrollbar { display: none; }

#chat-input::placeholder { color: #4b5563; }

#chat-input:focus {
  outline: none;
  border-color: rgba(16,185,129,0.5);
  background: rgba(16,185,129,0.04);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.1);
}

#chat-input:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* Bouton photo (injecté par JS) */
#chat-photo-btn {
  width: 40px !important;
  height: 40px !important;
  border-radius: 12px !important;
  background: rgba(42,157,143,0.15) !important;
  border: 1px solid rgba(42,157,143,0.3) !important;
  color: #2a9d8f !important;
  font-size: 17px !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all .2s !important;
  flex-shrink: 0 !important;
  margin-right: 0 !important;
}

#chat-photo-btn:hover {
  background: rgba(42,157,143,0.28) !important;
  border-color: rgba(42,157,143,0.55) !important;
  transform: translateY(-2px) scale(1.06) !important;
  box-shadow: 0 6px 18px rgba(42,157,143,0.25) !important;
}

/* Bouton envoi */
#chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #10b981, #059669);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .2s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 4px 14px rgba(16,185,129,0.35);
  font-size: 16px;
  font-family: inherit;
  padding: 0;
}

#chat-send-btn:hover {
  transform: translateY(-2px) scale(1.08);
  box-shadow: 0 8px 24px rgba(16,185,129,0.5);
}

#chat-send-btn:active { transform: scale(.95); }

#chat-send-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#chat-send-btn svg {
  width: 18px; height: 18px;
}

/* ══════════════════════════════════════════
   MODE FULLSCREEN
══════════════════════════════════════════ */
#chat-widget.ai-fullscreen {
  bottom: 20px;
  right: 20px;
  width: min(560px, calc(100vw - 40px));
}

#chat-widget.ai-fullscreen #chat-box {
  height: min(75vh, 700px);
  border-radius: 20px;
}

#chat-widget.ai-fullscreen-total {
  bottom: 0;
  right: 0;
  width: 100vw;
}

#chat-widget.ai-fullscreen-total #chat-box {
  height: 100vh;
  border-radius: 0;
}

/* ══════════════════════════════════════════
   INDICATEUR DE FRAPPE (typing)
══════════════════════════════════════════ */
.zc-typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.18);
  border-radius: 4px 18px 18px 18px;
  width: fit-content;
}

.zc-typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #10b981;
}

.zc-typing-dot:nth-child(1) { animation: zc-typing 1.4s ease-in-out infinite; }
.zc-typing-dot:nth-child(2) { animation: zc-typing 1.4s ease-in-out .2s infinite; }
.zc-typing-dot:nth-child(3) { animation: zc-typing 1.4s ease-in-out .4s infinite; }

/* ══════════════════════════════════════════
   MARKDOWN dans les bulles
══════════════════════════════════════════ */
.chat-bubble strong { color: #86efac; font-weight: 700; }
.chat-bubble em { color: #93c5fd; font-style: italic; }
.chat-bubble ul { margin: 8px 0; padding-left: 16px; }
.chat-bubble li { margin: 4px 0; color: #cbd5e1; }
.chat-bubble h3 { color: #86efac !important; }
.chat-bubble h4 { color: #93c5fd !important; }
.chat-bubble hr { border-color: rgba(255,255,255,0.1) !important; }
.chat-bubble span[style*="#10b981"] { font-weight: 700; }

/* ══════════════════════════════════════════
   RESPONSIVE MOBILE
══════════════════════════════════════════ */
@media (max-width: 480px) {
  #chat-widget {
    bottom: 90px;
    right: 12px;
    left: 12px;
    width: auto;
  }

  #chat-box {
    height: 72vh;
    border-radius: 20px;
  }

  #chat-toggle-btn {
    bottom: 20px;
    right: 16px;
    width: 56px;
    height: 56px;
  }

  #chat-widget.ai-fullscreen,
  #chat-widget.ai-fullscreen-total {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
  }

  #chat-widget.ai-fullscreen #chat-box,
  #chat-widget.ai-fullscreen-total #chat-box {
    height: 100vh;
    border-radius: 0;
  }
}