/* ============ Lanaland AI Chat Widget ============ */
#lnl-chat-root {
  --lnl-accent: #1d4ed8;
  --lnl-size: 62px;
  --lnl-offx: 22px;
  --lnl-offy: 22px;
  --lnl-side: right;
  --lnl-radius: 18px;
  --lnl-bg: #ffffff;
  --lnl-user: #1d4ed8;
  --lnl-bot: #f1f5f9;
  --lnl-text: #0f172a;
  direction: rtl;
}

/* از فونت پیش‌فرض سایت استفاده می‌شود (ارث‌بری از body) */
#lnl-chat-root,
#lnl-chat-root * {
  box-sizing: border-box;
  font-family: inherit;
}

/* دکمه شناور — موقعیت فیزیکی راست/چپ مستقل از جهت سایت */
.lnl-launcher {
  position: fixed;
  bottom: var(--lnl-offy);
  right: auto;
  left: auto;
  width: var(--lnl-size);
  height: var(--lnl-size);
  border-radius: 50%;
  background: var(--lnl-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999998;
  transition: transform .15s ease, box-shadow .15s ease;
}
#lnl-chat-root[data-side="right"] .lnl-launcher { right: var(--lnl-offx); }
#lnl-chat-root[data-side="left"]  .lnl-launcher { left:  var(--lnl-offx); }
.lnl-launcher:hover { transform: scale(1.06); box-shadow: 0 10px 28px rgba(0,0,0,.24); }
.lnl-launcher svg { width: 52%; height: 52%; }

.lnl-launcher-label {
  position: fixed;
  bottom: calc(var(--lnl-offy) + (var(--lnl-size) / 2) - 16px);
  background: #fff;
  color: var(--lnl-text);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
  white-space: nowrap;
  z-index: 999998;
  animation: lnl-fade 0.3s ease;
}
#lnl-chat-root[data-side="right"] .lnl-launcher-label { right: calc(var(--lnl-offx) + var(--lnl-size) + 10px); }
#lnl-chat-root[data-side="left"]  .lnl-launcher-label { left:  calc(var(--lnl-offx) + var(--lnl-size) + 10px); }

/* پنجره چت */
.lnl-window {
  position: fixed;
  bottom: calc(var(--lnl-offy) + var(--lnl-size) + 14px);
  width: 380px;
  max-width: calc(100vw - 28px);
  height: 560px;
  max-height: calc(100vh - 110px);
  background: var(--lnl-bg);
  border-radius: var(--lnl-radius);
  box-shadow: 0 18px 50px rgba(0,0,0,.26);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999;
  animation: lnl-pop .18s ease;
}
#lnl-chat-root[data-side="right"] .lnl-window { right: var(--lnl-offx); }
#lnl-chat-root[data-side="left"]  .lnl-window { left:  var(--lnl-offx); }
@keyframes lnl-pop { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes lnl-fade { from { opacity: 0; } to { opacity: 1; } }

.lnl-header {
  background: var(--lnl-accent);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.lnl-header .lnl-title { font-weight: 700; font-size: 15px; }
.lnl-header .lnl-sub { font-size: 11px; opacity: .85; margin-top: 2px; }
.lnl-header-actions { display: flex; gap: 4px; }
.lnl-iconbtn {
  background: rgba(255,255,255,.16);
  border: none; color: #fff; cursor: pointer;
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.lnl-iconbtn:hover { background: rgba(255,255,255,.28); }
.lnl-iconbtn svg { width: 16px; height: 16px; }

/* بدنه پیام‌ها */
.lnl-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  background: #fafbfc;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lnl-msg { max-width: 84%; padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.9; white-space: pre-wrap; word-break: break-word; }
.lnl-msg.bot { background: var(--lnl-bot); color: var(--lnl-text); align-self: flex-start; border-bottom-right-radius: 4px; }
.lnl-msg.user { background: var(--lnl-user); color: #fff; align-self: flex-end; border-bottom-left-radius: 4px; }
.lnl-msg a { color: inherit; text-decoration: underline; font-weight: 600; }
.lnl-msg.bot a { color: var(--lnl-accent); }

.lnl-typing { display: flex; gap: 4px; padding: 12px 14px; align-self: flex-start; }
.lnl-typing span { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; animation: lnl-bounce 1.2s infinite; }
.lnl-typing span:nth-child(2) { animation-delay: .2s; }
.lnl-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes lnl-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-6px); opacity: 1; } }

/* دکمه‌های سریع (نمایندگی و ...) */
.lnl-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 8px; }
.lnl-quick button {
  background: #fff; border: 1.5px solid var(--lnl-accent); color: var(--lnl-accent);
  border-radius: 999px; padding: 6px 13px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: background .12s, color .12s; font-family: inherit;
}
.lnl-quick button:hover { background: var(--lnl-accent); color: #fff; }

/* ناحیه ورودی */
.lnl-input {
  border-top: 1px solid #e5e7eb;
  padding: 10px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #fff;
}
.lnl-input textarea {
  flex: 1; resize: none; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 9px 12px; font-size: 14px; max-height: 96px; line-height: 1.6;
  outline: none; font-family: inherit;
}
.lnl-input textarea:focus { border-color: var(--lnl-accent); }
.lnl-send, .lnl-attach {
  border: none; cursor: pointer; border-radius: 10px;
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.lnl-send { background: var(--lnl-accent); color: #fff; }
.lnl-send:disabled { opacity: .5; cursor: default; }
.lnl-attach { background: #f1f5f9; color: #475569; }
.lnl-send svg, .lnl-attach svg { width: 19px; height: 19px; }

/* فرم نمایندگی (overlay داخل پنجره) */
.lnl-form-overlay {
  position: absolute; inset: 0; background: #fff; z-index: 5;
  display: flex; flex-direction: column; animation: lnl-fade .2s ease;
}
.lnl-form-overlay .lnl-header { flex-shrink: 0; }
.lnl-form-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 16px; display: flex; flex-direction: column; gap: 11px; }
.lnl-field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; color: #334155; }
.lnl-field input, .lnl-field textarea {
  width: 100%; border: 1px solid #d1d5db; border-radius: 10px; padding: 9px 11px; font-size: 13.5px;
  outline: none; font-family: inherit;
}
.lnl-field input:focus, .lnl-field textarea:focus { border-color: var(--lnl-accent); }
.lnl-field .req { color: #dc2626; }
.lnl-form-submit {
  background: var(--lnl-accent); color: #fff; border: none; border-radius: 11px;
  padding: 12px; font-size: 14px; font-weight: 700; cursor: pointer; margin-top: 4px; font-family: inherit;
}
.lnl-form-submit:disabled { opacity: .6; cursor: default; }
.lnl-form-note { font-size: 11.5px; color: #64748b; line-height: 1.7; }
.lnl-form-success { text-align: center; padding: 30px 18px; color: #16a34a; font-weight: 600; font-size: 14.5px; line-height: 1.9; }

.lnl-consent { font-size: 11px; color: #64748b; padding: 0 14px 8px; line-height: 1.7; }
.lnl-attach-preview { font-size: 11.5px; color: #475569; padding: 0 14px 6px; }

@media (max-width: 480px) {
  .lnl-window {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh;
    bottom: 0; right: 0; left: 0; border-radius: 0;
  }
}
