/* CHD-TECH live chat widget (Tawk.to-style, self-hosted) */

#chdchat {
  --cc-ink: #10243e;
  --cc-ink-2: #1b3354;
  --cc-accent: #e4572e;
  --cc-accent-2: #c9471f;
  --cc-paper: #f7f3ec;
  --cc-line: #e4dccf;
  --cc-muted: #5e6a78;
  --cc-ok: #1f9d6b;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--cc-ink);
  line-height: 1.45;
}

#chdchat *,
#chdchat *::before,
#chdchat *::after {
  box-sizing: border-box;
}

#chdchat .cc-launcher {
  position: relative;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin-left: auto;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cc-accent), var(--cc-accent-2));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(228, 87, 46, 0.35), 0 2px 6px rgba(16, 36, 62, 0.2);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

#chdchat .cc-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(228, 87, 46, 0.42), 0 3px 8px rgba(16, 36, 62, 0.22);
}

#chdchat .cc-launcher:focus-visible {
  outline: 3px solid rgba(228, 87, 46, 0.45);
  outline-offset: 3px;
}

#chdchat .cc-launcher svg {
  width: 28px;
  height: 28px;
  display: block;
}

#chdchat .cc-launcher .cc-launcher-icon--close {
  display: none;
}

#chdchat.is-open .cc-launcher .cc-launcher-icon--chat {
  display: none;
}

#chdchat.is-open .cc-launcher .cc-launcher-icon--close {
  display: block;
}

#chdchat .cc-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--cc-ink);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: none;
  place-items: center;
  box-shadow: 0 0 0 3px #fff;
}

#chdchat.has-unread .cc-badge {
  display: grid;
}

#chdchat .cc-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 120px);
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border-radius: 18px;
  border: 1px solid rgba(16, 36, 62, 0.08);
  box-shadow: 0 30px 70px rgba(16, 36, 62, 0.28), 0 6px 18px rgba(16, 36, 62, 0.12);
  transform-origin: bottom right;
}

#chdchat.is-open .cc-panel {
  display: flex;
  animation: cc-pop 0.18s ease-out;
}

@keyframes cc-pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#chdchat .cc-head {
  position: relative;
  padding: 18px 18px 16px;
  background: linear-gradient(135deg, var(--cc-ink), var(--cc-ink-2));
  color: #fff;
  flex: 0 0 auto;
}

#chdchat .cc-head-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

#chdchat .cc-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.14);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
}

#chdchat .cc-head-text {
  min-width: 0;
  flex: 1 1 auto;
}

#chdchat .cc-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

#chdchat .cc-close {
  align-self: flex-start;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}

#chdchat .cc-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

#chdchat .cc-close svg {
  width: 16px;
  height: 16px;
}

#chdchat .cc-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px 8px;
  background: var(--cc-paper);
}

#chdchat .cc-msg {
  display: flex;
  margin-bottom: 12px;
}

#chdchat .cc-msg.is-agent {
  justify-content: flex-start;
}

#chdchat .cc-msg.is-visitor {
  justify-content: flex-end;
}

#chdchat .cc-bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 2px rgba(16, 36, 62, 0.06);
}

#chdchat .cc-msg.is-agent .cc-bubble {
  background: #fff;
  border: 1px solid var(--cc-line);
  border-bottom-left-radius: 5px;
}

#chdchat .cc-msg.is-visitor .cc-bubble {
  background: var(--cc-accent);
  color: #fff;
  border-bottom-right-radius: 5px;
}

#chdchat .cc-time {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.6;
}

#chdchat .cc-note {
  margin: 0 auto 14px;
  padding: 7px 12px;
  max-width: 90%;
  border-radius: 999px;
  background: rgba(16, 36, 62, 0.06);
  color: var(--cc-muted);
  font-size: 12px;
  text-align: center;
}

#chdchat .cc-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

#chdchat .cc-chip {
  border: 1px solid var(--cc-line);
  background: #fff;
  color: var(--cc-ink);
  border-radius: 999px;
  padding: 7px 12px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

#chdchat .cc-chip:hover {
  border-color: var(--cc-accent);
  color: var(--cc-accent-2);
}

#chdchat .cc-typing {
  display: none;
  align-items: center;
  gap: 5px;
  margin: 0 0 10px;
  color: var(--cc-muted);
  font-size: 12px;
}

