/*
 * MohsinMarkaz E-Commerce - Chat Widget Stylesheet
 */

/* Chat Widget Container */
.chat-widget {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 9998;
}

/* Floating Action Button */
.chat-fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e87d0e, #d06700);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 5px 25px rgba(232, 125, 14, 0.4);
  transition: all 0.3s ease;
  position: relative;
  /* Ensure entire button is clickable */
  overflow: visible;
}

.chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 35px rgba(232, 125, 14, 0.5);
}

.chat-fab .fab-icons {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 1.1rem;
  /* Make icons NOT block clicks - parent button handles it */
  pointer-events: none;
}

.chat-fab .fab-icons i {
  pointer-events: none;
}

.chat-fab .fab-icons i:first-child {
  color: #ffffff;
}

.chat-fab .fab-icons i:last-child {
  color: #25d366;
}

.chat-fab .unread-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #dc3545;
  color: #ffffff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  animation: pulse 2s ease infinite;
}

/* Chat Options Menu */
.chat-options {
  position: absolute;
  bottom: 75px;
  right: 0;
  background: #ffffff;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  padding: 15px;
  width: 200px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
}

.chat-options.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.chat-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #333;
  text-decoration: none;
}

.chat-option:hover {
  background: #f5f5f5;
}

.chat-option i {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.chat-option.live-chat i {
  background: rgba(232, 125, 14, 0.1);
  color: #e87d0e;
}

.chat-option.whatsapp i {
  background: rgba(37, 211, 102, 0.1);
  color: #25d366;
}

.chat-option span {
  font-weight: 500;
}

/* Chat Window */
.chat-window {
  position: absolute;
  bottom: 75px;
  right: 0;
  width: 380px;
  height: 550px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s ease;
  overflow: hidden;
}

.chat-window.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chat Header */
.chat-header {
  background: linear-gradient(135deg, #e87d0e, #d06700);
  color: #ffffff;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.chat-header-text h4 {
  margin: 0 0 3px;
  font-size: 1rem;
}

.chat-status {
  font-size: 0.8rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chat-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4caf50;
}

.chat-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #ffffff;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.chat-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Chat Body - scrollable area */
.chat-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: #f8f9fa;
  min-height: 0;
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  background: #f8f9fa;
}

.chat-messages::-webkit-scrollbar {
  width: 5px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 5px;
}

.message {
  max-width: 80%;
  display: flex;
  flex-direction: column;
}

.message.received {
  align-self: flex-start;
}

.message.sent {
  align-self: flex-end;
}

.message-content {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.message.received .message-content {
  background: #ffffff;
  color: #333;
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.message.sent .message-content {
  background: linear-gradient(135deg, #e87d0e, #d06700);
  color: #ffffff;
  border-bottom-right-radius: 5px;
}

.message-time {
  font-size: 0.7rem;
  color: #999;
  margin-top: 5px;
  padding: 0 5px;
}

.message.sent .message-time {
  text-align: right;
}

.message-status {
  font-size: 0.7rem;
  margin-top: 3px;
  text-align: right;
  color: #999;
}

.message-status i {
  color: #4caf50;
}

/* Chat file/image attachments */
.message-content img {
  max-width: 200px;
  border-radius: 8px;
  display: block;
  margin: 5px 0;
  cursor: pointer;
}

.chat-file-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  font-size: 0.9rem;
}

.chat-file-link:hover {
  background: rgba(0, 0, 0, 0.1);
}

.message.sent .chat-file-link {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.message.sent .chat-file-link:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Welcome Message */
.welcome-message {
  text-align: center;
  padding: 20px;
  color: #666;
}

.welcome-message i {
  font-size: 3rem;
  color: #e87d0e;
  margin-bottom: 15px;
}

.welcome-message h4 {
  margin: 0 0 10px;
  color: #333;
}

.welcome-message p {
  margin: 0;
  font-size: 0.9rem;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 15px;
  background: #ffffff;
  border-radius: 18px;
  border-bottom-left-radius: 5px;
  width: fit-content;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ccc;
  animation: typing 1.4s ease infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
    background: #e87d0e;
  }
}

/* Chat Input - Fixed at bottom */
.chat-input {
  padding: 15px 20px;
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
  position: relative;
}

/* File attachment button */
.chat-attach {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #f0f0f0;
  color: #666;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.chat-attach:hover {
  background: #e5e5e5;
  color: #e87d0e;
}

.chat-attach input[type="file"] {
  display: none;
}

.chat-input input {
  flex: 1;
  padding: 12px 18px;
  border: 1px solid #e5e7eb;
  border-radius: 25px;
  outline: none;
  font-size: 0.95rem;
  transition: all 0.3s ease;
}

.chat-input input:focus {
  border-color: #e87d0e;
  box-shadow: 0 0 0 3px rgba(232, 125, 14, 0.1);
}

.chat-input input::placeholder {
  color: #aaa;
}

.chat-send {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e87d0e, #d06700);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.3s ease;
}

.chat-send:hover {
  transform: scale(1.1);
}

.chat-send:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

/* Guest Form */
.guest-form {
  padding: 30px 20px;
  text-align: center;
}

.guest-form h4 {
  margin: 0 0 20px;
  color: #333;
}

.guest-form .form-group {
  margin-bottom: 15px;
  text-align: left;
}

.guest-form label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.85rem;
  color: #666;
}

.guest-form input {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  outline: none;
  transition: all 0.3s ease;
}

.guest-form input:focus {
  border-color: #e87d0e;
}

.guest-form button {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #e87d0e, #d06700);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.guest-form button:hover {
  transform: translateY(-2px);
}

/* Admin Chat Panel */
.admin-chat-panel {
  display: grid;
  grid-template-columns: 350px 1fr;
  height: calc(100vh - 170px);
  background: #ffffff;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
}

.chat-users-panel {
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
}

.chat-users-header {
  padding: 20px;
  border-bottom: 1px solid #e5e7eb;
}

.chat-users-header h3 {
  margin: 0 0 15px;
  font-size: 1.1rem;
}

.chat-search {
  position: relative;
}

.chat-search input {
  width: 100%;
  padding: 10px 15px 10px 40px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  outline: none;
}

.chat-search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
}

.chat-users-list {
  flex: 1;
  overflow-y: auto;
}

.chat-user-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  border-bottom: 1px solid #f5f5f5;
}

