/* Chat Widget Styles */
.chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  height: 520px;
  background: #181818;
  border: 1px solid #333;
  border-radius: 14px;
  box-shadow: none;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  font-family: 'Segoe UI', 'Roboto', Arial, sans-serif;
  transition: none;
  overflow: hidden;
}

.chat-widget.minimized {
  height: 56px;
  width: 56px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: none;
  background: none;
  border: none;
}

.chat-widget.minimized .chat-content {
  display: none;
}

.chat-widget.minimized .chat-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 30px;
  color: #fff;
  opacity: 0.85;
}

.chat-header {
  background: #222;
  color: #fff;
  padding: 14px 18px 12px 18px;
  border-radius: 14px 14px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 17px;
  border-bottom: 1px solid #333;
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.online-count {
  background: #fff;
  color: #222;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: none;
  border: 1px solid #eee;
}

.chat-minimize {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 20px;
  padding: 4px;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: none;
}

.chat-minimize:hover {
  background: #333;
}

.chat-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 12px 10px 12px;
  background: #181818;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-messages::-webkit-scrollbar {
  width: 7px;
}

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

.message {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 80%;
}

.message.own {
  align-items: flex-end;
  margin-left: auto;
}

.message-header {
  font-size: 13px;
  color: #888;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
}

.message.own .message-header {
  flex-direction: row-reverse;
}

.username {
  font-weight: 700;
  color: #222;
}

.timestamp {
  font-size: 12px;
  color: #888;
}

.message-content {
  background: #fff;
  color: #181818;
  padding: 10px 16px;
  border-radius: 10px 10px 10px 4px;
  font-size: 15px;
  line-height: 1.6;
  word-break: break-word;
  font-weight: 400;
  margin-top: 2px;
  border: 1px solid #eee;
}

.message.own .message-content {
  background: #fff;
  color: #181818;
  border-radius: 10px 10px 4px 10px;
  border: 1px solid #eee;
}

.system-message {
  text-align: center;
  color: #888;
  font-size: 13px;
  font-style: italic;
  padding: 6px 0 0 0;
  opacity: 0.7;
  letter-spacing: 0.5px;
}

.chat-input-area {
  padding: 14px 12px 14px 12px;
  background: #222;
  border-top: 1px solid #333;
  border-radius: 0 0 14px 14px;
}

.chat-input-container {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.chat-input {
  box-sizing: border-box;
  flex: 1;
  background: #181818;
  color: #fff;
  border: 1px solid #444;
  border-radius: 7px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  min-height: 38px;
  overflow-y: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.chat-input:focus {
  outline: none;
  border: 1.5px solid #fff;
}

.chat-input::placeholder {
  color: #888;
  opacity: 0.8;
}

.chat-input::-webkit-scrollbar {
  display: none;
}

.chat-input {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.chat-send {
  background: #fff;
  color: #181818;
  border: 1px solid #eee;
  border-radius: 7px;
  padding: 12px 20px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  min-width: 70px;
  margin-left: 0;
  box-shadow: none;
  transition: none;
}

.chat-send:hover {
  background: #fafafa;
}

.chat-send:disabled {
  background: #333;
  color: #888;
  cursor: not-allowed;
}

.typing-indicator {
  padding: 8px 18px;
  font-size: 13px;
  color: #43e97b;
  font-style: italic;
  min-height: 28px;
  display: flex;
  align-items: center;
  opacity: 0.85;
}

.typing-dots {
  display: inline-flex;
  gap: 2px;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  background: #43e97b;
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Mobile Responsive */
@media only screen and (max-width: 700px) {
  .chat-widget {
    width: calc(100vw - 24px);
    max-width: 360px;
    height: 65vh;
    max-height: 480px;
    min-height: 300px;
    bottom: 12px;
    right: 12px;
    left: auto;
    border-radius: 14px;
  }

  .chat-widget.minimized {
    width: 52px;
    height: 52px;
    bottom: 16px;
    right: 16px;
    left: auto;
    border-radius: 50%;
  }

  .chat-toggle svg {
    width: 32px;
    height: 32px;
  }

  .chat-header {
    padding: 12px 14px;
    font-size: 16px;
  }

  .chat-header, .chat-input-area {
    border-radius: 14px 14px 0 0;
    padding-left: 12px;
    padding-right: 12px;
  }

  .chat-input-area {
    border-radius: 0 0 14px 14px;
    padding: 10px 12px;
  }

  .chat-messages {
    padding: 12px 8px 6px 8px;
  }

  .chat-input {
    padding: 9px 10px;
    font-size: 14px;
  }

  .chat-send {
    padding: 9px 14px;
    font-size: 14px;
    min-width: 52px;
  }

  .online-count {
    font-size: 12px;
    padding: 2px 8px;
  }

  .message {
    max-width: 85%;
  }

  .message-content {
    font-size: 14px;
    padding: 9px 12px;
  }

  .message-username {
    font-size: 11px;
  }

  .message-time {
    font-size: 10px;
  }
}

@media only screen and (max-width: 480px) {
  .chat-widget {
    width: calc(100vw - 16px);
    max-width: 100%;
    height: 60vh;
    max-height: 400px;
    bottom: 8px;
    right: 8px;
  }

  .chat-widget.minimized {
    width: 48px;
    height: 48px;
    bottom: 12px;
    right: 12px;
  }
}

/* Image message style */
.chat-image {
  max-width: 180px;
  max-height: 120px;
  border-radius: 7px;
  margin-top: 6px;
  border: 1px solid #eee;
  display: block;
}

#chatImageBtn {
  background: none;
  border: none;
  padding: 6px;
  margin: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ccc;
  transition: color 0.2s ease;
}
#chatImageBtn:hover {
  color: #fff;
}

.chat-widget:not(.minimized) .chat-toggle {
  display: none !important;
}

#imagePreviewContainer {
  margin-top: 0;
  margin-left: 8px;
  display: flex;
  align-items: center;
}
#imagePreviewContainer img {
  max-width: 60px;
  max-height: 60px;
  border-radius: 6px;
  border: 1px solid #eee;
}
#removeImagePreview {
  margin-left: 6px;
  cursor: pointer;
  background: none;
  border: none;
  color: #ccc;
  font-size: 16px;
}
#removeImagePreview:hover {
  color: #fff;
}

.textButton {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #888;
  font-size: 15px;
  text-decoration: none;
  transition: color 0.2s ease;
}
.textButton:hover {
  color: #fff;
}
.textButton svg {
  display: block;
  width: 18px;
  height: 18px;
}

.chat-toggle {
  padding: 0;
  background: none;
}
.chat-toggle svg {
  width: 28px;
  height: 28px;
}

