/* ============================================================
   Live Chat Widget — Zara Hayat support-agent theme (blue).
   Floating button + panel with quick-reply buttons.
   Sits ABOVE the existing support widget (bottom:24px, h:60px).
   ============================================================ */

/* ---------- Floating action button ---------- */
.bc-chat-fab {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%);
  border: 3px solid #ffffff;
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  box-shadow: 0 10px 26px rgba(29, 78, 216, .45), 0 4px 10px rgba(0,0,0,.15);
  transition: transform .25s ease, box-shadow .25s ease;
  font-family: 'Inter', system-ui, sans-serif;
  padding: 0;
  line-height: 1;
}
.bc-chat-fab:hover { transform: translateY(-3px) scale(1.05); }
.bc-chat-fab .bc-chat-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 18px; height: 18px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid #fff;
}
.bc-chat-fab .bc-chat-badge.show { display: inline-flex; }

/* ---------- Panel ---------- */
.bc-chat-panel {
  position: fixed;
  bottom: 164px;
  right: 24px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 200px);
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .28), 0 4px 12px rgba(0,0,0,.1);
  z-index: 9998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Inter', system-ui, sans-serif;
  border: 1px solid #e2e8f0;
}
.bc-chat-panel.open { display: flex; animation: bcChatIn .22s ease; }
@keyframes bcChatIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }

/* ---------- Header (agent) ---------- */
.bc-chat-header {
  background: linear-gradient(120deg, #1e3a8a 0%, #1d4ed8 45%, #0ea5e9 100%);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 10px;
}
.bc-chat-agent { display: flex; align-items: center; gap: 12px; min-width: 0; }
.bc-chat-avatar {
  position: relative;
  width: 48px; height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.35);
}
.bc-chat-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bc-chat-avatar-fb { display: none; color: #fff; font-weight: 800; font-size: 16px; letter-spacing: .5px; }
.bc-chat-avatar.fallback .bc-chat-avatar-fb { display: block; }
.bc-chat-online-dot {
  position: absolute; bottom: 0; right: 0;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
}
.bc-chat-agent-meta { min-width: 0; }
.bc-chat-name { font-size: 16px; font-weight: 800; color: #fff; line-height: 1.2; }
.bc-chat-status { font-size: 12px; color: rgba(255,255,255,.9); margin-top: 3px; display: flex; align-items: center; gap: 6px; font-weight: 500; }
.bc-chat-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(34,197,94,.25); }
.bc-chat-close {
  background: rgba(37, 99, 235, .85);
  border: none; color: #fff;
  width: 38px; height: 38px;
  border-radius: 11px;
  cursor: pointer;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.bc-chat-close:hover { background: #1d4ed8; }

/* ---------- Quick-reply buttons (2-col grid, 5 items) ---------- */
.bc-chat-quick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
  background: #f5f8ff;
  border-bottom: 1px solid #e6ecf7;
  flex-shrink: 0;
}
.bc-qr-btn {
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 13px 10px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, .28);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
  white-space: nowrap;
}
.bc-qr-btn:hover { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 6px 14px rgba(37, 99, 235, .38); }
.bc-qr-btn:active { transform: translateY(0); }
.bc-qr-icon { font-size: 16px; line-height: 1; }

/* ---------- Messages ---------- */
.bc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: linear-gradient(180deg, #f5f8ff 0%, #eef3ff 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bc-msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  animation: bcMsgIn .18s ease;
}
@keyframes bcMsgIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.bc-msg .bc-msg-time { display: block; font-size: 10px; opacity: .55; margin-top: 4px; text-align: right; }
.bc-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 3px 8px rgba(37, 99, 235, .25);
}
.bc-msg-bot, .bc-msg-admin {
  align-self: flex-start;
  background: #fff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, .05);
}
.bc-msg-admin { border-left: 3px solid #6366f1; }
.bc-msg-sender {
  font-size: 11px;
  font-weight: 700;
  color: #334155;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.bc-msg-agent-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; flex-shrink: 0; }
.bc-msg-agent-tag {
  font-size: 9px;
  letter-spacing: .08em;
  color: #64748b;
  font-weight: 700;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
}
.bc-chat-empty { text-align: center; color: #94a3b8; font-size: 12px; padding: 30px 10px; }

/* ---------- Input row ---------- */
.bc-chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border-top: 1px solid #e6ecf7;
  flex-shrink: 0;
  align-items: center;
}
.bc-chat-attach {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(37, 99, 235, .3);
}
.bc-chat-input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 13.5px;
  outline: none;
  font-family: inherit;
  background: #fff;
}
.bc-chat-input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, .15); }
.bc-chat-send {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0 20px;
  height: 40px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 700;
  font-family: inherit;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(15, 23, 42, .25);
  transition: filter .15s;
}
.bc-chat-send:hover { filter: brightness(1.2); }
.bc-chat-send:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
  .bc-chat-fab { width: 50px; height: 50px; bottom: 88px; right: 18px; font-size: 19px; }
  .bc-chat-panel { right: 12px; left: 12px; width: auto; bottom: 150px; height: 65vh; }
  .bc-qr-btn { font-size: 12.5px; padding: 11px 6px; }
  .bc-chat-name { font-size: 14px; }
  .bc-chat-status { font-size: 11px; }
}

