/* ─────────────────────────────────────────────────────────────────
   SD Store Chat Widget — chat-widget.css
   Include on every page: <link rel="stylesheet" href="chat-widget.css">
───────────────────────────────────────────────────────────────── */

/* FAB BUTTON */
#sd-chat-fab {
  position: fixed !important;
  bottom: 32px !important;
  right: 32px !important;
  z-index: 100001 !important;
  width: 58px !important;
  height: 58px !important;
  border-radius: 50% !important;
  background: #7c3aed !important;
  border: none !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 4px 20px rgba(124,58,237,.5) !important;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease !important;
  outline: none !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}
#sd-chat-fab:hover {
  transform: scale(1.1) !important;
  box-shadow: 0 8px 32px rgba(124,58,237,.65) !important;
}
#sd-chat-fab:active { transform: scale(.93) !important; }

#sd-chat-fab .sdc-fab-icon {
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; pointer-events: none;
}
#sd-chat-fab .sdc-fab-icon svg {
  width: 24px; height: 24px; color: #fff; flex-shrink: 0;
}
#sd-chat-fab .sdc-fab-label { display: none; }

#sd-chat-fab-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 20px; height: 20px; padding: 0 5px;
  background: linear-gradient(135deg, #f43f5e, #dc2626);
  border-radius: 999px;
  border: 2px solid #07070a;
  font-size: 10px; font-weight: 900; color: #fff;
  display: none; align-items: center; justify-content: center;
  line-height: 1; font-family: inherit;
  box-shadow: 0 2px 8px rgba(244,63,94,.5);
  animation: sdc-badge-pop .25s cubic-bezier(.34,1.56,.64,1);
}
@keyframes sdc-badge-pop { from { transform: scale(0); } to { transform: scale(1); } }

/* PANEL */
#sd-chat-panel {
  position: fixed !important;
  bottom: 108px !important;
  right: 32px !important;
  z-index: 100000 !important;
  width: 400px !important;
  height: 580px !important;
  display: flex !important;
  flex-direction: column !important;
  background: #0b0b0f !important;
  border: 1px solid rgba(139,92,246,.18) !important;
  border-radius: 24px !important;
  box-shadow:
    0 32px 80px rgba(0,0,0,.7),
    0 0 0 1px rgba(139,92,246,.06),
    inset 0 1px 0 rgba(255,255,255,.04) !important;
  overflow: hidden !important;
  transform: scale(.88) translateY(28px) !important;
  opacity: 0 !important;
  pointer-events: none !important;
  transform-origin: bottom right !important;
  transition: transform .26s cubic-bezier(.34,1.56,.64,1), opacity .2s ease !important;
}
#sd-chat-panel.sdc-open {
  transform: scale(1) translateY(0) !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}
#sd-chat-panel::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, #7c3aed, #a78bfa, #7c3aed);
  z-index: 1;
}

/* VIEWS */
.sdc-view { display: none; flex-direction: column; height: 100%; min-height: 0; }
.sdc-view.sdc-active { display: flex; }

