@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=Playfair+Display:wght@600&display=swap');

:root {
  --ai-red:    #E8271A;
  --ai-dark:   #111111;
  --ai-card:   #1A1A1A;
  --ai-border: rgba(255,255,255,0.09);
  --ai-text:   #F0F0F0;
  --ai-muted:  rgba(255,255,255,0.45);
  --ai-radius: 16px;
  --ai-shadow: 0 24px 80px rgba(0,0,0,0.55), 0 8px 24px rgba(0,0,0,0.35);
}

#alefba-ai-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9998;
  height: 52px;
  padding: 0 20px 0 8px;
  border-radius: 30px;
  background: var(--ai-dark);
  border: 1px solid rgba(232,39,26,0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(232,39,26,0.2);
  transition: transform 0.3s cubic-bezier(.34,1.56,.64,1), box-shadow 0.3s, background 0.3s;
  animation: ai-pulse 3s ease-in-out infinite;
  white-space: nowrap;
}

#alefba-ai-trigger:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow: 0 12px 40px rgba(232,39,26,0.4), 0 0 0 1px rgba(232,39,26,0.5);
  background: #1a1a1a;
}

#alefba-ai-trigger.open { animation: none; background: var(--ai-red); border-color: var(--ai-red); }

.ai-trigger-logo {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #ffffff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  transition: background 0.3s;
}

#alefba-ai-trigger.open .ai-trigger-logo { background: #ffffff; }

.ai-trigger-logo img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.ai-trigger-logo {
  box-shadow: inset 0 0 0 1px rgba(17,17,17,0.08);
}

.ai-trigger-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}

.ai-trigger-label-top {
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  font-family: 'DM Sans', sans-serif;
}

.ai-trigger-label-main {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ai-trigger-label-main span {
  color: var(--ai-red);
  font-style: italic;
}

#alefba-ai-trigger.open .ai-trigger-label-top { color: rgba(255,255,255,0.7); }
#alefba-ai-trigger.open .ai-trigger-label-main span { color: rgba(255,255,255,0.9); }

.ai-icon-close-x {
  display: none;
  color: #fff;
  font-size: 18px;
  margin-left: 4px;
}
#alefba-ai-trigger.open .ai-icon-close-x { display: block; }
#alefba-ai-trigger.open .ai-trigger-label { display: none; }
#alefba-ai-trigger.open { padding: 0 16px; gap: 8px; }

@keyframes ai-pulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(232,39,26,0.45); }
  50%       { box-shadow: 0 8px 48px rgba(232,39,26,0.7), 0 0 0 12px rgba(232,39,26,0.08); }
}

.ai-img-btn {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--ai-border);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--ai-muted);
  font-size: 17px;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}
.ai-img-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.ai-img-btn input { display: none; }

.ai-img-preview {
  padding: 8px 16px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-img-thumb {
  position: relative;
  width: 64px; height: 64px;
}

.ai-img-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--ai-border);
}

.ai-img-thumb-del {
  position: absolute;
  top: -5px; right: -5px;
  width: 18px; height: 18px;
  background: var(--ai-red);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

.ai-bubble img.ai-chat-img {
  max-width: 200px;
  border-radius: 8px;
  margin-top: 6px;
  display: block;
}

#alefba-ai-window {
  position: fixed;
  bottom: 104px;
  right: 28px;
  z-index: 9999;
  width: 380px;
  max-height: 580px;
  background: var(--ai-dark);
  border-radius: var(--ai-radius);
  box-shadow: var(--ai-shadow);
  border: 1px solid var(--ai-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'DM Sans', sans-serif;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(.4,0,.2,1), transform 0.3s cubic-bezier(.34,1.2,.64,1);
  transform-origin: bottom right;
}

#alefba-ai-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

.ai-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  background: var(--ai-card);
  border-bottom: 1px solid var(--ai-border);
  flex-shrink: 0;
}

.ai-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ai-red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}

.ai-avatar::after {
  content: '';
  position: absolute;
  bottom: 1px; right: 1px;
  width: 10px; height: 10px;
  background: #2ECC71;
  border-radius: 50%;
  border: 2px solid var(--ai-dark);
}

.ai-header-info { flex: 1; }

.ai-header-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ai-text);
  line-height: 1;
  margin-bottom: 3px;
}

.ai-header-status {
  font-size: 11px;
  color: #2ECC71;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-header-status::before {
  content: '';
  width: 6px; height: 6px;
  background: #2ECC71;
  border-radius: 50%;
  animation: ai-blink 1.5s ease-in-out infinite;
}

@keyframes ai-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

.ai-header-actions { display: flex; gap: 8px; }

.ai-btn-icon {
  width: 30px; height: 30px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--ai-border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--ai-muted);
  transition: background 0.2s, color 0.2s;
  font-size: 14px;
}

