/* ── FAB ─────────────────────────────────────────────────── */
.xld-chat-fab {
  position: fixed; bottom: 28px; right: 28px; z-index: 9998;
  width: 56px; height: 56px; border-radius: 50%;
  background: #1A1916; color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,.25); transition: transform .2s, box-shadow .2s;
}
.xld-chat-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0,0,0,.3); }
.xld-chat-fab svg { width: 22px; height: 22px; transition: opacity .2s, transform .2s; }
.xld-icon-close { display: none; }
.xld-chat-fab.open .xld-icon-chat  { display: none; }
.xld-chat-fab.open .xld-icon-close { display: block; }
.xld-badge {
  position: absolute; top: -4px; right: -4px;
  background: #E8452C; color: #fff; font-size: 10px; font-weight: 700;
  width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}

/* ── Window ──────────────────────────────────────────────── */
.xld-win {
  position: fixed; bottom: 96px; right: 28px; z-index: 9997;
  width: 360px; max-height: 580px;
  background: #fff; border-radius: 20px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  display: flex; flex-direction: column;
  opacity: 0; transform: translateY(12px) scale(.97);
  pointer-events: none; transition: opacity .2s, transform .22s;
  font-family: 'DM Sans', sans-serif; overflow: hidden;
}
.xld-win.open { opacity: 1; transform: none; pointer-events: all; }

