/* AI poradce Narovnáno.cz — plovoucí chat widget. */

#nv-chat-root {
  --nv-gold: #beac73;
  --nv-gold-deep: #937416;
  --nv-ink: #0d0d0c;
  --nv-paper: #f6f3ec;
  --nv-paper-2: #e9e6dc;
  --nv-green: #2f5d4f;
  --nv-line: rgba(13, 13, 12, .12);
  --nv-shadow: 0 30px 60px -25px rgba(13, 13, 12, .45);
  --nv-bubble-bot: #ffffff;
  --nv-bubble-user: var(--nv-ink);

  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10000;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
}

#nv-chat-root * { box-sizing: border-box; }

/* ── FAB (plovoucí tlačítko) ── */
.nv-fab {
  pointer-events: auto;
  position: absolute;
  right: 22px;
  bottom: 22px;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  background: var(--nv-ink);
  color: #fff;
  border: none;
  border-radius: 100px;
  padding: .85rem 1.2rem .85rem 1rem;
  font-family: inherit;
  font-weight: 700;
  font-size: .92rem;
  cursor: pointer;
  box-shadow: 0 18px 40px -18px rgba(13, 13, 12, .55);
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}
.nv-fab:hover {
  background: var(--nv-gold-deep);
  transform: translateY(-2px);
  box-shadow: 0 24px 50px -18px rgba(147, 116, 22, .55);
}
.nv-fab-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--nv-gold);
  color: var(--nv-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: .92rem;
}
.nv-fab-pulse {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  background: var(--nv-gold);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(190, 172, 115, .9);
  animation: nv-pulse 1.8s infinite;
}
@keyframes nv-pulse {
  0% { box-shadow: 0 0 0 0 rgba(190, 172, 115, .7); }
  70% { box-shadow: 0 0 0 12px rgba(190, 172, 115, 0); }
  100% { box-shadow: 0 0 0 0 rgba(190, 172, 115, 0); }
}

/* ── Panel ── */
.nv-panel {
  pointer-events: auto;
  position: absolute;
  right: 22px;
  bottom: 22px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 40px);
  background: var(--nv-paper);
  border-radius: 20px;
  box-shadow: var(--nv-shadow);
  border: 1px solid var(--nv-line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(.96);
  opacity: 0;
  visibility: hidden;
  transition: transform .25s ease, opacity .25s ease, visibility .25s;
}
.nv-panel.nv-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
}

/* Header */
.nv-head {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: 1rem 1.1rem;
  background: var(--nv-ink);
  color: #fff;
}
.nv-head-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--nv-gold) 0%, var(--nv-gold-deep) 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #fff;
  font-size: .95rem;
  flex-shrink: 0;
}
.nv-head-title {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}
.nv-head-title b {
  font-size: .95rem;
  font-weight: 700;
}
.nv-head-title small {
  font-size: .72rem;
  opacity: .65;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.nv-head-title small::before {
  content: "";
  width: 6px;
  height: 6px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
}
.nv-head-human {
  background: var(--nv-gold);
  color: var(--nv-ink);
  border: none;
  border-radius: 100px;
  padding: .5rem .85rem;
  font-family: inherit;
  font-weight: 700;
  font-size: .76rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s, transform .15s;
  flex-shrink: 0;
}
.nv-head-human:hover {
  background: #fff;
  transform: translateY(-1px);
}
.nv-head-close {
  background: rgba(255, 255, 255, .08);
  color: #fff;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  transition: background .2s;
  flex-shrink: 0;
}
.nv-head-close:hover { background: rgba(255, 255, 255, .18); }

/* Tighten layout on narrow panels so all 3 elements fit. */
@media (max-width: 420px) {
  .nv-head { gap: .55rem; padding: .85rem .9rem; }
  .nv-head-human { padding: .45rem .7rem; font-size: .72rem; }
  .nv-head-title small { font-size: .68rem; }
}

/* Body */
.nv-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
  scroll-behavior: smooth;
}
.nv-body::-webkit-scrollbar { width: 6px; }
.nv-body::-webkit-scrollbar-thumb { background: rgba(13, 13, 12, .15); border-radius: 3px; }

