/* ═══════════════════════════════════════════════════
   永凌數位科技 — AI 助理聊天視窗樣式
   chat-widget.css
═══════════════════════════════════════════════════ */

/* ── 浮動按鈕 ─────────────────────────────── */
#yl-chat-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;          /* 右下角，LINE 在上方 100px，不重疊 */
  left: auto;
  z-index: 9999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F5B400, #E09000);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(245, 180, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s, box-shadow 0.25s;
  outline: none;
}
#yl-chat-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(245, 180, 0, 0.65);
}
#yl-chat-btn svg {
  width: 28px;
  height: 28px;
  fill: #0F172A;
  transition: opacity 0.2s;
}
#yl-chat-btn .yl-btn-close { display: none; }

/* 按鈕已開啟狀態 */
#yl-chat-btn.open .yl-btn-chat  { display: none; }
#yl-chat-btn.open .yl-btn-close { display: block; }

/* 通知泡泡 */
#yl-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: #EF4444;
  border-radius: 50%;
  border: 2px solid #fff;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: yl-badge-pulse 2s infinite;
}
@keyframes yl-badge-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* 提示泡泡 */
#yl-chat-hint {
  position: fixed;
  bottom: 100px;
  right: 28px;           /* 右側對齊 */
  left: auto;
  z-index: 9998;
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 14px 14px 4px 14px;
  padding: 12px 16px;
  font-size: 14px;
  color: #1E293B;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  max-width: 220px;
  line-height: 1.5;
  animation: yl-hint-in 0.4s ease;
  cursor: pointer;
}
#yl-chat-hint::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 18px;           /* 小三角對齊右側 */
  border: 8px solid transparent;
  border-top-color: #fff;
  border-bottom: none;
}
@keyframes yl-hint-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 聊天視窗 ─────────────────────────────── */
#yl-chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;            /* 右側對齊按鈕 */
  left: auto;
  z-index: 9998;
  width: 380px;
  height: 560px;
  background: #0F172A;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s;
  transform-origin: bottom right;  /* 右偵 */
}
#yl-chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* 標頭 */
#yl-chat-header {
  background: linear-gradient(135deg, #1E293B, #0D1B2A);
  border-bottom: 1px solid rgba(245,180,0,0.2);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.yl-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F5B400, #E09000);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.yl-header-info { flex: 1; }
.yl-header-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  margin-bottom: 3px;
}
.yl-header-status {
  font-size: 12px;
  color: #22C55E;
  display: flex;
  align-items: center;
  gap: 5px;
}
.yl-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22C55E;
  animation: yl-pulse 2s infinite;
}
@keyframes yl-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* 訊息區 */
#yl-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
#yl-chat-messages::-webkit-scrollbar { width: 4px; }
#yl-chat-messages::-webkit-scrollbar-track { background: transparent; }
#yl-chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* 訊息泡泡 */
.yl-msg {
  display: flex;
  gap: 8px;
  animation: yl-msg-in 0.3s ease;
}
@keyframes yl-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.yl-msg.user { flex-direction: row-reverse; }

.yl-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F5B400, #E09000);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  align-self: flex-end;
}
.yl-msg.user .yl-msg-avatar {
  background: linear-gradient(135deg, #0EA5E9, #0369A1);
}

.yl-msg-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.65;
  color: #fff;
}
.yl-msg.bot .yl-msg-bubble {
  background: #1E293B;
  border-radius: 4px 16px 16px 16px;
  border: 1px solid rgba(255,255,255,0.07);
}
.yl-msg.user .yl-msg-bubble {
  background: linear-gradient(135deg, #F5B400, #E09000);
  color: #0F172A;
  font-weight: 500;
  border-radius: 16px 4px 16px 16px;
}

/* 打字中動畫 */
.yl-typing {
  display: flex;
  gap: 5px;
  padding: 12px 16px;
  align-items: center;
}
.yl-typing span {
  width: 7px;
  height: 7px;
  background: rgba(245,180,0,0.7);
  border-radius: 50%;
  animation: yl-bounce 1.2s infinite;
}
.yl-typing span:nth-child(2) { animation-delay: 0.2s; }
.yl-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes yl-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* 快速選項 */
#yl-quick-options {
  padding: 0 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex-shrink: 0;
}
.yl-quick-btn {
  background: rgba(245,180,0,0.1);
  border: 1px solid rgba(245,180,0,0.3);
  color: #F5B400;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, border-color 0.2s;
  width: 100%;
}
.yl-quick-btn:hover {
  background: rgba(245,180,0,0.2);
  border-color: rgba(245,180,0,0.6);
}

