/* DO AI Chat Widget — v1.0 */

/* ── Root ── */
#do-chat-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: -apple-system, "SF Pro Display", "Helvetica Neue", Arial, sans-serif !important;
}

/* ── Bubble button ── */
#do-chat-bubble {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #007aff, #30d158) !important;
  border: none !important;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(0,122,255,0.45), 0 2px 8px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: transform 0.25s cubic-bezier(0.22,1,0.36,1), box-shadow 0.25s;
  position: relative;
  outline: none !important;
}
#do-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(0,122,255,0.55), 0 4px 12px rgba(0,0,0,0.2);
}
#do-chat-bubble:active { transform: scale(0.96); }

#do-chat-unread {
  position: absolute;
  top: -4px; right: -4px;
  width: 20px; height: 20px;
  background: #ff2d55;
  color: #fff !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  border-radius: 50%;
  display: flex !important;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: dc-bounce 2s ease-in-out infinite;
}
@keyframes dc-bounce {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.2); }
}

/* ── Chat window ── */
#do-chat-window {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 360px;
  max-height: 540px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: dc-slide-up 0.3s cubic-bezier(0.22,1,0.36,1);
}
@keyframes dc-slide-up {
  from { opacity:0; transform: translateY(16px) scale(0.97); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}

/* ── Header ── */
#do-chat-header {
  background: #000;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}
#do-chat-header::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 100% at 20% 50%, rgba(0,122,255,0.18), transparent),
    radial-gradient(ellipse 60% 80% at 80% 50%, rgba(48,209,88,0.12), transparent);
}
.dch-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg,#007aff,#30d158);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  flex-shrink: 0;
  position: relative; z-index: 1;
}
.dch-info {
  flex: 1; position: relative; z-index: 1;
}
.dch-name {
  font-size: 14px !important;
  font-weight: 700 !important;
  color: #fff !important;
  margin: 0 !important;
  line-height: 1.2;
}
.dch-status {
  font-size: 11px !important;
  color: rgba(255,255,255,0.5) !important;
  margin: 2px 0 0 0 !important;
  display: flex; align-items: center; gap: 5px;
}
.dch-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #30d158;
  display: inline-block;
  animation: dc-pulse 2s ease-in-out infinite;
}
@keyframes dc-pulse {
  0%,100% { opacity:1; }
  50%      { opacity:0.5; }
}
.dch-close {
  background: rgba(255,255,255,0.1) !important;
  border: none !important;
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  color: rgba(255,255,255,0.6);
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1;
  transition: background 0.2s, color 0.2s;
}
.dch-close:hover { background: rgba(255,255,255,0.2) !important; color:#fff; }

/* ── Messages ── */
#do-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: #f9f9fb;
}
#do-chat-messages::-webkit-scrollbar { width: 4px; }
#do-chat-messages::-webkit-scrollbar-track { background: transparent; }
#do-chat-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 2px; }

.dc-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px !important;
  line-height: 1.5;
  animation: dc-msg-in 0.2s ease;
  word-break: break-word;
}
@keyframes dc-msg-in {
  from { opacity:0; transform:translateY(6px); }
  to   { opacity:1; transform:translateY(0); }
}
.dc-msg-bot {
  background: #fff;
  color: #1d1d1f !important;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.dc-msg-user {
  background: linear-gradient(135deg,#007aff,#34aadc);
  color: #fff !important;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.dc-msg-system {
  font-size: 11px !important;
  color: #86868b !important;
  background: none;
  padding: 4px 0;
  align-self: center;
  text-align: center;
  max-width: 100%;
}
.dc-lead-badge {
  background: rgba(48,209,88,0.12);
  border: 1px solid rgba(48,209,88,0.25);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 12px !important;
  font-weight: 600 !important;
  color: #1a8a40 !important;
  align-self: center;
  margin-top: 4px;
}

/* ── Typing indicator ── */
#do-chat-typing {
  padding: 8px 16px;
  flex-shrink: 0;
  background: #f9f9fb;
}
.dct-bubble {
  background: #fff;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 10px 14px;
  display: inline-flex;
  gap: 4px;
  align-items: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.dct-bubble span {
  width: 6px; height: 6px; border-radius: 50%;
  background: #aeaeb2;
  animation: dc-typing 1.2s ease-in-out infinite;
}
.dct-bubble span:nth-child(2) { animation-delay: 0.2s; }
.dct-bubble span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dc-typing {
  0%,60%,100% { transform: translateY(0); opacity:0.4; }
  30%          { transform: translateY(-5px); opacity:1; }
}

/* ── Input row ── */
#do-chat-input-row {
  padding: 12px 14px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  border-top: 1px solid rgba(0,0,0,0.07);
  background: #fff;
  flex-shrink: 0;
}
#do-chat-input {
  flex: 1;
  border: 1px solid rgba(0,0,0,0.12) !important;
  border-radius: 12px;
  padding: 10px 13px;
  font-size: 14px !important;
  font-family: inherit !important;
  color: #1d1d1f !important;
  background: #f5f5f7 !important;
  resize: none;
  outline: none !important;
  line-height: 1.4;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.2s;
}
#do-chat-input:focus {
  border-color: rgba(0,122,255,0.5) !important;
  background: #fff !important;
}
#do-chat-input::placeholder { color: #aeaeb2 !important; }

#do-chat-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg,#007aff,#34aadc) !important;
  border: none !important;
  cursor: pointer;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, opacity 0.2s;
  outline: none !important;
}
#do-chat-send:hover   { transform: scale(1.08); }
#do-chat-send:active  { transform: scale(0.94); }
#do-chat-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ── Footer ── */
#do-chat-footer {
  font-size: 10px !important;
  color: #aeaeb2 !important;
  text-align: center;
  padding: 0 14px 10px;
  margin: 0 !important;
  background: #fff;
  flex-shrink: 0;
}
#do-chat-footer a {
  color: #007aff !important;
  text-decoration: none !important;
}

/* ── Mobile ── */
@media screen and (max-width: 480px) {
  #do-chat-root { bottom: 16px; right: 16px; }
  #do-chat-window {
    width: calc(100vw - 32px);
    max-height: 70vh;
    right: 0;
    bottom: 68px;
  }
}
