/* =====================================================================
   chat-widget.css  —  Dark brutalism, accent #E8452C
   ===================================================================== */

/* ── FAB ──────────────────────────────────────────────────────────── */
.xld-chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1A1916;
  color: #fff;
  border: none;
  border-radius: 100px;
  padding: 14px 22px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(0,0,0,.22);
  transition: transform .18s, box-shadow .18s;
}
.xld-chat-fab:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(0,0,0,.28); }
.xld-chat-fab svg { flex-shrink: 0; }

/* ── Panel ────────────────────────────────────────────────────────── */
.xld-chat-panel {
  position: fixed;
  bottom: 88px;
  right: 28px;
  z-index: 9991;
  width: 360px;
  max-height: 580px;
  background: #1A1916;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 16px 64px rgba(0,0,0,.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(.97);
  pointer-events: none;
  transition: opacity .22s, transform .22s;
}
.xld-chat-panel--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ───────────────────────────────────────────────────────── */
.xld-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.xld-chat-header-info { display: flex; align-items: center; gap: 10px; }
.xld-chat-avatar {
  width: 36px;
  height: 36px;
  background: #E8452C;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}
.xld-chat-name { font-family: 'Syne', sans-serif; font-weight: 700; color: #fff; font-size: 15px; }
.xld-chat-status { font-size: 12px; color: rgba(255,255,255,.45); display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.xld-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; flex-shrink: 0; }
.xld-chat-close {
  background: rgba(255,255,255,.07);
  border: none;
  color: rgba(255,255,255,.5);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.xld-chat-close:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ── Gate (email form) ────────────────────────────────────────────── */
.xld-chat-gate {
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex: 1;
}
.xld-chat-gate-icon { font-size: 36px; margin-bottom: 4px; }
.xld-chat-gate-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  text-align: center;
  line-height: 1.4;
}
.xld-chat-input-email,
.xld-chat-input-name {
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 10px;
  padding: 11px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: #fff;
  outline: none;
  transition: border-color .15s;
}
.xld-chat-input-email::placeholder,
.xld-chat-input-name::placeholder { color: rgba(255,255,255,.3); }
.xld-chat-input-email:focus,
.xld-chat-input-name:focus { border-color: #E8452C; }
.xld-chat-input-email.xld-input-error { border-color: #E8452C; box-shadow: 0 0 0 2px rgba(232,69,44,.25); }
.xld-chat-btn-start {
  width: 100%;
  background: #E8452C;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .15s;
  margin-top: 4px;
}
.xld-chat-btn-start:hover { opacity: .88; transform: translateY(-1px); }
.xld-chat-gate-hint { font-size: 12px; color: rgba(255,255,255,.3); text-align: center; }

/* ── Chat body ────────────────────────────────────────────────────── */
.xld-chat-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  position: relative;
}

/* ── Messages ─────────────────────────────────────────────────────── */
.xld-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
.xld-chat-messages::-webkit-scrollbar { width: 4px; }
.xld-chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 2px; }

.xld-msg {
  max-width: 78%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.xld-msg--visitor { align-self: flex-end; align-items: flex-end; }
.xld-msg--admin   { align-self: flex-start; align-items: flex-start; }

.xld-msg-text {
  display: inline-block;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}
.xld-msg--visitor .xld-msg-text {
  background: #E8452C;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.xld-msg--admin .xld-msg-text {
  background: rgba(255,255,255,.09);
  color: #fff;
  border-bottom-left-radius: 4px;
}

.xld-msg-img {
  max-width: 220px;
  max-height: 200px;
  border-radius: 12px;
  object-fit: cover;
  cursor: pointer;
  display: block;
}

.xld-msg-file {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  background: rgba(255,255,255,.09);
  border-radius: 12px;
  color: #fff;
  font-size: 13px;
  text-decoration: none;
  transition: background .15s;
}
.xld-msg-file:hover { background: rgba(255,255,255,.14); }
.xld-msg--visitor .xld-msg-file { background: rgba(232,69,44,.3); }

.xld-msg-time {
  font-size: 10.5px;
  color: rgba(255,255,255,.3);
  padding: 0 3px;
}

/* ── Preview bar ──────────────────────────────────────────────────── */
.xld-chat-preview {
  padding: 8px 14px;
  border-top: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.04);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.xld-chat-preview img {
  max-height: 60px;
  max-width: 80px;
  border-radius: 8px;
  object-fit: cover;
}
.xld-chat-preview span { color: rgba(255,255,255,.7); font-size: 13px; flex: 1; }
.xld-pv-remove {
  background: rgba(255,255,255,.08);
  border: none;
  color: rgba(255,255,255,.5);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Toolbar ──────────────────────────────────────────────────────── */
.xld-chat-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.xld-chat-attach {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.4);
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: color .15s;
  flex-shrink: 0;
  align-self: flex-end;
  margin-bottom: 2px;
}
.xld-chat-attach:hover { color: rgba(255,255,255,.8); }
.xld-chat-textarea {
  scrollbar-width: none;
  flex: 1;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 12px;
  padding: 9px 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  color: #fff;
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 120px;
  transition: border-color .15s;
}

.xld-chat-textarea::-webkit-scrollbar {
  display: none;
}
.xld-chat-textarea::placeholder { color: rgba(255,255,255,.3); }
.xld-chat-textarea:focus { border-color: rgba(232,69,44,.5); }
.xld-chat-send {
  background: #E8452C;
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity .15s, transform .15s;
}
.xld-chat-send:hover { opacity: .85; transform: scale(1.05); }

/* ── Drop zone ────────────────────────────────────────────────────── */
.xld-chat-drop-zone {
  position: absolute;
  inset: 0;
  background: rgba(26,25,22,.9);
  border: 2px dashed rgba(232,69,44,.6);
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: #E8452C;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 10;
}
.xld-drop--active { opacity: 1; }

@media (max-width: 480px) {
  .xld-chat-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }
  .xld-chat-fab { bottom: 20px; right: 16px; }
  .xld-chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .xld-chat-input-row {
    position: sticky;
    bottom: 0;
    background: #1A1916;
    padding-bottom: env(safe-area-inset-bottom);
  }
}


.xld-fab-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #E8452C;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  pointer-events: none;
}
