/**
 * Spook – Widget CSS v2.1
 * À placer dans : /wp-content/themes/TON-THEME/spook/spook-widget.css
 */

/* ----------------------------------------------------------------
   VARIABLES
---------------------------------------------------------------- */
:root {
  --spook-blue:       #1B6FFF;
  --spook-blue-deep:  #0A3EBF;
  --spook-blue-glow:  rgba(27, 111, 255, 0.15);
  --spook-blue-soft:  #e8f0ff;
  --spook-bg:         #f4f6fb;
  --spook-surface:    #ffffff;
  --spook-surface2:   #f0f3fa;
  --spook-text:       #141824;
  --spook-muted:      #6b7492;
  --spook-border:     #e2e6f0;
  --spook-radius:     18px;
  --spook-shadow:     0 4px 32px rgba(27,111,255,0.12), 0 1px 4px rgba(0,0,0,0.06);
  --spook-shadow-lg:  0 12px 64px rgba(27,111,255,0.2), 0 2px 8px rgba(0,0,0,0.1);
}

/* ----------------------------------------------------------------
   RESET PARTIEL
---------------------------------------------------------------- */
.spook-fab, .spook-panel, .spook-inline-wrap,
.spook-msg, .spook-bubble, .spook-chip,
.spook-product-card, .spook-send-btn {
  box-sizing: border-box;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ----------------------------------------------------------------
   FAB
---------------------------------------------------------------- */
.spook-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9998;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--spook-blue-deep), var(--spook-blue));
  box-shadow: var(--spook-shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
  user-select: none;
}
.spook-fab:hover { transform: scale(1.07); }
.spook-fab--hidden { opacity: 0; pointer-events: none; transform: scale(0.8); }

.spook-fab-badge {
  position: absolute;
  top: -5px; right: -5px;
  background: #ff4757;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  animation: spook-pulse 2s infinite;
}
@keyframes spook-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.15); }
}

/* ----------------------------------------------------------------
   PANEL FLOTTANT
---------------------------------------------------------------- */
.spook-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9999;
  width: 380px;
  max-height: 680px;
  background: var(--spook-surface);
  border-radius: 24px;
  box-shadow: var(--spook-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.spook-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

@media (max-width: 460px) {
  .spook-panel {
    right: 0;
    bottom: 0;
    left: 0;
    top: 0;
    width: 100vw;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }
  .spook-fab {
    bottom: 16px;
    right: 16px;
  }
}

/* ----------------------------------------------------------------
   HEADER
---------------------------------------------------------------- */
.spook-panel-header,
.spook-inline-header {
  background: linear-gradient(135deg, var(--spook-blue-deep), var(--spook-blue));
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.spook-panel-header::after,
.spook-inline-header::after {
  content: '';
  position: absolute;
  right: -20px; top: -20px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  pointer-events: none;
}

.spook-panel-avatar {
  width: 50px; height: 50px;
  border-radius: 12px;
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  position: relative;
}
.spook-online-dot {
  position: absolute;
  bottom: -2px; right: -2px;
  width: 10px; height: 10px;
  background: #22d67a;
  border-radius: 50%;
  border: 2px solid var(--spook-blue-deep);
}
.spook-inline-icon {
  font-size: 24px;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.15);
  border-radius: 12px;
  flex-shrink: 0;
}
.spook-panel-header strong,
.spook-inline-header strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: #fff;
}
.spook-panel-sub,
.spook-inline-sub {
  display: block;
  font-size: 11px;
  color: rgba(255,255,255,0.65);
  margin-top: 1px;
}
.spook-close-btn {
  margin-left: auto;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 28px; height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
  position: relative; z-index: 1;
}
.spook-close-btn:hover { background: rgba(255,255,255,0.25); }

/* ----------------------------------------------------------------
   FENÊTRE DE CHAT
---------------------------------------------------------------- */
.spook-chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  min-height: 220px;
  max-height: 400px;
}
.spook-inline-wrap .spook-chat-window {
  min-height: 260px;
  max-height: 420px;
}
.spook-chat-window::-webkit-scrollbar { width: 3px; }
.spook-chat-window::-webkit-scrollbar-thumb { background: var(--spook-border); border-radius: 3px; }

/* ----------------------------------------------------------------
   MESSAGES
---------------------------------------------------------------- */
.spook-msg {
  display: flex;
  gap: 7px;
  align-items: flex-end;
  animation: spook-fadeup 0.22s ease both;
}
@keyframes spook-fadeup {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.spook-msg--user { flex-direction: row-reverse; }

.spook-msg-av {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-bottom: 2px;
}
.spook-msg--user .spook-msg-av {
  background: var(--spook-surface2);
  border: 1.5px solid var(--spook-border);
}
.spook-msg-inner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 82%;
}
.spook-msg--user .spook-msg-inner { align-items: flex-end; }

