/* IT SOS Agent v4 — mali launcher, panel se širi na klik */
#itsos-chat {
  position: fixed;
  right: 154px; /* levo od theme "back to top" (90–140px) */
  bottom: 18px;
  z-index: 99999;
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: #1e293b;
}
#itsos-chat *, #itsos-chat *::before, #itsos-chat *::after { box-sizing: border-box; }

/* ---------- LAUNCHER (zatvoreno stanje) ---------- */
.itsos-launcher {
  position: relative;
  display: block;
  width: 58px;
  height: 58px;
  padding: 0;
  margin: 0;
  border: 3px solid #1565d8;
  border-radius: 50%;
  background: #dbeafe;
  box-shadow: 0 6px 20px rgba(11, 37, 69, 0.35);
  cursor: pointer;
  transition: transform .2s ease, opacity .2s ease, box-shadow .2s ease;
}
.itsos-launcher:hover { transform: scale(1.07); box-shadow: 0 8px 24px rgba(11, 37, 69, 0.45); }
.itsos-launcher:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.itsos-launcher img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.itsos-launcher::after {
  content: "";
  display: block !important; /* tema Digitaz: button::after { display: none } */
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid #1565d8;
  opacity: 0;
  animation: itsos-pulse 2.4s ease-out 1s 12;
  pointer-events: none;
}
.itsos-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 15px;
  height: 15px;
  background: #22c55e;
  border: 2px solid #fff;
  border-radius: 50%;
}
@keyframes itsos-pulse {
  0%   { transform: scale(1);   opacity: .55; }
  100% { transform: scale(1.7); opacity: 0; }
}

/* Tooltip pored launchera */
.itsos-tip {
  position: absolute;
  right: 70px;
  bottom: 12px;
  white-space: nowrap;
  background: #fff;
  color: #1e293b;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
  opacity: 0;
  transform: translateX(6px);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.itsos-tip::after {
  content: "";
  position: absolute;
  right: -5px;
  top: 50%;
  width: 10px;
  height: 10px;
  background: #fff;
  transform: translateY(-50%) rotate(45deg);
}
.itsos-tip.show, .itsos-launcher:hover + .itsos-tip { opacity: 1; transform: translateX(0); }

/* ---------- PANEL (otvoreno stanje) ---------- */
.itsos-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 372px;
  max-height: min(600px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 20px;
  border: 1px solid rgba(21, 101, 216, 0.12);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22), 0 4px 16px rgba(0, 0, 0, 0.10);
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(.86) translateY(14px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform .26s cubic-bezier(.2, .8, .2, 1), opacity .2s ease, visibility 0s linear .26s;
}
#itsos-chat:not(.minimized) .itsos-panel {
  transform: none;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}
#itsos-chat:not(.minimized) .itsos-launcher,
#itsos-chat:not(.minimized) .itsos-tip {
  opacity: 0;
  transform: scale(.6);
  pointer-events: none;
}

