/* 即時對話浮動視窗樣式 */
/* 按鈕樣式已移至 sk_style.css 的 FAB 選單 */

/* 聊天視窗 */
#chat-widget {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#chat-widget.open {
  display: flex;
}

/* 標題列 */
#chat-widget .chat-header {
  background: #06c755;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#chat-widget .chat-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
#chat-widget .chat-header .chat-close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.8;
}
#chat-widget .chat-header .chat-close-btn:hover {
  opacity: 1;
}

/* 開始表單 */
#chat-start-form {
  padding: 24px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
#chat-start-form h5 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  text-align: center;
  color: #333;
}
#chat-start-form input {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.2s;
}
#chat-start-form input:focus {
  border-color: #06c755;
}
#chat-start-form button {
  background: #06c755;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.2s;
}
#chat-start-form button:hover {
  background: #05a847;
}

/* 訊息區域 */
#chat-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f5f5f5;
}

/* 訊息氣泡 */
.chat-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}
.chat-msg.visitor {
  align-self: flex-end;
  background: #06c755;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.admin {
  align-self: flex-start;
  background: #fff;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.chat-msg .msg-sender {
  font-size: 11px;
  opacity: 0.7;
  margin-bottom: 2px;
}
.chat-msg .msg-time {
  font-size: 10px;
  opacity: 0.6;
  margin-top: 4px;
  text-align: right;
}

/* 輸入區域 */
#chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #fff;
  flex-shrink: 0;
}
#chat-input-area textarea {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 14px;
  resize: none;
  max-height: 80px;
  outline: none;
  font-family: inherit;
  line-height: 1.4;
}
#chat-input-area textarea:focus {
  border-color: #06c755;
}
#chat-input-area button {
  background: #06c755;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
#chat-input-area button:hover {
  background: #05a847;
}
#chat-input-area button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* 對話已結束提示 */
#chat-closed-notice {
  padding: 16px;
  text-align: center;
  color: #999;
  font-size: 14px;
  border-top: 1px solid #eee;
  background: #fafafa;
}

/* 手機版調整 */
@media (max-width: 480px) {
  #chat-widget {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
}