.spook-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--spook-text);
  background: var(--spook-surface2);
  border: 1px solid var(--spook-border);
  border-bottom-left-radius: 3px;
  white-space: pre-wrap;
  word-break: break-word;
}
.spook-bubble ul {
  margin: 4px 0 4px 16px;
  padding: 0;
}
.spook-bubble li {
  margin-bottom: 2px;
}
.spook-msg--user .spook-bubble {
  background: linear-gradient(135deg, var(--spook-blue-deep), var(--spook-blue));
  color: #fff;
  border: none;
  border-bottom-right-radius: 3px;
  border-bottom-left-radius: 14px;
}

/* ----------------------------------------------------------------
   SKELETON / LOADING STATE
---------------------------------------------------------------- */
.spook-loading-state {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--spook-surface2);
  border: 1px solid var(--spook-border);
  border-radius: 14px;
  border-bottom-left-radius: 3px;
  animation: spook-fadeup 0.22s ease both;
}
.spook-loading-text {
  font-size: 13px;
  color: var(--spook-muted);
  font-style: italic;
  white-space: nowrap;
}

/* ----------------------------------------------------------------
   PRODUCT CARDS
---------------------------------------------------------------- */
.spook-product-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--spook-surface);
  border: 1.5px solid var(--spook-border);
  border-radius: 12px;
  padding: 10px 12px;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.12s;
}
.spook-product-card:hover {
  border-color: var(--spook-blue);
  box-shadow: 0 2px 14px var(--spook-blue-glow);
  transform: translateY(-1px);
}
.spook-product-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--spook-blue-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.spook-product-info { flex: 1; min-width: 0; }
.spook-product-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--spook-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.spook-product-price {
  font-size: 12px;
  color: var(--spook-blue);
  font-weight: 500;
  margin-top: 2px;
}
.spook-product-arrow { font-size: 15px; color: var(--spook-muted); }

/* ----------------------------------------------------------------
   CHIPS
---------------------------------------------------------------- */
.spook-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.spook-chip {
  background: var(--spook-surface);
  border: 1.5px solid var(--spook-blue);
  color: var(--spook-blue);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  white-space: nowrap;
  font-family: inherit;
}
.spook-chip:hover {
  background: var(--spook-blue);
  color: #fff;
  transform: translateY(-1px);
}

/* ----------------------------------------------------------------
   TYPING INDICATOR
---------------------------------------------------------------- */
.spook-thinking {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 10px 14px;
  background: var(--spook-surface2);
  border: 1px solid var(--spook-border);
  border-radius: 14px;
  border-bottom-left-radius: 3px;
  width: fit-content;
}
.spook-loading-state .spook-thinking {
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
}
.spook-thinking span {
  width: 6px; height: 6px;
  background: var(--spook-blue);
  border-radius: 50%;
  display: inline-block;
  animation: spook-bounce 1.2s infinite;
  opacity: 0.45;
}
.spook-thinking span:nth-child(2) { animation-delay: 0.2s; }
.spook-thinking span:nth-child(3) { animation-delay: 0.4s; }
@keyframes spook-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%            { transform: translateY(-5px); opacity: 1; }
}

/* ----------------------------------------------------------------
   INPUT
---------------------------------------------------------------- */
.spook-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px 14px;
  border-top: 1px solid var(--spook-border);
  background: var(--spook-surface);
  flex-shrink: 0;
}
.spook-textarea {
  flex: 1;
  border: 1.5px solid var(--spook-border);
  border-radius: 12px;
  background: var(--spook-surface2);
  font-family: inherit;
  font-size: 13.5px;
  color: var(--spook-text);
  padding: 9px 12px;
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 90px;
  min-height: 38px;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.spook-textarea:focus {
  border-color: var(--spook-blue);
  box-shadow: 0 0 0 3px var(--spook-blue-glow);
}
.spook-textarea::placeholder { color: var(--spook-muted); }

.spook-send-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--spook-blue-deep), var(--spook-blue));
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 15px;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
}
.spook-send-btn:hover  { transform: scale(1.07); }
.spook-send-btn:disabled { opacity: 0.4; cursor: default; transform: none; }

/* ----------------------------------------------------------------
   INLINE WRAP
---------------------------------------------------------------- */
.spook-inline-wrap {
  background: var(--spook-surface);
  border-radius: 20px;
  box-shadow: var(--spook-shadow);
  overflow: hidden;
  border: 1px solid var(--spook-border);
  margin: 24px 0;
}
