/* Chat "Sani" - izgled prema prijedlogu D1 "Mirno i prozračno" (vlasnica odobrila 11. 11. 2026.).
   Mobitel: list odozdo, visok koliko i sadržaj (najviše vidljiva visina ekrana); dok je tipkovnica otvorena,
   skripta ga postavlja točno na vidljivi dio ekrana (visualViewport). Računalo: plutajući prozor dolje desno.
   Učitava se bez blokiranja prikaza stranice (media=print -> all); dok se ne učita, list je skriven atributom hidden. */
.cx-sheet,
.cx-backdrop {
  --cx-accent: #0369a1;
  --cx-safe: env(safe-area-inset-bottom, 0px);
}

.cx-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(8, 18, 34, 0.46);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cx-sheet {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  max-height: calc(100vh - 0.75rem);
  max-height: calc(var(--cx-vh, 100dvh) - 0.75rem);
  overflow: hidden;
  border-radius: 1.25rem 1.25rem 0 0;
  background: #f6f7f9;
  box-shadow: 0 -20px 50px -18px rgba(8, 18, 34, 0.55);
  color: #0f172a;
  font-size: 1rem;
  line-height: 1.45;
  text-align: left;
  outline: none;
}

.cx-sheet[hidden],
.cx-backdrop[hidden],
.cx-sheet [hidden] {
  display: none !important;
}

.cx-sheet *,
.cx-sheet *::before,
.cx-sheet *::after {
  box-sizing: border-box;
}

.cx-head {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.5rem 0.75rem 1rem;
  border-bottom: 1px solid #e9ecf1;
  background: #ffffff;
}

.cx-avatar {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  object-fit: cover;
  object-position: 43% 14%;
}

.cx-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
  color: #0f172a;
}

.cx-role {
  margin: 0.0625rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.3;
  color: #64748b;
}

.cx-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0.75rem;
  background: none;
  color: #334155;
  font-size: 1.5rem;
  cursor: pointer;
}

.cx-close:active {
  background: #f1f5f9;
}

.cx-list {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
  padding: 1rem 1rem 0.875rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.cx-msg {
  max-width: 88%;
  margin: 0;
  padding: 0.6875rem 0.875rem;
  border-radius: 1rem;
  font-size: 1rem;
  line-height: 1.45;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.cx-msg--ai {
  align-self: flex-start;
  border: 1px solid #e9ecf1;
  border-top-left-radius: 0.375rem;
  background: #ffffff;
  color: #0f172a;
}

.cx-msg--me {
  align-self: flex-end;
  border-bottom-right-radius: 0.375rem;
  background: var(--cx-accent);
  color: #ffffff;
}

.cx-msg a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.cx-msg--ai a {
  color: #0369a1;
}

.cx-msg--notice {
  border-color: #fde68a;
  background: #fffbeb;
  color: #78350f;
}

.cx-notice-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.5rem;
  font-size: 0.875rem;
  font-weight: 700;
  white-space: normal;
}

/* The call and WhatsApp links are the way out when the chat fails: full 44 px touch height. */
.cx-notice-links a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

.cx-msg--notice .cx-notice-links a {
  color: #0369a1;
}

.cx-att {
  display: block;
  margin-top: 0.5rem;
  overflow: hidden;
  border-radius: 0.75rem;
  border: 1px solid rgba(15, 23, 42, 0.12);
  color: inherit;
  font-size: 0.8125rem;
  text-decoration: none;
  white-space: normal;
}

.cx-att img {
  display: block;
  width: 100%;
  max-height: 10rem;
  object-fit: cover;
}

.cx-att span {
  display: block;
  padding: 0.375rem 0.625rem;
}

.cx-typing {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  padding-top: 0.875rem;
  padding-bottom: 0.875rem;
}

.cx-typing span {
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 50%;
  background: #94a3b8;
  animation: cx-dot 1.1s ease-in-out infinite;
}

.cx-typing span:nth-child(2) { animation-delay: 0.15s; }
.cx-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes cx-dot {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-0.1875rem); }
}

.cx-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.375rem 0 0;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #0369a1;
}

