/* MJ WooChat Widget */
:root {
  --mjwc-primary: #1A1A1A;
  --mjwc-accent: #4CAF50;
  --mjwc-bg: #FAF9F6;
  --mjwc-bubble: #F0EDE8;
  --mjwc-border: #E8E5E0;
}

/* ─── Floating Button ─── */
#mjwc-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--mjwc-primary);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s, box-shadow .2s;
}
#mjwc-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0,0,0,.3);
}
#mjwc-toggle svg { transition: transform .2s; }
#mjwc-toggle.open svg { transform: rotate(45deg); }

/* ─── Chat Window ─── */
#mjwc-window {
  position: fixed;
  bottom: 88px;
  right: 20px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100dvh - 120px);
  border-radius: 16px;
  background: var(--mjwc-bg);
  box-shadow: 0 12px 48px rgba(0,0,0,.18);
  z-index: 99998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #1A1A1A;
}
#mjwc-window.visible {
  display: flex;
  animation: mjwcSlideUp .25s ease;
}
@keyframes mjwcSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile full screen */
@media (max-width: 480px) {
  #mjwc-window {
    bottom: 0; right: 0; left: 0; top: 0;
    width: 100vw; height: 100dvh; max-height: 100dvh;
    border-radius: 0;
    position: fixed;
    z-index: 999999;
  }
  #mjwc-window.visible ~ *,
  body.mjwc-chat-open .mj-fcart,
  body.mjwc-chat-open #mj-floating-cart {
    display: none !important;
  }
  #mjwc-toggle {
    bottom: 16px; right: 16px;
    z-index: 1000000;
  }
}
/* Prevent scroll behind chat on mobile */
@media (max-width: 480px) {
  body.mjwc-chat-open {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
  }
}

