/* ═══════════════════════════════════════════════════════════
   CHAT SYSTEM STYLES — Resume My Profile
   Used in: admin panel + client dashboard
═══════════════════════════════════════════════════════════ */

/* ── Floating Chat Widget (Homepage) ────────────────────── */
.live-chat-btn {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 9998;
  background: linear-gradient(135deg, #ff8c00 0%, #ffa500 100%);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(255, 140, 0, 0.45);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-decoration: none;
}
.live-chat-btn:hover {
  transform: translateY(-4px) scale(1.04);
  box-shadow: 0 14px 32px rgba(255, 140, 0, 0.55);
}
.live-chat-btn .chat-pulse {
  width: 10px;
  height: 10px;
  background: #4ade80;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}
.live-chat-btn .chat-pulse::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: rgba(74, 222, 128, 0.4);
  animation: pulse-ring 1.4s ease-out infinite;
}
@keyframes pulse-ring {
  0%   { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(2.0); opacity: 0; }
}

/* ── Chat Preview Popup ─────────────────────────────────── */
.chat-preview-popup {
  position: fixed;
  bottom: 160px;
  right: 24px;
  z-index: 9997;
  background: #fff;
  border-radius: 18px;
  padding: 1.25rem 1.5rem;
  max-width: 280px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: 'Inter', sans-serif;
}
.chat-preview-popup.show {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}
.chat-preview-popup h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 0.4rem;
}
.chat-preview-popup p {
  font-size: 0.82rem;
  color: #666;
  margin-bottom: 1rem;
}
.chat-preview-popup .popup-btns {
  display: flex;
  gap: 0.5rem;
}
.chat-preview-popup .popup-btn {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border: none;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  text-align: center;
  text-decoration: none;
  display: block;
}
.chat-preview-popup .popup-btn-primary {
  background: linear-gradient(135deg, #ff8c00, #ffa500);
  color: #fff;
}
.chat-preview-popup .popup-btn-secondary {
  background: #f5f5f5;
  color: #333;
}
.chat-preview-popup .popup-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: #999;
  line-height: 1;
}

/* ── Admin Chat Panel ────────────────────────────────────── */
.chat-panel-wrap {
  display: flex;
  height: calc(100vh - 140px);
  min-height: 500px;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: var(--shadow);
}

