/* ลิน — GooDelivery AI assistant widget (landing + market). Warm theme, same tokens as the landing page. */
.lin-root {
  --lin-primary: #FF6200;
  --lin-primary-hover: #E55800;
  --lin-bg: #FFF8F1;
  --lin-surface: #FFFFFF;
  --lin-cream: #FFF0DF;
  --lin-text: #1F2329;
  --lin-muted: #5A626C;
  --lin-border: #EADFD5;
  --lin-success: #0D8A4E;
  --lin-danger: #D92D20;
  font-family: 'Sriracha', 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--lin-text);
  position: fixed;
  right: 0;
  bottom: 0;
  z-index: 9990;
}
.lin-root *, .lin-root *::before, .lin-root *::after { box-sizing: border-box; }
.lin-root [hidden] { display: none !important; }
.lin-root button, .lin-root input, .lin-root textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------- launcher ---------- */
.lin-launcher {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.lin-root[data-page="market"] .lin-launcher { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 768px) {
  .lin-root[data-page="market"] .lin-launcher { bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
}
.lin-launcher-avatar {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid var(--lin-primary);
  background: var(--lin-surface);
  box-shadow: 0 8px 24px rgba(255, 98, 0, 0.35);
  display: block;
  flex: none;
}
.lin-launcher-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.lin-launcher-avatar::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--lin-success);
  border: 2px solid #FFFFFF;
}
.lin-launcher-label {
  order: -1;
  background: var(--lin-surface);
  border: 1px solid var(--lin-border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 15px;
  box-shadow: 0 6px 18px rgba(31, 35, 41, 0.12);
  white-space: nowrap;
}
/* The label stays visible on phones too, a little smaller, so visitors know what the picture is */
@media (max-width: 479px) {
  .lin-launcher { gap: 8px; right: 12px; }
  .lin-launcher-avatar { width: 58px; height: 58px; }
  .lin-launcher-label { font-size: 14px; padding: 6px 12px; }
}
.lin-launcher:hover .lin-launcher-avatar { transform: translateY(-2px); }
.lin-launcher:focus-visible, .lin-root button:focus-visible, .lin-root input:focus-visible, .lin-root textarea:focus-visible, .lin-root a:focus-visible {
  outline: 3px solid rgba(255, 98, 0, 0.55);
  outline-offset: 2px;
}
.lin-root[data-open="true"] .lin-launcher { display: none; }

/* ---------- panel ---------- */
.lin-panel {
  position: fixed;
  inset: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  background: var(--lin-bg);
  height: 100vh;
  height: 100dvh;
}
@media (min-width: 640px) {
  .lin-panel {
    inset: auto 20px 20px auto;
    width: 392px;
    height: min(620px, calc(100vh - 40px));
    border: 1px solid var(--lin-border);
    border-radius: 22px;
    box-shadow: 0 24px 60px rgba(31, 35, 41, 0.28);
    overflow: hidden;
  }
}

.lin-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--lin-surface);
  border-bottom: 1px solid var(--lin-border);
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}
.lin-head-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid var(--lin-primary); flex: none; }
.lin-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.lin-head-text strong { font-size: 18px; }
.lin-head-text span { font-size: 13px; color: var(--lin-muted); display: flex; align-items: center; gap: 6px; }
.lin-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--lin-success); display: inline-block; flex: none; }
.lin-close {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--lin-border); background: var(--lin-surface);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 18px; flex: none;
}
.lin-close:hover { background: var(--lin-cream); }

/* ---------- messages ---------- */
.lin-log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.lin-row { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; }
.lin-row.user { justify-content: flex-end; }
.lin-row-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; }
.lin-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 18px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 16px;
}
.lin-row.bot .lin-bubble { background: var(--lin-surface); border: 1px solid var(--lin-border); border-bottom-left-radius: 6px; }
.lin-row.user .lin-bubble { background: var(--lin-primary); color: #FFFFFF; border-bottom-right-radius: 6px; }
.lin-row.bot.error .lin-bubble { background: #FEF3F2; border-color: #FDA29B; color: #912018; }
.lin-typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.lin-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--lin-muted); opacity: .5; animation: lin-blink 1.2s infinite; }
.lin-typing i:nth-child(2) { animation-delay: .2s; }
.lin-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes lin-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .lin-typing i { animation: none; opacity: .6; } }

.lin-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: -2px 0 0 36px; }
.lin-action {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 16px; border-radius: 999px; font-size: 15px; text-decoration: none; cursor: pointer;
  border: 1.5px solid var(--lin-primary); background: var(--lin-surface); color: var(--lin-primary);
}
.lin-action.primary { background: var(--lin-primary); color: #FFFFFF; }
.lin-action:hover { background: var(--lin-primary-hover); color: #FFFFFF; border-color: var(--lin-primary-hover); }

/* ---------- quick replies ---------- */
.lin-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 10px 50px; }
.lin-chip {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--lin-border); background: var(--lin-surface);
  cursor: pointer; font-size: 15px;
}
.lin-chip:hover { border-color: var(--lin-primary); color: var(--lin-primary); }

/* ---------- lead form ---------- */
.lin-form {
  margin: 0 0 0 36px;
  padding: 14px;
  background: var(--lin-surface);
  border: 1px solid var(--lin-border);
  border-radius: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.lin-form h3 { margin: 0; font-size: 16px; font-weight: 400; }
.lin-form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--lin-muted); }
.lin-form input[type="text"], .lin-form input[type="tel"], .lin-form input[type="email"], .lin-form textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--lin-border); border-radius: 12px; background: var(--lin-bg); color: var(--lin-text);
}
.lin-form .lin-consent { flex-direction: row; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.45; color: var(--lin-text); }
.lin-form .lin-consent input { margin-top: 3px; width: 18px; height: 18px; flex: none; accent-color: var(--lin-primary); }
.lin-form .lin-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.lin-form-msg { font-size: 14px; color: var(--lin-danger); min-height: 18px; }
.lin-form-row { display: flex; gap: 8px; }
.lin-submit { flex: 1; padding: 11px 16px; border-radius: 999px; border: 0; background: var(--lin-primary); color: #FFFFFF; cursor: pointer; }
.lin-submit:disabled { opacity: .6; cursor: not-allowed; }
.lin-cancel { padding: 11px 16px; border-radius: 999px; border: 1px solid var(--lin-border); background: var(--lin-surface); cursor: pointer; }

/* ---------- input ---------- */
.lin-input { display: flex; gap: 8px; padding: 10px 14px; background: var(--lin-surface); border-top: 1px solid var(--lin-border); }
.lin-input input { flex: 1; min-width: 0; padding: 12px 16px; border-radius: 999px; border: 1px solid var(--lin-border); background: var(--lin-bg); }
.lin-send {
  width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--lin-primary); color: #FFFFFF; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.lin-send:disabled { background: var(--lin-border); cursor: not-allowed; }
.lin-note {
  margin: 0; padding: 8px 14px calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--lin-surface);
  font-size: 12px; line-height: 1.45; color: var(--lin-muted);
}
.lin-note a { color: var(--lin-primary); }
.lin-note button { border: 0; background: none; padding: 0; text-decoration: underline; cursor: pointer; color: var(--lin-primary); }