/* ---------- Isolation: chat stays WHITE even though the site theme is dark ---------- */
.bc-chat-panel, .bc-chat-fab { color-scheme: light; }
.bc-chat-panel { color: #0f172a; }
.bc-chat-panel .bc-chat-input { background: #ffffff; color: #0f172a; border-color: #cbd5e1; }
.bc-chat-panel .bc-chat-input:focus { background: #ffffff; color: #0f172a; border-color: #3b82f6 !important; box-shadow: 0 0 0 3px rgba(59,130,246,.15) !important; }
.bc-chat-panel .bc-chat-input::placeholder { color: #94a3b8 !important; opacity: 1; }
.bc-chat-panel a { color: #1d4ed8; }
.bc-chat-panel .bc-msg-user a { color: #ffffff; }
.bc-chat-panel .bc-chat-messages { color: #0f172a; }
.bc-chat-panel button { font-family: inherit; }

/* Tappable Order / Payment IDs inside bot replies */
.bc-chat-panel a.bc-id-chip {
  display: inline-block; background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe;
  border-radius: 6px; padding: 0 6px; margin: 1px 0; font-weight: 600; font-size: 12.5px;
  text-decoration: none; word-break: break-all; cursor: pointer;
}
.bc-chat-panel a.bc-id-chip:hover { background: #dbeafe; }

/* ============================================================
   Additions: attachments, promo slot, typing indicator,
   admin-reply accent, smoother slide-up animations.
   ============================================================ */
/* Smoother slide-up open animation (auto-popup friendly) */
@keyframes bcChatIn { from { opacity: 0; transform: translateY(24px) scale(.97); } to { opacity: 1; transform: none; } }
.bc-chat-panel.open { animation: bcChatIn .28s cubic-bezier(.22,.61,.36,1); }

/* Admin replies — distinct from bot (blue accent matching design tokens) */
.bc-msg-admin { border-left: 3px solid #1769E8 !important; background: linear-gradient(135deg,#eff6ff,#ffffff) !important; }
.bc-msg-admin .bc-msg-sender { color: #1769E8; }

/* Chat attachments */
.bc-attach { display: block; margin-top: 8px; text-decoration: none; }
.bc-attach-img { display: block; }
.bc-attach-img img { max-width: 200px; max-height: 160px; border-radius: 10px; display: block; border: 1px solid #e2e8f0; cursor: zoom-in; object-fit: cover; }
.bc-msg-user .bc-attach-img img { border-color: rgba(255,255,255,.4); }
.bc-attach-doc { display: inline-flex; align-items: center; gap: 10px; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 10px; padding: 9px 12px; max-width: 240px; color: #0f172a; transition: background .15s, transform .15s; }
.bc-attach-doc:hover { background: #e2e8f0; transform: translateY(-1px); }
.bc-msg-user .bc-attach-doc { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.35); color: #fff; }
.bc-msg-user .bc-attach-doc:hover { background: rgba(255,255,255,.28); }
.bc-attach-icon { width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; position: relative; background: #fff; border: 1px solid #e2e8f0; }
.bc-msg-user .bc-attach-icon { background: rgba(255,255,255,.25); border-color: rgba(255,255,255,.4); }
.bc-attach-icon::after { content: ''; position: absolute; bottom: 3px; right: 3px; width: 0; height: 0; border-left: 7px solid transparent; border-bottom: 7px solid #94a3b8; }
.bc-msg-user .bc-attach-icon::after { border-bottom-color: rgba(255,255,255,.8); }
.bc-fi-pdf { background: linear-gradient(135deg,#fee2e2,#fecaca) !important; }
.bc-fi-word { background: linear-gradient(135deg,#dbeafe,#bfdbfe) !important; }
.bc-fi-txt { background: linear-gradient(135deg,#f1f5f9,#e2e8f0) !important; }
.bc-attach-meta { display: flex; flex-direction: column; min-width: 0; }
.bc-attach-name { font-size: 12.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.bc-attach-size { font-size: 10.5px; opacity: .65; margin-top: 1px; }

/* Typing indicator (three bouncing dots) */
.bc-typing { align-self: flex-start; display: inline-flex; gap: 5px; padding: 12px 16px; background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; border-bottom-left-radius: 4px; box-shadow: 0 2px 6px rgba(15,23,42,.05); animation: bcMsgIn .18s ease; }
.bc-typing span { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; animation: bcTypingBounce 1.2s infinite; }
.bc-typing span:nth-child(2) { animation-delay: .15s; }
.bc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bcTypingBounce { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* Promo slot (compact card between quick-reply buttons and messages) */
.bc-promo-card { position: relative; margin: 0 12px 10px; border-radius: 12px; overflow: hidden; background: #0f172a; box-shadow: 0 6px 16px rgba(15,23,42,.2); flex-shrink: 0; animation: bcPromoIn .35s cubic-bezier(.22,.61,.36,1); }
@keyframes bcPromoIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.bc-promo-link { display: block; position: relative; text-decoration: none; color: #fff; }
.bc-promo-thumb { width: 100%; height: 92px; object-fit: cover; display: block; opacity: .85; }
.bc-promo-video { width: 100%; height: 110px; object-fit: cover; display: block; background: #000; }
.bc-promo-label { position: absolute; top: 8px; left: 8px; background: rgba(23,105,232,.9); color: #fff; font-size: 9.5px; font-weight: 800; letter-spacing: .08em; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; }
.bc-promo-play { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-60%); width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.92); color: #1769E8; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(0,0,0,.3); transition: transform .18s; }
.bc-promo-link:hover .bc-promo-play { transform: translate(-50%,-60%) scale(1.1); }
.bc-promo-text { position: absolute; bottom: 0; left: 0; right: 0; padding: 22px 12px 8px; background: linear-gradient(180deg, transparent, rgba(0,0,0,.75)); font-size: 12.5px; font-weight: 700; color: #fff; }
.bc-promo-close { position: absolute; top: 6px; right: 6px; z-index: 2; width: 24px; height: 24px; border-radius: 50%; background: rgba(15,23,42,.6); color: #fff; border: none; cursor: pointer; font-size: 15px; font-weight: 700; line-height: 1; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.bc-promo-close:hover { background: rgba(220,53,69,.9); }

/* Attach button active state */
.bc-chat-attach:hover { filter: brightness(1.1); transform: translateY(-1px); }
.bc-chat-attach:active { transform: translateY(0); }

/* ============================================================
   v2 RESTYLE (additive — all original classes/behavior preserved)
   Gradient FAB pulse, minimize button, message avatars,
   AI Assistant badge, inline quick-reply chips, chip row.
   ============================================================ */
/* FAB — richer gradient + soft pulse ring */
.bc-chat-fab {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 45%, #0ea5e9 100%);
  box-shadow: 0 12px 30px rgba(37, 99, 235, .45), 0 4px 12px rgba(0,0,0,.18);
  animation: bcChatFabPulse 2.6s infinite;
}
@keyframes bcChatFabPulse {
  0%   { box-shadow: 0 0 0 0 rgba(37,99,235,.5),  0 12px 30px rgba(37,99,235,.45), 0 4px 12px rgba(0,0,0,.18); }
  70%  { box-shadow: 0 0 0 16px rgba(37,99,235,0), 0 12px 30px rgba(37,99,235,.45), 0 4px 12px rgba(0,0,0,.18); }
  100% { box-shadow: 0 0 0 0 rgba(37,99,235,0),   0 12px 30px rgba(37,99,235,.45), 0 4px 12px rgba(0,0,0,.18); }
}
.bc-chat-fab:hover { animation: none; box-shadow: 0 16px 38px rgba(37,99,235,.55), 0 6px 16px rgba(0,0,0,.22); }

/* Panel — softer shadow, refined radius */
.bc-chat-panel { border-radius: 20px; box-shadow: 0 24px 60px rgba(15,23,42,.32), 0 6px 16px rgba(0,0,0,.12); border: 1px solid #e2e8f0; }

/* Header — gradient + minimize button */
.bc-chat-header { background: linear-gradient(120deg, #1e3a8a 0%, #2563eb 50%, #0ea5e9 100%); padding: 12px 12px 12px 14px; }
.bc-chat-header-actions { display: flex; align-items: center; gap: 6px; }
.bc-chat-minimize {
  background: rgba(37,99,235,.85); border: none; color: #fff;
  width: 38px; height: 38px; border-radius: 11px; cursor: pointer;
  font-size: 20px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background .15s;
}
.bc-chat-minimize:hover { background: #1d4ed8; }
.bc-chat-close { background: rgba(239,68,68,.85); }
.bc-chat-close:hover { background: #dc2626; }

/* Minimized state — only header visible */
.bc-chat-panel.minimized .bc-chat-quick,
.bc-chat-panel.minimized .bc-chat-messages,
.bc-chat-panel.minimized .bc-chat-input-row,
.bc-chat-panel.minimized .bc-promo-card { display: none !important; }
.bc-chat-panel.minimized { height: auto; }

/* Quick-reply row — horizontal scrollable chips (was 2-col grid) */
.bc-chat-quick {
  display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 8px;
  padding: 10px 12px; background: #f8fafc; border-bottom: 1px solid #e6ecf7;
  scrollbar-width: thin;
}
.bc-chat-quick::-webkit-scrollbar { height: 4px; }
.bc-chat-quick::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.bc-qr-btn {
  background: #fff; color: #1d4ed8; border: 1.5px solid #bfdbfe;
  border-radius: 999px; padding: 9px 14px; font-size: 12.5px; font-weight: 700;
  box-shadow: 0 2px 6px rgba(37,99,235,.10); white-space: nowrap; flex-shrink: 0;
}
.bc-qr-btn:hover { background: linear-gradient(135deg,#2563eb,#3b82f6); color: #fff; border-color: transparent; transform: translateY(-1px); }

/* Message rows with avatars */
.bc-msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: 86%; animation: bcMsgIn .18s ease; }
.bc-msg-row.row-user { align-self: flex-end; flex-direction: row-reverse; }
.bc-msg-row.row-bot, .bc-msg-row.row-admin { align-self: flex-start; }
.bc-msg-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: #fff; overflow: hidden;
}
.av-user  { background: linear-gradient(135deg,#64748b,#334155); }
.av-bot   { background: linear-gradient(135deg,#8b5cf6,#ec4899); }
.av-ai    { background: linear-gradient(135deg,#059669,#10b981); }
.av-admin { background: linear-gradient(135deg,#1769E8,#0ea5e9); }
.bc-msg-row .bc-msg { max-width: 100%; margin: 0; }

/* AI Assistant distinct badge */
.bc-ai-tag {
  font-size: 9px; letter-spacing: .06em; font-weight: 800;
  background: linear-gradient(135deg,#059669,#10b981); color: #fff;
  padding: 2px 7px; border-radius: 5px; text-transform: uppercase;
}
.bc-msg.bc-msg-ai { border-left: 3px solid #10b981 !important; background: linear-gradient(135deg,#ecfdf5,#ffffff) !important; }
.bc-msg.bc-msg-ai .bc-msg-sender { color: #059669; }

/* Inline quick-reply chips inside a bot message */
.bc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.bc-chip {
  background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe;
  border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: all .15s;
}
.bc-chip:hover { background: #2563eb; color: #fff; border-color: #2563eb; transform: translateY(-1px); }

/* Input area — rounded + softer */
.bc-chat-input { border-radius: 999px; padding: 11px 16px; }
.bc-chat-send { border-radius: 999px; background: linear-gradient(135deg,#2563eb,#3b82f6); }
.bc-chat-attach { border-radius: 999px; }

/* Mobile positions — keep stack: support(24) < chat(88) < notif(152) */
@media (max-width: 480px) {
  .bc-chat-fab { bottom: 88px; }
  .bc-chat-panel { bottom: 150px; height: 62vh; }
  .bc-qr-btn { font-size: 12px; padding: 8px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .bc-chat-fab { animation: none !important; }
}