#chdchat .cc-typing.is-on {
  display: flex;
}

#chdchat .cc-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cc-muted);
  animation: cc-blink 1.2s infinite ease-in-out;
}

#chdchat .cc-typing i:nth-child(2) {
  animation-delay: 0.15s;
}

#chdchat .cc-typing i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes cc-blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}

#chdchat .cc-foot {
  flex: 0 0 auto;
  padding: 10px 12px 12px;
  background: #fff;
  border-top: 1px solid var(--cc-line);
}

#chdchat .cc-prechat {
  display: none;
  gap: 8px;
  margin-bottom: 8px;
}

#chdchat .cc-prechat.is-on {
  display: grid;
}

#chdchat .cc-field {
  width: 100%;
  border: 1px solid var(--cc-line);
  border-radius: 10px;
  padding: 9px 11px;
  font: inherit;
  font-size: 13.5px;
  color: var(--cc-ink);
  background: #fff;
}

#chdchat .cc-field:focus {
  outline: 2px solid rgba(228, 87, 46, 0.35);
  border-color: var(--cc-accent);
}

#chdchat .cc-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

#chdchat .cc-input {
  flex: 1 1 auto;
  resize: none;
  max-height: 120px;
  min-height: 42px;
  border: 1px solid var(--cc-line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--cc-ink);
  background: var(--cc-paper);
}

#chdchat .cc-input:focus {
  outline: 2px solid rgba(228, 87, 46, 0.35);
  border-color: var(--cc-accent);
  background: #fff;
}

#chdchat .cc-send {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: var(--cc-accent);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}

#chdchat .cc-send:hover {
  background: var(--cc-accent-2);
}

#chdchat .cc-send:disabled {
  opacity: 0.5;
  cursor: default;
}

#chdchat .cc-send svg {
  width: 18px;
  height: 18px;
}

#chdchat .cc-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  font-size: 12.5px;
}

#chdchat .cc-links a {
  color: var(--cc-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

#chdchat .cc-links a:hover {
  color: var(--cc-accent-2);
}

#chdchat .cc-links svg {
  width: 14px;
  height: 14px;
}

#chdchat .cc-error {
  margin: 0 0 8px;
  color: #b3341c;
  font-size: 12.5px;
  display: none;
}

#chdchat .cc-error.is-on {
  display: block;
}

#chdchat .cc-closed {
  display: none;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid var(--cc-line);
  text-align: center;
}

#chdchat.is-closed .cc-closed {
  display: block;
}

#chdchat.is-closed .cc-foot {
  display: none;
}

#chdchat .cc-new {
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  background: var(--cc-ink);
  color: #fff;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}

#chdchat .cc-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 480px) {
  #chdchat {
    right: 14px;
    bottom: 14px;
  }

  #chdchat .cc-panel {
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    border-radius: 0;
    bottom: 0;
    right: 0;
  }

  #chdchat.is-open .cc-launcher {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #chdchat .cc-panel,
  #chdchat .cc-launcher,
  #chdchat .cc-typing i {
    animation: none !important;
    transition: none !important;
  }
}

/* ------------------------- attachments (widget) ------------------------- */

#chdchat .cc-attach {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid var(--cc-line);
  border-radius: 12px;
  background: #fff;
  color: var(--cc-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

#chdchat .cc-attach:hover {
  border-color: var(--cc-accent);
  color: var(--cc-accent);
}

#chdchat .cc-attach:disabled {
  opacity: 0.5;
  cursor: default;
}

#chdchat .cc-attach svg {
  width: 19px;
  height: 19px;
}

#chdchat .cc-preview {
  position: relative;
  display: inline-block;
  margin: 0 0 8px;
}

#chdchat .cc-preview[hidden] {
  display: none;
}

#chdchat .cc-preview img {
  display: block;
  max-width: 180px;
  max-height: 100px;
  border-radius: 10px;
  border: 1px solid var(--cc-line);
}

#chdchat .cc-preview-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--cc-ink);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

#chdchat .cc-bubble__image {
  display: block;
  margin-bottom: 6px;
}

#chdchat .cc-bubble__image img {
  display: block;
  max-width: 220px;
  max-height: 180px;
  border-radius: 10px;
  border: 1px solid rgba(16, 36, 62, 0.12);
}

#chdchat .cc-bubble__text {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
