/* Nord Bite customer chat — isolated styles. */
:root { --nb-chat-reserve: 82px; }

body.nb-chat-ready {
  padding-bottom: calc(var(--nb-chat-reserve) + env(safe-area-inset-bottom, 0px));
}

.nb-chat,
.nb-chat * { box-sizing: border-box; }

.nb-chat {
  --nb-bg: var(--bg, #12100d);
  --nb-panel: var(--panel, #211c15);
  --nb-panel-2: var(--panel-2, #2a231a);
  --nb-border: var(--border, #3a3125);
  --nb-copper: var(--copper, #c98a4b);
  --nb-copper-bright: var(--copper-bright, #e0a866);
  --nb-parchment: var(--parchment, #ecdcc0);
  --nb-text: var(--text, #d9cbb2);
  --nb-muted: var(--muted, #9a8b73);
  --nb-ok: var(--ok, #7fb069);
  --nb-bad: var(--bad, #c85c5c);
  position: fixed;
  z-index: 1000;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(14px, env(safe-area-inset-bottom, 0px));
  color: var(--nb-text);
  font: 400 15px/1.45 'Manrope', 'Segoe UI', system-ui, sans-serif;
}

.nb-chat [hidden] { display: none !important; }

.nb-chat button,
.nb-chat input,
.nb-chat textarea { font: inherit; }

.nb-chat button:focus-visible,
.nb-chat input:focus-visible,
.nb-chat textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--nb-copper-bright) 80%, white);
  outline-offset: 2px;
}

.nb-chat-launcher {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-left: auto;
  padding: 11px 16px;
  border: 1px solid rgba(224, 168, 102, .7);
  border-radius: 999px;
  color: #241505;
  background: linear-gradient(180deg, #e2b173, #bd793b);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .48);
  font-weight: 850;
  cursor: pointer;
}

.nb-chat-launcher:hover { filter: brightness(1.07); }
.nb-chat-launcher-icon { font-size: 1.15rem; line-height: 1; }

.nb-chat-unread {
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #fff;
  background: #8b2a2a;
  box-shadow: 0 0 0 2px var(--nb-panel);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.nb-chat-launcher .nb-chat-unread {
  position: absolute;
  top: -5px;
  right: -3px;
  box-shadow: 0 0 0 2px var(--nb-bg);
}

.nb-chat-panel {
  position: absolute;
  right: 0;
  bottom: 66px;
  width: min(400px, calc(100vw - 24px));
  height: min(670px, calc(100dvh - 104px - env(safe-area-inset-top, 0px)));
  min-height: min(470px, calc(100dvh - 104px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid rgba(201, 138, 75, .58);
  border-radius: 18px;
  background: var(--nb-panel);
  box-shadow: 0 22px 60px rgba(0, 0, 0, .65);
}

.nb-chat-header {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px 16px;
  border-bottom: 1px solid var(--nb-border);
  background: linear-gradient(145deg, var(--nb-panel-2), var(--nb-panel));
}

.nb-chat-heading { min-width: 0; flex: 1; }
.nb-chat-heading h2 { margin: 0; color: var(--nb-parchment); font-size: 1.03rem; line-height: 1.25; }
.nb-chat-heading p { margin: 2px 0 0; overflow: hidden; color: var(--nb-muted); font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }

.nb-chat-close {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--nb-text);
  background: transparent;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.nb-chat-close:hover { border-color: var(--nb-border); background: rgba(255, 255, 255, .04); }

.nb-chat-presence {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-height: 51px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--nb-border);
  background: rgba(0, 0, 0, .08);
}
.nb-chat-presence > span:last-child { min-width: 0; display: grid; }
.nb-chat-presence strong { color: var(--nb-parchment); font-size: .78rem; }
.nb-chat-presence small { color: var(--nb-muted); font-size: .7rem; }
.nb-chat-presence .nb-chat-schedule-hint { margin-top: 1px; color: var(--nb-copper); font-size: .64rem; }
.nb-chat-presence-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  margin-top: 5px;
  border-radius: 50%;
  background: #777064;
  box-shadow: 0 0 0 3px rgba(119, 112, 100, .16);
}
.nb-chat-presence-dot.is-online { background: var(--nb-ok); box-shadow: 0 0 0 3px rgba(127, 176, 105, .18); }

.nb-chat-body { min-height: 0; overflow: hidden; }

.nb-chat-prechat {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 17px;
}
.nb-chat-prechat h3 { margin: 0 0 5px; color: var(--nb-parchment); font-size: 1rem; }
.nb-chat-note { margin: 0 0 14px; color: var(--nb-muted); font-size: .78rem; }
.nb-chat-prechat label { display: block; margin: 11px 0 5px; color: var(--nb-copper-bright); font-size: .78rem; font-weight: 800; }
.nb-chat-prechat input {
  width: 100%;
  min-height: 43px;
  padding: 9px 11px;
  border: 1px solid var(--nb-border);
  border-radius: 9px;
  color: var(--nb-parchment);
  background: var(--nb-bg);
}
.nb-chat-prechat input::placeholder,
.nb-chat-input::placeholder { color: color-mix(in srgb, var(--nb-muted) 78%, transparent); }

.nb-chat-button {
  min-height: 42px;
  padding: 9px 15px;
  border: 1px solid rgba(224, 168, 102, .55);
  border-radius: 9px;
  color: #241505;
  background: linear-gradient(180deg, #dda966, #ae6b2e);
  font-weight: 850;
  cursor: pointer;
}
.nb-chat-button:hover:not(:disabled) { filter: brightness(1.08); }
.nb-chat-button:disabled { cursor: wait; opacity: .62; }
.nb-chat-start { width: 100%; margin-top: 17px; }

.nb-chat-conversation {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.nb-chat-load-older {
  grid-row: 1;
  justify-self: center;
  margin: 8px 0 2px;
  padding: 5px 10px;
  border: 0;
  color: var(--nb-copper-bright);
  background: transparent;
  text-decoration: underline;
  cursor: pointer;
  font-size: .75rem;
}

.nb-chat-messages {
  grid-row: 2;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 11px 13px 8px;
  scrollbar-color: var(--nb-border) transparent;
}

.nb-chat-empty { margin: auto; max-width: 250px; color: var(--nb-muted); text-align: center; font-size: .8rem; }

.nb-chat-message-row {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 7px;
}
.nb-chat-message-row.is-incoming { justify-content: flex-start; }
.nb-chat-message-row.is-outgoing { justify-content: flex-end; }

.nb-chat-message {
  min-width: 0;
  width: fit-content;
  max-width: 84%;
  padding: 9px 11px 6px;
  border: 1px solid var(--nb-border);
  border-radius: 13px 13px 13px 4px;
  background: var(--nb-panel-2);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .13);
}
.nb-chat-message-row.is-incoming .nb-chat-message { max-width: calc(100% - 39px); }
.nb-chat-message.is-outgoing {
  border-color: rgba(201, 138, 75, .38);
  border-radius: 13px 13px 4px 13px;
  background: rgba(139, 42, 42, .28);
}
.nb-chat-message p { margin: 0; color: var(--nb-text); white-space: pre-wrap; overflow-wrap: anywhere; }
.nb-chat-message-meta { display: flex; justify-content: flex-end; gap: 7px; margin-top: 3px; color: var(--nb-muted); font-size: .63rem; }
.nb-chat-receipt { color: color-mix(in srgb, var(--nb-ok) 82%, var(--nb-muted)); }

.nb-chat-support-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(201, 138, 75, .62);
  border-radius: 50%;
  color: var(--nb-copper-bright);
  background: radial-gradient(circle at 35% 28%, rgba(201, 138, 75, .2), transparent 50%), var(--nb-bg);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .25);
}
.nb-chat-support-icon svg {
  width: 18px;
  height: 18px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nb-chat-support-icon circle { fill: currentColor; stroke: none; }

.nb-chat-closed-note {
  grid-row: 3;
  margin: 0 12px 7px;
  padding: 7px 9px;
  border: 1px solid rgba(217, 162, 75, .35);
  border-radius: 8px;
  color: #dfbe87;
  background: rgba(217, 162, 75, .06);
  font-size: .69rem;
}

.nb-chat-composer {
  grid-row: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  padding: 10px 11px;
  border-top: 1px solid var(--nb-border);
  background: var(--nb-panel);
}
.nb-chat-input {
  width: 100%;
  min-height: 42px;
  max-height: 112px;
  resize: none;
  overflow-y: auto;
  padding: 9px 11px;
  border: 1px solid var(--nb-border);
  border-radius: 10px;
  color: var(--nb-parchment);
  background: var(--nb-bg);
}
.nb-chat-send { min-width: 88px; }

.nb-chat-status {
  min-height: 0;
  margin: 0;
  padding: 0 13px;
  color: var(--nb-muted);
  background: var(--nb-panel);
  font-size: .7rem;
}
.nb-chat-status:not(:empty) { min-height: 30px; padding-top: 5px; padding-bottom: 7px; border-top: 1px solid var(--nb-border); }
.nb-chat-status.is-error { color: #efaaaa; }

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

@media (max-width: 680px) {
  body.nb-chat-mobile-open { overflow: hidden; }
  .nb-chat { inset: 0; pointer-events: none; }
  .nb-chat-launcher {
    position: fixed;
    right: max(12px, env(safe-area-inset-right, 0px));
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
    pointer-events: auto;
  }
  .nb-chat.is-open .nb-chat-launcher { visibility: hidden; pointer-events: none; }
  .nb-chat-panel {
    position: fixed;
    top: var(--nb-chat-viewport-top, 0px);
    right: 0;
    bottom: auto;
    left: 0;
    width: 100%;
    height: var(--nb-chat-viewport-height, 100dvh);
    min-height: 0;
    max-height: none;
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    pointer-events: auto;
    border: 0;
    border-radius: 0;
  }
  .nb-chat-header { min-height: 62px; }
  .nb-chat-message { max-width: 88%; }
}

@media (max-width: 380px) {
  .nb-chat-launcher { min-height: 48px; padding: 9px 13px; }
  .nb-chat-header { padding-left: 12px; }
  .nb-chat-presence { padding-left: 12px; padding-right: 12px; }
  .nb-chat-composer { grid-template-columns: minmax(0, 1fr); }
  .nb-chat-send { width: 100%; min-height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  .nb-chat * { scroll-behavior: auto !important; }
}

@media print {
  body.nb-chat-ready { padding-bottom: 0 !important; }
  .nb-chat { display: none !important; }
}
