/* Da Angelo — Live Chat · matte black / cream / tricolore */
:root {
  --lc-cream: #f7f5f1;
  --lc-gold: #f7f5f1;
  --lc-fire: #ce2b37;
  --lc-bg: #0a0a0a;
  --lc-card: #141210;
  --lc-line: rgba(247, 245, 241, 0.12);
  --lc-text: #f7f5f1;
  --lc-muted: #a89888;
  --lc-green: #009246;
  --lc-red: #ce2b37;
  --lc-ai: #009246;
  --lc-safe-b: env(safe-area-inset-bottom, 0px);
  --lc-safe-r: env(safe-area-inset-right, 0px);
  --lc-safe-l: env(safe-area-inset-left, 0px);
  --lc-safe-t: env(safe-area-inset-top, 0px);
}

.lc-wrap {
  position: fixed;
  bottom: calc(1.25rem + var(--lc-safe-b));
  right: calc(1.35rem + var(--lc-safe-r));
  z-index: 11020;
  font-family: 'Figtree', system-ui, sans-serif;
  pointer-events: none;
}

.lc-wrap > * {
  pointer-events: auto;
}

html.lc-open,
body.lc-open {
  overscroll-behavior: none;
}

body.lc-open .sticky-cta {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

/* Sit above sticky CTA when the dual bar is on screen */
body:has(.sticky-cta.is-visible) .lc-wrap,
body:has(.sticky-cta.visible) .lc-wrap {
  bottom: calc(3.85rem + var(--lc-safe-b));
}
@media (max-width: 720px) {
  body:has(.sticky-cta.is-visible) .lc-wrap,
  body:has(.sticky-cta.visible) .lc-wrap {
    bottom: calc(4.1rem + var(--lc-safe-b));
    right: calc(0.85rem + var(--lc-safe-r));
  }
  body.lc-open:has(.sticky-cta.is-visible) .lc-wrap,
  body.lc-open:has(.sticky-cta.visible) .lc-wrap {
    bottom: 0;
  }
}

/* Dim page when chat open — tap to dismiss */
.lc-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: rgba(4, 3, 2, 0.55);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease, visibility 0.22s;
  -webkit-tap-highlight-color: transparent;
}

.lc-wrap.is-open .lc-backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.lc-fab {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 48px;
  padding: 0.85rem 1.25rem;
  border-radius: 4px;
  border: 1px solid rgba(247, 245, 241, 0.16);
  cursor: pointer;
  overflow: hidden;
  background: #141210;
  color: var(--lc-cream);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.45);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s, background 0.2s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.lc-fab::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, #009246 0 33.33%, #f7f5f1 33.33% 66.66%, #ce2b37 66.66% 100%);
  pointer-events: none;
}

.lc-fab:hover {
  transform: translateY(-2px);
  border-color: rgba(247, 245, 241, 0.28);
  background: #1a1714;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.5);
}

.lc-fab:focus-visible {
  outline: 2px solid #f7f5f1;
  outline-offset: 3px;
}

.lc-fab__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--lc-green);
  box-shadow: 0 0 0 2px rgba(0, 146, 70, 0.25);
  animation: lcPulse 2s infinite;
}

@keyframes lcPulse {
  50% { opacity: 0.45; transform: scale(0.88); }
}

@media (prefers-reduced-motion: reduce) {
  .lc-fab__dot,
  .lc-head__live::before,
  .lc-panel,
  .lc-backdrop,
  .lc-msg {
    animation: none !important;
    transition: none !important;
  }
}

.lc-panel {
  position: absolute;
  bottom: calc(100% + 0.75rem);
  right: 0;
  z-index: 3;
  width: min(392px, calc(100vw - 1.5rem - var(--lc-safe-l) - var(--lc-safe-r)));
  height: min(540px, calc(100dvh - 6rem - var(--lc-safe-t) - var(--lc-safe-b)));
  max-height: calc(100dvh - 5.5rem - var(--lc-safe-t) - var(--lc-safe-b));
  background: linear-gradient(180deg, #161410 0%, var(--lc-bg) 100%);
  border: 1px solid rgba(247, 245, 241, 0.14);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.03);
  transform: translateY(16px) scale(0.97);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s, visibility 0.22s;
}

.lc-panel[hidden] {
  display: none !important;
}

.lc-wrap.is-open .lc-panel {
  display: flex !important;
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.lc-wrap.is-open .lc-fab {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
  visibility: hidden;
}

/* ── Header + close (close is in-flow — never covered) ── */
.lc-head {
  position: relative;
  z-index: 2;
  padding: 0.75rem 0.65rem 0.75rem 0.9rem;
  background: rgba(247, 245, 241, 0.04);
  border-bottom: 1px solid var(--lc-line);
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
}

.lc-head::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, #009246 0 33.33%, #f7f5f1 33.33% 66.66%, #ce2b37 66.66% 100%);
  pointer-events: none;
}