.chat-user-item:hover,
.chat-user-item.active {
  background: #fff8f3;
}

.chat-user-item.active {
  border-left: 3px solid #e87d0e;
}

.user-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e87d0e, #f59e3d);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 600;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-weight: 600;
  margin-bottom: 3px;
  color: #333;
}

.user-last-message {
  font-size: 0.85rem;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-meta {
  text-align: right;
  flex-shrink: 0;
}

.message-time-meta {
  font-size: 0.75rem;
  color: #999;
  margin-bottom: 5px;
}

.unread-count {
  background: #e87d0e;
  color: #ffffff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: auto;
}

/* Chat Conversation Panel */
.chat-conversation-panel {
  display: flex;
  flex-direction: column;
}

.chat-conv-header {
  padding: 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-conv-user {
  display: flex;
  align-items: center;
  gap: 15px;
}

.conv-user-info h4 {
  margin: 0 0 3px;
  font-size: 1rem;
}

.conv-user-info p {
  margin: 0;
  font-size: 0.85rem;
  color: #999;
}

.chat-conv-actions {
  display: flex;
  gap: 10px;
}

.conv-action-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #f5f5f5;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  transition: all 0.3s ease;
}

.conv-action-btn:hover {
  background: #e87d0e;
  color: #ffffff;
}

.chat-conv-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  background: #f8f9fa;
}

.date-divider {
  text-align: center;
  color: #999;
  font-size: 0.8rem;
  margin: 10px 0;
  position: relative;
}

.date-divider span {
  background: #f8f9fa;
  padding: 0 15px;
  position: relative;
  z-index: 1;
}

.date-divider::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  height: 1px;
  background: #e5e7eb;
}

.admin-message {
  max-width: 70%;
}

.admin-message.from-user {
  align-self: flex-start;
}

.admin-message.from-admin {
  align-self: flex-end;
}

.admin-message .msg-content {
  padding: 12px 18px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.admin-message.from-user .msg-content {
  background: #ffffff;
  color: #333;
  border-bottom-left-radius: 5px;
}

.admin-message.from-admin .msg-content {
  background: linear-gradient(135deg, #e87d0e, #d06700);
  color: #ffffff;
  border-bottom-right-radius: 5px;
}

.admin-message .msg-time {
  font-size: 0.7rem;
  color: #999;
  margin-top: 5px;
  padding: 0 5px;
}

.admin-message.from-admin .msg-time {
  text-align: right;
}

.chat-conv-input {
  padding: 20px;
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 15px;
  align-items: center;
}

.chat-conv-input input {
  flex: 1;
  padding: 15px 20px;
  border: 1px solid #e5e7eb;
  border-radius: 25px;
  outline: none;
  font-size: 0.95rem;
}

.chat-conv-input input:focus {
  border-color: #e87d0e;
}

.chat-conv-input button {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e87d0e, #d06700);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.3s ease;
}

.chat-conv-input button:hover {
  transform: scale(1.1);
}

/* No Conversation Selected */
.no-conversation {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #999;
}

.no-conversation i {
  font-size: 5rem;
  color: #e5e7eb;
  margin-bottom: 20px;
}

.no-conversation h4 {
  margin: 0 0 10px;
  color: #666;
}

.no-conversation p {
  margin: 0;
}

/* Responsive Chat */
@media (max-width: 768px) {
  .chat-window {
    width: calc(100vw - 30px);
    height: calc(100vh - 100px);
    bottom: 80px;
    right: 15px;
    border-radius: 15px;
  }

  .chat-widget {
    bottom: 20px;
    right: 20px;
  }

  .admin-chat-panel {
    grid-template-columns: 1fr;
  }

  .chat-users-panel {
    display: none;
  }

  .chat-users-panel.active {
    display: flex;
    position: absolute;
    inset: 0;
    z-index: 10;
    background: #ffffff;
  }
}

@media (max-width: 480px) {
  .chat-widget {
    bottom: 15px;
    right: auto;
    left: 15px;
  }

  .chat-fab {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }

  .chat-window {
    width: calc(100vw - 20px);
    height: calc(100vh - 90px);
    bottom: 75px;
    right: auto;
    left: 10px;
    border-radius: 12px;
  }

  .chat-options {
    right: auto;
    left: 0;
    width: 180px;
    padding: 10px;
  }

  .chat-option {
    padding: 10px 12px;
    font-size: 0.9rem;
  }

  .guest-form {
    padding: 15px;
  }

  .guest-form h4 {
    font-size: 1.1rem;
  }

  .guest-form input {
    padding: 10px 12px;
    font-size: 0.9rem;
  }

  .guest-form button {
    padding: 10px 20px;
    font-size: 0.9rem;
  }
}

/* Animations */
@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message {
  animation: slideUp 0.3s ease;
}
