/*
 * Dino Jr. Chat Widget — Light theme to match dinozhao.com
 */

/* ── Make existing sidebar avatar look clickable ─────────────────────────── */
.djr-trigger-active {
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.djr-trigger-active:hover {
  transform: scale(1.06);
  box-shadow: 0 0 0 3px rgba(61, 107, 142, 0.18), 0 4px 16px rgba(44, 42, 38, 0.12);
}

/* ── Speech bubble (position: fixed, set by JS) ───────────────────────────── */
#djr-bubble {
  position: fixed;
  background: #fff;
  border: 1px solid #e8e4dd;
  border-radius: 14px;
  padding: 8px 13px;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  color: #2c2a26;
  white-space: nowrap;
  box-shadow: 0 3px 14px rgba(44, 42, 38, 0.1);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 999998;
}

/* Arrow pointing left (toward avatar on left) */
#djr-bubble::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: #fff;
  border-left: 1px solid #e8e4dd;
  border-bottom: 1px solid #e8e4dd;
}

#djr-bubble.djr-visible {
  opacity: 1;
  transform: translateX(0);
}

/* ── Chat panel (position: fixed, bottom-left) ────────────────────────────── */
#djr-panel {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 340px;
  height: 500px;
  background: #fff;
  border: 1.5px solid #e8e4dd;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 48px rgba(44, 42, 38, 0.13), 0 2px 8px rgba(44, 42, 38, 0.06);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  opacity: 0;
  transform: scale(0.93) translateY(12px);
  transform-origin: bottom left;
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
  z-index: 999999;
}

#djr-panel.djr-open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.djr-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1.5px solid #e8e4dd;
  flex-shrink: 0;
}

.djr-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.djr-header-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid #e8e4dd;
  flex-shrink: 0;
}

.djr-header-name {
  font-family: 'Lora', Georgia, serif;
  font-size: 14px;
  font-weight: 600;
  color: #2c2a26;
}

.djr-header-sub {
  font-size: 11px;
  color: #7a7570;
  margin-top: 1px;
}

.djr-close {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid #e8e4dd;
  background: #f5f3f0;
  color: #7a7570;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  padding: 0;
  flex-shrink: 0;
}

.djr-close:hover {
  background: #e8e4dd;
  color: #2c2a26;
}

/* ── Messages ─────────────────────────────────────────────────────────────── */
.djr-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: #fff;
}

.djr-messages::-webkit-scrollbar { width: 3px; }
.djr-messages::-webkit-scrollbar-track { background: transparent; }
.djr-messages::-webkit-scrollbar-thumb {
  background: #e8e4dd;
  border-radius: 3px;
}

.djr-msg-row { display: flex; align-items: flex-end; }
.djr-msg-row.djr-user      { justify-content: flex-end; }
.djr-msg-row.djr-assistant { justify-content: flex-start; }

.djr-msg-bubble {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
}

/* Bot: light gray background */
.djr-msg-row.djr-assistant .djr-msg-bubble {
  background: #f5f3f0;
  color: #2c2a26;
  border-bottom-left-radius: 3px;
}

/* User: site accent color */
.djr-msg-row.djr-user .djr-msg-bubble {
  background: #3d6b8e;
  color: #fff;
  border-bottom-right-radius: 3px;
}

/* Typing dots */
.djr-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 3px 1px;
}

.djr-dots span {
  width: 6px;
  height: 6px;
  background: #c5c0b8;
  border-radius: 50%;
  animation: djr-bounce 1.3s infinite ease-in-out;
}

.djr-dots span:nth-child(2) { animation-delay: 0.18s; }
.djr-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes djr-bounce {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.5; }
  30%            { transform: translateY(-5px); opacity: 1;   }
}

/* ── Input area ───────────────────────────────────────────────────────────── */
.djr-input-area {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px;
  background: #fff;
  border-top: 1.5px solid #e8e4dd;
  flex-shrink: 0;
}

.djr-input {
  flex: 1;
  background: #f5f3f0;
  border: 1px solid #e8e4dd;
  border-radius: 10px;
  padding: 8px 11px;
  color: #2c2a26;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 36px;
  max-height: 90px;
  line-height: 1.45;
  transition: border-color 0.15s;
}

.djr-input::placeholder { color: #b0aba4; }
.djr-input:focus { border-color: #3d6b8e; }
.djr-input:disabled { opacity: 0.55; }

.djr-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #3d6b8e;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
  padding: 0;
}

.djr-send svg { width: 14px; height: 14px; }

.djr-send:hover:not(:disabled) {
  background: #2e5473;
  transform: scale(1.06);
}

.djr-send:disabled {
  background: #d4cfc8;
  cursor: default;
}

/* ── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  #djr-panel {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 72vh;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    transform: translateY(100%);
  }

  #djr-panel.djr-open {
    transform: translateY(0);
    opacity: 1;
  }

  #djr-bubble {
    /* on mobile bubble positioned below avatar by JS */
  }
}
