/* MATYLA DESIGN ASSISTANT — premium noir glass */

:root {
  --bg: #0a0a0a;
  --fg: #ffffff;
  --muted: rgba(255,255,255,.6);
  --glass: rgba(12,12,12,.7);
  --accent: #f25623; /* pomarańcz Matyla */
  --radius-lg: 20px;
  --radius-md: 14px;
  --blur: 18px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html, body { overflow-x: hidden !important; }

/* Uwaga: NIE zmieniamy tła body witryny! */

/* ============= floating bubble ============= */
.chat-bubble {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 82px;
  height: 82px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.9);
  color: #fff;
  font-weight: 800;
  font-size: 26px;
  letter-spacing: .5px;
  cursor: pointer;
  user-select: none;
  z-index: 2147483000;
  backdrop-filter: blur(8px);
  box-shadow:
    0 0 38px rgba(242,86,35,.55),
    0 0 120px rgba(242,86,35,.25),
    inset 0 0 10px rgba(255,255,255,.08);
  transition: transform .35s ease, box-shadow .35s ease;
  outline: none;
  border: 1px solid rgba(255,255,255,.06);
  opacity: 0;
  transform: scale(.9);
  animation: chatFadeIn 1.2s ease forwards 1.8s;
}
@keyframes chatFadeIn {
  to { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion:no-preference) {
  .chat-bubble { animation: levitate 4.5s ease-in-out infinite, chatFadeIn 1.2s ease forwards 1.8s; }
}
.chat-bubble:hover {
  transform: translateY(-4px) scale(1.04);
  box-shadow:
    0 0 45px rgba(242,86,35,.75),
    0 0 120px rgba(242,86,35,.35),
    inset 0 0 12px rgba(255,255,255,.10);
}
@keyframes levitate {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ============= chat window ============= */
.chat-window {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: calc(110px + env(safe-area-inset-bottom));
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--glass);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(var(--blur));
  border: 1px solid rgba(255,255,255,.06);
  box-shadow:
    0 0 28px rgba(242,86,35,.22),
    0 0 70px rgba(242,86,35,.10),
    0 12px 60px rgba(0,0,0,.55);
  opacity: 0;
  transform: translateY(12px) scale(.98);
  pointer-events: none;
  transition: opacity .35s ease, transform .35s ease;
  z-index: 2147482999;
}
.chat-window.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* subtelna aureola dookoła całego okna */
.chat-window::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: radial-gradient(65% 55% at 50% 0%, rgba(242,86,35,.22), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ===== header ===== */
.chat-header {
  position: relative;
  z-index: 1;
  padding: 14px 16px;
  background: linear-gradient(180deg, #ff6a3a, var(--accent));
  color: #fff;
  font-weight: 700;
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-title { font-size: 15px; }
.chat-close {
  appearance: none;
  border: 0;
  background: rgba(0,0,0,.18);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chat-close:hover { background: rgba(0,0,0,.28); }

/* ===== messages area ===== */
.chat-messages {
  position: relative;
  z-index: 1;
  flex: 1;
  padding: 18px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.15);
  border-radius: 10px;
}

/* message bubbles */
.msg {
  max-width: 80%;
  padding: 10px 14px;
  line-height: 1.55;
  font-size: 14px;
  border-radius: 14px;
  word-wrap: break-word;
  box-shadow: 0 3px 18px rgba(0,0,0,.28);
}
.msg strong { color: #fff; font-weight: 700; }
.msg.bot {
  align-self: flex-start;
  color: #fff;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.06);
  backdrop-filter: blur(6px);
}
.msg.user {
  align-self: flex-end;
  color: #fff;
  background: radial-gradient(120% 120% at 100% 0%, #ff6f40 0%, var(--accent) 65%, #e64a1f 100%);
  box-shadow: 0 0 18px rgba(242,86,35,.36);
}

/* avatar (M) w wątku bota – opcjonalny */
.msg-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #111;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: 0 0 10px rgba(242,86,35,.15);
}

/* KLIKALNY NUMER TELEFONU (dla przyszłej logiki) */
.msg-row a.phone-btn {
  display: inline-flex;
  padding: 6px 10px;
  margin-top: 6px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  font-weight: 600;
  transition: background-color 0.2s;
}
.msg-row a.phone-btn:hover {
  background: #ff6a3a;
}

/* ===== TYPING INDICATOR ===== */
.typing-bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 60px;
  height: 30px;
  border-radius: 14px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 10px rgba(255,255,255,0.05),
              0 0 8px rgba(242,86,35,0.3);
  backdrop-filter: blur(6px);
  animation: bubblePulse 1.8s infinite ease-in-out;
}
.typing-bubble .dot {
  width: 7px;
  height: 7px;
  background-color: var(--accent);
  border-radius: 50%;
  animation: dotPulse 1s infinite ease-in-out;
  opacity: 0.4;
}
.typing-bubble .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}
@keyframes bubblePulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 8px rgba(242,86,35,0.2); }
  50% { transform: scale(1.03); box-shadow: 0 0 14px rgba(242,86,35,0.4); }
}

/* ===== input row ===== */
.chat-input {
  display: flex;
  gap: 8px;
  padding: 12px 12px 14px;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255,255,255,.06);
}
.chat-input input {
  flex: 1;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.06);
  color: #fff;
  outline: none;
  padding: 0 12px;
  font-size: 14px;
}
.chat-input input::placeholder { color: var(--muted); }
.chat-input button {
  height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(242,86,35,.35);
  transition: transform .15s ease, box-shadow .25s ease, background .25s ease;
}
.chat-input button:hover {
  transform: translateY(-1px);
  background: #ff6a3a;
  box-shadow: 0 0 16px rgba(242,86,35,.45);
}

