:root{--chat-bg:#ffffff;--chat-border:#e5e7eb;--chat-text:#111827;--chat-muted:#6b7280;--chat-accent:#111;--chat-shadow:0 8px 24px rgba(0,0,0,.12)}
#chat-bubble{position:fixed;right:14px;bottom:14px;width:56px;height:56px;border-radius:50%;border:none;background:#111;color:#fff;display:flex;align-items:center;justify-content:center;font-size:22px;box-shadow:var(--chat-shadow);z-index:20000;cursor:pointer}
#chat-bubble.has-new{background:#c1121f; box-shadow:0 0 0 3px rgba(193,18,31,.15), var(--chat-shadow)}
#chat-bubble .dot{width:6px;height:6px;border-radius:50%;background:#4ade80;margin-left:6px;}
#chat-panel{position:fixed;right:12px;bottom:80px;width:320px;max-width:calc(100vw - 24px);height:420px;max-height:60vh;background:var(--chat-bg);border:1px solid var(--chat-border);border-radius:12px;box-shadow:var(--chat-shadow);display:none;flex-direction:column;overflow:hidden;z-index:20001}
#chat-header{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border-bottom:1px solid var(--chat-border);background:#fff}
#chat-title{font-weight:700;color:var(--chat-text);font-size:14px}
#chat-status{font-size:12px;color:var(--chat-muted)}
#chat-messages{flex:1;overflow:auto;padding:10px;background:#f9fafb}
.chat-msg{max-width:80%;padding:8px 10px;border-radius:10px;margin:6px 0;box-shadow:0 2px 6px rgba(0,0,0,.06);font-size:13px;line-height:1.35}
.chat-msg.visitor{background:#fff;color:var(--chat-text);border-top-left-radius:2px;}
.chat-msg.admin{background:#111;color:#fff;margin-left:auto;border-top-right-radius:2px;}
#chat-input{display:flex;padding:8px;border-top:1px solid var(--chat-border);background:#fff}
#chat-input input{flex:1;border:1px solid var(--chat-border);border-radius:8px;padding:10px 12px;font-size:14px;outline:none}
#chat-input button{margin-left:8px;background:#111;color:#fff;border:none;border-radius:8px;padding:10px 12px;cursor:pointer}
#chat-input input:disabled, #chat-input button:disabled{opacity:.6; cursor:not-allowed;}
@media (max-width:768px){
  #chat-panel {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: 76px;
    max-height: 65vh;
    display: flex;
    flex-direction: column;
  }
  
  #chat-input {
    padding: 8px 12px;
    justify-content: center;
  }
  
  #chat-input input {
    max-width: 85%;
    margin: 0 auto;
    text-align: center;
  }
  
  #chat-input button {
    position: absolute;
    right: 20px;
  }
}

/* ===== Pulsating state for new messages ===== */
@keyframes chatPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(193,18,31,.35), var(--chat-shadow); }
  70% { transform: scale(1.06); box-shadow: 0 0 0 10px rgba(193,18,31,0), var(--chat-shadow); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(193,18,31,0), var(--chat-shadow); }
}
#chat-bubble.pulse { animation: chatPulse 1.3s ease-out infinite; }

/* ===== Admin multi-chat windows (Facebook-style) ===== */
.admin-chat-dock {
  position: fixed;
  right: 12px;
  bottom: 80px;
  z-index: 20002;
  display: flex;
  gap: 10px;
}

.admin-chat-window {
  width: 300px;
  max-width: calc(100vw - 24px);
  height: 360px;
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--chat-border);
  background: #fff;
}

.admin-chat-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--chat-text);
}

.admin-chat-close {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #777;
}

.admin-chat-messages { flex: 1; overflow: auto; padding: 10px; background: #f9fafb; }
.admin-chat-input { display: flex; padding: 8px; border-top: 1px solid var(--chat-border); background: #fff; }
.admin-chat-input input { flex: 1; border: 1px solid var(--chat-border); border-radius: 8px; padding: 10px 12px; font-size: 14px; outline: none; }
.admin-chat-input button { margin-left: 8px; background: #111; color: #fff; border: none; border-radius: 8px; padding: 10px 12px; cursor: pointer; }

@media (max-width: 1024px) {
  .admin-chat-dock { right: 8px; bottom: 76px; gap: 8px; }
  .admin-chat-window { width: 260px; height: 320px; }
}