/* 輸入區 */
#yl-chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
  background: #0F172A;
}
#yl-chat-input {
  flex: 1;
  background: #1E293B;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  color: #fff;
  font-size: 14px;
  padding: 10px 14px;
  resize: none;
  max-height: 100px;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color 0.2s;
}
#yl-chat-input::placeholder { color: rgba(255,255,255,0.3); }
#yl-chat-input:focus { border-color: rgba(245,180,0,0.5); }

#yl-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #F5B400, #E09000);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, opacity 0.2s;
}
#yl-chat-send:hover { transform: scale(1.08); }
#yl-chat-send:disabled { opacity: 0.4; cursor: default; }
#yl-chat-send svg { width: 18px; height: 18px; fill: #0F172A; }

/* ── LINE QR Code 區 ────────────────────────── */
#yl-line-bar {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: rgba(11, 128, 67, 0.15);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  text-decoration: none;
  transition: background 0.2s;
}
#yl-line-bar:hover {
  background: rgba(11, 128, 67, 0.25);
}
#yl-line-bar img {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  background: #fff;
  padding: 4px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.yl-line-bar-text {
  flex: 1;
}
.yl-line-bar-title {
  font-size: 14px;
  font-weight: 700;
  color: #4ADE80;
  line-height: 1.3;
  margin-bottom: 4px;
}
.yl-line-bar-sub {
  font-size: 11.5px;
  color: rgba(255,255,255,0.6);
  line-height: 1.4;
}
.yl-line-bar-arrow {
  font-size: 20px;
  color: #4ADE80;
  flex-shrink: 0;
}
/* ── 留下聯絡資訊表單與接手標籤 ───────────────── */
#yl-header-lead-btn {
  background: linear-gradient(135deg, #F5B400, #E09000);
  color: #0F172A;
  border: none;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 12px;
  cursor: pointer;
  margin-left: auto;
  transition: transform 0.2s;
}
#yl-header-lead-btn:hover {
  transform: scale(1.05);
}

/* 專人接管提示條 */
#yl-chat-takeover-banner {
  background: rgba(34, 197, 94, 0.15);
  border-bottom: 1px solid rgba(34, 197, 94, 0.3);
  color: #4ADE80;
  font-size: 12px;
  text-align: center;
  padding: 6px 12px;
  font-weight: 500;
  flex-shrink: 0;
}

/* 聯絡資訊覆蓋層 */
#yl-contact-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #0F172A;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 20px;
  z-index: 10000;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#yl-contact-overlay.open {
  transform: translateY(0);
}
.yl-contact-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding-bottom: 8px;
}
.yl-contact-header h3 {
  font-size: 15px;
  color: #fff;
  font-weight: 700;
}
#yl-contact-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}
#yl-contact-close:hover {
  color: #fff;
}
.yl-form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.yl-form-group label {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  font-weight: 500;
}
.yl-form-group input {
  background: #1E293B;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 13.5px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.2s;
}
.yl-form-group input:focus {
  border-color: #F5B400;
}
#yl-contact-submit-btn {
  background: linear-gradient(135deg, #F5B400, #E09000);
  color: #0F172A;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s;
  width: 100%;
  margin-top: 5px;
}
#yl-contact-submit-btn:hover {
  transform: scale(1.02);
}

/* ── 輸入區 ─────────────────────────────────── */
@media (max-width: 480px) {
  #yl-chat-window {
    width: 100vw;
    height: 100dvh;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 0;
    transform: translateY(100%);
  }
  #yl-chat-window.open { transform: translateY(0); }
  #yl-chat-btn { bottom: 20px; right: 20px; left: auto; }
  #yl-chat-hint { right: 20px; left: auto; bottom: 92px; }
}