/* Header */
.itsos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  color: #fff;
  background: linear-gradient(135deg, #0f4fb0 0%, #0b2545 100%);
  flex-shrink: 0;
}
.itsos-header-info { display: flex; align-items: center; gap: 11px; min-width: 0; }
.itsos-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  background: #dbeafe;
  border: 2px solid rgba(255, 255, 255, 0.55);
  flex-shrink: 0;
}
.itsos-header-text { display: flex; flex-direction: column; min-width: 0; }
.itsos-header-text strong { font-size: 15px; font-weight: 700; }
.itsos-header-text span { font-size: 12px; opacity: .9; display: flex; align-items: center; gap: 6px; }
.itsos-status-dot { width: 8px; height: 8px; background: #4ade80; border-radius: 50%; display: inline-block; }
.itsos-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.itsos-close:hover { background: rgba(255, 255, 255, 0.3); }

/* Statusna traka */
.itsos-urgent-bar {
  background: #eff6ff;
  border-bottom: 1px solid #bfdbfe;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: #1d4ed8;
  flex-shrink: 0;
}

/* Poruke */
.itsos-body {
  flex: 1 1 auto;
  min-height: 220px;
  height: 330px;
  padding: 14px 12px 8px;
  overflow-y: auto;
  background: #fafafa;
  scroll-behavior: smooth;
}
.itsos-body::-webkit-scrollbar { width: 4px; }
.itsos-body::-webkit-scrollbar-thumb { background: #93c5fd; border-radius: 4px; }

.msg { display: flex; flex-direction: column; margin-bottom: 12px; animation: itsos-in .25s ease-out; }
@keyframes itsos-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg-name { font-size: 11px; font-weight: 600; color: #94a3b8; margin: 0 0 3px 38px; }
.msg-row { display: flex; align-items: flex-end; gap: 8px; }
.msg-avt {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: #dbeafe;
  flex-shrink: 0;
}
.msg.ai .bubble {
  max-width: 82%;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 18px 18px 18px 4px;
  padding: 10px 14px;
  box-shadow: 0 2px 8px rgba(21, 101, 216, 0.06);
  word-wrap: break-word;
}
.msg.user { align-items: flex-end; }
.msg.user .bubble {
  max-width: 82%;
  background: linear-gradient(135deg, #1565d8, #0f4fb0);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  padding: 10px 14px;
  word-wrap: break-word;
}

/* CTA dugmad */
.cta-wrap { margin-top: 10px; }
.cta {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1565d8, #0f4fb0);
  color: #fff !important;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  text-decoration: none !important;
  box-shadow: 0 3px 10px rgba(21, 101, 216, 0.25);
  transition: transform .15s ease, box-shadow .15s ease;
}
.cta:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(21, 101, 216, 0.32); }
.cta.secondary { background: #16a34a; box-shadow: 0 3px 10px rgba(22, 163, 74, 0.25); }
.cta.phone { background: #0f172a; box-shadow: 0 3px 10px rgba(15, 23, 42, 0.25); }
.cta.download { background: #fff; color: #1d4ed8 !important; border: 2px solid #1565d8; box-shadow: none; }
.cta-note { font-size: 11px; color: #888; margin-top: 4px; text-align: center; }

/* Brza pitanja */
.itsos-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 2px 0 10px 38px; }
.itsos-chip {
  padding: 7px 12px;
  border: 1.5px solid #93c5fd;
  border-radius: 999px;
  background: #fff;
  color: #1d4ed8;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.itsos-chip:hover { background: #1565d8; border-color: #1565d8; color: #fff; }

/* Kucanje */
.typing-indicator { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 12px; }
.typing-indicator .bubble {
  display: flex;
  gap: 5px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 18px 18px 18px 4px;
}
.typing-dot { width: 7px; height: 7px; background: #94a3b8; border-radius: 50%; animation: itsos-dot 1.2s infinite; }
.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes itsos-dot { 0%, 80%, 100% { transform: none; opacity: .5; } 40% { transform: translateY(-5px); opacity: 1; } }

/* Unos */
.itsos-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
}
#itsos-input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 999px;
  background: #f8fafc;
  font: inherit;
  font-size: 14px;
  color: #1e293b;
  outline: none;
}
#itsos-input:focus { border-color: #1565d8; background: #fff; }
.itsos-send-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #1565d8, #0f4fb0);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.itsos-send-btn:disabled { opacity: .5; cursor: default; }

/* ---------- MOBILNI ---------- */
@media (max-width: 520px) {
  #itsos-chat { right: 12px; bottom: 86px; }
  .itsos-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }
  .itsos-body { height: auto; min-height: 0; max-height: 62vh; }
  .itsos-tip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #itsos-chat *, #itsos-chat *::after { animation: none !important; transition-duration: 0s !important; }
}

/* ---------- RESET protiv stilova teme (dugmad, tekst) ---------- */
#itsos-chat button, #itsos-chat input {
  -webkit-appearance: none; appearance: none;
  text-transform: none !important; letter-spacing: normal !important;
  min-width: 0 !important; min-height: 0 !important; max-width: none;
  margin: 0; font-family: inherit; text-shadow: none; filter: none;
}
#itsos-chat button { box-shadow: none; line-height: 1; }
#itsos-chat .itsos-launcher { width: 58px !important; height: 58px !important; padding: 0 !important; border-radius: 50% !important; box-shadow: 0 6px 20px rgba(11, 37, 69, .35); }
#itsos-chat .itsos-close,
#itsos-chat .itsos-send-btn {
  width: 36px !important; height: 36px !important; padding: 0 !important;
  border-radius: 50% !important; display: flex !important; align-items: center; justify-content: center;
  flex: 0 0 36px !important; aspect-ratio: 1 / 1; line-height: 0;
}
#itsos-chat .itsos-send-btn { width: 42px !important; height: 42px !important; flex-basis: 42px !important; background: linear-gradient(135deg, #1565d8, #0f4fb0) !important; }
#itsos-chat .itsos-close { background: rgba(255,255,255,.18) !important; color: #fff !important; }
#itsos-chat .itsos-close:hover { background: rgba(255,255,255,.32) !important; }
#itsos-chat .itsos-close svg, #itsos-chat .itsos-send-btn svg { display: block; width: 18px; height: 18px; fill: none !important; stroke: #fff !important; }
#itsos-chat .itsos-chip { padding: 8px 13px !important; border-radius: 999px !important; text-transform: none !important; background: #fff !important; color: #1d4ed8 !important; border: 1.5px solid #93c5fd !important; font-size: 13px; font-weight: 600; line-height: 1.2; }
#itsos-chat .itsos-chip:hover { background: #1565d8 !important; border-color: #1565d8 !important; color: #fff !important; }
#itsos-chat #itsos-input { height: 42px !important; padding: 0 16px !important; border-radius: 999px !important; border: 1.5px solid #dbe4f0 !important; background: #f8fafc !important; box-shadow: none !important; color: #0f172a !important; }
#itsos-chat #itsos-input:focus { border-color: #1565d8 !important; background: #fff !important; }
#itsos-chat .msg-name { text-transform: none; }
#itsos-chat .cta { text-transform: none; letter-spacing: normal; }
#itsos-chat .itsos-launcher img, #itsos-chat .itsos-avatar, #itsos-chat .msg-avt { max-width: none; border-radius: 50%; }
#itsos-chat .itsos-avatar { width: 42px; height: 42px; }
