/* Live chat widget — Extreme Bearing brand-passend redesign (CSS-only)
   DOM-structuur en classnames ongewijzigd t.o.v. chat-widget.js. */

.exb-chat-root {
  position: fixed;
  z-index: 9998;
  bottom: 1.5rem;
  right: 1.5rem;
  font-family: var(--font-sans, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  font-size: 0.9375rem;
  color: rgb(0, 44, 53);
  --exb-chat-navy: var(--primary-dark, rgb(0, 44, 53));
  --exb-chat-navy-2: rgb(0, 64, 77);
  --exb-chat-blue: var(--primary-blue, rgb(0, 142, 201));
  --exb-chat-blue-strong: var(--primary-blue-strong, rgb(77, 163, 255));
  --exb-chat-blue-soft: rgba(0, 142, 201, 0.18);
  --exb-chat-online: #22c55e;
  --exb-chat-border: rgba(0, 44, 53, 0.08);
  --exb-chat-surface: #ffffff;
  --exb-chat-surface-2: #f5f8fa;
}

[dir="rtl"] .exb-chat-root {
  right: auto;
  left: 1.5rem;
}

/* ---------- Floating action button ---------- */
.exb-chat-launcher {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background:
    radial-gradient(circle at 30% 28%, var(--exb-chat-blue-strong) 0%, var(--exb-chat-blue) 60%, rgb(0, 110, 158) 100%);
  color: #fff;
  box-shadow:
    0 10px 28px rgba(0, 142, 201, 0.38),
    0 3px 8px rgba(0, 44, 53, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2), box-shadow 0.18s ease;
}

.exb-chat-launcher:hover {
  transform: translateY(-2px) scale(1.06);
  box-shadow:
    0 14px 32px rgba(0, 142, 201, 0.5),
    0 4px 10px rgba(0, 44, 53, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.exb-chat-launcher:active {
  transform: translateY(0) scale(1.02);
}

.exb-chat-launcher i {
  font-size: 1.6rem;
  line-height: 1;
}

/* ---------- Invite popup ---------- */
.exb-chat-invite {
  position: absolute;
  bottom: 4.25rem;
  right: 0;
  max-width: 17rem;
  padding: 0.85rem 1rem 0.75rem;
  background: var(--exb-chat-surface);
  color: var(--exb-chat-navy);
  border: 1px solid var(--exb-chat-border);
  border-radius: 0.85rem;
  box-shadow:
    0 18px 42px rgba(0, 44, 53, 0.22),
    0 4px 10px rgba(0, 44, 53, 0.1);
  animation: exbChatFadeIn 0.35s ease;
}

.exb-chat-invite::after {
  content: "";
  position: absolute;
  right: 1.25rem;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: var(--exb-chat-surface);
  border-right: 1px solid var(--exb-chat-border);
  border-bottom: 1px solid var(--exb-chat-border);
  transform: rotate(45deg);
}

[dir="rtl"] .exb-chat-invite {
  right: auto;
  left: 0;
}

[dir="rtl"] .exb-chat-invite::after {
  right: auto;
  left: 1.25rem;
}

.exb-chat-invite p {
  margin: 0 0 0.6rem;
  line-height: 1.45;
  font-size: 0.875rem;
  color: var(--exb-chat-navy);
}

.exb-chat-invite-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.exb-chat-invite-actions button {
  border: none;
  border-radius: 0.5rem;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease;
}

.exb-chat-invite-yes {
  background: var(--exb-chat-blue);
  color: #fff;
}

.exb-chat-invite-yes:hover {
  background: rgb(0, 110, 158);
}

.exb-chat-invite-no {
  background: transparent;
  color: rgb(107, 114, 128);
}

.exb-chat-invite-no:hover {
  background: rgba(0, 44, 53, 0.06);
  color: var(--exb-chat-navy);
}

/* ---------- Panel ---------- */
.exb-chat-panel {
  position: absolute;
  bottom: 4.25rem;
  right: 0;
  width: min(24rem, calc(100vw - 2rem));
  max-height: min(32rem, 75vh);
  background: var(--exb-chat-surface);
  color: var(--exb-chat-navy);
  border-radius: 1rem;
  box-shadow:
    0 24px 60px rgba(0, 44, 53, 0.32),
    0 8px 20px rgba(0, 44, 53, 0.16);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--exb-chat-border);
}

.exb-chat-panel:not(.exb-chat-hidden) {
  animation: exbChatPanelIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.05);
}

[dir="rtl"] .exb-chat-panel {
  right: auto;
  left: 0;
}

/* ---------- Header (branded) ---------- */
.exb-chat-panel-header {
  position: relative;
  padding: 1rem 1rem 1rem 4.25rem;
  background: linear-gradient(135deg, var(--exb-chat-navy) 0%, var(--exb-chat-navy-2) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 4.25rem;
}

/* Avatar (logo + status dot) injected purely via CSS */
.exb-chat-panel-header::before {
  content: "";
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background-color: var(--exb-chat-blue);
  background-image: url("/images/logo/SVG/EXB%20%28White%29.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 64% auto;
  border: 2px solid rgba(255, 255, 255, 0.18);
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Status dot (green online indicator) */
.exb-chat-panel-header::after {
  content: "";
  position: absolute;
  left: 2.85rem;
  top: calc(50% + 0.55rem);
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--exb-chat-online);
  border: 2px solid var(--exb-chat-navy);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

[dir="rtl"] .exb-chat-panel-header {
  padding: 1rem 4.25rem 1rem 1rem;
}

[dir="rtl"] .exb-chat-panel-header::before {
  left: auto;
  right: 1rem;
}

[dir="rtl"] .exb-chat-panel-header::after {
  left: auto;
  right: 2.85rem;
}

.exb-chat-panel-header > div:first-child {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.1rem;
}

.exb-chat-panel-header h3,
.exb-chat-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.25;
  color: #fff;
}

.exb-chat-panel-header p,
.exb-chat-subtitle {
  margin: 0;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.4;
}

.exb-chat-panel-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  padding: 0.4rem;
  line-height: 1;
  border-radius: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.exb-chat-panel-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.exb-chat-panel-close i {
  font-size: 1.15rem;
}

/* ---------- Body / messages ---------- */
.exb-chat-pre,
.exb-chat-body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  flex: 1;
  min-height: 6rem;
  background: var(--exb-chat-surface);
}

.exb-chat-body {
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
}

.exb-chat-body::-webkit-scrollbar {
  width: 8px;
}

.exb-chat-body::-webkit-scrollbar-thumb {
  background: rgba(0, 44, 53, 0.18);
  border-radius: 4px;
}

.exb-chat-body::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 44, 53, 0.32);
}

