/* ============================================
   Element Chat Widget Styles
   ============================================ */

.elem-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}

.elem-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: elemMsgIn 0.35s ease-out;
}
@keyframes elemMsgIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.elem-chat-msg.user {
  align-self: flex-end;
  align-items: flex-end;
}
.elem-chat-msg.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.elem-chat-bubble {
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
}
.elem-chat-msg.user .elem-chat-bubble {
  background: var(--primary-color);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.elem-chat-msg.assistant .elem-chat-bubble {
  background: #f5f5f5;
  color: #222;
  border-bottom-left-radius: 6px;
}
.elem-chat-msg.assistant .elem-chat-bubble p { margin: 0 0 8px; }
.elem-chat-msg.assistant .elem-chat-bubble p:last-child { margin-bottom: 0; }
.elem-chat-msg.assistant .elem-chat-bubble strong { color: #111; }
.elem-chat-msg.assistant .elem-chat-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 0.85rem;
}
.elem-chat-msg.assistant .elem-chat-bubble th,
.elem-chat-msg.assistant .elem-chat-bubble td {
  border: 1px solid #ddd;
  padding: 6px 10px;
  text-align: left;
}
.elem-chat-msg.assistant .elem-chat-bubble th {
  background: #eee;
  font-weight: 600;
}

/* Think block */
.elem-chat-think {
  margin-bottom: 6px;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  font-size: 0.82rem;
}
.elem-chat-think-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 14px;
  background: #fafafa;
  border: none;
  cursor: pointer;
  color: #888;
  font-size: 0.82rem;
  text-align: left;
  transition: background 0.2s;
}
.elem-chat-think-toggle:hover { background: #f0f0f0; }
.elem-chat-think-toggle svg {
  width: 14px;
  height: 14px;
  transition: transform 0.25s;
  flex-shrink: 0;
}
.elem-chat-think.open .elem-chat-think-toggle svg {
  transform: rotate(90deg);
}
.elem-chat-think-body {
  display: none;
  padding: 10px 14px;
  color: #999;
  line-height: 1.6;
  border-top: 1px solid #e8e8e8;
  white-space: pre-wrap;
  font-style: italic;
}
.elem-chat-think.open .elem-chat-think-body { display: block; }

/* Typing indicator */
.elem-chat-typing {
  display: flex;
  gap: 5px;
  padding: 14px 18px;
  align-items: center;
}
.elem-chat-typing span {
  width: 8px; height: 8px;
  background: #bbb;
  border-radius: 50%;
  animation: elemDot 1.4s infinite ease-in-out both;
}
.elem-chat-typing span:nth-child(1) { animation-delay: -0.32s; }
.elem-chat-typing span:nth-child(2) { animation-delay: -0.16s; }
.elem-chat-typing span:nth-child(3) { animation-delay: 0s; }
@keyframes elemDot {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Input area */
.elem-chat-input-area {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid #eee;
  background: #fff;
  flex-shrink: 0;
}
.elem-chat-input {
  flex: 1;
  border: 1.5px solid #e0e0e0;
  border-radius: 24px;
  padding: 12px 20px;
  font-size: 0.95rem;
  outline: none;
  resize: none;
  font-family: inherit;
  transition: border-color 0.2s;
  max-height: 80px;
}
.elem-chat-input:focus { border-color: var(--primary-color); }
.elem-chat-send {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--primary-color);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s, opacity 0.2s;
}
.elem-chat-send:hover { transform: scale(1.05); }
.elem-chat-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.elem-chat-send svg { width: 18px; height: 18px; }

/* Product shelf */
.elem-chat-products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 10px;
  width: 100%;
}
.elem-chat-product-card {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.25s, transform 0.25s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.elem-chat-product-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}
.elem-chat-product-cover {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #f5f5f5;
}
.elem-chat-product-info {
  padding: 10px 12px;
}
.elem-chat-product-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #222;
  margin-bottom: 4px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.elem-chat-product-summary {
  font-size: 0.78rem;
  color: #888;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Empty state */
.elem-chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #aaa;
  gap: 12px;
  padding: 40px;
  text-align: center;
}
.elem-chat-empty svg { width: 48px; height: 48px; opacity: 0.4; }
.elem-chat-empty-title { font-size: 1.1rem; font-weight: 500; color: #888; }
.elem-chat-empty-hint { font-size: 0.85rem; color: #bbb; }

/* Desktop panel header */
.elem-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}
.elem-chat-header-title { font-size: 1.05rem; font-weight: 600; color: #222; display: flex; align-items: center; gap: 8px; }
.elem-chat-header-title span { font-weight: 400; font-size: 0.8rem; color: #999; background: #f5f5f5; padding: 2px 10px; border-radius: 10px; }
.elem-chat-header-clear {
  background: none; border: none; color: #aaa; font-size: 0.85rem; cursor: pointer; padding: 4px 8px;
  transition: color 0.2s;
}
.elem-chat-header-clear:hover { color: #666; }
