/* Safelify AI Concierge v3.0 — Premium Glass Design */
:root { --sac-p: #e30613; --sac-pd: #b5000b; --sac-pl: rgba(227,6,19,0.08); }

/* Floating Button */
.sac-btn {
  position: fixed; z-index: 999999; cursor: pointer;
  width: 60px; height: 60px; border-radius: 20px;
  background: linear-gradient(135deg, var(--sac-p), var(--sac-pd));
  color: #fff; border: none;
  box-shadow: 0 8px 32px rgba(227,6,19,0.3), 0 2px 8px rgba(0,0,0,0.08);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
  backdrop-filter: blur(12px);
}
.sac-btn:hover { transform: scale(1.06) translateY(-2px); box-shadow: 0 12px 40px rgba(227,6,19,0.35); }
.sac-btn svg { width: 28px; height: 28px; }
.sac-bottom-right { bottom: 28px; right: 28px; }
.sac-bottom-left { bottom: 28px; left: 28px; }

/* Chat Window — Wider, Spacious */
.sac-win {
  position: fixed; z-index: 999998; display: none;
  width: 440px; height: 640px; max-height: 90vh;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  box-shadow: 0 32px 64px -12px rgba(0,0,0,0.2), 0 0 0 1px rgba(255,255,255,0.1) inset;
  overflow: hidden; flex-direction: column;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  animation: sac-up 0.35s cubic-bezier(0.16,1,0.3,1);
  border: 1px solid rgba(255,255,255,0.2);
}
.sac-win.sac-o { display: flex; }
.sac-bottom-right + .sac-win { bottom: 100px; right: 28px; }
.sac-bottom-left + .sac-win { bottom: 100px; left: 28px; }
@keyframes sac-up { from { opacity:0; transform:translateY(20px) scale(0.96); } to { opacity:1; transform:translateY(0) scale(1); } }

/* Header */
.sac-hd {
  background: linear-gradient(135deg, var(--sac-p), var(--sac-pd));
  color: #fff; padding: 18px 24px 14px;
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.sac-hd-l { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.sac-av {
  width: 40px; height: 40px; border-radius: 14px;
  background: rgba(255,255,255,0.2); display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
  backdrop-filter: blur(4px);
}
.sac-av svg { width: 22px; height: 22px; }
.sac-ti { font-size: 16px; font-weight: 700; letter-spacing: -0.3px; }
.sac-st { font-size: 12px; opacity: 0.75; }
.sac-hdb {
  background: none; border: none; color: #fff; cursor: pointer;
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s; flex-shrink: 0;
}
.sac-hdb:hover { background: rgba(255,255,255,0.15); }
.sac-hdb svg { width: 20px; height: 20px; }

/* Messages area */
.sac-ms {
  flex: 1; overflow-y: auto; padding: 24px;
  display: flex; flex-direction: column; gap: 10px;
  background: rgba(249,250,251,0.5);
}
.sac-msg { display: flex; animation: sac-in 0.3s ease; }
@keyframes sac-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
.sac-bot { justify-content: flex-start; }
.sac-user { justify-content: flex-end; }
.sac-bub {
  max-width: 88%; padding: 14px 20px; border-radius: 20px;
  font-size: 14px; line-height: 1.6; word-wrap: break-word;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.sac-bot .sac-bub { background: #fff; color: #1a1c1c; border-bottom-left-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.sac-user .sac-bub { background: var(--sac-p); color: #fff; border-bottom-right-radius: 6px; }

/* Typing dots */
.sac-d { display:inline-block; width:8px; height:8px; border-radius:50%; background:#9ca3af; margin-right:4px; animation:sac-b 1.4s infinite; }
.sac-d:nth-child(2) { animation-delay:0.2s; }
.sac-d:nth-child(3) { animation-delay:0.4s; margin-right:0; }
@keyframes sac-b { 0%,60%,100% { transform:translateY(0); } 30% { transform:translateY(-6px); } }

/* Quick Actions */
.sac-ac { padding: 12px 24px 16px; display: flex; flex-wrap: wrap; gap: 8px; border-top:1px solid rgba(0,0,0,0.04); background:rgba(255,255,255,0.8); }
.sac-ab {
  padding: 10px 20px; border-radius: 999px; border: 1px solid rgba(0,0,0,0.06);
  background: #fff; color: #374151; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.2s; font-family: inherit;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.sac-ab:hover { border-color: var(--sac-p); color: var(--sac-p); background: var(--sac-pl); transform: translateY(-1px); }

/* Suggestions */
.sac-sg { display: none; flex-direction: column; gap: 2px; padding: 8px 24px 4px; background: rgba(255,255,255,0.9); border-top:1px solid rgba(0,0,0,0.04); max-height:120px; overflow-y:auto; }
.sac-su { padding: 10px 12px; font-size: 13px; color: #374151; cursor: pointer; border-radius: 10px; transition: all 0.15s; }
.sac-su:hover { background: var(--sac-pl); color: var(--sac-p); }
.sac-su b { color: var(--sac-p); }

/* Input Area — Spacious, Uncluttered */
.sac-in {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 24px 22px; border-top: 1px solid rgba(0,0,0,0.04);
  background: rgba(255,255,255,0.95); flex-shrink: 0;
}
.sac-fd {
  flex: 1; border: none; outline: none; font-size: 15px;
  font-family: inherit; color: #1a1c1c;
  padding: 12px 4px; background: transparent;
}
.sac-fd::placeholder { color: #b0b7c3; font-weight: 400; font-size: 14px; }
.sac-ib {
  width: 42px; height: 42px; border-radius: 12px; border: none;
  background: transparent; color: #6b7280; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; flex-shrink: 0;
}
.sac-ib:hover { background: #f3f4f6; color: var(--sac-p); }
.sac-ib svg { width: 20px; height: 20px; }
.sac-snd {
  width: 48px; height: 48px; border-radius: 14px; border: none;
  background: var(--sac-p); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1); flex-shrink: 0;
  margin-left: 2px; margin-right: 4px; box-shadow: 0 4px 12px rgba(227,6,19,0.2);
}
.sac-snd:hover { background: var(--sac-pd); transform: scale(1.06); }
.sac-snd:disabled { background: #e5e7eb; cursor: not-allowed; transform: none; box-shadow: none; }
.sac-snd svg { width: 22px; height: 22px; }

/* Proactive notification bubble */
.sac-pro {
  position: fixed; z-index: 1000000; cursor: pointer;
  max-width: 280px; padding: 14px 18px;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 12px 48px -8px rgba(0,0,0,0.15), 0 0 0 1px rgba(227,6,19,0.08) inset;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px; line-height: 1.5; color: #1f2937;
  animation: sac-bounce 0.6s cubic-bezier(0.34,1.56,0.64,1);
  transform-origin: bottom left;
  pointer-events: auto;
}
.sac-pro.sac-bottom-right { bottom: 100px; right: 28px; transform-origin: bottom right; }
.sac-pro.sac-bottom-left { bottom: 100px; left: 28px; }
.sac-pro::after {
  content: ''; position: absolute; bottom: -8px;
  width: 16px; height: 16px; background: rgba(255,255,255,0.97);
  border-radius: 0 0 4px 0; box-shadow: 2px 2px 4px -2px rgba(0,0,0,0.06);
}
.sac-pro.sac-bottom-right::after { right: 20px; }
.sac-pro.sac-bottom-left::after { left: 20px; }
.sac-pro:hover { transform: scale(1.03); box-shadow: 0 16px 56px -8px rgba(0,0,0,0.2); }
.sac-pro-close {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #f3f4f6; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #6b7280; font-size: 14px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.2s;
}
.sac-pro-close:hover { background: #fee2e2; color: #dc2626; transform: scale(1.1); }
@keyframes sac-bounce {
  0% { opacity: 0; transform: scale(0.5) translateY(20px); }
  50% { transform: scale(1.08) translateY(-4px); }
  70% { transform: scale(0.96) translateY(2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes sac-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.sac-pro-pulse { animation: sac-pulse 2s ease-in-out infinite; }

/* Lead form */
.sac-lf { padding: 8px 0; max-width: 100%; animation: sac-in 0.3s ease; }

/* Mobile */
@media (max-width: 480px) {
  .sac-win { width: 100vw; height: 100vh; max-height: 100vh; bottom: 0 !important; right: 0 !important; left: 0 !important; border-radius: 0; }
  .sac-btn { width: 54px; height: 54px; border-radius: 16px; }
  .sac-btn svg { width: 24px; height: 24px; }
}

/* Chat bubbles preserve newlines from textContent-rendered messages */
.sac-bub { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Backdrop blur is GPU-heavy on low-end devices: flat fallback */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .sac-btn, .sac-win, .sac-av, .sac-pro { backdrop-filter: none; -webkit-backdrop-filter: none; }
  .sac-win { background: #fff; }
  .sac-pro { background: #fff; }
}

/* Ensure input icons are always visible */
.sac-ib svg, .sac-snd svg, .sac-hdb svg, .sac-av svg { display: block !important; opacity: 1 !important; visibility: visible !important; }
