/* =====================================================================
   Door Repairs UK Ltd  ·  Website Assistant widget styles
   Uses the site brand tokens: navy #163e7c, navy-dark #0e2c5c, sky #29abe2.
   Everything is namespaced under .druk-chat so it cannot leak into the
   page, and vice versa.
   ===================================================================== */

.druk-chat {
  --dk-navy: #064287;
  --dk-navy-d: #042f61;
  --dk-sky: #3eabe8;
  --dk-accent: #3eabe8;
  --dk-ink: #24313f;
  --dk-muted: #5b6773;
  --dk-line: #dfe6ec;
  --dk-soft: #f2f6f9;
  --dk-bad: #b3261e;
  --dk-radius: 14px;
  --dk-font: "Encode Sans", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;

  position: fixed;
  right: 20px;
  bottom: 34px;
  z-index: 2147483000;
  font-family: var(--dk-font);
  color: var(--dk-ink);
  font-size: 15px;
  line-height: 1.55;
}

.druk-chat *,
.druk-chat *::before,
.druk-chat *::after { box-sizing: border-box; }

.druk-sr {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --------------------------------------------------------- launcher ---- */

.druk-launcher {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  margin-left: auto;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--dk-navy) 0%, var(--dk-navy-d) 100%);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 26px rgba(14, 44, 92, .34);
  transition: transform .18s cubic-bezier(.2, .8, .3, 1), box-shadow .18s ease;
}
.druk-launcher:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(14, 44, 92, .42); }
.druk-launcher:active { transform: translateY(0); }

.druk-launcher-icon,
.druk-launcher-close {
  position: absolute;
  display: flex;
  transition: opacity .18s ease, transform .18s ease;
}
.druk-launcher-close { opacity: 0; transform: rotate(-90deg) scale(.6); }
.druk-chat.is-open .druk-launcher-icon { opacity: 0; transform: rotate(90deg) scale(.6); }
.druk-chat.is-open .druk-launcher-close { opacity: 1; transform: none; }

.druk-badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 20px; height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--dk-sky);
  color: #06263f;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}
.druk-badge[hidden] { display: none; }

/* ------------------------------------------------------------ panel ---- */

.druk-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  display: flex;
  flex-direction: column;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 130px);
  background: #fff;
  border: 1px solid var(--dk-line);
  border-radius: var(--dk-radius);
  box-shadow: 0 20px 50px rgba(14, 44, 92, .24);
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px) scale(.98);
  transform-origin: bottom right;
  transition: opacity .2s ease, transform .2s cubic-bezier(.2, .8, .3, 1);
  pointer-events: none;
}
.druk-panel[hidden] { display: none; }
.druk-chat.is-open .druk-panel { opacity: 1; transform: none; pointer-events: auto; }

/* ------------------------------------------------------------- head ---- */