.cx-eyebrow::before {
  content: "";
  flex: none;
  width: 1.5rem;
  height: 2px;
  background: #0369a1;
}

.cx-rail {
  display: flex;
  flex: none;
  gap: 0.5rem;
  margin: 0 -1rem;
  padding: 0.125rem 1rem;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-padding-left: 1rem;
  scrollbar-width: none;
}

.cx-rail::-webkit-scrollbar {
  display: none;
}

.cx-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  margin: 0;
  padding: 0 0.9375rem 0 0.8125rem;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #ffffff;
  color: #0f172a;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  scroll-snap-align: start;
  cursor: pointer;
  touch-action: manipulation;
}

.cx-chip i {
  font-size: 1.125rem;
  line-height: 1;
}

.cx-chip:active {
  border-color: #0369a1;
  background: #f0f9ff;
}

.cx-chip:disabled {
  opacity: 0.55;
  cursor: default;
}

.cx-c1 { color: #0369a1; }
.cx-c2 { color: #0891b2; }
.cx-c3 { color: #7c3aed; }
.cx-c4 { color: #d97706; }

.cx-handoff {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem 0.5rem;
  margin-top: 0.375rem;
  padding-top: 0.875rem;
  border-top: 1px solid #e9ecf1;
  font-size: 0.875rem;
  color: #475569;
}

.cx-handoff-label {
  margin-right: auto;
}

.cx-handoff a {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 2.75rem;
  padding: 0 0.875rem;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}

.cx-handoff a i {
  font-size: 1.0625rem;
  line-height: 1;
}

.cx-wa {
  color: #16a34a;
}

.cx-hours {
  flex-basis: 100%;
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: #5f6f86;
}

.cx-file {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid #e9ecf1;
  background: #ffffff;
  font-size: 0.8125rem;
  color: #475569;
}

.cx-file-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cx-file-clear {
  display: grid;
  flex: none;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  border: 1px solid #e2e8f0;
  border-radius: 50%;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
}

.cx-compose {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  gap: 0.375rem;
  margin: 0;
  padding: 0.5rem 0.625rem calc(0.5rem + var(--cx-safe)) 0.25rem;
  border-top: 1px solid #e9ecf1;
  background: #ffffff;
}

.cx-attach,
.cx-send {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
}

.cx-attach {
  background: none;
  color: #64748b;
  font-size: 1.375rem;
}

.cx-send {
  position: relative;
  background: var(--cx-accent);
  color: #ffffff;
  font-size: 1.1875rem;
}

.cx-send::after {
  content: "";
  position: absolute;
  inset: -0.25rem;
}

.cx-send:disabled,
.cx-send[aria-disabled="true"] {
  opacity: 0.7;
  cursor: default;
}

.cx-spin {
  display: inline-block;
  animation: cx-spin 0.9s linear infinite;
}

@keyframes cx-spin {
  to { transform: rotate(360deg); }
}

.cx-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 2.75rem;
  max-height: 8.25rem;
  margin: 0;
  padding: 0.625rem 0.9375rem;
  border: 1px solid #dbe1ea;
  border-radius: 1.375rem;
  background: #f6f7f9;
  color: #0f172a;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.4;
  resize: none;
  overflow-y: hidden;
}

.cx-input:focus {
  border-color: #7dd3fc;
  outline: 2px solid #e0f2fe;
  outline-offset: 0;
}

.cx-input::placeholder {
  color: #5f6f86;
  opacity: 1;
}

.cx-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 374.98px) {
  .cx-handoff-label {
    flex-basis: 100%;
  }

  .cx-handoff a {
    flex: 1 1 0;
    justify-content: center;
  }
}

@media (min-width: 768px) {
  .cx-backdrop {
    display: none !important;
  }

  .cx-sheet {
    right: 1.5rem;
    bottom: 5.5rem;
    left: auto;
    width: 23rem;
    max-height: min(40rem, calc(100vh - 7rem));
    border-radius: 1.25rem;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.28);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cx-typing span,
  .cx-spin {
    animation: none;
  }
}
