/* Online icon */
.online-icon {
  color: green;
  animation: pulse 1.5s infinite;
  font-size: 16px;
}
@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.8); opacity: 0.7; }
}

/* Chat Button */
#chat-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #007bff;
  color: white;
  font-size: 1.3rem;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999999999;
  box-shadow: 0 0 10px rgba(0,0,0,0.3);
}

/* Badge */
#chat-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: red;
  color: white;
  width: 16px;
  height: 16px;
  font-size: 10px;
  font-weight: bold;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: glow 1s infinite alternate;
}
@keyframes glow {
  from { box-shadow: 0 0 5px red; }
  to { box-shadow: 0 0 15px red; }
}

/* Chat Modal */
#chat-modal {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 400px;
  max-height: 80vh;
  background: white;
  border-radius: 10px;
  box-shadow: 0 0 15px rgba(0,0,0,0.3);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999999;
}

/* Chat Header */
#chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #007bff;
  color: white;
  padding: 10px;
}
#chat-header .admin-label {
  display: flex;
  align-items: center;
  gap: 10px;
}
#chat-header .admin-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #6c757d;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}
#chat-header .chat-close {
  font-size: 20px;
  cursor: pointer;
}

/* Messages */
#chat-messages {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #f7f7f7;
}

/* Message bubble */
.message-bubble {
  display: flex;
  align-items: flex-start;
  max-width: 100%;
}
.message-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white;
  flex-shrink: 0;
}
.admin-msg .message-avatar { background: #6c757d; }
.admin-msg .message-text { 
  background: #e6e6e6; 
  color: black; 
  margin-left: 8px; 
  border-radius: 10px; 
  padding: 8px 12px; 
  word-wrap: break-word;
}
.user-msg { flex-direction: row-reverse; }
.user-msg .message-avatar { background: #007bff; }
.user-msg .message-text { 
  background: #007bff; 
  color: white; 
  margin-right: 8px; 
  border-radius: 10px; 
  padding: 8px 12px; 
  word-wrap: break-word;
}

/* Input Box */
#chat-input-box {
  display: flex;
  border-top: 1px solid #ccc;
  flex-wrap: nowrap; /* prevent wrapping on mobile */
}
#chat-input {
  flex: 1;
  padding: 10px;
  border: none;
  outline: none;
  min-width: 0; /* ensures input shrinks on small screens */
}
#chat-send {
  background: #28a745;
  color: white;
  border: none;
  padding: 10px 15px;
  cursor: pointer;
  flex-shrink: 0; /* keeps button visible */
  white-space: nowrap;
  min-width: 60px; /* always visible on mobile */
}

/* Responsive */
@media (max-width: 768px) {
  #chat-modal {
    width: 90%;
    right: 5%;
    bottom: 70px;
  }
  #chat-btn {
    width: 45px;
    height: 45px;
    font-size: 1.1rem;
  }
  #chat-badge {
    width: 14px;
    height: 14px;
    font-size: 9px;
  }
  .message-avatar {
    width: 25px;
    height: 25px;
    font-size: 0.8rem;
  }
  .admin-msg .message-text,
  .user-msg .message-text {
    padding: 6px 10px;
    font-size: 0.85rem;
  }
  #chat-input {
    padding: 8px;
    font-size: 0.9rem;
  }
  #chat-send {
    padding: 8px 12px;
    font-size: 0.9rem;
    min-width: 50px;
  }
}
