/* ══════════════════════════════════════════════
   AvyaEvents — Unified Contact FAB + Chat Panel
   ══════════════════════════════════════════════ */

/* ── Contact FAB ── */
.contact-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 0;
}

/* Main button */
.fab-main {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4a90d9, #1a73e8);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(26, 115, 232, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}
.fab-main:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(26, 115, 232, 0.5);
}

/* Icon swap */
.fab-icon-close { display: none; }
.contact-fab.open .fab-icon-open { display: none; }
.contact-fab.open .fab-icon-close { display: block; }
.contact-fab.open .fab-main {
  background: linear-gradient(135deg, #e94560, #c73652);
  box-shadow: 0 4px 18px rgba(233, 69, 96, 0.4);
}

/* Unread badge */
.fab-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #e94560;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  animation: fab-pulse 2s ease-in-out infinite;
}
@keyframes fab-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Fan-out options */
.fab-options {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.8);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.contact-fab.open .fab-options {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Individual option buttons */
.fab-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: none;
  cursor: pointer;
  background: none;
  position: relative;
}
.fab-opt svg {
  width: 44px;
  height: 44px;
  padding: 10px;
  border-radius: 50%;
  box-shadow: 0 3px 12px rgba(0,0,0,0.15);
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}
.fab-opt:hover svg {
  transform: scale(1.1);
  box-shadow: 0 5px 18px rgba(0,0,0,0.2);
}

