/* CraftEngineer SmartCommerce AI — Frontend Chatbot */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

#ssai-chatbot-wrapper {
  position: fixed;
  z-index: 999999;
  font-family: 'Inter', sans-serif;
}
#ssai-chatbot-wrapper.ssai-position-bottom-right { bottom: 24px; right: 24px; }
#ssai-chatbot-wrapper.ssai-position-bottom-left  { bottom: 24px; left: 24px; }

/* Toggle Button */
#ssai-chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  transition: transform .2s, box-shadow .2s;
  position: relative;
  z-index: 1;
}
#ssai-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0,0,0,.35);
}
#ssai-chat-toggle svg { pointer-events: none; }

/* Chat Window */
#ssai-chat-window {
  width: 360px;
  height: 520px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 12px;
  animation: ssaiSlideUp .25s ease;
}
@keyframes ssaiSlideUp {
  from { opacity:0; transform: translateY(16px) scale(.97); }
  to   { opacity:1; transform: translateY(0) scale(1); }
}

/* Header */
#ssai-chat-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ssai-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ssai-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
#ssai-chat-header strong {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  display: block;
}
.ssai-status {
  color: rgba(255,255,255,.8);
  font-size: 11px;
}
.ssai-close-btn {
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}
.ssai-close-btn:hover { background: rgba(255,255,255,.35); }

/* Messages */
#ssai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8f9fb;
}
#ssai-chat-messages::-webkit-scrollbar { width: 4px; }
#ssai-chat-messages::-webkit-scrollbar-track { background: transparent; }
#ssai-chat-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

.ssai-msg { display: flex; }
.ssai-bot-msg  { justify-content: flex-start; }
.ssai-user-msg { justify-content: flex-end; }

.ssai-msg-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}
.ssai-bot-msg  .ssai-msg-bubble {
  background: #fff;
  color: #1a1a2e;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.ssai-user-msg .ssai-msg-bubble {
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.ssai-typing .ssai-msg-bubble {
  background: #fff;
  padding: 12px 16px;
}
.ssai-typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 18px;
}
.ssai-typing-dots span {
  width: 7px;
  height: 7px;
  background: #bbb;
  border-radius: 50%;
  animation: ssaiTyping 1.2s infinite;
}
.ssai-typing-dots span:nth-child(2) { animation-delay: .2s; }
.ssai-typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes ssaiTyping {
  0%,80%,100% { transform: scale(1); opacity: .5; }
  40%          { transform: scale(1.3); opacity: 1; }
}

/* Quick replies */
#ssai-quick-replies {
  padding: 8px 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: #f8f9fb;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}
.ssai-quick-btn {
  background: #fff;
  border: 1px solid #e2e2ea;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  color: #444;
  font-family: inherit;
  transition: all .2s;
}
.ssai-quick-btn:hover {
  border-color: #6366f1;
  color: #6366f1;
}

/* Input area */
#ssai-chat-input-area {
  padding: 12px 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  background: #fff;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}
#ssai-chat-input {
  flex: 1;
  border: 1px solid #e2e2ea;
  border-radius: 24px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
  background: #f8f9fb;
}
#ssai-chat-input:focus {
  border-color: #6366f1;
  background: #fff;
}
#ssai-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity .2s, transform .2s;
}
#ssai-send-btn:hover { opacity: .88; transform: scale(1.05); }
#ssai-send-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Notification dot */
.ssai-notif-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: ssaiPulse 2s infinite;
}
@keyframes ssaiPulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.2); }
}

/* Mobile */
@media (max-width: 480px) {
  #ssai-chat-window {
    width: calc(100vw - 24px);
    height: 70vh;
    border-radius: 16px;
  }
  #ssai-chatbot-wrapper.ssai-position-bottom-right { right: 12px; bottom: 12px; }
  #ssai-chatbot-wrapper.ssai-position-bottom-left  { left: 12px;  bottom: 12px; }
}

/* Frontend CPT output */
.ssai-cpt-wrapper {
  display: grid;
  gap: 24px;
  padding: 20px 0;
}
.ssai-cols-1 { grid-template-columns: 1fr; }
.ssai-cols-2 { grid-template-columns: repeat(2, 1fr); }
.ssai-cols-3 { grid-template-columns: repeat(3, 1fr); }
.ssai-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .ssai-cols-3, .ssai-cols-4 { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 480px) {
  .ssai-cols-2, .ssai-cols-3, .ssai-cols-4 { grid-template-columns: 1fr; }
}

.ssai-cpt-item {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
  transition: transform .2s, box-shadow .2s;
}
.ssai-cpt-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 24px rgba(0,0,0,.12);
}
.ssai-item-image img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}
.ssai-item-content { padding: 16px 20px; }
.ssai-item-title { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.ssai-item-title a { color: inherit; text-decoration: none; }
.ssai-item-title a:hover { color: #6366f1; }
.ssai-item-excerpt { color: #666; font-size: 14px; line-height: 1.6; margin-bottom: 12px; }
.ssai-meta { font-size: 13px; color: #888; margin-bottom: 6px; }
.ssai-meta-label { font-weight: 600; color: #555; }
.ssai-read-more {
  display: inline-block;
  padding: 8px 18px;
  background: #6366f1;
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  margin-top: 10px;
  transition: background .2s;
}
.ssai-read-more:hover { background: #4f46e5; color: #fff; }

/* Recommendations */
.ssai-recommendations {
  padding: 30px 0;
}
.ssai-rec-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
  color: #1a1a2e;
}
.ssai-rec-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
@media (max-width: 900px) { .ssai-rec-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 480px) { .ssai-rec-grid { grid-template-columns: 1fr; } }

.ssai-rec-item {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 10px;
  overflow: hidden;
  transition: box-shadow .2s;
  text-align: center;
}
.ssai-rec-item:hover { box-shadow: 0 4px 20px rgba(0,0,0,.1); }
.ssai-rec-item a { text-decoration: none; color: inherit; display: block; padding: 12px; }
.ssai-rec-item img { width: 100%; height: 160px; object-fit: cover; border-radius: 6px; }
.ssai-rec-item h4 { font-size: 13px; margin: 8px 0 4px; font-weight: 600; }
.ssai-rec-price { color: #6366f1; font-weight: 700; font-size: 14px; }
.ssai-add-cart {
  display: block;
  margin: 0 12px 12px;
  padding: 8px;
  background: #6366f1;
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}
.ssai-add-cart:hover { background: #4f46e5; color: #fff; }
