/* ── ALK Chatbot Widget ───────────────────────────────────────────────────── */

#alk-chatbot {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99999;
  font-family: 'Segoe UI', Arial, sans-serif;
  display: none;   /* shown by JS once chat/start fires */
}

/* ── Bubble ─────────────────────────────────────────────────────────────── */
#alk-chatbot-bubble {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  transition: transform 0.2s ease;
  position: relative;
  border: none;
  background: transparent;
  padding: 0;
}

#alk-chatbot-bubble:hover {
  transform: scale(1.08);
}

#alk-bubble-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

#alk-chatbot-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #f39c12;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: alk-pulse 1.8s infinite;
}

@keyframes alk-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.2); }
}

/* ── Panel ──────────────────────────────────────────────────────────────── */
#alk-chatbot-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 320px;
  height: 480px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

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

/* ── Header ─────────────────────────────────────────────────────────────── */
#alk-chatbot-header {
  background: #c0392b;
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

#alk-chatbot-title {
  font-weight: 700;
  font-size: 15px;
}

#alk-chatbot-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.85;
  transition: opacity 0.15s;
}
#alk-chatbot-close:hover { opacity: 1; }

/* ── Message list ───────────────────────────────────────────────────────── */
#alk-chat-messages {
  flex: 1;
  padding: 14px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.alk-message {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.45;
  word-wrap: break-word;
}

.alk-message-assistant {
  align-self: flex-start;
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}

.alk-message-user {
  align-self: flex-end;
  background: #c0392b;
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ── Product cards (shown before opening message) ───────────────────────── */
.alk-product-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.alk-product-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 10px;
  padding: 8px 10px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s, border-color 0.15s;
  overflow: hidden;
}

.alk-product-card:hover {
  border-color: #c0392b;
  box-shadow: 0 2px 10px rgba(192,57,43,0.12);
}

.alk-product-img {
  width: 52px;
  height: 68px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  background: #f5f5f5;
}

.alk-product-card-name {
  flex: 1;
  font-size: 12.5px;
  font-weight: 600;
  color: #222;
  line-height: 1.4;
  direction: rtl;
  text-align: right;
}

/* ── Product links inside messages ─────────────────────────────────────── */
.alk-msg-link {
  display: block;
  margin-top: 7px;
  padding: 7px 12px;
  background: #c0392b;
  color: #fff !important;
  border-radius: 8px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  direction: rtl;
  text-align: right;
  transition: background 0.15s;
}
.alk-msg-link:hover { background: #a93226; }

/* ── Quick-reply buttons ────────────────────────────────────────────────── */
.alk-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 4px;
  justify-content: flex-end;
}

.alk-qr-btn {
  background: #fff8f8;
  color: #c0392b;
  border: 1.5px solid #e8a89e;
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.alk-qr-btn:hover {
  background: #c0392b;
  border-color: #c0392b;
  color: #fff;
}

/* ── Conversation end note ──────────────────────────────────────────────── */
.alk-end-note {
  text-align: center;
  font-size: 11px;
  color: #b0b0b0;
  margin: 10px 14px 4px;
  padding-top: 8px;
  border-top: 1px dashed #e8e8e8;
}

#alk-chat-input:disabled,
#alk-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Typing indicator ───────────────────────────────────────────────────── */
#alk-chat-typing {
  padding: 0 14px 10px;
  display: flex;
  gap: 4px;
  color: #94a3b8;
}

#alk-chat-typing span {
  font-size: 20px;
  line-height: 1;
  animation: alk-blink 1.4s infinite both;
}
#alk-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
#alk-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes alk-blink {
  0%   { opacity: 0.2; }
  20%  { opacity: 1;   }
  100% { opacity: 0.2; }
}

/* ── Input bar ──────────────────────────────────────────────────────────── */
#alk-chat-input-container {
  padding: 10px 12px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

#alk-chat-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}
#alk-chat-input:focus { border-color: #c0392b; }

#alk-chat-send {
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
#alk-chat-send:hover { background: #a93226; }

/* ── RTL support ────────────────────────────────────────────────────────── */
[dir="rtl"] #alk-chatbot { right: auto; left: 20px; }
[dir="rtl"] #alk-chatbot-panel { right: auto; left: 0; }