/* ─── Header ─── */
.mjwc-header {
  background: var(--mjwc-primary);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.mjwc-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mjwc-header-icon {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #2E7D32, #43A047);
  display: flex; align-items: center; justify-content: center;
}
.mjwc-header-title { font-size: 14px; font-weight: 700; }
.mjwc-header-sub {
  font-size: 10px; color: #8A8A8A;
  display: flex; align-items: center; gap: 4px;
}
.mjwc-header-dot {
  width: 5px; height: 5px; border-radius: 50%;
  display: inline-block;
}
.mjwc-header-right {
  display: flex; gap: 6px; align-items: center;
}
.mjwc-header-right a,
.mjwc-header-right button {
  background: rgba(255,255,255,.08);
  border: none; color: #888;
  border-radius: 8px; padding: 5px 10px;
  font-size: 10px; cursor: pointer;
  font-family: inherit; font-weight: 600;
  text-decoration: none;
}
.mjwc-header-right a { color: var(--mjwc-accent); }

/* ─── Messages ─── */
.mjwc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Welcome screen */
.mjwc-welcome {
  flex: 1; display: flex; flex-direction: column;
  justify-content: center; align-items: center; padding: 16px;
}
.mjwc-welcome-icon {
  width: 50px; height: 50px; border-radius: 14px;
  background: linear-gradient(135deg, #1A1A1A, #333);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
}
.mjwc-welcome h3 { font-size: 17px; font-weight: 800; letter-spacing: -.03em; margin: 0; }
.mjwc-welcome-role {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 20px; font-size: 10px; font-weight: 600; margin-top: 5px;
}
.mjwc-welcome-desc { font-size: 12px; color: #888; margin-top: 6px; text-align: center; line-height: 1.4; }
.mjwc-tips-label {
  font-size: 9px; font-weight: 700; color: #BBB;
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; margin-top: 14px;
  width: 100%; text-align: left;
}
.mjwc-tips { display: flex; flex-wrap: wrap; gap: 5px; width: 100%; }
.mjwc-tips button {
  padding: 6px 12px; border-radius: 18px; border: 1px solid #D4CFC7;
  background: transparent; font-size: 11px; font-weight: 500; cursor: pointer;
  font-family: inherit; color: #555; white-space: nowrap;
}

/* Message row */
.mjwc-msg-row {
  display: flex; gap: 6px; padding: 3px 0;
  align-items: flex-end;
  animation: mjwcFadeUp .2s ease;
}
@keyframes mjwcFadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.mjwc-msg-row.user { justify-content: flex-end; }
.mjwc-msg-row.assistant { justify-content: flex-start; }
.mjwc-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--mjwc-primary); display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.mjwc-msg-wrap { max-width: 82%; }
.mjwc-msg-bubble {
  padding: 10px 14px; font-size: 13px; line-height: 1.55; font-weight: 450;
}
.mjwc-msg-bubble.user-bubble {
  background: var(--mjwc-primary); color: #fff;
  border-radius: 16px 16px 4px 16px;
  white-space: pre-wrap; word-break: break-word;
}
.mjwc-msg-bubble.bot-bubble {
  background: var(--mjwc-bubble); color: #1A1A1A;
  border-radius: 16px 16px 16px 4px;
}
.mjwc-msg-time {
  font-size: 9px; color: #CCC; margin-top: 2px; padding: 0 4px;
}
.mjwc-msg-row.user .mjwc-msg-time { text-align: right; }

/* Action card */
.mjwc-action {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 10px; margin-top: 6px;
  border: 1px solid;
}
.mjwc-action.success { background: rgba(46,125,50,.08); border-color: rgba(46,125,50,.15); }
.mjwc-action.error { background: rgba(198,40,40,.08); border-color: rgba(198,40,40,.15); }
.mjwc-action-icon { font-size: 16px; }
.mjwc-action-label-top {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
}
.mjwc-action.success .mjwc-action-label-top { color: #2E7D32; }
.mjwc-action.error .mjwc-action-label-top { color: #C62828; }
.mjwc-action-text { font-size: 12px; font-weight: 500; color: #1A1A1A; margin-top: 1px; word-break: break-word; }
.mjwc-action-error { font-size: 10px; color: #C62828; margin-top: 1px; }

/* Typing indicator */
.mjwc-typing {
  display: flex; gap: 4px; padding: 10px 14px; align-items: flex-end;
}
.mjwc-typing-dots {
  background: var(--mjwc-bubble); border-radius: 16px 16px 16px 4px;
  padding: 12px 16px; display: flex; gap: 4px; align-items: center;
}
.mjwc-typing-dots span {
  width: 6px; height: 6px; border-radius: 50%; background: #999;
  animation: mjwcBounce 1.2s ease-in-out infinite;
}
.mjwc-typing-dots span:nth-child(2) { animation-delay: .15s; }
.mjwc-typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes mjwcBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* ─── Quick Chips ─── */
.mjwc-chips {
  padding: 0 12px 3px;
  overflow-x: auto; display: flex; gap: 5px; flex-shrink: 0;
}
.mjwc-chips button {
  padding: 4px 10px; border-radius: 14px; border: 1px solid #E0DCD6;
  background: #fff; font-size: 10px; font-weight: 600; cursor: pointer;
  font-family: inherit; color: #777; white-space: nowrap; flex-shrink: 0;
}

/* ─── Input ─── */
.mjwc-input-bar {
  padding: 8px 12px 12px;
  background: #fff; border-top: 1px solid var(--mjwc-border);
  display: flex; gap: 8px; align-items: flex-end; flex-shrink: 0;
}
.mjwc-input-wrap {
  flex: 1; background: #F5F3EF; border-radius: 20px;
  padding: 8px 14px; display: flex; align-items: center;
}
.mjwc-input-wrap textarea {
  border: none; outline: none; flex: 1; font-size: 13px;
  font-family: inherit; background: transparent; color: #1A1A1A;
  resize: none; max-height: 80px; line-height: 1.4;
}
.mjwc-send-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s; flex-shrink: 0;
}
.mjwc-send-btn.active { background: var(--mjwc-primary); cursor: pointer; }
.mjwc-send-btn.inactive { background: #D4CFC7; cursor: default; }

/* ─── Links in messages ─── */
.mjwc-msg-bubble a {
  text-decoration: none; font-weight: 600;
  padding: 1px 6px; border-radius: 5px; word-break: break-all;
}
.mjwc-msg-bubble a.wa-link { color: #25D366; background: rgba(37,211,102,.1); }
.mjwc-msg-bubble a.ig-link { color: #E1306C; background: rgba(225,48,108,.1); }
.mjwc-msg-bubble a.orders-link { color: #2E7D32; background: rgba(46,125,50,.1); }
.mjwc-msg-bubble a.generic-link { color: #2E7D32; }

/* Lists in messages */
.mjwc-list-item {
  display: flex; gap: 5px; padding-left: 3px; margin: 1px 0;
}
.mjwc-list-bullet {
  color: #2E7D32; font-weight: 700; flex-shrink: 0; width: 12px; text-align: center;
}
