/* ─── AIStackCreator Chat Widget ────────────────────────────────────── */

/* Floating trigger button */
#asc-chat-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9000;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2d1b69 0%, #3d2b7a 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(45, 27, 105, 0.4), 0 2px 8px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

#asc-chat-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(45, 27, 105, 0.5), 0 3px 12px rgba(0,0,0,0.18);
}

#asc-chat-trigger:active {
  transform: scale(0.97);
}

#asc-chat-trigger svg {
  width: 26px;
  height: 26px;
  fill: white;
  transition: opacity 0.15s;
}

#asc-chat-trigger .asc-icon-open { display: flex; }
#asc-chat-trigger .asc-icon-close { display: none; }
#asc-chat-trigger.open .asc-icon-open { display: none; }
#asc-chat-trigger.open .asc-icon-close { display: flex; }

/* Unread badge */
.asc-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  background: #d4910a;
  border-radius: 50%;
  border: 2px solid white;
  display: none;
}
.asc-chat-badge.visible { display: block; }

/* Chat panel */
#asc-chat-panel {
  position: fixed;
  bottom: 96px;
  right: 28px;
  z-index: 8999;
  width: 380px;
  max-height: 560px;
  min-height: 440px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow:
    0 20px 60px rgba(45, 27, 105, 0.18),
    0 4px 20px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(45, 27, 105, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

/* Panel header */
.asc-chat-header {
  padding: 16px 18px 14px;
  background: linear-gradient(135deg, #2d1b69 0%, #3d2b7a 100%);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.asc-chat-header-icon {
  width: 34px;
  height: 34px;
  background: rgba(255,255,255,0.12);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.asc-chat-header-icon svg {
  width: 18px;
  height: 18px;
  fill: #f7c948;
}

.asc-chat-header-text {
  flex: 1;
  min-width: 0;
}

.asc-chat-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  color: white;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.asc-chat-subtitle {
  font-size: 0.73rem;
  color: rgba(255,255,255,0.6);
  margin-top: 1px;
}

.asc-chat-header-close {
  background: rgba(255,255,255,0.1);
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.asc-chat-header-close:hover { background: rgba(255,255,255,0.2); }

.asc-chat-header-close svg {
  width: 15px;
  height: 15px;
  stroke: rgba(255,255,255,0.8);
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
}

/* Messages area */
.asc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: #faf8f5;
}

.asc-chat-messages::-webkit-scrollbar { width: 4px; }
.asc-chat-messages::-webkit-scrollbar-track { background: transparent; }
.asc-chat-messages::-webkit-scrollbar-thumb { background: #e8e4f0; border-radius: 4px; }

/* Message bubbles */
.asc-msg {
  max-width: 88%;
  animation: ascFadeIn 0.18s ease;
}

@keyframes ascFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.asc-msg-ai {
  align-self: flex-start;
}

.asc-msg-user {
  align-self: flex-end;
}

.asc-msg-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.55;
  word-wrap: break-word;
}

.asc-msg-ai .asc-msg-bubble {
  background: white;
  color: #1a1a2e;
  border-radius: 4px 14px 14px 14px;
  box-shadow: 0 1px 6px rgba(45, 27, 105, 0.08), 0 0 0 1px rgba(45, 27, 105, 0.05);
}

.asc-msg-user .asc-msg-bubble {
  background: linear-gradient(135deg, #2d1b69 0%, #3d2b7a 100%);
  color: white;
  border-radius: 14px 4px 14px 14px;
}

/* Typing indicator */
.asc-typing {
  align-self: flex-start;
}

.asc-typing-dots {
  background: white;
  border-radius: 4px 14px 14px 14px;
  box-shadow: 0 1px 6px rgba(45, 27, 105, 0.08);
  padding: 12px 16px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.asc-typing-dots span {
  width: 6px;
  height: 6px;
  background: #c8c4d4;
  border-radius: 50%;
  animation: ascBounce 1.2s ease-in-out infinite;
}

.asc-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.asc-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

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

/* Suggestion chips */
.asc-suggestions {
  padding: 0 16px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: #faf8f5;
  flex-shrink: 0;
}

.asc-chip {
  background: white;
  border: 1px solid #e8e4f0;
  color: #3d2b7a;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.76rem;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  line-height: 1.4;
  white-space: normal;
  text-align: left;
}

.asc-chip:hover {
  background: #f0ecf8;
  border-color: #c8c0e0;
  transform: translateY(-1px);
}

.asc-chip:active { transform: translateY(0); }

/* Input area */
.asc-chat-input-area {
  padding: 10px 14px 14px;
  background: white;
  border-top: 1px solid rgba(45, 27, 105, 0.07);
  flex-shrink: 0;
}

.asc-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.asc-chat-input {
  flex: 1;
  border: 1.5px solid #e8e4f0;
  border-radius: 12px;
  padding: 9px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  color: #1a1a2e;
  background: #faf8f5;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.5;
  min-height: 38px;
  max-height: 100px;
  overflow-y: auto;
}

.asc-chat-input:focus { border-color: #3d2b7a; background: white; }
.asc-chat-input::placeholder { color: #a09ab8; }

.asc-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2d1b69 0%, #3d2b7a 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s;
}

.asc-send-btn:hover { opacity: 0.9; transform: scale(1.05); }
.asc-send-btn:active { transform: scale(0.96); }
.asc-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.asc-send-btn svg {
  width: 17px;
  height: 17px;
  fill: white;
}

.asc-input-hint {
  font-size: 0.7rem;
  color: #a09ab8;
  text-align: center;
  margin-top: 6px;
}

/* Mobile */
@media (max-width: 480px) {
  #asc-chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 72vh;
    border-radius: 20px 20px 0 0;
  }

  #asc-chat-trigger {
    bottom: 20px;
    right: 20px;
  }
}