/* Left: User list */
.chat-users-panel {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
}
.chat-users-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.chat-users-search {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.chat-users-search input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  font-family: inherit;
}
.chat-users-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}
.chat-user-card {
  padding: 0.75rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
  position: relative;
}
.chat-user-card:hover { background: var(--bg-card); }
.chat-user-card.active {
  background: rgba(255, 140, 0, 0.12);
  border: 1px solid rgba(255, 140, 0, 0.25);
}
.chat-user-card .cu-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-user-card .cu-preview {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.chat-user-card .cu-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}
.chat-user-card .cu-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.chat-user-card .cu-badge {
  background: #ef4444;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 20px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}

/* Right: Thread */
.chat-thread-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chat-thread-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
}
.chat-thread-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff8c00, #ffa500);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}
.chat-thread-info .ct-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}
.chat-thread-info .ct-email {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 0.75rem;
}
.chat-empty-state .ce-icon { font-size: 3rem; }
.chat-empty-state p { font-size: 0.9rem; }
.chat-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  scroll-behavior: smooth;
}
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 72%;
}
.chat-msg.from-admin {
  align-self: flex-end;
  align-items: flex-end;
}
.chat-msg.from-user {
  align-self: flex-start;
  align-items: flex-start;
}
.chat-msg .msg-bubble {
  padding: 0.65rem 0.95rem;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.5;
  word-break: break-word;
}
.from-user .msg-bubble {
  background: var(--bg-secondary);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.from-admin .msg-bubble {
  background: linear-gradient(135deg, #ff8c00, #ffa500);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg .msg-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 3px;
  padding: 0 2px;
}

/* Input area */
.chat-input-area {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  background: var(--bg-card);
}
.chat-input-area textarea {
  flex: 1;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-secondary);
  color: var(--text);
  font-size: 0.88rem;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  min-height: 42px;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.4;
}
.chat-input-area textarea:focus { border-color: #ff8c00; }
.chat-input-area textarea::placeholder { color: var(--text-muted); }
.chat-send-btn {
  padding: 0.7rem 1.2rem;
  background: linear-gradient(135deg, #ff8c00, #ffa500);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  white-space: nowrap;
  height: 42px;
}
.chat-send-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(255,140,0,0.4); }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Client Dashboard Chat Panel ────────────────────────── */
.client-chat-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 180px);
  min-height: 400px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg-card, #fff);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}
.client-chat-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: linear-gradient(135deg, #fff8f3 0%, #ffe8d6 100%);
}
.client-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff8c00, #ffa500);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.client-chat-info .cc-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #1a1a1a;
}
.client-chat-info .cc-sub {
  font-size: 0.78rem;
  color: #888;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.online-dot {
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
}
.client-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  scroll-behavior: smooth;
}
.client-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}
.client-chat-msg.from-me {
  align-self: flex-end;
  align-items: flex-end;
}
.client-chat-msg.from-admin {
  align-self: flex-start;
  align-items: flex-start;
}
.client-chat-msg .cc-bubble {
  padding: 0.7rem 1rem;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
}
.from-me .cc-bubble {
  background: linear-gradient(135deg, #ff8c00, #ffa500);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.from-admin .cc-bubble {
  background: #f3f4f6;
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
}
.client-chat-msg .cc-time {
  font-size: 0.7rem;
  color: #999;
  margin-top: 3px;
  padding: 0 2px;
}
.client-chat-input {
  padding: 1rem;
  border-top: 1px solid var(--border, #e5e7eb);
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
  background: #fff;
}
.client-chat-input textarea {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid #ede8e0;
  border-radius: 12px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  min-height: 44px;
  outline: none;
  transition: border-color 0.2s;
  background: #f9f9f9;
  color: #1a1a1a;
}
.client-chat-input textarea:focus { border-color: #ff8c00; background: #fff; }
.client-chat-input textarea::placeholder { color: #b0b0b0; }
.client-chat-send {
  padding: 0 1.25rem;
  height: 44px;
  background: linear-gradient(135deg, #ff8c00, #ffa500);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(255,140,0,0.3);
}
.client-chat-send:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(255,140,0,0.4); }
.client-chat-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Sidebar chat unread badge */
.sidebar-unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  margin-left: auto;
  flex-shrink: 0;
}

/* Dark mode adjustments for client chat */
@media (prefers-color-scheme: dark) {
  .client-chat-wrap { background: #1e1e2e; }
  .client-chat-header { background: linear-gradient(135deg, #1e1a14, #2a2010); }
  .client-chat-info .cc-title { color: #f0f0f0; }
  .from-admin .cc-bubble { background: #2a2a3e; color: #e0e0e0; }
  .client-chat-input { background: #1e1e2e; border-color: #333; }
  .client-chat-input textarea { background: #2a2a3e; color: #f0f0f0; border-color: #3a3a4e; }
  .client-chat-msg .cc-time { color: #666; }
}

/* No chat yet */
.chat-no-msgs {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 0.75rem;
  color: #aaa;
  padding: 2rem;
}
.chat-no-msgs .cnm-icon { font-size: 2.5rem; }
.chat-no-msgs p { font-size: 0.88rem; text-align: center; }

/* Responsive */
@media (max-width: 640px) {
  .chat-panel-wrap { flex-direction: column; height: auto; min-height: unset; }
  .chat-users-panel { width: 100%; max-height: 220px; border-right: none; border-bottom: 1px solid var(--border); }
  .live-chat-btn { bottom: 80px; right: 16px; padding: 12px 16px; font-size: 0.82rem; }
  .chat-preview-popup { right: 16px; bottom: 148px; }
}
