/* ===== Chat vidžet (isti mehanizam/CSS kao pratilac_vidžit/assets/css/widget.css,
   ponovo iskorišten bez izmjena — Skalamerija style.css definiše iste CSS
   varijable --blue/--navy/--pale/--line/--ink/--blue-dark). ===== */
.pw-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), #6a8bff);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(47, 91, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: transform 0.2s;
}
.pw-launcher:hover { transform: translateY(-3px); }
.pw-launcher svg { width: 26px; height: 26px; }
.pw-launcher .pw-close-icon { display: none; }
.pw-launcher.pw-open .pw-chat-icon { display: none; }
.pw-launcher.pw-open .pw-close-icon { display: block; }

.pw-panel {
  position: fixed;
  right: 20px;
  bottom: 88px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 24px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(15, 26, 48, 0.28);
  border: 1px solid var(--line);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 200;
}
.pw-panel.pw-open { display: flex; }

.pw-panel.pw-collapsed {
  height: auto !important;
  min-height: 0;
}
.pw-panel.pw-collapsed .pw-messages,
.pw-panel.pw-collapsed .pw-form,
.pw-panel.pw-collapsed .pw-resize-handle { display: none; }
.pw-panel.pw-collapsed .pw-min-btn svg { transform: rotate(180deg); }

.pw-header {
  background: linear-gradient(135deg, var(--navy), var(--blue));
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: move;
  user-select: none;
  touch-action: none;
}
.pw-header .pw-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 800;
  font-size: 0.8rem;
}
.pw-header .pw-avatar svg { width: 18px; height: 18px; }
.pw-header-text { flex: 1; min-width: 0; }
.pw-header .pw-title { font-weight: 700; font-size: 0.98rem; }
.pw-header .pw-subtitle { font-size: 0.78rem; opacity: 0.82; }

.pw-header-actions { display: flex; align-items: center; flex-shrink: 0; }
.pw-min-btn, .pw-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.14);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.pw-close-btn { margin-left: 6px; }
.pw-min-btn:hover, .pw-close-btn:hover { background: rgba(255,255,255,0.26); }
.pw-min-btn svg { width: 15px; height: 15px; transition: transform 0.2s; }
.pw-close-btn svg { width: 14px; height: 14px; }

.pw-resize-handle, .pw-resize-handle-left {
  position: absolute;
  bottom: 0;
  width: 26px;
  height: 26px;
  touch-action: none;
  z-index: 5;
}
.pw-resize-handle { right: 0; cursor: nwse-resize; }
.pw-resize-handle-left { left: 0; cursor: nesw-resize; }
.pw-resize-handle::before {
  content: "";
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 12px;
  height: 12px;
  border-right: 3px solid var(--blue);
  border-bottom: 3px solid var(--blue);
  border-radius: 0 0 3px 0;
  opacity: 0.6;
}
.pw-resize-handle-left::before {
  content: "";
  position: absolute;
  left: 5px;
  bottom: 5px;
  width: 12px;
  height: 12px;
  border-left: 3px solid var(--blue);
  border-bottom: 3px solid var(--blue);
  border-radius: 0 0 0 3px;
  opacity: 0.6;
}
.pw-resize-handle:hover::before, .pw-resize-handle-left:hover::before { opacity: 1; }

.pw-drag-hint {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  gap: 3px;
  width: 12px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.6;
}
.pw-drag-hint span { width: 4px; height: 4px; border-radius: 50%; background: #fff; }

.pw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--pale);
}

.pw-msg {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.pw-msg-bot {
  align-self: flex-start;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.pw-msg-bot strong { color: var(--blue); font-weight: 800; }
.pw-msg-user {
  align-self: flex-end;
  background: var(--blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.pw-msg-notice {
  align-self: center;
  background: #fff4e0;
  color: #8a5a12;
  border-radius: 10px;
  font-size: 0.82rem;
  text-align: center;
}
.pw-msg-notice a { color: #8a5a12; font-weight: 700; text-decoration: underline; }

.pw-typing { align-self: flex-start; display: flex; gap: 4px; padding: 10px 13px; }
.pw-typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--blue);
  animation: pw-bounce 1.2s infinite ease-in-out;
}
.pw-typing span:nth-child(2) { animation-delay: 0.15s; }
.pw-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pw-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* TP-SAFET-AUDIO-I-OLDTAJMER-C1-004: audio traka (mik/stop/govor/utišaj) */
.pw-audio-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-top: 1px solid var(--line);
  background: var(--pale);
  font-size: 0.78rem;
  color: var(--ink);
}
.pw-audio-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c7cbd4;
  flex-shrink: 0;
}
.pw-audio-bar.is-listening .pw-audio-indicator { background: #e0433a; animation: pw-audio-pulse 1.1s infinite; }
.pw-audio-bar.is-speaking .pw-audio-indicator { background: var(--blue); animation: pw-audio-pulse 1.1s infinite; }
@keyframes pw-audio-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.pw-audio-status { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw-audio-controls { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
/* Isti oblik/stil kao Pratiočevi #btnDictate/#btnVoiceConvo (icon-btn
   composer-icon, assets/styles.css) — zaobljeno-kvadratna dugmad, plava boja
   za "slušam" (kao #btnVoiceConvo.active), zelena za "govorim"
   (kao #btnVoiceConvo.speaking) — vizuelno ISTI jezik kao Pratiočev meni. */
.pw-audio-btn {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: #4a5361;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color .15s, border-color .15s, background .15s;
}
.pw-audio-btn svg { width: 16px; height: 16px; }
.pw-audio-btn:hover { background: var(--pale); }
.pw-audio-mic.is-active { color: var(--blue); border-color: var(--blue); background: rgba(47,91,255,0.08); }
.pw-audio-speak.is-active { color: #1a7a3e; border-color: #1a7a3e; background: rgba(26,122,62,0.08); }
.pw-audio-mute.is-muted { color: #e0433a; border-color: #e0433a; background: rgba(224,67,58,0.08); }
.pw-audio-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pw-audio-bar.is-locked .pw-audio-indicator { background: #c7cbd4; }

.pw-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.pw-form input {
  flex: 1;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-family: inherit;
}
.pw-form input:focus { outline: none; border-color: var(--blue); }
.pw-form button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pw-form button:hover { background: var(--blue-dark); }
.pw-form button svg { width: 18px; height: 18px; }

@media (max-width: 480px) {
  .pw-panel {
    right: 10px;
    left: 10px;
    width: auto;
    bottom: 82px;
  }
  .pw-launcher { right: 14px; bottom: 14px; }
}

/* C1-172: obavijest o čuvanju razgovora — diskretna, uvijek vidljiva. */
.pw-privatnost { padding:6px 12px; font-size:.72rem; line-height:1.35; opacity:.7;
                 border-top:1px solid rgba(255,255,255,.12); }

/* C1-177: traka „Provjeri obrazac" u Safetovom panelu (stranica procjene). */
.pw-obrazac-traka { padding:6px 12px; border-top:1px solid rgba(255,255,255,.12); }
.pw-obrazac-btn { width:100%; padding:8px 10px; border-radius:8px; cursor:pointer;
                  border:1px solid rgba(255,255,255,.28); background:rgba(255,255,255,.10);
                  color:inherit; font:inherit; font-weight:600; }
.pw-obrazac-btn:hover { background:rgba(255,255,255,.18); }