/* Message bubbles */
.nv-msg {
  max-width: 86%;
  padding: .7rem .95rem;
  border-radius: 16px;
  font-size: .93rem;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: nv-msg-in .25s ease;
}
@keyframes nv-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.nv-msg.nv-bot {
  background: var(--nv-bubble-bot);
  color: var(--nv-ink);
  border: 1px solid var(--nv-line);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.nv-msg.nv-user {
  background: var(--nv-bubble-user);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.nv-typing {
  align-self: flex-start;
  background: var(--nv-bubble-bot);
  border: 1px solid var(--nv-line);
  padding: .8rem 1rem;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  display: inline-flex;
  gap: .25rem;
}
.nv-typing span {
  width: 7px;
  height: 7px;
  background: var(--nv-gold-deep);
  border-radius: 50%;
  animation: nv-typing 1.2s infinite;
}
.nv-typing span:nth-child(2) { animation-delay: .15s; }
.nv-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes nv-typing {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* Footer / input */
.nv-foot {
  border-top: 1px solid var(--nv-line);
  padding: .7rem .8rem;
  background: #fff;
}
.nv-input-row {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
}
.nv-input {
  flex: 1;
  border: 1px solid var(--nv-line);
  border-radius: 14px;
  padding: .65rem .85rem;
  font-family: inherit;
  font-size: .92rem;
  resize: none;
  outline: none;
  min-height: 42px;
  max-height: 110px;
  line-height: 1.4;
  transition: border-color .2s;
  background: #fff;
  color: var(--nv-ink);
}
.nv-input:focus { border-color: var(--nv-gold-deep); }
.nv-send,
.nv-mic {
  background: var(--nv-gold-deep);
  color: #fff;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background .2s, transform .15s;
  flex-shrink: 0;
  padding: 0;
}
.nv-send:hover:not(:disabled),
.nv-mic:hover:not(:disabled) { background: var(--nv-ink); transform: translateY(-1px); }
.nv-send:disabled,
.nv-mic:disabled { opacity: .4; cursor: not-allowed; }

.nv-mic {
  background: transparent;
  color: var(--nv-gold-deep);
  border: 1px solid var(--nv-gold);
}
.nv-mic:hover:not(:disabled) {
  background: var(--nv-gold-deep);
  color: #fff;
}
.nv-mic svg { width: 18px; height: 18px; display: block; }

.nv-mic.recording {
  background: #c14a3a;
  color: #fff;
  border-color: #c14a3a;
  animation: nv-rec-pulse 1.3s infinite;
}
.nv-mic.recording:hover { background: #a33b2c; }
@keyframes nv-rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(193, 74, 58, .6); }
  50% { box-shadow: 0 0 0 8px rgba(193, 74, 58, 0); }
}

.nv-rec-banner {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .55rem .85rem;
  background: rgba(193, 74, 58, .08);
  border: 1px solid rgba(193, 74, 58, .25);
  border-radius: 12px;
  margin-bottom: .55rem;
  font-size: .85rem;
  font-weight: 600;
  color: #8b3528;
}
.nv-rec-banner .dot {
  width: 9px;
  height: 9px;
  background: #c14a3a;
  border-radius: 50%;
  animation: nv-rec-blink 1s infinite;
}
@keyframes nv-rec-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}
.nv-rec-banner .timer { font-variant-numeric: tabular-nums; margin-left: auto; opacity: .8; }
.nv-disclaimer {
  text-align: center;
  font-size: .68rem;
  color: rgba(13, 13, 12, .5);
  margin-top: .5rem;
  font-weight: 500;
}

/* Gate form (shown first before chat) */
.nv-gate {
  align-self: stretch;
  background: #fff;
  border: 1px solid var(--nv-line);
  border-radius: 16px;
  padding: 1.2rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.nv-gate h3 {
  font-family: inherit;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--nv-ink);
  margin: 0;
}
.nv-gate > p {
  font-size: .86rem;
  color: rgba(13, 13, 12, .7);
  margin: 0 0 .3rem;
  line-height: 1.45;
}
.nv-gate-form {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.nv-gate-submit {
  background: var(--nv-gold-deep);
  color: #fff;
  border: none;
  border-radius: 100px;
  padding: .85rem 1.2rem;
  font-family: inherit;
  font-weight: 800;
  font-size: .95rem;
  cursor: pointer;
  margin-top: .3rem;
  transition: background .2s, transform .15s;
}
.nv-gate-submit:hover:not(:disabled) { background: var(--nv-ink); transform: translateY(-1px); }
.nv-gate-submit:disabled { opacity: .55; cursor: not-allowed; }
.nv-gate-err {
  font-size: .8rem;
  color: #c14a3a;
}
.nv-gate-foot {
  font-size: .7rem;
  color: rgba(13, 13, 12, .5);
  text-align: center;
  line-height: 1.45;
  margin-top: .3rem;
}

/* Lead form (embedded in chat) */
.nv-lead-form {
  align-self: stretch;
  background: #fff;
  border: 1px solid var(--nv-gold);
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.nv-lead-form h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--nv-ink);
  margin: 0 0 .2rem;
}
.nv-lead-form p {
  font-size: .82rem;
  color: rgba(13, 13, 12, .65);
  margin: 0 0 .4rem;
  line-height: 1.4;
}
.nv-field {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.nv-field label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--nv-ink);
  letter-spacing: .02em;
}
.nv-field label .req { color: var(--nv-gold-deep); }
.nv-field input,
.nv-field textarea,
.nv-field select {
  border: 1px solid var(--nv-line);
  border-radius: 10px;
  padding: .55rem .7rem;
  font-family: inherit;
  font-size: .9rem;
  outline: none;
  background: #fff;
  color: var(--nv-ink);
  transition: border-color .2s;
}
.nv-field input:focus,
.nv-field textarea:focus,
.nv-field select:focus { border-color: var(--nv-gold-deep); }
.nv-field textarea { min-height: 60px; resize: vertical; line-height: 1.4; }
.nv-lead-submit {
  background: var(--nv-gold-deep);
  color: #fff;
  border: none;
  border-radius: 100px;
  padding: .8rem 1.2rem;
  font-family: inherit;
  font-weight: 800;
  font-size: .92rem;
  cursor: pointer;
  margin-top: .4rem;
  transition: background .2s, transform .15s;
}
.nv-lead-submit:hover:not(:disabled) { background: var(--nv-ink); transform: translateY(-1px); }
.nv-lead-submit:disabled { opacity: .5; cursor: not-allowed; }
.nv-lead-err {
  font-size: .8rem;
  color: #c14a3a;
  margin-top: .2rem;
}