/* ── Header ─────────────────────────────────────────────── */
.xld-header {
  padding: 16px 18px; background: #1A1916; color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.xld-header-info { display: flex; align-items: center; gap: 12px; }
.xld-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #E8452C; color: #fff;
  font-family: 'Syne', sans-serif; font-weight: 800; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.xld-header-name { font-weight: 600; font-size: 14px; }
.xld-header-sub  { font-size: 12px; color: rgba(255,255,255,.55); margin-top: 1px; }

/* ── Auth steps ─────────────────────────────────────────── */
.xld-auth {
  padding: 28px 24px; display: flex; flex-direction: column; gap: 10px;
  align-items: center; text-align: center; flex: 1;
}
.xld-auth-icon  { font-size: 36px; line-height: 1; }
.xld-auth-title { font-size: 16px; font-weight: 700; color: #1A1916; }
.xld-auth-sub   { font-size: 13px; color: #9C9A95; margin-bottom: 4px; }
.xld-input {
  width: 100%; padding: 11px 14px; border: 1.5px solid rgba(26,25,22,.15);
  border-radius: 10px; font-size: 14px; font-family: inherit;
  color: #1A1916; outline: none; transition: border-color .2s; box-sizing: border-box;
}
.xld-input:focus { border-color: #1A1916; }
.xld-input.xld-otp { font-size: 24px; letter-spacing: 6px; text-align: center; font-weight: 700; }
.xld-btn-main {
  width: 100%; padding: 12px; border: none; border-radius: 10px;
  background: #1A1916; color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s; font-family: inherit;
}
.xld-btn-main:hover { background: #2d2d29; }
.xld-btn-main:disabled { opacity: .6; cursor: not-allowed; }
.xld-btn-ghost {
  background: transparent; border: none; color: #9C9A95; font-size: 13px;
  cursor: pointer; font-family: inherit; padding: 4px;
}
.xld-btn-ghost:hover { color: #1A1916; }

/* ── Messages ────────────────────────────────────────────── */
.xld-messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex;
  flex-direction: column; gap: 8px; min-height: 0;
}
.xld-msg {
  max-width: 80%; display: flex; flex-direction: column; gap: 2px;
}
.xld-msg--out { align-self: flex-end; align-items: flex-end; }
.xld-msg--in  { align-self: flex-start; }
.xld-msg-text {
  padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.5; word-break: break-word;
}
.xld-msg--out .xld-msg-text { background: #1A1916; color: #fff; border-bottom-right-radius: 4px; }
.xld-msg--in  .xld-msg-text { background: #f4f2ed; color: #1A1916; border-bottom-left-radius: 4px; }
.xld-msg-time { font-size: 10px; color: #C0BEB9; padding: 0 4px; }
.xld-msg-img  { max-width: 200px; border-radius: 10px; display: block; }
.xld-msg-file {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px;
  background: #f4f2ed; border-radius: 10px; font-size: 13px; color: #1A1916;
  text-decoration: none; max-width: 200px; word-break: break-word;
}
.xld-msg-file:hover { background: #eae8e3; }

/* ── Contract card ───────────────────────────────────────── */
.xld-contract-card {
  background: #fff; border: 1.5px solid rgba(26,25,22,.12);
  border-radius: 14px; padding: 16px 18px; margin: 4px 0; font-size: 13px;
  display: flex; flex-direction: column; gap: 6px; max-width: 100%;
}
.xld-contract-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.xld-contract-badge  { font-weight: 700; font-size: 13px; color: #1A1916; }
.xld-contract-signed-badge {
  font-size: 11px; font-weight: 600; color: #2e7d32;
  background: #e8f5e9; padding: 3px 10px; border-radius: 100px;
}
.xld-contract-row    { color: #5C5A55; font-size: 13px; }
.xld-contract-row b  { color: #1A1916; }
.xld-contract-desc   { color: #5C5A55; font-size: 12px; line-height: 1.6; border-top: 1px solid rgba(26,25,22,.07); padding-top: 8px; }
.xld-contract-footer { font-size: 10px; color: #C0BEB9; border-top: 1px solid rgba(26,25,22,.07); padding-top: 8px; }
.xld-btn-sign {
  background: #E8452C; color: #fff; border: none; border-radius: 8px;
  padding: 10px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit; margin-top: 4px; transition: opacity .15s;
}
.xld-btn-sign:hover { opacity: .88; }

/* ── Footer / input ─────────────────────────────────────── */
.xld-footer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 14px; border-top: 1px solid rgba(26,25,22,.07);
  background: #fff; flex-shrink: 0;
}
.xld-textarea {
  flex: 1; border: none; outline: none; resize: none;
  font-size: 14px; font-family: inherit; color: #1A1916;
  background: transparent; max-height: 120px; line-height: 1.5;
}
.xld-attach {
  cursor: pointer; color: #9C9A95; display: flex; align-items: center;
  padding: 4px; flex-shrink: 0;
}
.xld-attach:hover { color: #1A1916; }
.xld-attach svg { width: 18px; height: 18px; }
.xld-send {
  background: #E8452C; color: #fff; border: none; border-radius: 8px;
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: opacity .15s;
}
.xld-send:hover { opacity: .88; }
.xld-send svg { width: 15px; height: 15px; }

/* ── Contract modal ─────────────────────────────────────── */
.xld-contract-modal {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.45); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  padding: 24px;
}
.xld-contract-modal[style*="flex"] { display: flex !important; }
.xld-contract-box {
  background: #fff; border-radius: 20px; padding: 28px; max-width: 500px; width: 100%;
  position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.xld-contract-title { font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.xld-contract-sub   { font-size: 13px; color: #9C9A95; margin-bottom: 16px; }
.xld-sig-canvas {
  width: 100%; height: 160px; border: 1.5px solid rgba(26,25,22,.15);
  border-radius: 12px; cursor: crosshair; touch-action: none; display: block;
  background: #fafaf8;
}
.xld-contract-actions {
  display: flex; gap: 10px; margin-top: 16px;
}
.xld-contract-actions .xld-btn-main { flex: 1; }
.xld-sig-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(26,25,22,.07); border: none; border-radius: 50%;
  width: 30px; height: 30px; cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center; color: #5C5A55;
}
.xld-sig-close:hover { background: rgba(26,25,22,.12); }

/* ── Error toast ─────────────────────────────────────────── */
.xld-error {
  position: absolute; bottom: 70px; left: 12px; right: 12px;
  background: #E8452C; color: #fff; padding: 10px 14px; border-radius: 10px;
  font-size: 13px; z-index: 10; animation: fadeIn .2s;
}

/* ── Shake animation ─────────────────────────────────────── */
@keyframes xldShake {
  0%,100%{ transform:translateX(0) }
  20%{ transform:translateX(-5px) }
  40%{ transform:translateX(5px) }
  60%{ transform:translateX(-4px) }
  80%{ transform:translateX(4px) }
}
.xld-shake { animation: xldShake .4s ease; }

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  .xld-win { right: 12px; left: 12px; width: auto; bottom: 80px; }
  .xld-chat-fab { bottom: 20px; right: 20px; }
  .xld-contract-box { padding: 20px; }
  .xld-sig-canvas { height: 130px; }
}

@keyframes fadeIn { from { opacity:0; transform:translateY(6px) } to { opacity:1; transform:none } }

/* ── PDF download button ─────────────────────────────────── */
.xld-btn-pdf {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f4f2ed; color: #1A1916; text-decoration: none;
  border: 1.5px solid rgba(26,25,22,.12); border-radius: 8px;
  padding: 8px 14px; font-size: 12px; font-weight: 600;
  margin-top: 4px; transition: background .15s, border-color .15s;
  font-family: inherit;
}
.xld-btn-pdf:hover {
  background: #eae8e3; border-color: rgba(26,25,22,.2);
}

/* ── Typing indicator ─────────────────────────────── */
.xld-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  min-width: 48px;
}
.xld-typing span {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--xld-ink2, #888);
  animation: xld-bounce 1.2s infinite ease-in-out;
}
.xld-typing span:nth-child(2) { animation-delay: 0.2s; }
.xld-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes xld-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}