/* HEADER */
.sdc-header {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 16px 14px;
  background: rgba(255,255,255,.025);
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0; position: relative; z-index: 1;
}
.sdc-header-title {
  flex: 1; font-size: 15px; font-weight: 800; color: #f4f4f8;
  display: flex; align-items: center; gap: 8px; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sdc-header-title span.sdc-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: #a78bfa;
  box-shadow: 0 0 8px rgba(167,139,250,.8);
  animation: sdc-dot-pulse 2.5s ease-in-out infinite;
}
@keyframes sdc-dot-pulse {
  0%,100% { box-shadow: 0 0 8px rgba(167,139,250,.8); }
  50%      { box-shadow: 0 0 16px rgba(167,139,250,1); }
}
.sdc-back-btn, .sdc-close-btn {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.07);
  color: #7070a0; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
}
.sdc-back-btn:hover, .sdc-close-btn:hover {
  background: rgba(139,92,246,.15); border-color: rgba(139,92,246,.35); color: #c4b5fd;
}
.sdc-back-btn svg, .sdc-close-btn svg { width: 14px; height: 14px; }
.sdc-header-avatar {
  width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff; overflow: hidden;
  border: 1.5px solid rgba(167,139,250,.3);
}
.sdc-header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sdc-header-online { font-size: 11px; color: #7070a0; font-weight: 500; margin-top: 1px; }

/* CONVERSATION LIST */
.sdc-conv-list { flex: 1; overflow-y: auto; padding: 6px 0; min-height: 0; }
.sdc-conv-list::-webkit-scrollbar { width: 3px; }
.sdc-conv-list::-webkit-scrollbar-track { background: transparent; }
.sdc-conv-list::-webkit-scrollbar-thumb { background: rgba(139,92,246,.2); border-radius: 4px; }

.sdc-conv-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; cursor: pointer;
  transition: background .15s;
  border-bottom: 1px solid rgba(255,255,255,.03);
  position: relative;
}
.sdc-conv-item::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: linear-gradient(180deg, #7c3aed, #a78bfa);
  border-radius: 0 3px 3px 0; transition: width .15s;
}
.sdc-conv-item:hover { background: rgba(139,92,246,.06); }
.sdc-conv-item:hover::before { width: 3px; }
.sdc-conv-item.sdc-unread { background: rgba(139,92,246,.05); }
.sdc-conv-item.sdc-unread::before { width: 3px; }

