/* AI Style Advisor Chat Widget */

#dtd-chat-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 58px;
  height: 58px;
  background: var(--brown-dark, #341d16);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 9998;
  box-shadow: 0 4px 20px rgba(52,29,22,0.32);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.22s ease, background 0.22s ease, box-shadow 0.22s ease;
}
#dtd-chat-trigger:hover {
  transform: scale(1.08);
  background: var(--brown-mid, #b45d2e);
  box-shadow: 0 6px 26px rgba(180,93,46,0.42);
}
#dtd-chat-trigger::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--brown-mid, #b45d2e);
  animation: dtd-pulse 2.6s ease-out infinite;
  pointer-events: none;
}
#dtd-chat-trigger.open::after { animation: none; opacity: 0; }

@keyframes dtd-pulse {
  0%   { transform: scale(1);    opacity: 0.7; }
  70%  { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}

#dtd-chat-trigger .icon-chat,
#dtd-chat-trigger .icon-close {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -47%);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
#dtd-chat-trigger.open .icon-chat  { opacity: 0; transform: translate(-50%, -47%) scale(0.6) rotate(20deg); }
#dtd-chat-trigger.open .icon-close { opacity: 1; transform: translate(-50%, -47%) scale(1) rotate(0deg); }
#dtd-chat-trigger:not(.open) .icon-chat  { opacity: 1; transform: translate(-50%, -47%) scale(1); }
#dtd-chat-trigger:not(.open) .icon-close { opacity: 0; transform: translate(-50%, -47%) scale(0.6) rotate(-20deg); }

#dtd-chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 360px;
  max-height: 560px;
  background: var(--cream, #fffdf7);
  border-radius: 18px;
  box-shadow: 0 12px 48px rgba(52,29,22,0.2), 0 2px 8px rgba(52,29,22,0.08);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.34,1.56,0.64,1),
              transform 0.28s cubic-bezier(0.34,1.56,0.64,1);
  transform-origin: bottom right;
}
#dtd-chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

.dtd-header {
  background: var(--brown-dark, #341d16);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}
.dtd-header-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #b45d2e, #d4b59a);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.dtd-header-name {
  font-family: var(--font-serif, 'BioRhyme', Georgia, serif);
  color: #fffdf7;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}
.dtd-header-status {
  font-family: var(--font-serif, 'BioRhyme', Georgia, serif);
  color: #d4b59a;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}
.dtd-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #7ecb8a;
  border-radius: 50%;
  display: inline-block;
}

.dtd-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: #d4b59a transparent;
}
.dtd-messages::-webkit-scrollbar { width: 4px; }
.dtd-messages::-webkit-scrollbar-thumb { background: #d4b59a; border-radius: 2px; }

.dtd-msg {
  display: flex;
  gap: 7px;
  animation: dtd-msg-in 0.25s ease;
}
@keyframes dtd-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.dtd-msg.user { flex-direction: row-reverse; }

.dtd-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #b45d2e, #d4b59a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  align-self: flex-end;
}
.dtd-msg.user .dtd-msg-avatar { background: #d4b59a; }

.dtd-msg-bubble {
  max-width: 80%;
  padding: 9px 13px;
  border-radius: 14px;
  font-family: var(--font-serif, 'BioRhyme', Georgia, serif);
  font-size: 13px;
  line-height: 1.55;
  color: var(--brown-dark, #341d16);
}
.dtd-msg.ai   .dtd-msg-bubble { background: #f5ede4; border-bottom-left-radius: 3px; }
.dtd-msg.user .dtd-msg-bubble { background: var(--brown-dark, #341d16); color: #fffdf7; border-bottom-right-radius: 3px; }

.dtd-typing {
  display: flex;
  gap: 4px;
  padding: 9px 13px;
  background: #f5ede4;
  border-radius: 14px;
  border-bottom-left-radius: 3px;
  width: fit-content;
}
.dtd-typing span {
  width: 6px;
  height: 6px;
  background: #b45d2e;
  border-radius: 50%;
  animation: dtd-bounce 1.1s ease infinite;
}
.dtd-typing span:nth-child(2) { animation-delay: 0.14s; }
.dtd-typing span:nth-child(3) { animation-delay: 0.28s; }
@keyframes dtd-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-5px); }
}

.dtd-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 0 4px;
}
.dtd-chip {
  background: transparent;
  border: 1.5px solid var(--brown-mid, #b45d2e);
  color: var(--brown-mid, #b45d2e);
  font-family: var(--font-serif, 'BioRhyme', Georgia, serif);
  font-size: 11.5px;
  padding: 5px 11px;
  border-radius: 18px;
  cursor: pointer;
  transition: background 0.16s, color 0.16s, transform 0.14s;
  line-height: 1.3;
}
.dtd-chip:hover {
  background: var(--brown-mid, #b45d2e);
  color: #fffdf7;
  transform: translateY(-1px);
}

.dtd-divider {
  height: 1px;
  background: #e8ddd4;
  margin: 0 14px;
  flex-shrink: 0;
}

.dtd-input-area {
  padding: 10px 14px 14px;
  flex-shrink: 0;
  display: flex;
  gap: 7px;
  align-items: flex-end;
}
.dtd-input {
  flex: 1;
  background: #f5ede4;
  border: 1.5px solid transparent;
  border-radius: 10px;
  padding: 9px 12px;
  font-family: var(--font-serif, 'BioRhyme', Georgia, serif);
  font-size: 13px;
  color: var(--brown-dark, #341d16);
  resize: none;
  outline: none;
  min-height: 38px;
  max-height: 90px;
  line-height: 1.4;
  transition: border-color 0.18s;
}
.dtd-input::placeholder { color: #a08070; }
.dtd-input:focus { border-color: var(--brown-mid, #b45d2e); }

.dtd-send {
  width: 38px;
  height: 38px;
  background: var(--brown-dark, #341d16);
  border: none;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.18s, transform 0.14s;
}
.dtd-send:hover { background: var(--brown-mid, #b45d2e); transform: translateY(-1px); }
.dtd-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.dtd-footer {
  padding: 0 14px 10px;
  font-family: var(--font-serif, 'BioRhyme', Georgia, serif);
  font-size: 10px;
  color: #a08070;
  text-align: center;
  flex-shrink: 0;
}

@media (max-width: 420px) {
  #dtd-chat-window { right: 10px; left: 10px; width: auto; bottom: 90px; }
  #dtd-chat-trigger { right: 18px; bottom: 20px; }
}