.lc-head__logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex-shrink: 0;
}

.lc-head__text {
  min-width: 0;
  flex: 1;
}

.lc-head__title {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--lc-text);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.lc-head__sub {
  font-size: 0.68rem;
  color: var(--lc-muted);
  margin-top: 0.15rem;
  line-height: 1.35;
}

.lc-head__live {
  flex-shrink: 0;
  display: none;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lc-green);
  padding: 0.25rem 0.45rem;
  border-radius: 2px;
  background: rgba(0, 146, 70, 0.12);
  border: 1px solid rgba(0, 146, 70, 0.35);
}

@media (min-width: 641px) {
  .lc-head__live {
    display: inline-flex;
  }
}

.lc-head__live::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lc-green);
  animation: lcPulse 2s infinite;
}

/* Large, always-on-top dismiss control */
.lc-close {
  position: relative;
  z-index: 5;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 44px;
  min-height: 44px;
  padding: 0 0.7rem;
  margin: 0;
  border-radius: 4px;
  border: 1px solid rgba(247, 245, 241, 0.22);
  background: rgba(247, 245, 241, 0.08);
  color: var(--lc-cream);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.lc-close:hover,
.lc-close:focus-visible {
  background: rgba(247, 245, 241, 0.16);
  border-color: rgba(247, 245, 241, 0.4);
  color: #fff;
  outline: none;
}

.lc-close:focus-visible {
  outline: 2px solid #f7f5f1;
  outline-offset: 2px;
}

.lc-close:active {
  transform: scale(0.97);
}

.lc-close__icon {
  display: block;
  flex-shrink: 0;
}

.lc-close__label {
  display: none;
}

@media (min-width: 641px) {
  .lc-close__label {
    display: inline;
  }
  .lc-close {
    min-width: auto;
    padding: 0 0.85rem;
  }
}

.lc-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0.9rem 0.9rem 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  scroll-behavior: smooth;
  min-height: 0;
}

.lc-msg {
  max-width: 88%;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  animation: lcFadeIn 0.25s ease;
}

@keyframes lcFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.lc-msg--guest {
  align-self: flex-end;
  align-items: flex-end;
}

.lc-msg--staff,
.lc-msg--ai {
  align-self: flex-start;
  align-items: flex-start;
}

.lc-msg__bubble {
  padding: 0.65rem 0.85rem;
  border-radius: 4px;
  font-size: 0.88rem;
  line-height: 1.5;
  word-break: break-word;
}

.lc-msg--guest .lc-msg__bubble {
  background: rgba(247, 245, 241, 0.1);
  border: 1px solid rgba(247, 245, 241, 0.18);
  color: var(--lc-text);
}

.lc-msg--ai .lc-msg__bubble {
  background: rgba(0, 146, 70, 0.1);
  border: 1px solid rgba(0, 146, 70, 0.28);
}

.lc-msg--staff .lc-msg__bubble {
  background: var(--lc-card);
  border: 1px solid rgba(247, 245, 241, 0.12);
}

.lc-msg__meta {
  font-size: 0.58rem;
  color: var(--lc-muted);
  padding: 0 0.15rem;
}

.lc-msg__name {
  font-weight: 700;
  font-size: 0.62rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.lc-msg--ai .lc-msg__name { color: var(--lc-ai); }
.lc-msg--staff .lc-msg__name { color: var(--lc-cream); }
.lc-msg--guest .lc-msg__name { color: var(--lc-cream); opacity: 0.85; }

.lc-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: var(--lc-muted);
  padding: 0.35rem 0.5rem;
}

.lc-typing__dots { display: flex; gap: 4px; }

.lc-typing__dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lc-ai);
  animation: lcDot 1.2s infinite;
}