.druk-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--dk-navy) 0%, var(--dk-navy-d) 100%);
  color: #fff;
  flex: 0 0 auto;
}
.druk-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  flex: 0 0 auto;
}
.druk-head-txt { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.druk-head-txt strong { font-size: 15px; font-weight: 600; }
.druk-head-txt span {
  font-size: 12px;
  color: #cfe6f7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.druk-min {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #cfe6f7;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.druk-min:hover { background: rgba(255, 255, 255, .14); color: #fff; }

/* -------------------------------------------------------------- log ---- */

.druk-log {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  background: var(--dk-soft);
  scrollbar-width: thin;
}
.druk-log::-webkit-scrollbar { width: 8px; }
.druk-log::-webkit-scrollbar-thumb { background: #cfdcea; border-radius: 4px; }

.druk-msg { display: flex; margin-bottom: 10px; }
.druk-user { justify-content: flex-end; }

.druk-bubble {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.55;
  animation: druk-in .22s cubic-bezier(.2, .8, .3, 1);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.druk-bot .druk-bubble {
  background: #fff;
  border: 1px solid var(--dk-line);
  border-bottom-left-radius: 5px;
  color: var(--dk-ink);
}
.druk-user .druk-bubble {
  background: var(--dk-navy);
  border-bottom-right-radius: 5px;
  color: #fff;
}
.druk-bubble p { margin: 0 0 8px; }
.druk-bubble p:last-child { margin-bottom: 0; }
.druk-bubble ul { margin: 4px 0 0; padding-left: 18px; }
.druk-bubble li { margin-bottom: 4px; }

@keyframes druk-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.druk-typing { display: flex; gap: 4px; padding: 14px; }
.druk-typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #a9b7c6;
  animation: druk-bounce 1.2s infinite ease-in-out;
}
.druk-typing span:nth-child(2) { animation-delay: .16s; }
.druk-typing span:nth-child(3) { animation-delay: .32s; }
@keyframes druk-bounce {
  0%, 60%, 100% { transform: none; opacity: .5; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* ------------------------------------------------------------- form ---- */

.druk-form {
  flex: 0 0 auto;
  max-height: 62%;
  overflow-y: auto;
  padding: 16px;
  background: #fff;
  border-top: 1px solid var(--dk-line);
}
.druk-form[hidden] { display: none; }

.druk-form-lead {
  margin: 0 0 12px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--dk-muted);
}
.druk-form p { margin: 0 0 10px; }
.druk-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.druk-form label {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--dk-muted);
}
.druk-form label abbr {
  color: var(--dk-bad);
  text-decoration: none;
  border: 0;
}

.druk-form input,
.druk-form textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--dk-line);
  border-radius: 8px;
  font: inherit;
  font-size: 14.5px;
  color: var(--dk-ink);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.druk-form input:focus,
.druk-form textarea:focus {
  outline: 0;
  border-color: var(--dk-navy);
  box-shadow: 0 0 0 3px rgba(22, 62, 124, .14);
}
.druk-form [aria-invalid="true"] {
  border-color: var(--dk-bad);
  box-shadow: 0 0 0 3px rgba(179, 38, 30, .12);
}
.druk-form textarea { resize: vertical; min-height: 66px; }

/* Honeypot. Clipped rather than pushed off-screen or set to zero size,
   so it never reads as cloaking. */
.druk-hp {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.druk-consent {
  font-size: 11.5px;
  color: var(--dk-muted);
  line-height: 1.5;
}

.druk-send-lead {
  width: 100%;
  padding: 11px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--dk-navy);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
}
.druk-send-lead:hover { background: var(--dk-navy-d); }
.druk-send-lead[disabled] { opacity: .6; cursor: progress; }

.druk-form-msg { margin: 8px 0 0; font-size: 13px; min-height: 1em; }
.druk-form-msg.is-error { color: var(--dk-bad); font-weight: 600; }

/* --------------------------------------------------------- input bar --- */

.druk-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px;
  background: #fff;
  border-top: 1px solid var(--dk-line);
  flex: 0 0 auto;
}
.druk-bar[hidden] { display: none; }

.druk-bar input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--dk-line);
  border-radius: 22px;
  font: inherit;
  font-size: 14.5px;
  background: var(--dk-soft);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.druk-bar input:focus {
  outline: 0;
  background: #fff;
  border-color: var(--dk-navy);
  box-shadow: 0 0 0 3px rgba(22, 62, 124, .14);
}
.druk-bar input[disabled] { opacity: .6; }

.druk-bar button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: var(--dk-navy);
  color: #fff;
  cursor: pointer;
  transition: background .15s ease, transform .12s ease;
}
.druk-bar button:hover { background: var(--dk-navy-d); }
.druk-bar button:active { transform: scale(.94); }

/* -------------------------------------------------------------- foot --- */

.druk-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 8px 14px 10px;
  background: #fff;
  border-top: 1px solid #eef2f7;
  font-size: 11.5px;
  color: var(--dk-muted);
  flex: 0 0 auto;
}
.druk-foot a { color: var(--dk-accent); text-decoration: none; font-weight: 600; }
.druk-foot a:hover { text-decoration: underline; }

/* ------------------------------------------------------------- focus --- */

.druk-chat :focus-visible {
  outline: 3px solid var(--dk-sky);
  outline-offset: 2px;
}

/* ------------------------------------------------------------ mobile --- */

@media (max-width: 480px) {
  .druk-chat { right: 14px; bottom: 14px; }
  .druk-panel {
    position: fixed;
    right: 0; left: 0; bottom: 0;
    width: 100%;
    max-width: none;
    height: 86vh;
    max-height: 86vh;
    border-radius: var(--dk-radius) var(--dk-radius) 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    transform-origin: bottom center;
  }
  .druk-row { grid-template-columns: 1fr; }
  .druk-launcher { width: 56px; height: 56px; }
}

@media print { .druk-chat { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
  .druk-chat *,
  .druk-chat *::before,
  .druk-chat *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
