/* ========================================================
   NajwyzszyZwrot.pl - Chat AI widget
   Asystent w prawym dolnym rogu. Jasny panel, brand niebieski
   #0052FF / pomaranczowy #FF6B35, akcent flagi NL. Typewriter.
   Prefix klas: nzc-  (NajwyzszyZwrot Chat)
   ======================================================== */

:root {
  --nzc-primary: #0052FF;
  --nzc-primary-dark: #003BB3;
  --nzc-accent: #FF6B35;
  --nzc-success: #00C896;
  --nzc-ink: #0A1628;
  --nzc-gray-700: #374151;
  --nzc-gray-500: #6B7280;
  --nzc-gray-100: #F3F4F6;
  --nzc-soft: #EEF3FF;
}

/* ============ FAB ============ */
.nzc-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0052FF 0%, #003BB3 100%);
  border: none;
  cursor: pointer;
  z-index: 9998;
  box-shadow: 0 8px 26px rgba(0, 82, 255, 0.42), 0 0 0 0 rgba(0, 82, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  animation: nzc-pulse 2.6s ease-out infinite;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  padding: 0;
}
.nzc-fab:hover {
  transform: scale(1.07) rotate(-4deg);
  animation-play-state: paused;
  box-shadow: 0 12px 34px rgba(0, 82, 255, 0.55);
}
.nzc-fab:active { transform: scale(0.95); }
.nzc-fab svg { width: 30px; height: 30px; }
.nzc-fab-dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--nzc-success);
  box-shadow: 0 0 8px var(--nzc-success), 0 0 0 2px #fff;
}

@keyframes nzc-pulse {
  0%   { box-shadow: 0 8px 26px rgba(0,82,255,0.42), 0 0 0 0 rgba(0,82,255,0.55); }
  70%  { box-shadow: 0 8px 26px rgba(0,82,255,0.42), 0 0 0 18px rgba(0,82,255,0); }
  100% { box-shadow: 0 8px 26px rgba(0,82,255,0.42), 0 0 0 0 rgba(0,82,255,0); }
}

/* ============ Tooltip ============ */
.nzc-tooltip {
  position: fixed;
  right: 98px;
  bottom: 36px;
  background: #fff;
  color: var(--nzc-ink);
  padding: 12px 16px;
  border-radius: 14px 14px 4px 14px;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 500;
  max-width: 240px;
  line-height: 1.45;
  box-shadow: 0 10px 30px rgba(10, 22, 40, 0.18), 0 0 0 1px rgba(0, 82, 255, 0.12);
  z-index: 9997;
  opacity: 0;
  transform: translateX(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}
.nzc-tooltip.visible { opacity: 1; transform: translateX(0); pointer-events: auto; }
.nzc-tooltip::after {
  content: '';
  position: absolute;
  right: -7px; top: 60%;
  transform: translateY(-50%);
  border: 7px solid transparent;
  border-left-color: #fff;
}
.nzc-tooltip strong { color: var(--nzc-primary); font-weight: 700; }
.nzc-tt-close {
  display: inline-block;
  margin-left: 8px;
  opacity: 0.45;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}
.nzc-tt-close:hover { opacity: 1; }

/* ============ Panel ============ */
.nzc-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 400px;
  height: min(640px, calc(100vh - 48px));
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 28px 70px rgba(10, 22, 40, 0.28), 0 0 0 1px rgba(10, 22, 40, 0.06);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--nzc-ink);
  transform-origin: bottom right;
  animation: nzc-panel-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.nzc-panel.open { display: flex; }