.fab-opt-chat svg { background: #4a90d9; color: #fff; }
.fab-opt-wa svg { background: #25D366; color: #fff; }
.fab-opt-call svg { background: #e94560; color: #fff; }

/* Labels */
.fab-label {
  position: absolute;
  right: 54px;
  background: #1a1a2e;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.fab-label::after {
  content: '';
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-left-color: #1a1a2e;
}
.fab-opt:hover .fab-label {
  opacity: 1;
  transform: translateX(0);
}

/* Hidden old bubble (kept for JS compat) */
.chat-bubble { display: none !important; }
.chat-unread-badge { display: none !important; }

/* ── Chat Panel ── */
.chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 370px;
  max-height: 520px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: chatPanelIn 0.2s ease-out;
}
@keyframes chatPanelIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: #4a90d9; color: #fff; flex-shrink: 0;
}
.chat-panel-title { font-size: 0.95rem; font-weight: 600; }
.chat-close-panel-btn {
  background: none; border: none; color: #fff; font-size: 1.4rem;
  cursor: pointer; line-height: 1; padding: 0 2px; opacity: 0.8; transition: opacity 0.2s;
}
.chat-close-panel-btn:hover { opacity: 1; }

.chat-tabs { display: flex; border-bottom: 1px solid #e8e8e8; flex-shrink: 0; background: #fafafa; }
.chat-tab {
  flex: 1; padding: 10px 8px; border: none; background: none;
  font-size: 0.82rem; font-weight: 600; color: #888; cursor: pointer;
  transition: color 0.2s; border-bottom: 2px solid transparent; text-align: center;
}
.chat-tab:hover { color: #4a90d9; }
.chat-tab.active { color: #4a90d9; border-bottom-color: #4a90d9; }

.chat-tab-content { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.chat-tab-content.active { display: flex; }

.chat-screen { flex: 1; display: flex; flex-direction: column; padding: 14px 16px; overflow-y: auto; }
.chat-screen-heading { font-size: 0.85rem; color: #555; margin: 0 0 12px; font-weight: 500; }

.chat-form-group { margin-bottom: 12px; }
.chat-form-group label { display: block; font-size: 0.78rem; font-weight: 600; color: #444; margin-bottom: 4px; }
.chat-form-group input { width: 100%; padding: 8px 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 0.85rem; color: #333; box-sizing: border-box; }
.chat-form-group input:focus { outline: none; border-color: #4a90d9; box-shadow: 0 0 0 2px rgba(74,144,217,0.15); }
.chat-field-error { display: block; font-size: 0.72rem; color: #e94560; margin-top: 3px; min-height: 14px; }
.chat-btn-primary { width: 100%; padding: 10px; background: #4a90d9; color: #fff; border: none; border-radius: 6px; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.chat-btn-primary:hover { background: #3a7bc8; }
.chat-btn-primary:disabled { background: #a0c4e8; cursor: not-allowed; }

.chat-target-list { display: flex; flex-direction: column; gap: 8px; }
.chat-target-list .chat-target-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: #f7f9fc; border: 1px solid #e8ecf1;
  border-radius: 8px; cursor: pointer; font-size: 0.85rem; color: #333;
  transition: background 0.15s, border-color 0.15s; text-decoration: none;
}
.chat-target-list .chat-target-item:hover { background: #edf2fa; border-color: #4a90d9; }
.chat-target-list .chat-target-item.disabled { opacity: 0.5; cursor: not-allowed; }
.chat-loading { text-align: center; padding: 20px 0; color: #999; font-size: 0.82rem; }

.chat-active-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0 10px; border-bottom: 1px solid #eee; margin-bottom: 8px; flex-shrink: 0;
}
.chat-active-target-name { font-size: 0.88rem; font-weight: 600; color: #1a1a2e; }
.chat-status-indicator { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; }
.chat-status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.chat-status-dot.online { background: #27ae60; box-shadow: 0 0 4px rgba(39,174,96,0.5); animation: status-pulse 2s ease-in-out infinite; }
.chat-status-dot.offline { background: #95a5a6; }
.chat-status-text { font-size: 0.7rem; color: #888; font-weight: 500; }
.chat-status-text.online { color: #27ae60; }
@keyframes status-pulse { 0%,100%{opacity:1;} 50%{opacity:0.5;} }
.chat-btn-close-conv { padding: 4px 10px; background: #e94560; color: #fff; border: none; border-radius: 4px; font-size: 0.72rem; font-weight: 600; cursor: pointer; }
.chat-btn-close-conv:hover { background: #d63851; }

.chat-messages { flex: 1; overflow-y: auto; padding: 8px 0; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.chat-msg { max-width: 80%; padding: 8px 12px; border-radius: 12px; font-size: 0.82rem; line-height: 1.45; word-wrap: break-word; position: relative; }
.chat-msg .chat-msg-sender { font-size: 0.68rem; font-weight: 600; margin-bottom: 2px; display: block; }
.chat-msg .chat-msg-time { font-size: 0.65rem; margin-top: 3px; display: block; opacity: 0.7; }
.chat-msg-sent { align-self: flex-end; background: #4a90d9; color: #fff; border-bottom-right-radius: 4px; }
.chat-msg-sent .chat-msg-sender { color: rgba(255,255,255,0.85); }
.chat-msg-sent .chat-msg-time { text-align: right; color: rgba(255,255,255,0.7); }
.chat-msg-received { align-self: flex-start; background: #f0f2f5; color: #333; border-bottom-left-radius: 4px; }
.chat-msg-received .chat-msg-sender { color: #4a90d9; }
.chat-msg-received .chat-msg-time { text-align: left; color: #999; }

.chat-send-bar { display: flex; align-items: center; gap: 8px; padding: 10px 0 4px; border-top: 1px solid #eee; flex-shrink: 0; }
.chat-message-input { flex: 1; padding: 8px 12px; border: 1px solid #ddd; border-radius: 20px; font-size: 0.82rem; color: #333; outline: none; }
.chat-message-input:focus { border-color: #4a90d9; }
.chat-send-btn { width: 36px; height: 36px; border-radius: 50%; background: #4a90d9; color: #fff; border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.chat-send-btn:hover { background: #3a7bc8; }
.chat-send-btn:disabled { background: #a0c4e8; cursor: not-allowed; }
.chat-send-btn svg { width: 18px; height: 18px; }

.chat-closed-overlay { position: absolute; bottom: 0; left: 0; right: 0; top: 0; background: rgba(255,255,255,0.85); display: flex; align-items: center; justify-content: center; z-index: 2; backdrop-filter: blur(2px); }
.chat-closed-label { background: #f0f2f5; color: #666; padding: 8px 18px; border-radius: 20px; font-size: 0.82rem; font-weight: 600; border: 1px solid #ddd; }
#chat-active-screen { position: relative; }

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* ── Responsive ── */
@media (max-width: 480px) {
  .contact-fab { bottom: 16px; right: 16px; }
  .fab-main { width: 50px; height: 50px; }
  .fab-opt svg { width: 40px; height: 40px; padding: 8px; }
  .fab-label { display: none; }
  .chat-panel {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%; max-height: none; border-radius: 0; z-index: 9999;
  }
}
@media (min-width: 481px) and (max-width: 768px) {
  .chat-panel { width: 340px; max-height: 480px; bottom: 80px; right: 16px; }
}
