/* ==============================================================
   ASHLEY AI — wspólne style czatu
   Ładowane przez index.html oraz /shop/shop.html
   ============================================================== */

/* ---- KONTENER + AWATAR ---- */
#ashley-container {
  position: fixed; right: 20px; bottom: 20px; z-index: 9999;
  display: flex; align-items: flex-end; gap: 15px;
  transition: bottom 0.3s ease;
}
#ashley-avatar-wrap { position: relative; flex-shrink: 0; }
#ashley-avatar {
  position: relative; width: clamp(90px, 15vw, 160px); height: auto;
  cursor: pointer; transition: transform 0.3s ease; user-select: none; display: block;
}
#ashley-avatar:hover { transform: scale(1.05); }

/* ---- DYMek ---- */
#ashley-bubble {
  position: relative; width: 360px; background: rgba(1, 2, 5, 0.94);
  border: 1px solid rgba(0, 242, 254, 0.25); border-radius: 22px; padding: 16px;
  box-shadow: 0 0 40px rgba(0, 242, 254, 0.15), 0 20px 50px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  display: none; flex-shrink: 0;
  font-family: "Manrope", -apple-system, sans-serif; color: #f1f5f9;
}
#ashley-bubble.show { display: block; }

/* ---- HISTORIA CZATU ---- */
#ashley-chat-history {
  max-height: 300px; overflow-y: auto;
  padding-right: 6px; margin-bottom: 10px;
}
#ashley-chat-history::-webkit-scrollbar { width: 6px; }
#ashley-chat-history::-webkit-scrollbar-track { background: transparent; }
#ashley-chat-history::-webkit-scrollbar-thumb {
  background: rgba(0, 242, 254, 0.35); border-radius: 3px;
}

/* ---- BĄBELKI ---- */
.chat-user { text-align: right; margin-bottom: 12px; }
.chat-ai { text-align: left; margin-bottom: 12px; }
.chat-bubble-user {
  display: inline-block; background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12); color: #e5e7eb;
  padding: 9px 14px; border-radius: 18px; max-width: 85%;
  word-break: break-word; text-align: left;
}
.chat-bubble-ai {
  display: inline-block;
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.12), rgba(139, 92, 246, 0.10));
  border: 1px solid rgba(0, 242, 254, 0.25);
  padding: 10px 14px; border-radius: 22px; max-width: 85%;
  word-break: break-word;
  box-shadow: 0 4px 18px rgba(0, 242, 254, 0.12);
  line-height: 1.5; font-size: 0.92rem; color: #f1f5f9; margin: 4px 0;
}

/* ---- POLE TEKSTOWE + MIKROFON + WYŚLIJ ---- */
.ashley-input-row { display: flex; gap: 8px; align-items: stretch; }

#ashley-text {
  width: 100%; height: 78px; resize: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 12px; padding: 10px;
  box-sizing: border-box; font-size: 14px;
  font-family: "Manrope", sans-serif; color: #fff;
}
#ashley-text::placeholder { color: rgba(255, 255, 255, 0.4); }
#ashley-text:focus {
  outline: none; border-color: rgba(0, 242, 254, 0.6);
  box-shadow: 0 0 0 3px rgba(0, 242, 254, 0.15);
}

#ashley-mic {
  flex-shrink: 0; width: 44px; height: 78px; border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, border-color 0.2s;
}
#ashley-mic:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(0, 242, 254, 0.4); }
#ashley-mic svg { width: 19px; height: 19px; }
#ashley-mic.listening {
  background: rgba(255, 51, 102, 0.16);
  border-color: rgba(255, 51, 102, 0.6);
  animation: micPulse 1.4s ease-in-out infinite;
}
#ashley-mic.listening svg { color: #ff3366; }
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 51, 102, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(255, 51, 102, 0); }
}
#ashley-mic:disabled { opacity: 0.35; cursor: not-allowed; }

#ashley-send {
  width: 100%; margin-top: 10px;
  background: linear-gradient(135deg, #00f2fe, #8b5cf6);
  color: #04101c; border: none; border-radius: 12px; padding: 12px; cursor: pointer;
  font-weight: 700; font-family: "Rajdhani", sans-serif;
  letter-spacing: 0.04em; font-size: 1rem;
}
#ashley-send:hover { filter: brightness(1.1); transform: translateY(-1px); }
#ashley-send:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.ashley-voice-hint {
  font-size: 0.72rem; color: var(--text-muted, #94a3b8);
  margin-top: 6px; text-align: center;
}

/* ---- BLOKADA SCROLLA TŁA, GDY CZAT OTWARTY ---- */
body.ashley-lock, html.ashley-lock {
  overflow: hidden !important; overscroll-behavior: none;
}
body.ashley-lock #ashley-chat-history {
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
body.ashley-lock #ashley-bubble { touch-action: pan-y; }

/* ---- PODNIESIENIE AWATARA NAD BANER COOKIES (także na desktopie) ----
   Baner cookies ma z-index 10000 i leży na dole, więc zasłania
   dolną część awatara i dymka. Podnosimy kontener, gdy baner jest
   widoczny. Na mobile mamy dodatkowe reguły niżej. */
body.has-cookie-banner #ashley-container {
  bottom: 110px;
}

/* ---- MOBILE ---- */
@media (max-width: 768px) {
  #ashley-container { right: 10px; bottom: 12px; left: auto; justify-content: flex-end; }
  #ashley-avatar { width: 88px; }
  #ashley-bubble {
    position: fixed; left: 10px; right: 10px; width: auto;
    bottom: calc(110px + env(safe-area-inset-bottom, 0px));
    top: auto; max-height: min(72vh, 72dvh);
    overflow: hidden; display: none; flex-direction: column;
  }
  #ashley-bubble.show { display: flex; }
  #ashley-chat-history { max-height: none; flex: 1 1 auto; min-height: 0; }
  body.has-cookie-banner #ashley-container { bottom: 100px; }
  body.has-cookie-banner #ashley-bubble {
    bottom: calc(190px + env(safe-area-inset-bottom, 0px));
  }
}