.exb-chat-body::-webkit-scrollbar-track {
  background: transparent;
}

/* Pre-chat form */
.exb-chat-pre label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: rgb(75, 85, 99);
  letter-spacing: 0.01em;
}

.exb-chat-pre input {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 0.85rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid rgba(0, 44, 53, 0.14);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--exb-chat-navy);
  background: var(--exb-chat-surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.exb-chat-pre input:focus {
  outline: none;
  border-color: var(--exb-chat-blue);
  box-shadow: 0 0 0 3px var(--exb-chat-blue-soft);
}

.exb-chat-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* ---------- Message bubbles ---------- */
.exb-chat-msg {
  margin-bottom: 0.5rem;
  padding: 0.55rem 0.9rem;
  max-width: 78%;
  line-height: 1.45;
  word-break: break-word;
  font-size: 0.875rem;
  animation: exbChatBubbleIn 0.22s ease-out;
}

.exb-chat-msg-visitor {
  margin-left: auto;
  background: var(--exb-chat-blue);
  color: #fff;
  border-radius: 1.1rem 1.1rem 0.3rem 1.1rem;
  box-shadow: 0 2px 6px rgba(0, 142, 201, 0.22);
}

[dir="rtl"] .exb-chat-msg-visitor {
  margin-left: 0;
  margin-right: auto;
  border-radius: 1.1rem 1.1rem 1.1rem 0.3rem;
}

.exb-chat-msg-agent {
  margin-right: auto;
  background: var(--exb-chat-surface-2);
  color: var(--exb-chat-navy);
  border: 1px solid var(--exb-chat-border);
  border-radius: 1.1rem 1.1rem 1.1rem 0.3rem;
}

[dir="rtl"] .exb-chat-msg-agent {
  margin-right: 0;
  margin-left: auto;
  border-radius: 1.1rem 1.1rem 0.3rem 1.1rem;
}

/* Consecutive same-sender bubbles cluster closer */
.exb-chat-msg-visitor + .exb-chat-msg-visitor,
.exb-chat-msg-agent + .exb-chat-msg-agent {
  margin-top: -0.2rem;
  margin-bottom: 0.3rem;
}

.exb-chat-msg-system {
  font-size: 0.75rem;
  color: rgb(107, 114, 128);
  text-align: center;
  margin: 0.6rem auto;
  max-width: 80%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.exb-chat-msg-system::before,
.exb-chat-msg-system::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(0, 44, 53, 0.1);
}

/* ---------- Compose row (pill style) ---------- */
.exb-chat-compose {
  padding: 0.65rem 0.9rem 0.85rem;
  border-top: 1px solid var(--exb-chat-border);
  background: var(--exb-chat-surface);
  display: flex;
  gap: 0;
  align-items: stretch;
}

.exb-chat-compose > textarea,
.exb-chat-compose > button {
  display: block;
}

/* Pill wrapper: simulated via using compose + textarea + button styling */
.exb-chat-compose {
  position: relative;
}

.exb-chat-compose::before {
  content: "";
  position: absolute;
  left: 0.9rem;
  right: 0.9rem;
  top: 0.65rem;
  bottom: 0.85rem;
  background: var(--exb-chat-surface-2);
  border: 1px solid var(--exb-chat-border);
  border-radius: 1.5rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  pointer-events: none;
}

.exb-chat-compose:focus-within::before {
  border-color: var(--exb-chat-blue);
  background: #fff;
  box-shadow: 0 0 0 3px var(--exb-chat-blue-soft);
}

.exb-chat-compose textarea {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 2.4rem;
  max-height: 6rem;
  resize: none;
  border: none;
  background: transparent;
  padding: 0.55rem 0.5rem 0.55rem 1rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--exb-chat-navy);
  line-height: 1.4;
}