@keyframes nzc-panel-in {
  from { opacity: 0; transform: scale(0.9) translateY(18px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ============ Header ============ */
.nzc-header {
  position: relative;
  z-index: 2;
  padding: 15px 16px;
  background: linear-gradient(135deg, #0052FF 0%, #003BB3 100%);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.nzc-header-avatar {
  width: 40px; height: 40px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.16);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.nzc-header-avatar svg { width: 26px; height: 26px; display: block; }
.nzc-header-info { flex: 1; min-width: 0; }
.nzc-header-info .nzc-name {
  font-size: 14.5px; font-weight: 700; letter-spacing: 0.2px; color: #fff;
}
.nzc-header-info .nzc-status {
  font-size: 11.5px; color: rgba(255, 255, 255, 0.85);
  display: flex; align-items: center; gap: 6px; margin-top: 2px; font-weight: 500;
}
.nzc-header-info .nzc-status::before {
  content: '';
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--nzc-success);
  box-shadow: 0 0 6px var(--nzc-success);
  animation: nzc-blink 2s ease-in-out infinite;
}
@keyframes nzc-blink { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.nzc-header-close {
  background: rgba(255, 255, 255, 0.14);
  border: none;
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s ease;
  padding: 0; line-height: 1;
}
.nzc-header-close:hover { background: rgba(255, 255, 255, 0.28); transform: rotate(90deg); }

/* ============ Body ============ */
.nzc-body {
  position: relative;
  z-index: 2;
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  background: #F7FAFF;
  scroll-behavior: smooth;
}
.nzc-body::-webkit-scrollbar { width: 6px; }
.nzc-body::-webkit-scrollbar-thumb { background: rgba(0, 82, 255, 0.25); border-radius: 3px; }
.nzc-body::-webkit-scrollbar-track { background: transparent; }

.nzc-msg {
  display: flex;
  margin-bottom: 13px;
  animation: nzc-msg-in 0.4s ease;
  align-items: flex-start;
  gap: 9px;
}
@keyframes nzc-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.nzc-msg.assistant { justify-content: flex-start; }
.nzc-msg.user { justify-content: flex-end; }

.nzc-msg-avatar {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0052FF, #003BB3);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.nzc-msg-avatar svg { width: 16px; height: 16px; }
.nzc-msg.user .nzc-msg-avatar { display: none; }

.nzc-msg-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.nzc-msg.assistant .nzc-msg-bubble {
  background: #fff;
  border: 1px solid rgba(10, 22, 40, 0.08);
  color: var(--nzc-ink);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(10, 22, 40, 0.04);
}
.nzc-msg.user .nzc-msg-bubble {
  background: linear-gradient(135deg, #0052FF 0%, #003BB3 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 82, 255, 0.22);
}

.nzc-msg-bubble .nzc-typing-char {
  opacity: 0;
  display: inline;
  animation: nzc-char-in 0.16s ease forwards;
}
@keyframes nzc-char-in {
  0%   { opacity: 0; filter: blur(2px); }
  100% { opacity: 1; filter: blur(0); }
}

.nzc-msg.assistant .nzc-msg-bubble a {
  color: var(--nzc-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
  word-break: break-word;
}
.nzc-msg.assistant .nzc-msg-bubble a:hover { color: var(--nzc-primary-dark); }
.nzc-msg.assistant .nzc-msg-bubble strong { color: var(--nzc-ink); font-weight: 700; }

.nzc-msg.assistant .nzc-msg-bubble.typing::after {
  content: '▍';
  display: inline-block;
  color: var(--nzc-primary);
  animation: nzc-blink 0.8s steps(2) infinite;
  margin-left: 2px;
}

/* Typing dots */
.nzc-typing {
  display: flex; gap: 4px;
  padding: 12px 15px;
  background: #fff;
  border: 1px solid rgba(10, 22, 40, 0.08);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.nzc-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--nzc-primary);
  animation: nzc-dot 1.2s ease-in-out infinite;
}
.nzc-typing span:nth-child(2) { animation-delay: 0.15s; }
.nzc-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes nzc-dot {
  0%, 100% { transform: scale(0.7); opacity: 0.4; }
  50% { transform: scale(1.15); opacity: 1; }
}

/* ============ Suggestions ============ */
.nzc-suggestions {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 2px 0 14px 37px;
  animation: nzc-msg-in 0.5s ease 0.1s both;
}
.nzc-suggestion {
  background: #fff;
  border: 1px solid rgba(0, 82, 255, 0.3);
  color: var(--nzc-primary);
  padding: 7px 13px;
  border-radius: 16px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}
.nzc-suggestion:hover {
  background: var(--nzc-primary);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 82, 255, 0.25);
}

/* ============ Welcome chips ============ */
.nzc-welcome {
  margin: 0 0 14px 37px;
  display: flex; flex-direction: column; gap: 7px;
  animation: nzc-msg-in 0.4s ease 0.15s both;
}
.nzc-welcome-chip {
  background: #fff;
  border: 1px solid rgba(0, 82, 255, 0.22);
  color: var(--nzc-ink);
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s ease;
  font-family: inherit;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 1px 2px rgba(10, 22, 40, 0.04);
}
.nzc-welcome-chip:hover {
  border-color: var(--nzc-primary);
  background: var(--nzc-soft);
  transform: translateX(2px);
}
.nzc-welcome-chip .nzc-ico { font-size: 17px; line-height: 1; }

/* ============ CTA cards ============ */
.nzc-cta-block {
  margin: 4px 0 14px 37px;
  display: grid; grid-template-columns: 1fr; gap: 8px;
  animation: nzc-msg-in 0.4s ease 0.2s both;
}
.nzc-cta-card {
  background: #fff;
  border: 1px solid rgba(10, 22, 40, 0.1);
  border-radius: 13px;
  padding: 13px 14px;
  cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  transition: all 0.2s ease;
  font-family: inherit;
  text-align: left;
  width: 100%;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 2px rgba(10, 22, 40, 0.04);
}
.nzc-cta-card:hover {
  border-color: var(--nzc-primary);
  transform: translateX(2px);
  box-shadow: 0 6px 18px rgba(0, 82, 255, 0.12);
}
.nzc-cta-card.primary {
  background: linear-gradient(135deg, #0052FF 0%, #003BB3 100%);
  border-color: transparent;
}
.nzc-cta-card.primary .nzc-cta-text .t { color: #fff; }
.nzc-cta-card.primary .nzc-cta-text .s { color: rgba(255, 255, 255, 0.85); }
.nzc-cta-card.primary .nzc-cta-icon { background: rgba(255, 255, 255, 0.18); }
.nzc-cta-icon {
  font-size: 19px;
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--nzc-soft);
  border-radius: 10px;
}
.nzc-cta-text { flex: 1; min-width: 0; }
.nzc-cta-text .t { font-weight: 700; color: var(--nzc-ink); font-size: 13.5px; }
.nzc-cta-text .s { color: var(--nzc-gray-500); font-size: 11.5px; margin-top: 2px; line-height: 1.4; }

/* ============ Lead form / questions form ============ */
.nzc-lead-form {
  margin: 4px 0 14px 37px;
  background: #fff;
  border: 1px solid rgba(0, 82, 255, 0.25);
  border-radius: 14px;
  padding: 16px;
  animation: nzc-msg-in 0.4s ease;
  box-shadow: 0 6px 20px rgba(10, 22, 40, 0.08);
}
.nzc-lead-form .nzc-lf-title { font-size: 14.5px; font-weight: 700; color: var(--nzc-ink); margin-bottom: 4px; }
.nzc-lead-form .nzc-lf-sub { font-size: 12.5px; color: var(--nzc-gray-500); margin-bottom: 14px; line-height: 1.5; }
.nzc-lead-form .nzc-lf-field { margin-bottom: 10px; }
.nzc-lead-form .nzc-lf-field label {
  display: block; font-size: 11px; letter-spacing: 0.3px;
  text-transform: uppercase; color: var(--nzc-gray-700);
  margin-bottom: 4px; font-weight: 700;
}
.nzc-lead-form .nzc-lf-field label .req { color: var(--nzc-accent); }
.nzc-lead-form .nzc-lf-field input,
.nzc-lead-form .nzc-lf-field textarea,
.nzc-lead-form .nzc-lf-field select {
  width: 100%;
  background: #F7FAFF;
  border: 1px solid rgba(10, 22, 40, 0.14);
  color: var(--nzc-ink);
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
  resize: vertical;
}
.nzc-lead-form .nzc-lf-field input:focus,
.nzc-lead-form .nzc-lf-field textarea:focus,
.nzc-lead-form .nzc-lf-field select:focus {
  border-color: var(--nzc-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 82, 255, 0.12);
}
.nzc-lead-form .nzc-lf-rodo {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 11.5px; color: var(--nzc-gray-500); line-height: 1.45;
  margin: 4px 0 8px;
}
.nzc-lead-form .nzc-lf-rodo input { width: 15px; height: 15px; margin-top: 1px; accent-color: var(--nzc-primary); flex-shrink: 0; cursor: pointer; }
.nzc-lead-form .nzc-lf-rodo a { color: var(--nzc-primary); }
.nzc-lead-form .nzc-lf-submit {
  width: 100%;
  background: linear-gradient(135deg, #0052FF 0%, #003BB3 100%);
  color: #fff;
  border: none;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
  transition: all 0.2s ease;
  font-family: inherit;
  box-shadow: 0 6px 16px rgba(0, 82, 255, 0.28);
}
.nzc-lead-form .nzc-lf-submit:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(0, 82, 255, 0.4); }
.nzc-lead-form .nzc-lf-submit:disabled { opacity: 0.6; cursor: wait; }
.nzc-lead-form .nzc-lf-status { margin-top: 8px; font-size: 12px; min-height: 14px; }
.nzc-lead-form .nzc-lf-status.err { color: #DC2626; }

.nzc-lead-form .nzc-lf-success { text-align: center; padding: 8px 4px; }
.nzc-lead-form .nzc-lf-success-icon {
  width: 48px; height: 48px; line-height: 48px;
  background: linear-gradient(135deg, var(--nzc-success), #00A578);
  color: #fff; font-size: 26px; border-radius: 50%;
  margin: 0 auto 10px;
  box-shadow: 0 6px 16px rgba(0, 200, 150, 0.35);
}
.nzc-lead-form .nzc-lf-success-title { font-size: 15px; font-weight: 700; color: var(--nzc-ink); margin-bottom: 6px; }
.nzc-lead-form .nzc-lf-success-sub { font-size: 12.5px; color: var(--nzc-gray-700); line-height: 1.5; }

/* radio dla questions form */
.nzc-qf-radio-group { display: flex; flex-direction: column; gap: 6px; }
.nzc-qf-radio {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  background: #F7FAFF;
  border: 1px solid rgba(10, 22, 40, 0.12);
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 13px;
  color: var(--nzc-ink);
}
.nzc-qf-radio:hover { background: var(--nzc-soft); border-color: rgba(0, 82, 255, 0.4); }
.nzc-qf-radio input[type="radio"] { width: 15px; height: 15px; accent-color: var(--nzc-primary); margin: 0; cursor: pointer; flex-shrink: 0; }
.nzc-qf-radio:has(input:checked) { background: var(--nzc-soft); border-color: var(--nzc-primary); font-weight: 600; }
.nzc-qf-radio span { flex: 1; }

/* ============ Input bar ============ */
.nzc-input-wrap {
  position: relative;
  z-index: 2;
  padding: 12px 14px 12px;
  border-top: 1px solid rgba(10, 22, 40, 0.07);
  background: #fff;
  flex-shrink: 0;
}
.nzc-input-row { display: flex; gap: 8px; align-items: flex-end; }
.nzc-input {
  flex: 1;
  background: #F7FAFF;
  border: 1px solid rgba(10, 22, 40, 0.12);
  color: var(--nzc-ink);
  padding: 11px 14px;
  border-radius: 22px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 100px;
  min-height: 44px;
  transition: all 0.2s ease;
  line-height: 1.4;
}
.nzc-input:focus { border-color: var(--nzc-primary); background: #fff; box-shadow: 0 0 0 3px rgba(0, 82, 255, 0.1); }
.nzc-input::placeholder { color: var(--nzc-gray-500); }
.nzc-send {
  background: linear-gradient(135deg, #0052FF 0%, #003BB3 100%);
  border: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 82, 255, 0.3);
}
.nzc-send:hover:not(:disabled) { transform: scale(1.05); box-shadow: 0 6px 16px rgba(0, 82, 255, 0.45); }
.nzc-send:active { transform: scale(0.95); }
.nzc-send:disabled { opacity: 0.4; cursor: not-allowed; }

.nzc-input-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px;
  font-size: 10px;
  color: var(--nzc-gray-500);
}
.nzc-input-meta .nzc-clear-btn {
  background: none; border: none; color: var(--nzc-gray-500);
  cursor: pointer; font-size: 10px; padding: 2px 6px; border-radius: 4px; font-family: inherit;
}
.nzc-input-meta .nzc-clear-btn:hover { color: var(--nzc-primary); }
.nzc-input-meta .nzc-powered strong { color: var(--nzc-primary); font-weight: 700; }

/* Limit + error */
.nzc-limit-warn {
  background: #FFF7ED;
  border: 1px solid #FED7AA;
  color: #B45309;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 12px;
  margin: 0 16px 14px 37px;
  line-height: 1.5;
}
.nzc-limit-warn a { color: var(--nzc-primary); font-weight: 600; }
.nzc-msg.error .nzc-msg-bubble {
  background: #FEF2F2;
  border-color: rgba(220, 38, 38, 0.3);
  color: #B91C1C;
}

/* ============ Mobile - full screen ============ */
@media (max-width: 560px) {
  .nzc-fab { width: 56px; height: 56px; right: 16px; bottom: 16px; }
  .nzc-fab svg { width: 27px; height: 27px; }
  .nzc-tooltip { right: 80px; bottom: 26px; font-size: 13px; padding: 10px 14px; max-width: 200px; }
  .nzc-panel {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    right: 0; bottom: 0;
    border-radius: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nzc-fab { animation: none; }
  .nzc-msg, .nzc-suggestions, .nzc-welcome, .nzc-cta-block, .nzc-lead-form { animation: none; }
  .nzc-msg-bubble .nzc-typing-char { animation: none; opacity: 1; }
}
