/* SHAREIDE - Chat Widget */

.chat-widget {
  position: fixed;
  bottom: 25px;
  right: 25px;
  z-index: 1000;
}

.chat-toggle {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--black);
  border-radius: 50%;
  font-size: 22px;
  box-shadow: 0 8px 30px rgba(252,192,20,0.35);
  transition: all 0.3s ease;
  position: relative;
}

.chat-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 40px rgba(252,192,20,0.45);
}

.chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--red);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  border: 2px solid var(--white);
}

.chat-popup {
  position: absolute;
  bottom: 75px;
  right: 0;
  width: 360px;
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 60px rgba(0,0,0,0.15);
  overflow: hidden;
  display: none;
  border: 1px solid var(--border);
}

.chat-popup.show {
  display: block;
  animation: chatSlideUp 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

@keyframes chatSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-popup__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

.chat-popup__title {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--black);
}

.chat-popup__avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0,0,0,0.1);
  transition: all 0.3s ease;
}

.chat-popup__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* When agent photo is shown in header */
.chat-popup__avatar.has-agent-photo {
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.15);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chat-popup__title strong {
  display: block;
  font-size: 15px;
}

.online-status {
  font-size: 12px;
  color: rgba(0,0,0,0.6);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
}

.online-dot {
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
}

.chat-popup__close {
  font-size: 18px;
  color: var(--black);
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

.chat-popup__close:hover {
  opacity: 1;
}

.chat-popup__messages {
  height: 260px;
  padding: 20px;
  overflow-y: auto;
  background: var(--bg-alt);
}

.chat-message {
  margin-bottom: 12px;
}

.chat-message p {
  display: inline-block;
  padding: 12px 16px;
  background: var(--white);
  border-radius: 16px 16px 16px 4px;
  font-size: 14px;
  max-width: 80%;
  line-height: 1.5;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.chat-message--user {
  text-align: right;
}

.chat-message--user p {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--black);
  border-radius: 16px 16px 4px 16px;
  box-shadow: none;
}

.chat-message--system p {
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
  width: 100%;
  box-shadow: none;
}

.chat-popup__quick {
  display: flex;
  gap: 8px;
  padding: 12px 15px;
  flex-wrap: wrap;
  background: var(--white);
  border-top: 1px solid var(--border-light);
}

.quick-btn {
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 50px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

.quick-btn:hover {
  background: rgba(252,192,20,0.1);
  border-color: rgba(252,192,20,0.3);
  color: var(--primary-dark);
}

.chat-popup__contact {
  padding: 20px;
  background: var(--white);
}

.chat-popup__contact h4 {
  font-size: 15px;
  margin-bottom: 15px;
  color: var(--text);
}

.chat-popup__contact input {
  width: 100%;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  outline: none;
  color: var(--text);
  margin-bottom: 10px;
  transition: border-color 0.3s ease;
}

.chat-popup__contact input:focus {
  border-color: var(--primary);
}

.chat-popup__contact .btn {
  width: 100%;
  justify-content: center;
  margin-top: 5px;
}

.chat-popup__form {
  display: flex;
  padding: 12px 15px;
  gap: 10px;
  background: var(--white);
  border-top: 1px solid var(--border-light);
  align-items: center;
}

.chat-popup__form input[type="text"] {
  flex: 1;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 50px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  outline: none;
  color: var(--text);
  transition: border-color 0.3s ease;
  min-width: 0;
}

.chat-popup__form input::placeholder {
  color: var(--gray-400);
}

.chat-popup__form input:focus {
  border-color: var(--primary);
}

.chat-popup__form button[type="submit"] {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  font-size: 15px;
  color: var(--black);
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.chat-popup__form button[type="submit"]:hover {
  transform: scale(1.05);
}

.chat-popup__new-ticket {
  display: block;
  width: 100%;
  padding: 10px;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface);
  transition: all 0.3s ease;
}

.chat-popup__new-ticket:hover {
  color: var(--primary-dark);
  background: rgba(252,192,20,0.08);
}

/* Bot typing indicator */
.chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--white);
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.chat-typing .typing-dots {
  display: flex;
  gap: 4px;
}

.chat-typing .typing-dots span {
  width: 7px;
  height: 7px;
  background: var(--gray-400);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.chat-typing .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing .typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Typing indicator with agent avatar */
.chat-typing--with-avatar {
  gap: 10px;
}

.chat-typing__avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

/* Bot message slide-in */
.chat-message--bot {
  animation: slideInLeft 0.3s ease-out;
}

.chat-message--bot p {
  white-space: pre-line;
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-15px); }
  to { opacity: 1; transform: translateX(0); }
}

/* User message slide-in */
.chat-message--user {
  text-align: right;
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(15px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Quick button variants */
.quick-btn--confirm {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: #16a34a;
}

.quick-btn--confirm:hover {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(34, 197, 94, 0.5);
  color: #15803d;
}

.quick-btn--danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #dc2626;
}

.quick-btn--danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
  color: #b91c1c;
}

.quick-btn--escalate {
  background: rgba(147, 51, 234, 0.1);
  border-color: rgba(147, 51, 234, 0.3);
  color: #7c3aed;
}

.quick-btn--escalate:hover {
  background: rgba(147, 51, 234, 0.2);
  border-color: rgba(147, 51, 234, 0.5);
  color: #6d28d9;
}

/* Chat transition divider */
.chat-transition {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chat-transition::before,
.chat-transition::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

/* Live badge with pulse dot */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: rgba(34, 197, 94, 0.15);
  border-radius: 50px;
  font-size: 11px;
  font-weight: 600;
  color: #16a34a;
}

