/* =========================================================
   TestDaF Beograd – AI asistent (widget)
   ========================================================= */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.chat-launcher {
  position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); z-index: 95;
  display: inline-flex; align-items: center; gap: 10px;
  height: 56px; min-width: 56px; padding: 0 16px; justify-content: center;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--navy); color: #fff; font: inherit; font-weight: 700;
  box-shadow: 0 10px 28px rgba(27, 33, 80, .32);
  transition: transform 160ms var(--ease-out), background-color 200ms ease;
}
.chat-launcher:active { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) {
  .chat-launcher:hover { background: var(--navy-dark); }
}
.chat-launcher svg { width: 24px; height: 24px; flex: none; }
.chat-launcher-label { display: none; }
@media (min-width: 900px) {
  .chat-launcher { right: 28px; bottom: 28px; padding: 0 22px 0 18px; }
  .chat-launcher-label { display: inline; }
}
.chat-open .chat-launcher { display: none; }
@media (max-width: 899px) { .chat-open .fab { display: none; } }

.chat-panel {
  position: fixed; z-index: 120; inset: 0;
  display: flex; flex-direction: column;
  background: #fff; color: var(--text-body);
  /* Ulazak: kratko, bez animacije pri zatvaranju (sistem odgovara odmah) */
  transition: opacity 200ms var(--ease-out), transform 240ms var(--ease-out);
  @starting-style { opacity: 0; transform: translateY(16px); }
}
.chat-panel[hidden] { display: none; }
@media (min-width: 640px) {
  .chat-panel {
    inset: auto 28px 28px auto; width: 400px; height: min(640px, calc(100dvh - 56px));
    border-radius: 20px; box-shadow: 0 24px 64px rgba(27, 33, 80, .25); overflow: hidden;
    border: 1px solid var(--border);
    transform-origin: bottom right; /* raste iz dugmeta za čet */
    @starting-style { opacity: 0; transform: scale(0.96) translateY(8px); }
  }
}
@media (prefers-reduced-motion: reduce) {
  .chat-panel, .chat-msg { @starting-style { transform: none; } }
  .chat-launcher:active { transform: none; }
}

.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); background: var(--navy); color: #fff; }
@media (min-width: 640px) { .chat-head { padding-top: 14px; } }
.chat-avatar { display: grid; grid-template-columns: repeat(2, 8px); gap: 3px; padding: 10px; background: #fff; border-radius: 12px; }
.chat-avatar i { width: 8px; height: 8px; border-radius: 2px; display: block; }
.chat-avatar i:nth-child(1) { background: var(--orange); }
.chat-avatar i:nth-child(2) { background: var(--red); }
.chat-avatar i:nth-child(3) { background: var(--navy); }
.chat-avatar i:nth-child(4) { background: var(--gray); }
.chat-title { flex: 1; line-height: 1.25; }
.chat-title strong { display: block; font-size: 1rem; }
.chat-title small { color: rgba(255, 255, 255, .75); font-size: .8rem; }
.chat-close { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .1); color: #fff; cursor: pointer; }
@media (hover: hover) and (pointer: fine) {
  .chat-close:hover { background: rgba(255, 255, 255, .2); }
  .chat-chip:hover { border-color: var(--navy); }
}
.chat-close, .chat-chip, .chat-send { transition: transform 160ms var(--ease-out), background-color 200ms ease, border-color 200ms ease; }
.chat-close:active, .chat-chip:active, .chat-send:active:not(:disabled) { transform: scale(0.95); }
.chat-close svg { width: 20px; height: 20px; }

.chat-log { flex: 1; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 10px; background: var(--bg-alt); overscroll-behavior: contain; }
.chat-msg {
  max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: .95rem; line-height: 1.5; overflow-wrap: anywhere;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
  @starting-style { opacity: 0; transform: translateY(6px); }
}
.chat-msg p { margin: 0 0 .5em; }
.chat-msg p:last-child { margin: 0; }
.chat-msg ul { margin: .2em 0 .5em; padding-left: 1.1em; }
.chat-msg-bot { align-self: flex-start; background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 6px; }
.chat-msg-user { align-self: flex-end; background: var(--navy); color: #fff; border-bottom-right-radius: 6px; }
.chat-success { border-color: #BFE3CD; background: #E7F5EC; color: var(--success); }

.chat-typing { display: inline-flex; gap: 4px; padding: 14px; }
.chat-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--gray); animation: chat-dot 1s infinite ease-in-out; }
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .chat-typing span { animation: none; } }

.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 10px; background: var(--bg-alt); }
.chat-chips:empty { display: none; }
.chat-chip { border: 1px solid var(--border); background: #fff; color: var(--navy); font: inherit; font-size: .86rem; font-weight: 600; padding: 7px 12px; border-radius: 999px; cursor: pointer; }

.chat-input { display: flex; align-items: flex-end; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: #fff; }
.chat-input textarea {
  flex: 1; resize: none; font: inherit; font-size: 1rem; line-height: 1.4; color: var(--text-body);
  border: 1.5px solid #CDD1E2; border-radius: 12px; padding: 10px 12px; max-height: 120px;
  scrollbar-width: none; /* bez strelica za skrol u polju */
}
.chat-input textarea::-webkit-scrollbar { display: none; }
.chat-input textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(61, 74, 138, .15); }
.chat-send { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 12px; background: var(--orange); color: var(--navy-ink); cursor: pointer; }
.chat-send:disabled { opacity: .5; cursor: progress; }
.chat-send svg { width: 20px; height: 20px; }
.chat-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.chat-note { margin: 0; padding: 0 12px calc(10px + env(safe-area-inset-bottom, 0px)); font-size: .74rem; color: var(--muted); background: #fff; text-align: center; }

.chat-lead { align-self: stretch; background: #fff; border: 1.5px solid var(--orange); border-radius: 16px; padding: 14px; display: grid; gap: 10px; font-size: .9rem; }
.chat-lead-title { margin: 0; font-weight: 700; color: var(--navy); }
.chat-lead label { display: grid; gap: 4px; font-weight: 600; color: var(--navy); }
.chat-lead label[hidden] { display: none; }
.chat-lead input:not([type=radio]):not([type=checkbox]), .chat-lead select {
  font: inherit; font-size: 16px; /* ispod 16px iOS zumira stranicu pri fokusu */
  font-weight: 400; color: var(--text-body); border: 1.5px solid #CDD1E2; border-radius: 10px; padding: 9px 11px; min-height: 42px; background: #fff;
}
.chat-lead input:focus, .chat-lead select:focus { outline: none; border-color: var(--navy); }
.chat-lead-radios { display: flex; gap: 16px; }
.chat-lead-radios label, .chat-lead-consent { display: flex !important; align-items: flex-start; gap: 8px; font-weight: 500 !important; color: var(--text-body) !important; }
.chat-lead-radios input, .chat-lead-consent input { accent-color: var(--navy); margin-top: 3px; }
.chat-lead-error { margin: 0; color: var(--error); font-weight: 600; }
.chat-lead .btn { padding: 12px; }