.ai-btn-icon:hover { background: rgba(255,255,255,0.12); color: #fff; }

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.ai-messages::-webkit-scrollbar { width: 4px; }
.ai-messages::-webkit-scrollbar-track { background: transparent; }
.ai-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.ai-msg {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  animation: ai-msg-in 0.3s cubic-bezier(.34,1.2,.64,1) both;
}

@keyframes ai-msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-msg.user { flex-direction: row-reverse; }

.ai-msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--ai-red);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.ai-msg.user .ai-msg-avatar { background: rgba(255,255,255,0.12); }

.ai-bubble {
  max-width: 78%;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ai-text);
}

.ai-msg.bot .ai-bubble {
  background: var(--ai-card);
  border: 1px solid var(--ai-border);
  border-bottom-left-radius: 4px;
}

.ai-msg.user .ai-bubble {
  background: var(--ai-red);
  border-bottom-right-radius: 4px;
  color: #fff;
}

.ai-time {
  font-size: 10px;
  color: var(--ai-muted);
  margin-top: 4px;
  text-align: center;
  width: 100%;
}

.ai-typing {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.ai-typing-dots {
  background: var(--ai-card);
  border: 1px solid var(--ai-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.ai-typing-dots span {
  width: 7px; height: 7px;
  background: rgba(255,255,255,0.3);
  border-radius: 50%;
  animation: ai-dot 1.2s ease-in-out infinite;
}

.ai-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-dot {
  0%, 60%, 100% { transform: translateY(0); background: rgba(255,255,255,0.2); }
  30%            { transform: translateY(-6px); background: var(--ai-red); }
}

.ai-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 4px 0 8px;
}

.ai-quick-btn {
  background: rgba(232,39,26,0.1);
  border: 1px solid rgba(232,39,26,0.3);
  color: #ff6b60;
  padding: 6px 13px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
}

.ai-quick-btn:hover {
  background: var(--ai-red);
  color: #fff;
  border-color: var(--ai-red);
}

.ai-product-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--ai-border);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 8px;
  transition: border-color 0.2s;
}

.ai-product-card:hover { border-color: var(--ai-red); }

.ai-product-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
}

.ai-product-card-body { padding: 10px 12px; }

.ai-product-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ai-text);
  margin-bottom: 4px;
}

.ai-product-price {
  font-size: 14px;
  color: var(--ai-red);
  font-weight: 700;
  margin-bottom: 8px;
}

.ai-product-add {
  width: 100%;
  background: var(--ai-red);
  color: #fff;
  border: none;
  padding: 8px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.2s;
}

.ai-product-add:hover { background: #c41f14; }
.ai-product-add:disabled { background: #2ECC71; cursor: default; }

.ai-input-area {
  padding: 14px 16px;
  background: var(--ai-card);
  border-top: 1px solid var(--ai-border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
}

.ai-input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--ai-border);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--ai-text);
  font-size: 13.5px;
  font-family: 'DM Sans', sans-serif;
  resize: none;
  outline: none;
  min-height: 42px;
  max-height: 100px;
  line-height: 1.5;
  transition: border-color 0.2s;
}

.ai-input:focus { border-color: rgba(232,39,26,0.5); }
.ai-input::placeholder { color: var(--ai-muted); }

.ai-send {
  width: 42px; height: 42px;
  background: var(--ai-red);
  border: none;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}

.ai-send:hover { background: #c41f14; transform: scale(1.05); }
.ai-send:active { transform: scale(0.95); }
.ai-send svg { width: 18px; height: 18px; fill: #fff; }
.ai-send:disabled { background: rgba(255,255,255,0.1); cursor: not-allowed; transform: none; }

.ai-powered {
  text-align: center;
  font-size: 10px;
  color: rgba(255,255,255,0.18);
  padding: 6px;
  background: var(--ai-card);
  border-top: 1px solid var(--ai-border);
  letter-spacing: 0.5px;
}

@media (max-width: 480px) {
  #alefba-ai-window {
    right: 12px; left: 12px;
    width: auto;
    bottom: 96px;
  }
  #alefba-ai-trigger { right: 16px; bottom: 20px; }
}

/* Dedicated page mode: https://chat.alefba.eu */
body.alefba-chat-standalone {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(232,39,26,0.10), transparent 32rem),
    #0d0d0d;
  overflow: hidden;
}

body.alefba-chat-standalone #alefba-ai-trigger {
  display: none;
}

body.alefba-chat-standalone #alefba-ai-window {
  position: fixed;
  inset: 24px;
  width: auto;
  max-height: none;
  border-radius: 20px;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

body.alefba-chat-standalone .ai-messages {
  min-height: 0;
}

@media (max-width: 680px) {
  body.alefba-chat-standalone #alefba-ai-window {
    inset: 0;
    border-radius: 0;
    border: 0;
  }
}