.live-badge .pulse-dot {
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  animation: livePulse 2s infinite;
}

@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
  70% { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* ============================================
   AGENT PROFILE BAR (enhanced with photo)
   ============================================ */
.chat-agent-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--border-light);
  animation: agentBarSlide 0.3s ease;
}

@keyframes agentBarSlide {
  from { opacity: 0; max-height: 0; padding: 0 16px; }
  to { opacity: 1; max-height: 60px; padding: 10px 16px; }
}

.chat-agent-bar__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--black);
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  overflow: hidden;
}

/* When avatar has actual photo */
.chat-agent-bar__avatar.has-photo {
  background: none;
  border: 2px solid var(--primary);
}

.chat-agent-bar__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.chat-agent-bar__info {
  flex: 1;
  min-width: 0;
}

.chat-agent-bar__name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-agent-bar__role {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
}

.chat-agent-bar__live {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(34, 197, 94, 0.12);
  border-radius: 50px;
  font-size: 10px;
  font-weight: 600;
  color: #16a34a;
  flex-shrink: 0;
}

/* ============================================
   AGENT JOINED NOTIFICATION
   ============================================ */
.chat-agent-joined {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  padding: 10px 14px;
  background: rgba(34, 197, 94, 0.06);
  border: 1px solid rgba(34, 197, 94, 0.15);
  border-radius: 14px;
  animation: agentJoinedFade 0.5s ease;
}

@keyframes agentJoinedFade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-agent-joined__photo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #22c55e;
  flex-shrink: 0;
}

.chat-agent-joined__initial {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--black);
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.chat-agent-joined__info {
  flex: 1;
  min-width: 0;
}

.chat-agent-joined__info strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.chat-agent-joined__info span {
  font-size: 11px;
  color: #16a34a;
  font-weight: 500;
}

/* ============================================
   SENDER ROW (avatar + name on admin messages)
   ============================================ */
.chat-sender-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  padding: 0 4px;
}

.chat-sender-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-sender {
  display: inline;
  font-size: 10px;
  font-weight: 600;
  color: var(--primary-dark);
}

/* Chat time - hidden by default, shown on hover */
.chat-time {
  display: block;
  font-size: 10px;
  color: var(--gray-400);
  margin-top: 2px;
  opacity: 0;
  transition: opacity 0.2s ease;
  padding: 0 4px;
}

.chat-message:hover .chat-time {
  opacity: 1;
}

.chat-message--user .chat-time {
  text-align: right;
}

/* ============================================
   ATTACH & IMAGE BUTTONS
   ============================================ */
.chat-attach-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--gray-400);
  border-radius: 50%;
  font-size: 14px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chat-attach-btn:hover {
  color: var(--primary-dark);
  background: rgba(252,192,20,0.1);
}

/* Camera/image button - more prominent */
#chatImageBtn {
  color: var(--text-secondary);
  font-size: 15px;
}

#chatImageBtn:hover {
  color: var(--primary-dark);
  background: rgba(252,192,20,0.12);
}

/* Subtle tooltip-like indicator when form is in live mode */
.chat-popup__form.live-mode {
  gap: 6px;
}

/* File preview bar */
.chat-popup__file-preview {
  padding: 8px 15px;
  background: var(--white);
  border-top: 1px solid var(--border-light);
}

.chat-file-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border-light);
}

.chat-file-preview__thumb {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  color: var(--gray-400);
  font-size: 14px;
}

.chat-file-preview__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-file-preview__info {
  flex: 1;
  min-width: 0;
}

.chat-file-preview__name {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-file-preview__size {
  display: block;
  font-size: 10px;
  color: var(--gray-400);
}

.chat-file-preview__remove {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--gray-400);
  font-size: 10px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chat-file-preview__remove:hover {
  background: rgba(239,68,68,0.1);
  color: var(--red);
}

/* Attachment display in messages */
.chat-attachment-img {
  display: block;
  margin-bottom: 4px;
  cursor: pointer;
}

.chat-attachment-img img {
  max-width: 180px;
  max-height: 180px;
  border-radius: 10px;
  object-fit: cover;
}

.chat-attachment-file {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.05);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
  color: inherit;
  margin-bottom: 4px;
  transition: background 0.2s ease;
  text-decoration: none;
}

.chat-attachment-file:hover {
  background: rgba(0,0,0,0.1);
}

.chat-attachment-file span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-attachment-file .fa-download {
  font-size: 10px;
  opacity: 0.5;
}

/* Image lightbox modal */
.chat-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.85);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  cursor: zoom-out;
}

.chat-lightbox.active {
  opacity: 1;
  visibility: visible;
}

.chat-lightbox img {
  max-width: 90%;
  max-height: 85vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  transform: scale(0.9);
  transition: transform 0.25s ease;
  cursor: default;
}

.chat-lightbox.active img {
  transform: scale(1);
}

.chat-lightbox__close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.15);
  color: white;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s ease;
  border: none;
}

.chat-lightbox__close:hover {
  background: rgba(255,255,255,0.3);
}

@media (max-width: 480px) {
  .chat-popup {
    width: calc(100vw - 50px);
    right: -12px;
  }
  .chat-time {
    opacity: 1;
  }
}

/* Fix iOS zoom on input focus */
.chat-popup__contact input,
.chat-popup__form input[type="text"],
.chat-popup__form textarea,
select, input, textarea {
  font-size: 16px !important;
}