/* ===== mobile ===== */
@media (max-width: 520px) {
  .chat-window {
    right: 12px;
    bottom: calc(90px + env(safe-area-inset-bottom));
    width: calc(100vw - 24px);
    height: min(78vh, 640px);
  }
  .chat-bubble {
    right: 12px;
    bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .chat-input input,
  .chat-input button {
    height: 46px;
  }
}

/* --- FORMULARZ ZGODY & CHECKBOX --- */
.chat-input-area-wrapper { position: relative; z-index: 10; }
.chat-consent-form {
  display: none;
  flex-direction: column;
  padding: 15px;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255,255,255,.06);
  gap: 12px;
  position: absolute;
  bottom: 0; left: 0; right: 0;
  width: 100%;
}
.chat-consent-form .form-title {
  color: var(--fg);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}
.chat-consent-form input[type="text"],
.chat-consent-form input[type="email"],
.chat-consent-form input[type="tel"] {
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.06);
  color: var(--fg);
  outline: none;
  padding: 0 12px;
  font-size: 14px;
}
.chat-consent-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.chat-consent-form input::placeholder { color: var(--muted); }
.chat-consent-form button {
  height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
  font-weight: 700;
  color: var(--fg);
  background: var(--accent);
  box-shadow: 0 0 10px rgba(242,86,35,.35);
  transition: transform .15s ease, box-shadow .25s ease, background .25s ease;
}
.chat-consent-form button:hover {
  background: #ff6a3a;
  box-shadow: 0 0 16px rgba(242,86,35,.45);
}

.consent-checkbox-container {
  display: flex;
  align-items: flex-start;
  position: relative;
  padding-left: 28px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  user-select: none;
  line-height: 18px;
  min-height: 18px;
}
.consent-checkbox-container input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0; width: 0;
}
.checkmark {
  position: absolute;
  top: 0px; left: 0;
  height: 16px; width: 16px;
  background-color: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 4px;
  transition: all 0.2s;
}
.consent-checkbox-container:hover input:not(:checked) ~ .checkmark {
  background-color: rgba(255,255,255,.12);
}
.consent-checkbox-container input:checked ~ .checkmark {
  background-color: var(--accent);
  border-color: var(--accent);
}
.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}
.consent-checkbox-container input:checked ~ .checkmark:after {
  display: block;
  left: 5px; top: 2px;
  width: 4px; height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
/* --- Dymek mniejszy na mobile --- */
@media (max-width: 520px) {
.chat-bubble {
width: 54px !important;
height: 54px !important;
font-size: 20px !important;
}
} 

/* === MOBILE FIX: blokada zoomu i stabilna pozycja chata === */
@media screen and (max-width: 800px) {
/* zapobiega auto-zoomowi Safari / Chrome */
input,
textarea,
select,
button {
font-size: 16px !important;
-webkit-text-size-adjust: 100%;
touch-action: manipulation;
}

/* utrzymanie stałej pozycji */
.chat-window {
position: fixed !important;
bottom: 0 !important;
left: 50% !important;
transform: translateX(-50%) !important;
width: 90vw !important;
max-width: 420px !important;
max-height: 90vh !important;
overflow: hidden !important;
height: auto !important;
}
}

/* === Dymek M — poprawka pozycji względem okna === */

/* pozycja początkowa (gdy chat zamknięty) */
.chat-bubble {
position: fixed;
bottom: 20px;
right: 20px;
z-index: 999999; /* nad wszystkim */
transition: all 0.3s ease;
}

/* gdy chat się otwiera — chowamy bąbelek pod oknem */
.chat-window.active ~ .chat-bubble,
.chat-window.open ~ .chat-bubble {
opacity: 0;
pointer-events: none;
transform: translateY(30px);
}

/* gdy chat zamknięty — pokazujemy bąbelek z powrotem */
.chat-window:not(.active):not(.open) ~ .chat-bubble {
opacity: 1;
pointer-events: auto;
transform: translateY(0);
}

/* === DODANE: klasa blokująca scroll tylko przy otwartym czacie === */
body.chat-locked {
  position: fixed;
  width: 100%;
  overflow: hidden;
}

/* === OSTATECZNA BLOKADA HOVERA DLA BĄBELKA === */
.chat-bubble,
.chat-bubble:hover,
.chat-bubble:focus,
.chat-bubble:active {
  animation: none !important;
  transform: none !important;
  transition: none !important;
  box-shadow:
    0 0 38px rgba(242,86,35,.55),
    0 0 120px rgba(242,86,35,.25),
    inset 0 0 10px rgba(255,255,255,.08) !important;
  opacity: 1 !important;
  filter: none !important;
  background: rgba(0, 0, 0, .9) !important;
  cursor: pointer !important;
}

/* Całkowite wyłączenie reakcji hover na literce (tylko klik działa) */
.chat-bubble * {
  pointer-events: none !important;
}

