/* Floating chat widget */
#eilc-launch {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom,0px));
  padding: 12px 14px;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  background: #2563eb;
  color: #fff;
  font-weight: 700;
  z-index: 999999;
  cursor: pointer;
  min-width: 56px; min-height: 44px;
  font-size: 14px;
}
#eilc-box {
  position: fixed;
  right: 18px;
  bottom: calc(78px + env(safe-area-inset-bottom,0px));
  width: 320px;
  max-height: 60vh;
  background: var(--eilc-bg,#fff);
  color: var(--eilc-fg,#111);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0,0,0,.2);
  overflow: hidden;
  display: none;
  z-index: 999999;
}
#eilc-header {
  padding: 10px 12px;
  font-weight: 700;
  background: #111827;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#eilc-body { padding: 10px; height: 42vh; overflow-y: auto; background:#fff; }
#eilc-input { display: none; gap: 6px; padding: 8px; border-top: 1px solid #e5e7eb; background:#f8fafc; }
#eilc-input textarea { flex: 1; min-height: 42px; max-height: 120px; font-size:16px; }
.eilc-msg { margin: 6px 0; }
.eilc-msg.visitor { text-align: right; }
.eilc-bubble { display: inline-block; padding: 8px 10px; border-radius: 10px; background: #f3f4f6; }
.eilc-msg.visitor .eilc-bubble { background: #2563eb; color: #fff; }
.eilc-offline { font-size: 12px; color: #444; margin: 6px 0; }

/* Email-first form (mobile friendly) */
#eilc-emailgate { display:block; padding:12px; border-top:1px solid #e5e7eb; background:#f9fafb; }
#eilc-emailgate .row { display:flex; flex-direction:column; gap:8px; align-items:stretch; }
#eilc-emailgate input[type=email]{ flex:1; height:44px; border:1px solid #d1d5db; border-radius:10px; padding:10px; font-size:16px; }
#eilc-emailgate button{ width:100%;  height:44px; border-radius:10px; border:0; background:#2563eb; color:#fff; padding:0 14px; font-weight:700; cursor:pointer; }

/* Fullscreen email gate on small screens */
@media (max-width: 480px) {
  #eilc-box {
    width: 100vw; right: 0; left: 0;
    max-height: 90vh; bottom: 0;
    border-radius: 16px 16px 0 0;
  }
  #eilc-body { height: 48vh; }
  #eilc-emailgate { position: sticky; bottom: 0; left: 0; right: 0; padding: 12px; background:#fff; }
  #eilc-emailgate .row { flex-direction: column; align-items: stretch; }
  #eilc-emailgate input[type=email]{ width: 100%; }
  #eilc-emailgate button{ width:100%;  width: 100%; }
}

/* Lock background when open & hide launch to avoid overlaying Send button */
html.eilc-open, html.eilc-open body { overflow: hidden; touch-action: none; }
html.eilc-open #eilc-launch { opacity:0; pointer-events:none; transform:scale(.9); }

/* Dark preference */
@media (prefers-color-scheme: dark) {
  :root {
    --eilc-bg: #0f172a;
    --eilc-fg: #e5e7eb;
  }
}

.eilc-msg.admin .eilc-bubble { color: var(--eilc-admin-color, inherit); }

#eilc-emailgate small { color: #475569; }

/* Top-layer container to beat Safari stacking contexts */
#eilc-toplayer{
  position: fixed !important;
  bottom: 0 !important;
  right: 0 !important;
  width: 0 !important;
  height: 0 !important;
  z-index: 2147483647 !important;
  isolation: isolate;
}
#eilc-toplayer #eilc-box, 
#eilc-toplayer #eilc-launch{
  pointer-events: auto !important;
  position: fixed !important;
}
