/* ═══════════════════════════════════════
   WEBFORGE CHAT WIDGET  — matches site dark theme
   ═══════════════════════════════════════ */

/* ── FAB ─────────────────────────────── */
#chatFab {
  position: fixed !important;
  bottom: 32px;
  right: 32px !important;
  width: 58px !important;
  height: 58px !important;
  border-radius: 50% !important;
  background: var(--blue, #4F7EFF) !important;
  color: #fff !important;
  border: none !important;
  cursor: pointer !important;
  z-index: 9999 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 24px !important;
  box-shadow: 0 4px 24px rgba(79,126,255,.55) !important;
  transition: transform .25s, box-shadow .25s, bottom .4s cubic-bezier(.4,0,.2,1) !important;
}
#chatFab:hover {
  transform: scale(1.1) !important;
  box-shadow: 0 8px 32px rgba(79,126,255,.75) !important;
}
#chatFab.hidden { display: none !important; }

.notification-badge {
  position: absolute;
  top: -3px; right: -3px;
  background: #ef4444;
  color: #fff;
  border-radius: 50%;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  border: 2px solid #0C0C0E;
}

/* ── WIDGET ──────────────────────────── */
.chat-widget {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 400px;
  height: 580px;
  background: #111115;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  z-index: 9998;
  box-shadow: 0 28px 72px rgba(0,0,0,.8), 0 0 0 1px rgba(255,255,255,.04);
  overflow: hidden;
  font-family: 'Inter', sans-serif;
  transform-origin: bottom right;
  animation: chatOpen .22s cubic-bezier(.4,0,.2,1);
  transition: bottom .4s cubic-bezier(.4,0,.2,1);
}
@keyframes chatOpen {
  from { opacity: 0; transform: scale(.92); }
  to   { opacity: 1; transform: scale(1); }
}
.chat-widget.hidden { display: none !important; }

/* ── HEADER ──────────────────────────── */
.chat-header {
  background: #0C0C0E;
  border-bottom: 1px solid rgba(255,255,255,.08);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.chat-header-left { display: flex; align-items: center; gap: 12px; }
.chat-header-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4F7EFF, #7B5EA7);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  position: relative;
}
.chat-header-avatar::after {
  content: '';
  position: absolute;
  bottom: 1px; right: 1px;
  width: 10px; height: 10px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #0C0C0E;
}
.chat-header-info { display: flex; flex-direction: column; gap: 2px; }
.chat-header-title {
  font-family: 'Syne', 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #F0EFE9;
  letter-spacing: -.01em;
  line-height: 1;
}
.chat-header-status {
  font-size: 11px;
  color: #22c55e;
  display: flex; align-items: center; gap: 5px;
}
.chat-header-status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #22c55e;
  animation: onlinePulse 2s infinite;
}
@keyframes onlinePulse {
  0%,100% { opacity: 1; }
  50%      { opacity: .4; }
}
.chat-header-actions { display: flex; gap: 6px; }
.chat-header-btn {
  background: rgba(255,255,255,.07);
  border: none;
  color: rgba(255,255,255,.6);
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: background .18s, color .18s;
}
.chat-header-btn:hover { background: rgba(255,255,255,.14); color: #F0EFE9; }

/* ── MESSAGES ────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #0C0C0E;
}
/* Pushes messages to bottom when few; allows normal scroll when many */
.chat-messages::before {
  content: '';
  flex: 1;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 4px; }

/* ── MESSAGE ROWS ───────────────────── */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 88%;
  margin-bottom: 10px;
  animation: msgIn .2s ease;
}
@keyframes msgIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.msg-row.admin  { align-self: flex-start; }
.msg-row.client { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
  width: 28px; height: 28px; min-width: 28px;
  border-radius: 50%;
  background: rgba(79,126,255,.18);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  margin-bottom: 1px;
  flex-shrink: 0;
  overflow: hidden;
}
.msg-row.client .msg-avatar { background: rgba(79,126,255,.28); }
.msg-av-img {
  width: 100%; height: 100%;
  object-fit: cover; border-radius: 50%; display: block;
}
.msg-av-init {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: #fff; border-radius: 50%;
}

.msg-content { display: flex; flex-direction: column; gap: 4px; }
.msg-row.client .msg-content { align-items: flex-end; }

