/* 
 * 蝦皮風格固定聊天按鈕與聊天窗口 CSS
 * 在網頁右下角顯示固定的聊聊按鈕，點擊後展開聊天窗口
 */

/* 固定聊天按鈕 */
.fixed-chat-button {
  position: fixed;
  bottom: 50px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: #7367f0;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 100;
  transition: all 0.3s ease;
}

.fixed-chat-button:hover {
  transform: scale(1.05);
  background-color: #655bd3;
}

.fixed-chat-button svg,
.store-chat-button svg {
  width: 24px;
  height: 24px;
}

.store-chat-button svg {
  fill: #fff;
}

/* 固定商店通知按鈕 */
.store-chat-button {
  position: fixed;
  bottom: 115px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: #ffc43f;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 100;
  transition: all 0.3s ease;
}

.store-chat-button:hover {
  transform: scale(1.05);
  background-color: #f7a422;
}

.chat-notify {
  position: absolute;
  top: -10px;
  right: -5px;
  width: 25px;
  height: 25px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 25%;
  background-color: #dc3545;
  color: #fff;
}

/* 浮動聊天窗口 */
.shopee-chat-window {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 800px;
  height: 540px;
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 1001;
  display: none;
  overflow: hidden;
  flex-direction: column;
  transition: all 0.3s ease;
}

.shopee-chat-window.active {
  display: flex;
}

/* 聊天窗口標題欄 */
.shopee-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background-color: #7367f0;
  color: white;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.shopee-chat-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.shopee-chat-close {
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2);
  transition: background-color 0.2s;
}

.shopee-chat-close:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

/* 聊天窗口主體 */
.shopee-chat-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* 左側聊天室列表 */
.shopee-chat-rooms {
  width: 280px;
  background-color: #f5f5f5;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
}

/* 聊天室搜尋區塊 */
.shopee-chat-search {
  padding: 12px;
  border-bottom: 1px solid #e0e0e0;
  background-color: #ffffff;
}

.shopee-chat-search input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 20px;
  border: 1px solid #ddd;
  outline: none;
}

/* 聊天室列表區域 */
.shopee-chat-room-list {
  flex: 1;
  overflow-y: auto;
}

/* 聊天室項目 */
.shopee-chat-room-item {
  padding: 12px;
  border-bottom: 1px solid #e0e0e0;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background-color 0.2s;
}

.shopee-chat-room-item:hover {
  background-color: #eaeaea;
}

.shopee-chat-room-item.active {
  background-color: #e3f2fd;
}

/* 聊天室頭像 */
.shopee-chat-avatar {
  width: 40px;
  height: 40px;
  background-color: #7367f0;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 16px;
  margin-right: 12px;
  flex-shrink: 0;
}

/* 聊天室內容 */
.shopee-chat-room-content {
  flex: 1;
  min-width: 0;
}

.shopee-chat-room-name {
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shopee-chat-room-last-message {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shopee-chat-timestamp {
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}

/* 未讀消息計數器 */
.shopee-chat-unread-count {
  min-width: 18px;
  height: 18px;
  background-color: #ff5252;
  color: white;
  border-radius: 9px;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  margin-left: 8px;
}

/* 右側聊天內容區 */
.shopee-chat-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: #fff;
}

/* 聊天內容標題欄 */
.shopee-chat-content-header {
  padding: 12px 16px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
}

.shopee-chat-content-title {
  font-weight: 600;
  margin: 0;
}

/* 聊天消息區域 */
.shopee-chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background-color: #f5f5f5;
  display: flex;
  flex-direction: column;
}

/* 聊天消息氣泡 */
.shopee-message {
  max-width: 75%;
  padding: 10px 14px;
  margin-bottom: 8px;
  border-radius: 18px;
  word-wrap: break-word;
  position: relative;
}

.shopee-message-self {
  background-color: #dcf8c6;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.shopee-message-other {
  background-color: #e3f2fd;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* 消息時間 */
.shopee-message-time {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
  text-align: right;
}

/* 已讀標記 */
.shopee-message-read {
  font-size: 11px;
  color: #4caf50;
  margin-left: 4px;
}

/* 輸入區域 */
.shopee-chat-input-container {
  padding: 12px 16px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
}

.shopee-chat-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid #ddd;
  border-radius: 24px;
  outline: none;
  margin-right: 12px;
}

.shopee-chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #7367f0;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  outline: none;
}

.shopee-chat-send-btn:hover {
  background-color: #655bd3;
}

/* 空聊天室提示 */
.shopee-no-chat-selected {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #777;
  padding: 32px;
  text-align: center;
}

.shopee-no-chat-selected svg {
  margin-bottom: 16px;
  opacity: 0.5;
}

/* 聊天消息區域 */
.shopee-chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background-color: #f5f5f5;
  display: flex;
  flex-direction: column;
}

/* 聊天消息氣泡 */
.shopee-message {
  max-width: 75%;
  padding: 10px 14px;
  margin-bottom: 8px;
  border-radius: 18px;
  word-wrap: break-word;
  position: relative;
}

.shopee-message-self {
  background-color: #dcf8c6;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.shopee-message-other {
  background-color: #e3f2fd;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* 消息發送者 */
.shopee-message-sender {
  font-weight: bold;
  margin-bottom: 4px;
  font-size: 0.9em;
}

/* 消息內容 */
.shopee-message-content {
  margin-bottom: 4px;
}

/* 消息時間 */
.shopee-message-time {
  font-size: 11px;
  color: #888;
  text-align: right;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

/* 已讀標記 */
.shopee-message-read {
  font-size: 11px;
  color: #4caf50;
  margin-left: 4px;
}

/* 輸入區域 */
.shopee-chat-input-container {
  padding: 12px 16px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  align-items: center;
}

.shopee-chat-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid #ddd;
  border-radius: 24px;
  outline: none;
  margin-right: 12px;
}

.shopee-chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #7367f0;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  outline: none;
}

.shopee-chat-send-btn:hover {
  background-color: #655bd3;
}

/* 空聊天室提示 */
.shopee-no-chat-selected {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #777;
  padding: 32px;
  text-align: center;
}

.shopee-no-chat-selected svg {
  margin-bottom: 16px;
  opacity: 0.5;
}

.shopee-no-chat-selected h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.shopee-no-chat-selected p {
  max-width: 260px;
  font-size: 14px;
  color: #888;
}

/* 工具類 */
.shopee-text-center {
  text-align: center;
}

.shopee-p-4 {
  padding: 1rem;
}

.shopee-mt-2 {
  margin-top: 0.5rem;
}

/* 系統消息 */
.shopee-message-system {
  background: #f1f1f1;
  color: #666;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  text-align: center;
  margin: 8px auto;
  max-width: 80%;
}

/* 適應不同螢幕尺寸 */
@media (max-width: 991.98px) {
  .shopee-chat-window {
    width: 90vw;
    height: 80vh;
  }
}

@media (max-width: 767.98px) {
  .shopee-chat-window {
    width: 95vw;
    height: 90vh;
    bottom: 16px;
    right: 16px;
  }

  .shopee-chat-rooms {
    width: 220px;
  }
}

@media (max-width: 575.98px) {
  .shopee-chat-window {
    width: 100vw;
    height: 90vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }

  .shopee-chat-header {
    border-radius: 0;
  }

  .shopee-chat-rooms {
    width: 65px;
  }

  .fixed-chat-button {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }
}

.shopee-message-pending {
  opacity: 0.7;
}
.shopee-message-status {
  font-size: 11px;
  color: #888;
  margin-left: 4px;
  font-style: italic;
}
.sending-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
