/* K2 live-chat widget — self-contained styles for all site pages */
#k2-chat-root {
  --accent: #1D9E75;
  --accent-soft: #5DCAA5;
  --bg: #0B1628;
  --bg-elev: #112040;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --danger: #ff5d6c;
  --text: #ffffff;
  --text-mute: #8899AA;
  --text-dim: #5d6b80;
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
}

#k2-chat-root button {
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
}

#k2-chat-root .chat-fab {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  right: max(24px, env(safe-area-inset-right, 0px));
  z-index: 100;
  width: 56px;
  height: 56px;
  min-width: 56px;
  min-height: 56px;
  border-radius: 16px;
  background: var(--accent);
  color: #06241B;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 32px rgba(29, 158, 117, 0.4), 0 0 0 0 rgba(29, 158, 117, 0.5);
  transition: all 0.2s;
  animation: k2ChatPulse 2.5s infinite;
  -webkit-tap-highlight-color: transparent;
}

@keyframes k2ChatPulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(29, 158, 117, 0.4), 0 0 0 0 rgba(29, 158, 117, 0.5); }
  50% { box-shadow: 0 8px 32px rgba(29, 158, 117, 0.4), 0 0 0 12px rgba(29, 158, 117, 0); }
}

#k2-chat-root .chat-fab:hover { transform: scale(1.05); }

#k2-chat-root .chat-fab .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid var(--bg);
  font-family: 'DM Sans', sans-serif;
}

#k2-chat-root .chat-panel {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  right: max(24px, env(safe-area-inset-right, 0px));
  z-index: 101;
  width: 360px;
  max-width: min(360px, calc(100vw - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  height: 520px;
  max-height: calc(100vh - 48px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  max-height: calc(100dvh - 48px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  max-height: calc(100 * var(--app-vh, 1vh) - 48px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
}

#k2-chat-root .chat-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

#k2-chat-root .chat-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

#k2-chat-root .agent-ava {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  color: #06241B;
  display: grid;
  place-items: center;
  font-family: 'Unbounded', sans-serif;
  font-weight: 700;
  font-size: 13px;
  position: relative;
}

#k2-chat-root .agent-ava::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elev);
}

#k2-chat-root .agent-info .n { font-size: 13px; font-weight: 600; }

#k2-chat-root .agent-info .s {
  font-size: 11px;
  color: var(--accent-soft);
  display: flex;
  align-items: center;
  gap: 6px;
}

#k2-chat-root .chat-close {
  margin-left: auto;
  color: var(--text-mute);
  padding: 4px;
}

#k2-chat-root .chat-close:hover { color: var(--text); }

#k2-chat-root .chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#k2-chat-root .msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.45;
}

#k2-chat-root .msg.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
  border-top-left-radius: 4px;
}

#k2-chat-root .msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #06241B;
  border-top-right-radius: 4px;
  font-weight: 500;
}

#k2-chat-root .msg.operator {
  align-self: flex-start;
  background: rgba(56, 189, 120, 0.14);
  border: 1px solid rgba(56, 189, 120, 0.35);
  border-top-left-radius: 4px;
}

#k2-chat-root .msg .t {
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 4px;
  font-family: 'JetBrains Mono', monospace;
}

#k2-chat-root .msg.user .t { color: rgba(6, 36, 27, 0.6); }

#k2-chat-root .quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

#k2-chat-root .quick-replies button {
  padding: 7px 12px;
  background: rgba(29, 158, 117, 0.1);
  border: 1px solid rgba(29, 158, 117, 0.3);
  color: var(--accent-soft);
  border-radius: 999px;
  font-size: 12px;
  transition: all 0.15s;
}

#k2-chat-root .quick-replies button:hover { background: rgba(29, 158, 117, 0.2); }

#k2-chat-root .chat-input {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
}

#k2-chat-root .chat-input input {
  flex: 1;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
}

#k2-chat-root .chat-input input:focus {
  outline: none;
  border-color: var(--accent);
}