.exb-chat-compose textarea:focus {
  outline: none;
}

.exb-chat-compose textarea::placeholder {
  color: rgb(156, 163, 175);
}

.exb-chat-compose button[type="submit"] {
  position: relative;
  z-index: 1;
  border: none;
  width: 2.4rem;
  height: 2.4rem;
  margin: auto 0.35rem auto 0;
  border-radius: 50%;
  background: var(--exb-chat-blue);
  color: #fff;
  cursor: pointer;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.12s ease;
  align-self: flex-end;
}

.exb-chat-compose button[type="submit"]:hover:not(:disabled) {
  background: rgb(0, 110, 158);
  transform: scale(1.05);
}

.exb-chat-compose button[type="submit"]:active:not(:disabled) {
  transform: scale(0.96);
}

.exb-chat-compose button[type="submit"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Hide the text label; show paper-plane icon instead */
.exb-chat-send-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.exb-chat-compose button[type="submit"]::before {
  content: "\e398"; /* ph-paper-plane-tilt */
  font-family: "Phosphor";
  font-style: normal;
  font-weight: 400;
  font-size: 1.1rem;
  line-height: 1;
  display: inline-block;
  transform: translateX(-1px);
}

[dir="rtl"] .exb-chat-compose button[type="submit"] {
  margin: auto 0 auto 0.35rem;
}

[dir="rtl"] .exb-chat-compose button[type="submit"]::before {
  transform: scaleX(-1) translateX(-1px);
}

[dir="rtl"] .exb-chat-compose textarea {
  padding: 0.55rem 1rem 0.55rem 0.5rem;
}

/* ---------- Primary CTA (Start chat) ---------- */
.exb-chat-primary {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 0.55rem;
  background: var(--exb-chat-blue);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 12px rgba(0, 142, 201, 0.28);
}

.exb-chat-primary:hover {
  background: rgb(0, 110, 158);
  box-shadow: 0 6px 16px rgba(0, 142, 201, 0.38);
  transform: translateY(-1px);
}

.exb-chat-primary:active {
  transform: translateY(0);
}

.exb-chat-warn {
  font-size: 0.75rem;
  color: #b45309;
  margin-top: 0.5rem;
  line-height: 1.4;
}

/* ---------- Utility ---------- */
.exb-chat-hidden {
  display: none !important;
}

/* ---------- Animations ---------- */
@keyframes exbChatFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes exbChatPanelIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes exbChatBubbleIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
  .exb-chat-root {
    right: 1rem;
    bottom: 1rem;
  }

  [dir="rtl"] .exb-chat-root {
    left: 1rem;
    right: auto;
  }

  .exb-chat-panel {
    position: fixed;
    inset: auto 0 0 0;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 85vh;
    border-radius: 1.25rem 1.25rem 0 0;
  }

  .exb-chat-panel-header {
    padding: 0.9rem 1rem 0.9rem 3.85rem;
    min-height: 4rem;
  }

  .exb-chat-panel-header::before {
    width: 2.25rem;
    height: 2.25rem;
    left: 1rem;
  }

  .exb-chat-panel-header::after {
    left: 2.5rem;
  }

  [dir="rtl"] .exb-chat-panel-header {
    padding: 0.9rem 3.85rem 0.9rem 1rem;
  }

  [dir="rtl"] .exb-chat-panel-header::before {
    right: 1rem;
    left: auto;
  }

  [dir="rtl"] .exb-chat-panel-header::after {
    right: 2.5rem;
    left: auto;
  }
}