/* Thank-you screen */
.nv-thanks {
  align-self: stretch;
  text-align: center;
  background: linear-gradient(135deg, rgba(190, 172, 115, .15), rgba(47, 93, 79, .12));
  border-radius: 16px;
  padding: 1.4rem 1.1rem;
  border: 1px solid var(--nv-gold);
}
.nv-thanks-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--nv-green);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: .6rem;
}
.nv-thanks h4 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--nv-ink);
  margin: 0 0 .4rem;
}
.nv-thanks p {
  font-size: .88rem;
  color: rgba(13, 13, 12, .75);
  line-height: 1.5;
}

/* Mobile responsive — bottom sheet */
@media (max-width: 520px) {
  .nv-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 92vh;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
  }
  .nv-fab {
    right: 14px;
    bottom: 14px;
    padding: .8rem 1.1rem .8rem .9rem;
    font-size: .88rem;
  }
  .nv-fab-text { display: inline; }
}

@media (max-width: 360px) {
  .nv-fab-text { display: none; }
  .nv-fab { padding: .85rem; }
}

/* Když je sticky CTA bar viditelná, FAB se zúží na ikonu —
   bez toho dva velké bottom-fixed elementy soutěží o pozornost.
   Sticky CTA má primární akce (Volat + lead form); chat zůstává
   přístupný jako kompaktní ikona. */
@media (max-width: 720px) {
  /* Na mobilu je FAB VŽDY kompaktní kruh 64×64 (bez textu) — nezávisle na
     JS class. Sticky CTA lišta (bottom 14, výška 64, right 84) s ním sdílí
     řadu ⇒ středy všech 3 tlačítek v jedné lince a nikdy se nepřekrývají. */
  .nv-fab-text { display: none; }
  .nv-fab {
    padding: 0;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    justify-content: center;
    right: 12px;
    bottom: 14px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .nv-fab-pulse, .nv-typing span { animation: none; }
  .nv-panel { transition: opacity .15s ease; }
  .nv-msg { animation: none; }
}
