/* ==========================================================================
 * Jingyi Optoelectronics — Live Chat (visitor ⇄ operator) widget styles
 * Pairs with assets/js/live-chat.js. Panel anchors above the contact dock
 * (bottom-right), mirroring ai-chat.css conventions. Prefix: lc-
 * ========================================================================== */

/* NOTE: #lc-root is created with an ID (wrap.id = "lc-root") in
 * live-chat.js — the selector MUST be #lc-root, a .lc-root class rule
 * would never match and the panel would lose its stacking/positioning.
 * bottom: 141px clears the Contact Us dock (button 68 + gap 12 + label
 * 21 + bottom 22 ≈ 123px tall) with an 18px breathing gap. */
#lc-root { position: fixed; right: 22px; bottom: 141px; z-index: 1200; }

/* ---- Panel ------------------------------------------------------------- */
.lc-panel {
  position: fixed;
  right: 22px;
  bottom: 141px;
  width: 344px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: calc(100vh - 160px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(16, 42, 67, 0.22), 0 2px 10px rgba(16, 42, 67, 0.10);
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.lc-panel.open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.lc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #102a43, #1d3d5c);
  color: #fff;
  flex: none;
}
.lc-avatar {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; letter-spacing: 0.03em;
  flex: none;
}
.lc-head-txt { flex: 1; min-width: 0; line-height: 1.25; }
.lc-head-txt strong { display: block; font-size: 14px; }
.lc-head-txt small { font-size: 11px; opacity: 0.75; }
.lc-head-btn {
  border: 0; background: rgba(255, 255, 255, 0.12); color: #fff;
  width: 26px; height: 26px; border-radius: 7px;
  font-size: 14px; line-height: 1; cursor: pointer; flex: none;
}
.lc-head-btn:hover { background: rgba(255, 255, 255, 0.24); }

/* Optional name/email form (collapsed behind the ⚙ header button) */
.lc-idform {
  display: none;
  gap: 8px;
  padding: 10px 12px;
  background: #f4f8fb;
  border-bottom: 1px solid #e3ecf3;
}
.lc-idform.open { display: flex; }
.lc-idform input {
  flex: 1; min-width: 0;
  border: 1px solid #d7e2ec; border-radius: 8px;
  padding: 7px 10px; font-size: 12px; background: #fff;
}
.lc-idform input:focus { outline: none; border-color: #4a90c4; }

/* ---- Messages ---------------------------------------------------------- */
.lc-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f7fafc;
  scrollbar-width: thin;
}
.lc-empty {
  margin: auto;
  text-align: center;
  color: #7d93a8;
  font-size: 13px;
  line-height: 1.7;
  padding: 0 18px;
}
.lc-empty .lc-empty-icon { font-size: 26px; display: block; margin-bottom: 6px; }

.lc-row { display: flex; align-items: flex-end; gap: 6px; }
.lc-row--visitor { flex-direction: row-reverse; }

.lc-bubble {
  max-width: 78%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.lc-row--agent .lc-bubble {
  background: #fff;
  color: #22374c;
  border: 1px solid #e3ecf3;
  border-bottom-left-radius: 4px;
}
.lc-row--visitor .lc-bubble {
  background: #12508f;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.lc-time {
  font-size: 10px;
  color: #93a7ba;
  flex: none;
  margin-bottom: 3px;
}

.lc-bubble img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  border-radius: 9px;
  margin: 2px 0 4px;
  cursor: zoom-in;
  background: #eef4f8;
}
.lc-bubble video {
  display: block;
  max-width: 100%;
  max-height: 220px;
  border-radius: 9px;
  margin: 2px 0 4px;
  background: #10233a;
}
.lc-caption { display: block; }

/* Typing indicator */
.lc-typing { display: inline-flex; gap: 4px; padding: 3px 0; }
.lc-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: #9db4c8;
  animation: lc-blink 1.2s infinite;
}
.lc-typing span:nth-child(2) { animation-delay: 0.2s; }
.lc-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes lc-blink { 0%, 70%, 100% { opacity: 0.35; } 35% { opacity: 1; } }

/* ---- Input row ---------------------------------------------------------- */
.lc-inputrow {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #e3ecf3;
  background: #fff;
}
.lc-attach {
  border: 1px solid #d7e2ec;
  background: #f4f8fb;
  color: #48657f;
  width: 34px; height: 34px;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
  flex: none;
  display: grid; place-items: center;
}
.lc-attach:hover { background: #e7f1f9; }
.lc-inputrow input[type="text"] {
  flex: 1; min-width: 0;
  border: 1px solid #d7e2ec;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
}
.lc-inputrow input[type="text"]:focus { outline: none; border-color: #4a90c4; }
.lc-send {
  border: 0;
  background: #12508f;
  color: #fff;
  width: 36px; height: 36px;
  border-radius: 10px;
  cursor: pointer;
  flex: none;
  display: grid; place-items: center;
}
.lc-send:hover { background: #0d3f74; }
.lc-send:disabled { opacity: 0.55; cursor: default; }
.lc-send svg { width: 16px; height: 16px; }

.lc-foot {
  flex: none;
  padding: 6px 12px 8px;
  background: #fff;
  text-align: center;
  font-size: 10.5px;
  color: #93a7ba;
}
.lc-foot a { color: #12508f; text-decoration: none; }
.lc-foot a:hover { text-decoration: underline; }

/* Unread badge on the dock menu item */
.lc-dock-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 9px;
  background: #d64545;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  vertical-align: 1px;
}

/* ---- Mobile ------------------------------------------------------------- */
@media (max-width: 640px) {
  .lc-panel {
    right: 12px;
    left: 12px;
    width: auto;
    /* Mobile dock: bottom 74+safe, + gap 12 + label 21 + button 68 ≈ 175+safe;
       190px leaves a clear gap above it. */
    bottom: calc(190px + env(safe-area-inset-bottom));
    height: min(560px, calc(100vh - 220px));
  }
}

/* ---- Inline entry inside contact forms (index / service) ---------------- */
/* Full-width like Send Message — style.css's .contact-v2 rule only covers
   button[type=submit], this one targets the live-chat trigger ([data-lc-open]). */
.contact-v2 #contact-form button[data-lc-open] { width: 100%; margin-top: 10px; }
.contact-v2 #contact-form .lc-inline-or { display: block; margin: 14px 0 0; text-align: center; }


/* ---- Daoli floating entry (right-bottom pill) --------------------------- */
#dli-float-entry {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1190;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(234, 88, 12, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
#dli-float-entry:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(234, 88, 12, 0.42);
}
#dli-float-entry .dli-float-ico { font-size: 17px; line-height: 1; }
@media (max-width: 640px) {
  #dli-float-entry {
    right: 14px;
    bottom: calc(72px + env(safe-area-inset-bottom));
    padding: 11px 15px;
  }
  /* 面板收窄：两侧留 12px，位于悬浮按钮上方 */
  .lc-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: calc(128px + env(safe-area-inset-bottom));
    height: min(560px, calc(100vh - 200px));
  }
}