.sdc-conv-avatar {
  width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
  background: linear-gradient(135deg, #4c1d95, #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; color: #e9d5ff;
  overflow: hidden; position: relative;
  border: 1.5px solid rgba(139,92,246,.2);
}
.sdc-conv-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.sdc-conv-body { flex: 1; min-width: 0; }
.sdc-conv-name {
  font-size: 13.5px; font-weight: 700; color: #f0f0f8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 6px;
}
.sdc-conv-preview {
  font-size: 12px; color: #55556a; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sdc-conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.sdc-conv-time { font-size: 10px; color: #55556a; white-space: nowrap; }
.sdc-unread-badge {
  min-width: 19px; height: 19px; padding: 0 5px;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  border-radius: 999px;
  font-size: 10px; font-weight: 900; color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(124,58,237,.4);
}

/* EMPTY STATES */
.sdc-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 36px 24px; text-align: center; color: #55556a;
}
.sdc-empty svg { width: 52px; height: 52px; opacity: .18; margin-bottom: 14px; }
.sdc-empty p { font-size: 13.5px; line-height: 1.65; margin: 0; color: #70708a; }
.sdc-empty small { font-size: 11.5px; opacity: .65; }

/* MESSAGES AREA */
.sdc-messages {
  flex: 1; overflow-y: auto; padding: 16px 14px 10px;
  display: flex; flex-direction: column; gap: 6px; min-height: 0;
  background:
    radial-gradient(ellipse at 80% 20%, rgba(124,58,237,.04) 0%, transparent 60%),
    radial-gradient(ellipse at 20% 80%, rgba(124,58,237,.03) 0%, transparent 60%);
}
.sdc-messages::-webkit-scrollbar { width: 3px; }
.sdc-messages::-webkit-scrollbar-track { background: transparent; }
.sdc-messages::-webkit-scrollbar-thumb { background: rgba(139,92,246,.15); border-radius: 4px; }

.sdc-msg-row { display: flex; align-items: flex-end; gap: 6px; }
.sdc-msg-row.sdc-me    { justify-content: flex-end; }
.sdc-msg-row.sdc-them  { justify-content: flex-start; }

.sdc-bubble {
  max-width: 78%; padding: 10px 14px 8px; word-break: break-word;
  font-size: 13.5px; line-height: 1.55; position: relative;
}
.sdc-me .sdc-bubble {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: #f5f3ff; font-weight: 500;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 4px 16px rgba(109,40,217,.35);
}
.sdc-them .sdc-bubble {
  background: rgba(255,255,255,.065);
  color: #e8e8f4;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px 18px 18px 4px;
}
.sdc-msg-time {
  font-size: 9.5px; opacity: .45; margin-top: 4px;
  display: block; text-align: right; font-weight: 500;
}
.sdc-them .sdc-msg-time { text-align: left; }

.sdc-date-divider {
  text-align: center; font-size: 10.5px; color: #45455a;
  padding: 8px 0 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  display: flex; align-items: center; gap: 8px;
}
.sdc-date-divider::before, .sdc-date-divider::after {
  content: ''; flex: 1; height: 1px; background: rgba(255,255,255,.06);
}

/* INPUT ROW */
.sdc-input-row {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 12px 14px;
  background: rgba(255,255,255,.02);
  border-top: 1px solid rgba(255,255,255,.05);
  flex-shrink: 0;
}
.sdc-textarea {
  flex: 1; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px; padding: 10px 14px; color: #f0f0f8; font-size: 13.5px;
  font-family: inherit; outline: none; resize: none; max-height: 90px;
  transition: border-color .18s, background .18s; line-height: 1.45;
}
.sdc-textarea::placeholder { color: #45455a; }
.sdc-textarea:focus {
  border-color: rgba(139,92,246,.5);
  background: rgba(139,92,246,.06);
}
.sdc-send-btn {
  width: 42px; height: 42px; border-radius: 14px; flex-shrink: 0;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: opacity .15s, transform .15s, box-shadow .15s;
  box-shadow: 0 4px 14px rgba(109,40,217,.4);
}
.sdc-send-btn:hover   { transform: scale(1.07); box-shadow: 0 6px 20px rgba(109,40,217,.55); }
.sdc-send-btn:active  { transform: scale(.92); }
.sdc-send-btn:disabled{ opacity: .3; cursor: default; transform: none; box-shadow: none; }
.sdc-send-btn svg { width: 18px; height: 18px; color: #fff; }

/* LOADING BAR */
.sdc-status {
  height: 2px; background: linear-gradient(90deg, #7c3aed, #a78bfa);
  transform: scaleX(0); transform-origin: left; transition: transform .3s; position: relative; z-index: 2;
}
.sdc-status.loading { transform: scaleX(1); animation: sdc-progress 1.4s ease-in-out infinite; }
@keyframes sdc-progress {
  0%   { transform-origin: left;  transform: scaleX(0); }
  49%  { transform-origin: left;  transform: scaleX(.8); }
  50%  { transform-origin: right; transform: scaleX(.8); }
  100% { transform-origin: right; transform: scaleX(0); }
}

/* TOAST NOTIFICATION */
#sdc-toast {
  position: fixed !important;
  bottom: 104px !important;
  right: 32px !important;
  z-index: 100002 !important;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #18181f;
  border: 1px solid rgba(124,58,237,.35);
  border-left: 3px solid #7c3aed;
  border-radius: 14px;
  padding: 12px 16px 12px 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.55), 0 0 0 1px rgba(124,58,237,.07);
  cursor: pointer;
  max-width: 300px;
  transform: translateX(120%);
  opacity: 0;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .25s ease;
  pointer-events: none;
}
#sdc-toast.sdc-toast-show {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}
#sdc-toast-avatar {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff; overflow: hidden;
}
#sdc-toast-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
#sdc-toast-body { flex: 1; min-width: 0; }
#sdc-toast-name {
  font-size: 12px; font-weight: 800; color: #c4b5fd;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#sdc-toast-text {
  font-size: 12px; color: #8888aa; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#sdc-toast-close {
  width: 20px; height: 20px; flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  color: #55556a; display: flex; align-items: center; justify-content: center;
  border-radius: 5px; transition: color .15s; padding: 0;
}
#sdc-toast-close:hover { color: #a78bfa; }
#sdc-toast-close svg { width: 12px; height: 12px; }

/* RESPONSIVE */
@media (max-width: 480px) {
  #sd-chat-panel { width: calc(100vw - 20px) !important; right: 10px !important; bottom: 84px !important; height: 520px !important; }
  #sd-chat-fab   { right: 18px !important; bottom: 22px !important; width: 52px !important; height: 52px !important; }
  #sdc-toast     { right: 10px !important; max-width: calc(100vw - 20px) !important; }
}