#k2-chat-root .chat-input input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#k2-chat-root .chat-input button.send {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #06241B;
  display: grid;
  place-items: center;
}

#k2-chat-root .chat-input button.send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#k2-chat-root .chat-intro {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#k2-chat-root .intro-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px 2px;
}

#k2-chat-root .intro-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#k2-chat-root .intro-field > span {
  font-size: 11px;
  color: var(--text-mute);
  font-weight: 500;
  letter-spacing: 0.02em;
}

#k2-chat-root .intro-field input {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

#k2-chat-root .intro-field input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(29, 158, 117, 0.05);
}

#k2-chat-root .intro-field .phone-wrap { position: relative; }

#k2-chat-root .intro-field .phone-prefix {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--text-mute);
  pointer-events: none;
  font-family: 'JetBrains Mono', monospace;
}

#k2-chat-root .intro-field .phone-wrap input {
  padding-left: 42px;
  font-family: 'JetBrains Mono', monospace;
}

#k2-chat-root .intro-submit {
  background: var(--accent);
  color: #06241B;
  padding: 11px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
  transition: background 0.15s, opacity 0.15s;
}

#k2-chat-root .intro-submit:hover:not(:disabled) { background: var(--accent-soft); }

#k2-chat-root .intro-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#k2-chat-root .intro-error {
  font-size: 12px;
  color: var(--danger);
  padding: 4px 2px;
}

#k2-chat-root .escalation-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(245, 165, 36, 0.12);
  border: 1px solid rgba(245, 165, 36, 0.35);
  border-radius: 10px;
  color: #f5a524;
  font-size: 12px;
  line-height: 1.4;
  align-self: stretch;
}

#k2-chat-root .escalation-banner svg { flex-shrink: 0; }

#k2-chat-root .msg.typing .dots {
  display: inline-flex;
  gap: 5px;
  padding: 4px 2px;
}

#k2-chat-root .msg.typing .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-mute);
  animation: k2TypingDot 1.2s ease-in-out infinite;
}

#k2-chat-root .msg.typing .dot:nth-child(2) { animation-delay: 0.2s; }
#k2-chat-root .msg.typing .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes k2TypingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-5px); opacity: 1; }
}

@media (pointer: coarse) {
  #k2-chat-root .chat-input input,
  #k2-chat-root .intro-field input { font-size: 16px; }
  #k2-chat-root .chat-fab,
  #k2-chat-root .intro-submit { touch-action: manipulation; }
}

@media (max-width: 640px) {
  #k2-chat-root .chat-panel {
    left: max(8px, env(safe-area-inset-left, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    width: auto;
    max-width: none;
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
    height: min(70vh, calc(100vh - 100px));
    height: min(70dvh, calc(100dvh - 100px));
    height: min(calc(var(--app-vh, 1vh) * 70), calc(var(--app-vh, 1vh) * 100 - 100px));
    max-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px);
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px);
    max-height: calc(100 * var(--app-vh, 1vh) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px);
  }

  #k2-chat-root .chat-fab {
    bottom: max(16px, env(safe-area-inset-bottom, 0px));
    right: max(16px, env(safe-area-inset-right, 0px));
  }

  #k2-chat-root .chat-head {
    padding: 14px 14px;
    flex-wrap: nowrap;
    gap: 10px;
  }

  #k2-chat-root .agent-info .n { font-size: 12px; line-height: 1.3; }
  #k2-chat-root .agent-info .s { font-size: 10px; flex-wrap: wrap; }

  #k2-chat-root .chat-close {
    min-width: 44px;
    min-height: 44px;
    display: grid;
    place-items: center;
    margin-left: auto;
    flex-shrink: 0;
  }

  #k2-chat-root .chat-input input { font-size: 16px; }

  #k2-chat-root .chat-input button.send {
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
  }

  #k2-chat-root .quick-replies button {
    min-height: 40px;
    padding: 8px 14px;
  }

  #k2-chat-root .intro-field input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  #k2-chat-root .chat-fab { animation: none; }
  #k2-chat-root .msg.typing .dot { animation: none; }
}
