/* ==========================================================
   support-chat.css  v7  |  OUCRA 前台聊天  重設計版
   ========================================================== */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;600;700&display=swap');

/* ── reply.html 全頁佈局 ── */
body.reply-page {
  height: 100vh;
  overflow: hidden;
  background: #070707;
}

.reply-fullpage {
  position: fixed;
  top: var(--header-height, 72px);
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  background: #070707;
  z-index: 1;
}

/* ── 頂部列 ── */
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  background: #0d0d0d;
  border-bottom: 1px solid #1a1a1a;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
}

.chat-title {
  font-size: 16px;
  font-weight: 700;
  color: #f5f5f5;
  line-height: 1.3;
  margin: 0;
  letter-spacing: .01em;
}

.chat-sub {
  font-size: 12.5px;
  color: #666;
  margin-top: 5px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.chat-new-btn {
  padding: 9px 20px;
  border-radius: 99px;
  border: 1.5px solid #2a2a2a;
  background: transparent;
  color: #777;
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color .15s, color .15s, background .15s;
}
.chat-new-btn:hover {
  border-color: #d4af37;
  color: #d4af37;
  background: rgba(212,175,55,.06);
}

/* ── 訊息區 ── */
.chat-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #0a0a0a;
  scroll-behavior: smooth;
}
.chat-body::-webkit-scrollbar { width: 5px; }
.chat-body::-webkit-scrollbar-track { background: transparent; }
.chat-body::-webkit-scrollbar-thumb { background: #252525; border-radius: 99px; }
.chat-loading {
  font-size: 13px;
  color: #444;
  text-align: center;
  padding: 40px 0;
  font-family: 'Noto Sans TC', sans-serif;
}

/* 日期分隔線 */
.chat-date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 4px;
  font-size: 11px;
  color: #3a3a3a;
  font-family: 'Noto Sans TC', sans-serif;
}
.chat-date-divider::before,
.chat-date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #1a1a1a;
}

/* ── 訊息列 ── */
.chat-body .msg {
  all: initial !important;
  display: block !important;
  font-family: 'Noto Sans TC', sans-serif !important;
  width: fit-content !important;
  max-width: min(68%, 480px) !important;
  animation: msgPop .18s ease both !important;
}
.chat-body .msg:not(.me) { align-self: flex-start !important; }
.chat-body .msg.me       { align-self: flex-end !important; }

/* 泡泡 */
.chat-body .msg .bubble {
  all: initial !important;
  display: block !important;
  font-family: 'Noto Sans TC', sans-serif !important;
  padding: 10px 15px !important;
  border-radius: 18px !important;
  font-size: 14.5px !important;
  font-weight: 400 !important;
  line-height: 1.55 !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  white-space: normal !important;
  letter-spacing: .01em !important;
}

/* 對方訊息（客服） */
.chat-body .msg:not(.me) .bubble {
  background: #161616 !important;
  border: 1px solid #222 !important;
  color: #e8e8e8 !important;
  border-bottom-left-radius: 4px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.35) !important;
}