.lc-typing__dots i:nth-child(2) { animation-delay: 0.15s; }
.lc-typing__dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes lcDot {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

.lc-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.45rem 0.75rem 0.55rem;
  border-top: 1px solid var(--lc-line);
  flex-shrink: 0;
  max-height: 5.5rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.lc-chip {
  padding: 0.4rem 0.65rem;
  border-radius: 2px;
  border: 1px solid rgba(247, 245, 241, 0.16);
  background: rgba(247, 245, 241, 0.05);
  color: var(--lc-text);
  font: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.lc-chip:hover,
.lc-chip:focus-visible {
  background: rgba(247, 245, 241, 0.1);
  border-color: rgba(247, 245, 241, 0.32);
  outline: none;
}

.lc-error {
  margin: 0;
  padding: 0.4rem 0.75rem;
  font-size: 0.7rem;
  color: #f7f5f1;
  background: rgba(206, 43, 55, 0.12);
  border-top: 1px solid rgba(206, 43, 55, 0.28);
  flex-shrink: 0;
}

.lc-foot {
  padding: 0.65rem 0.75rem calc(0.75rem + var(--lc-safe-b));
  border-top: 1px solid var(--lc-line);
  background: var(--lc-card);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
}

.lc-name--ok {
  border-color: rgba(0, 146, 70, 0.55) !important;
}
.lc-name--bad {
  border-color: rgba(206, 43, 55, 0.75) !important;
  box-shadow: 0 0 0 1px rgba(206, 43, 55, 0.35);
}
.lc-name {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: 4px;
  border: 1px solid var(--lc-line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--lc-text);
  font: inherit;
  font-size: 16px; /* iOS zoom guard */
  box-sizing: border-box;
}

.lc-name::placeholder { color: var(--lc-muted); }
.lc-name:focus {
  outline: none;
  border-color: rgba(247, 245, 241, 0.4);
}

.lc-foot__row {
  display: flex;
  gap: 0.45rem;
  align-items: flex-end;
}

.lc-foot textarea {
  flex: 1;
  padding: 0.7rem 0.8rem;
  border-radius: 4px;
  border: 1px solid var(--lc-line);
  background: var(--lc-bg);
  color: var(--lc-text);
  font: inherit;
  font-size: 16px; /* iOS zoom guard */
  resize: none;
  min-height: 46px;
  max-height: 110px;
  line-height: 1.4;
  box-sizing: border-box;
}

.lc-foot textarea:focus {
  outline: none;
  border-color: rgba(247, 245, 241, 0.4);
}

.lc-send {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 4px;
  border: 1px solid rgba(247, 245, 241, 0.14);
  background: linear-gradient(180deg, #161410 0%, #0e0d0c 100%);
  color: #f7f5f1;
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  transition: transform 0.15s, filter 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.lc-send::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, #009246 0 33.33%, #f7f5f1 33.33% 66.66%, #ce2b37 66.66% 100%);
}

.lc-send:hover { transform: scale(1.04); filter: brightness(1.06); }
.lc-send svg { width: 18px; height: 18px; }

/* ── Phone: bottom sheet, stable, clean ── */
@media (max-width: 640px) {
  .lc-wrap {
    bottom: calc(0.85rem + var(--lc-safe-b));
    right: calc(0.85rem + var(--lc-safe-r));
    left: auto;
  }

  body.lc-open .lc-wrap {
    inset: 0;
    bottom: 0;
    right: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: stretch;
    padding: 0;
  }

  .lc-fab {
    min-width: 52px;
    min-height: 52px;
    padding: 0.85rem 1.15rem;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  }

  .lc-wrap.is-open .lc-fab {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  .lc-panel {
    position: relative;
    bottom: auto;
    right: auto;
    width: 100%;
    max-width: none;
    height: min(78dvh, 640px);
    max-height: calc(100dvh - var(--lc-safe-t) - 0.5rem);
    border-radius: 12px 12px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    transform: translateY(24px);
  }

  .lc-wrap.is-open .lc-panel {
    transform: translateY(0);
  }

  .lc-head {
    padding: 0.7rem 0.55rem 0.7rem 0.85rem;
    gap: 0.45rem;
  }

  .lc-head__logo {
    width: 34px;
    height: 34px;
  }

  .lc-head__title {
    font-size: 0.95rem;
  }

  .lc-head__sub {
    font-size: 0.64rem;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* Thumb-friendly close on phone */
  .lc-close {
    min-width: 48px;
    min-height: 48px;
    padding: 0;
    border-radius: 4px;
    background: rgba(247, 245, 241, 0.12);
    border-color: rgba(247, 245, 241, 0.28);
  }

  .lc-close__icon {
    width: 20px;
    height: 20px;
  }

  .lc-quick {
    max-height: 4.6rem;
    gap: 0.28rem;
    padding: 0.4rem 0.7rem 0.5rem;
  }

  .lc-chip {
    padding: 0.42rem 0.6rem;
    font-size: 0.68rem;
  }

  .lc-body {
    padding: 0.75rem 0.8rem 0.4rem;
  }

  .lc-msg__bubble {
    font-size: 0.86rem;
    padding: 0.6rem 0.8rem;
  }

  .lc-foot {
    padding: 0.55rem 0.7rem calc(0.65rem + var(--lc-safe-b));
  }
}

.lc-fab__ai {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 2px;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: rgba(0, 146, 70, 0.18);
  color: #f7f5f1;
  border: 1px solid rgba(0, 146, 70, 0.35);
}