.msg-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  max-width: 280px;
}
.msg-row.admin .msg-bubble {
  background: #1A1A1F;
  color: #E8E8F0;
  border: 1px solid rgba(255,255,255,.07);
  border-bottom-left-radius: 5px;
}
.msg-row.client .msg-bubble {
  background: linear-gradient(135deg, #4F7EFF 0%, #6B5EDB 100%);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.msg-time {
  font-size: 10px;
  color: rgba(255,255,255,.22);
  padding: 0 3px;
  letter-spacing: .02em;
}

/* ── CHAT LIST (conversations list) ─── */
.chat-list-wrap { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }

.btn-new-chat {
  width: 100%;
  padding: 12px;
  background: rgba(79,126,255,.1);
  border: 1px solid rgba(79,126,255,.25);
  border-radius: 12px;
  color: #6B94FF;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 6px;
  transition: background .18s;
  font-family: 'Inter', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-new-chat:hover { background: rgba(79,126,255,.2); }

.chat-section-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255,255,255,.25);
  margin: 8px 2px 4px;
}

.chat-list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 13px;
  border-radius: 12px;
  cursor: pointer;
  background: #18181D;
  border: 1px solid rgba(255,255,255,.06);
  transition: background .15s, border-color .15s;
}
.chat-list-item:hover { background: #1E1E26; border-color: rgba(255,255,255,.1); }
.chat-list-item.closed { opacity: .55; }

.chat-list-avatar {
  width: 38px; height: 38px; min-width: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4F7EFF, #7B5EA7);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.chat-list-info { flex: 1; overflow: hidden; }
.chat-list-name {
  font-size: 13px; font-weight: 600;
  color: #E0E0EE;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-list-preview {
  font-size: 11px; color: rgba(255,255,255,.32);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.chat-list-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.chat-list-time { font-size: 10px; color: rgba(255,255,255,.22); }
.chat-badge {
  padding: 2px 7px; border-radius: 20px;
  font-size: 10px; font-weight: 700;
  background: rgba(34,197,94,.14); color: #22c55e;
}
.chat-badge.closed { background: rgba(239,68,68,.14); color: #f87171; }

/* ── EMPTY STATE ─────────────────────── */
.chat-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  flex: 1;
  padding: 32px 24px;
  text-align: center;
  gap: 10px;
}
.chat-empty .empty-icon { font-size: 36px; }
.chat-empty p { font-size: 13px; color: rgba(255,255,255,.35); line-height: 1.6; }

/* ── AUTH NOTICE ─────────────────────── */
.chat-auth-notice {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  flex: 1;
  padding: 36px 24px;
  text-align: center;
  gap: 14px;
}
.chat-auth-notice .notice-icon { font-size: 44px; }
.chat-auth-notice p { font-size: 14px; color: rgba(255,255,255,.5); line-height: 1.65; }
.chat-auth-notice a {
  display: inline-block;
  padding: 10px 26px;
  background: linear-gradient(135deg, #4F7EFF, #6B94FF);
  color: #fff; border-radius: 10px;
  font-size: 13px; font-weight: 600;
  text-decoration: none;
  transition: opacity .18s;
}
.chat-auth-notice a:hover { opacity: .88; }

/* ── CLOSED BANNER ───────────────────── */
.chat-closed-banner {
  flex-shrink: 0;
  text-align: center;
  padding: 12px 16px;
  background: rgba(239,68,68,.07);
  border-top: 1px solid rgba(239,68,68,.13);
}
.chat-closed-banner p { font-size: 12px; color: #fca5a5; margin-bottom: 9px; }
.chat-closed-actions { display: flex; gap: 8px; justify-content: center; }

.btn-sm {
  padding: 7px 15px;
  border-radius: 9px;
  font-size: 12px; font-weight: 600;
  cursor: pointer; border: none;
  font-family: 'Inter', sans-serif;
  transition: opacity .15s;
}
.btn-sm:hover { opacity: .85; }
.btn-sm-primary { background: #4F7EFF; color: #fff; }
.btn-sm-secondary {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.65);
  border: 1px solid rgba(255,255,255,.1) !important;
}

/* ── INPUT AREA ──────────────────────── */
.chat-input-area {
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: #111115;
  flex-shrink: 0;
}
.chat-input-area textarea {
  flex: 1;
  background: #1A1A1F;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 14px;
  color: #E8E8F0;
  padding: 11px 14px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  resize: none;
  min-height: 44px;
  max-height: 110px;
  line-height: 1.5;
  outline: none;
  transition: border-color .2s;
}
.chat-input-area textarea:focus { border-color: rgba(79,126,255,.45); }
.chat-input-area textarea::placeholder { color: rgba(255,255,255,.22); }

.chat-send-btn {
  width: 44px; height: 44px; min-width: 44px;
  border-radius: 14px;
  background: #4F7EFF;
  color: #fff; border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  transition: background .18s, transform .12s;
  flex-shrink: 0;
}
.chat-send-btn:hover  { background: #6B94FF; transform: scale(1.06); }
.chat-send-btn:active { transform: scale(.93); }
.chat-send-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }

/* ── TOAST ───────────────────────────── */
.chat-toast {
  position: fixed;
  bottom: 108px;
  left: 20px;
  background: #111115;
  color: #E8E8F0;
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 13px; font-weight: 600;
  z-index: 10000;
  cursor: pointer;
  border: 1px solid rgba(79,126,255,.3);
  box-shadow: 0 6px 24px rgba(0,0,0,.6);
  animation: toastIn .25s ease;
  display: flex; align-items: center; gap: 10px;
}
.chat-toast::before { content: '📩'; font-size: 16px; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── RESPONSIVE ─────────────────────── */
@media (max-width: 480px) {
  .chat-widget {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 8px;
    height: 75vh;
    border-radius: 16px;
  }
  #chatFab {
    bottom: 20px !important;
    right: 20px !important;
    width: 52px !important;
    height: 52px !important;
    font-size: 22px !important;
  }
}

/* ── PRE-CHAT FORM ───────────────────── */
.prechat-form {
  padding: 12px 4px;
  display: flex;
  flex-direction: column;
}
.prechat-form select option { background: #1A1A1F; }

/* ── TYPING INDICATOR ────────────────── */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  background: #1A1A1F;
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 18px;
  border-bottom-left-radius: 5px;
  width: fit-content;
}
.typing-bubble span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,.35);
  animation: typingDot 1.4s infinite ease-in-out;
}
.typing-bubble span:nth-child(2) { animation-delay: .2s; }
.typing-bubble span:nth-child(3) { animation-delay: .4s; }
@keyframes typingDot {
  0%,80%,100% { transform: scale(1); opacity:.35; }
  40%          { transform: scale(1.35); opacity:1; }
}

/* ── FORM INQUIRY CARD (in chat bubble) ── */
.msg-form-card {
  background: linear-gradient(135deg, rgba(245,158,11,.1) 0%, rgba(245,158,11,.05) 100%);
  border: 1px solid rgba(245,158,11,.28);
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background .18s, border-color .18s;
  min-width: 210px;
  max-width: 260px;
  position: relative;
  overflow: hidden;
}
.msg-form-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(245,158,11,.6), transparent);
}
.msg-form-card:hover {
  background: linear-gradient(135deg, rgba(245,158,11,.15) 0%, rgba(245,158,11,.08) 100%);
  border-color: rgba(245,158,11,.45);
}
.mfc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: rgba(245,158,11,.85);
}
.mfc-title {
  font-size: 13px;
  font-weight: 700;
  color: rgba(240,239,234,.9);
  font-family: 'Syne', sans-serif;
}
.mfc-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 5px;
}
.mfc-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: rgba(240,239,234,.35);
  font-weight: 600;
  flex-shrink: 0;
  min-width: 52px;
}
.mfc-val {
  font-size: 12px;
  color: rgba(240,239,234,.75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mfc-view {
  margin-top: 11px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(245,158,11,.8);
  letter-spacing: .03em;
}

/* ── FORM DETAIL MODAL (client click) ── */
.form-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.78);
  backdrop-filter: blur(10px);
  z-index: 10100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.form-detail-modal {
  background: #111115;
  border: 1px solid rgba(245,158,11,.22);
  border-radius: 18px;
  width: 100%;
  max-width: 420px;
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: 0 32px 80px rgba(0,0,0,.8);
  position: relative;
}
.form-detail-modal::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(245,158,11,.55), transparent);
  border-radius: 18px 18px 0 0;
}
.fdm-head {
  padding: 20px 22px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.fdm-title {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  color: #F0EFEA;
}
.fdm-close {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 7px;
  color: rgba(255,255,255,.5);
  width: 28px; height: 28px;
  cursor: pointer;
  font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
  font-family: inherit;
  transition: all .15s;
}
.fdm-close:hover { background: rgba(255,255,255,.13); color: #fff; }
.fdm-body { padding: 18px 22px 24px; }
.fdm-row {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255,255,255,.05);
  align-items: baseline;
}
.fdm-row:last-of-type { border-bottom: none; }
.fdm-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(240,239,234,.35);
  font-weight: 700;
  min-width: 70px;
  flex-shrink: 0;
}
.fdm-val {
  font-size: 13px;
  color: rgba(240,239,234,.85);
  font-weight: 500;
}
.fdm-desc-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(240,239,234,.35);
  font-weight: 700;
  margin-top: 14px;
  margin-bottom: 8px;
}
.fdm-desc {
  font-size: 13px;
  color: rgba(240,239,234,.7);
  line-height: 1.65;
  white-space: pre-wrap;
}