/* 自己訊息（客人） */
.chat-body .msg.me .bubble {
  background: linear-gradient(145deg, #b8941f, #d4af37) !important;
  color: #1a0e00 !important;
  border-bottom-right-radius: 4px !important;
  box-shadow: 0 2px 10px rgba(212,175,55,.25) !important;
}

/* 時間戳 */
.chat-body .msg .bubble .meta {
  all: initial !important;
  display: block !important;
  font-family: 'Noto Sans TC', sans-serif !important;
  font-size: 10px !important;
  line-height: 1.2 !important;
  margin-top: 5px !important;
  white-space: nowrap !important;
  opacity: .65 !important;
}
.chat-body .msg:not(.me) .bubble .meta {
  color: #555 !important;
  text-align: left !important;
}
.chat-body .msg.me .bubble .meta {
  color: rgba(0,0,0,.45) !important;
  text-align: right !important;
}

@keyframes msgPop {
  from { opacity: 0; transform: translateY(6px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── 輸入列 ── */
.chat-foot {
  padding: 14px 28px 18px;
  background: #0d0d0d;
  border-top: 1px solid #1a1a1a;
  flex-shrink: 0;
}
.chat-form {
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: 900px;
  margin: 0 auto;
}
.chat-input {
  flex: 1;
  min-width: 0;
  background: #111;
  border: 1.5px solid #222;
  border-radius: 999px;
  color: #f0f0f0;
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 14.5px;
  line-height: 1.4;
  padding: 12px 20px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.chat-input:focus {
  border-color: #d4af37;
  box-shadow: 0 0 0 3px rgba(212,175,55,.1);
}
.chat-input::placeholder { color: #3a3a3a; }
.chat-input:disabled { opacity: .3; cursor: not-allowed; }

.chat-send {
  flex-shrink: 0;
  padding: 12px 26px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #b8941f, #d4af37);
  color: #180f00;
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s, transform .1s;
  box-shadow: 0 2px 14px rgba(212,175,55,.25);
}
.chat-send:hover { opacity: .88; transform: translateY(-1px); }
.chat-send:active { transform: translateY(0); }
.chat-send:disabled { opacity: .3; cursor: not-allowed; transform: none; }

/* ── support.html 啟動表單 ── */
.support-wrap {
  max-width: 560px;
  margin: 0 auto 60px;
}
.support-card {
  background: #0f0f0f;
  border: 1px solid #1e1e1e;
  border-radius: 20px;
  padding: 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.support-grid { display: flex; flex-direction: column; gap: 20px; }
.support-grid .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 500px) {
  .support-grid .row { grid-template-columns: 1fr; }
  .support-card { padding: 24px 18px; }
}
.support-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #555;
  margin-bottom: 8px;
  line-height: 1;
}
.support-input,
.support-textarea {
  display: block;
  width: 100%;
  background: #0a0a0a;
  border: 1.5px solid #1e1e1e;
  border-radius: 12px;
  color: #f0f0f0;
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  padding: 12px 16px;
  outline: none;
  resize: none;
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
}
.support-input:focus,
.support-textarea:focus {
  border-color: #d4af37;
  box-shadow: 0 0 0 3px rgba(212,175,55,.1);
}
.support-input::placeholder,
.support-textarea::placeholder { color: #333; }
.support-textarea { min-height: 100px; }
.support-hint {
  font-size: 11.5px;
  color: #444;
  margin-top: 8px;
  line-height: 1.6;
}
.support-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.support-btn {
  flex: 1;
  min-width: 110px;
  padding: 13px 22px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #b8941f, #d4af37);
  color: #1a0f00;
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  box-shadow: 0 4px 20px rgba(212,175,55,.25);
}
.support-btn:hover { opacity: .88; transform: translateY(-1px); }
.support-btn:disabled { opacity: .35; cursor: not-allowed; transform: none; }
.support-secondary {
  padding: 12px 18px;
  border-radius: 12px;
  border: 1.5px solid #232323;
  background: transparent;
  color: #666;
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.support-secondary:hover { border-color: #d4af37; color: #d4af37; }

/* Toast */
.support-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #161616;
  border: 1px solid #2a2a2a;
  color: #eee;
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 13px;
  line-height: 1.4;
  padding: 11px 22px;
  border-radius: 99px;
  z-index: 99999;
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
  animation: toastIn .2s ease;
  white-space: nowrap;
  max-width: 90vw;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── 手機 RWD ── */
@media (max-width: 768px) {
  /* 手機全屏：隱藏 header 增加聊天空間 */
  body.reply-page #mainHeader { display: none !important; }
  body.reply-page .reply-fullpage { top: 0 !important; }

  .chat-head {
    padding: 12px 16px;
    gap: 10px;
  }
  .chat-title { font-size: 14.5px; }
  .chat-sub { font-size: 11.5px; gap: 7px; }

  .chat-new-btn {
    padding: 7px 14px;
    font-size: 12px;
  }

  .chat-body {
    padding: 14px 12px;
    gap: 8px;
  }
  .chat-body .msg {
    max-width: min(84%, 300px) !important;
  }
  .chat-body .msg .bubble {
    font-size: 14px !important;
    padding: 9px 13px !important;
  }

  .chat-foot {
    padding: 10px 12px 14px;
    /* safe area for iPhone home bar */
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .chat-input {
    padding: 10px 16px;
    font-size: 15px; /* 避免 iOS 自動縮放 */
    border-radius: 22px;
  }
  .chat-send {
    padding: 10px 18px;
    font-size: 14px;
    border-radius: 22px;
  }
}

@media (max-width: 400px) {
  .chat-body .msg { max-width: 88% !important; }
  .chat-body { padding: 12px 10px; }
  .chat-head { padding: 10px 12px; }
}
