:root {
  --primary: #06C755;
  --bg-gradient: linear-gradient(135deg, #1e293b, #0f172a);
  --glass-color: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.12);
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --card-bg: rgba(15, 23, 42, 0.6);
  --phone-bg: #8cabd9; /* LINE 傳統藍色聊天背景 */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', 'Noto Sans TC', sans-serif;
  background-color: #0f172a;
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

/* 炫彩動態背景光球 */
.glass-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background: var(--bg-gradient);
  overflow: hidden;
}
.glass-bg::after {
  content: '';
  position: absolute;
  top: -10%;
  right: -10%;
  width: 50%;
  height: 50%;
  background: radial-gradient(circle, rgba(6, 199, 85, 0.15) 0%, transparent 70%);
  border-radius: 50%;
}
.glass-bg::before {
  content: '';
  position: absolute;
  bottom: -10%;
  left: -10%;
  width: 60%;
  height: 60%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.15) 0%, transparent 70%);
  border-radius: 50%;
}

.container {
  display: flex;
  gap: 30px;
  width: 100%;
  max-width: 1100px;
  padding: 20px;
  align-items: stretch;
  z-index: 2;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 24px;
  padding: 30px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* 左側控制面板 */
.panel {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.logo {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 10px;
}

h1 {
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1.2;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 25px;
}

.info-box {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 25px;
  border-left: 4px solid var(--primary);
}

.info-box h3 {
  font-size: 1rem;
  margin-bottom: 8px;
  color: var(--primary);
}

.info-box p {
  font-size: 0.9rem;
  color: #cbd5e1;
  line-height: 1.5;
  margin-bottom: 6px;
}

.update-section h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.update-section .description {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 15px;
  line-height: 1.4;
}

/* 狀態訊息樣式 */
.status-msg {
  font-size: 0.85rem;
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  transition: all 0.3s ease;
}
.status-msg.loading {
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.2);
  color: #fde047;
  animation: pulse 1.5s infinite;
}
.status-msg.success {
  background: rgba(6, 199, 85, 0.1);
  border: 1px solid rgba(6, 199, 85, 0.2);
  color: #86efac;
}
.status-msg.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* 按鈕樣式 */
.btn {
  width: 100%;
  padding: 14px 20px;
  border-radius: 14px;
  border: none;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}
.primary-btn {
  background: var(--primary);
  color: #ffffff;
}
.primary-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(6, 199, 85, 0.4);
}
.primary-btn:disabled {
  background: #475569;
  cursor: not-allowed;
  opacity: 0.7;
}

/* 右側手機模擬器 */
.phone-mockup {
  flex: 1;
  max-width: 400px;
  height: 650px;
  background: var(--phone-bg);
  border: 10px solid #1e293b;
  border-radius: 40px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  position: relative;
}

.phone-header {
  height: 55px;
  background: #1e293b;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 6px;
  z-index: 10;
}
.notch {
  width: 120px;
  height: 20px;
  background: #000;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  position: absolute;
  top: 0;
}
.phone-title {
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
}

/* 聊天內容區 */
.chat-area {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.chat-row {
  display: flex;
  gap: 8px;
  max-width: 85%;
}
.chat-row.bot {
  align-self: flex-start;
}
.chat-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #475569;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-row.user .avatar {
  background: var(--primary);
}

.message-bubble {
  background: #ffffff;
  color: #333333;
  padding: 10px 14px;
  border-radius: 16px;
  border-top-left-radius: 2px;
  font-size: 0.9rem;
  line-height: 1.4;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
.chat-row.user .message-bubble {
  background: #8de3a1; /* LINE 使用者綠色對話框 */
  color: #111111;
  border-radius: 16px;
  border-top-right-radius: 2px;
  border-top-left-radius: 16px;
}
.message-bubble.error-bubble {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* 歡迎訊息內部排版 */
.system-welcome p {
  margin-bottom: 8px;
}
.chip {
  display: inline-block;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  margin: 4px 4px 4px 0;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.2s ease;
}
.chip:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Flex Message 網頁端模擬樣式 */
.flex-bubble {
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 8px rgba(0,0,0,0.12);
  width: 270px;
  display: flex;
  flex-direction: column;
}
.flex-header {
  padding: 12px;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
}
.flex-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
}
.flex-label {
  font-size: 0.7rem;
  color: #888888;
  font-weight: 700;
  margin-bottom: 2px;
}
.flex-card-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: #111111;
  margin-bottom: 6px;
}
.flex-box-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 4px 0;
}
.flex-box-row span {
  font-size: 0.85rem;
  color: #333333;
}
.flex-big-rate {
  font-size: 1.6rem !important;
  color: var(--primary) !important;
  font-weight: 900;
}
.flex-right-text {
  font-weight: 700;
  color: #ff3b30 !important;
}
.flex-separator {
  border: 0;
  height: 1px;
  background: #e2e8f0;
  margin: 10px 0;
}
.flex-text {
  font-size: 0.8rem;
  color: #475569;
  line-height: 1.4;
  margin-top: 4px;
}
.flex-footer {
  padding: 12px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.flex-btn {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}
.flex-btn.primary {
  background-color: #06C755;
  color: #ffffff;
}
.flex-btn.primary:hover {
  background-color: #05b04b;
}
.flex-btn.secondary {
  background-color: #f1f5f9;
  color: #334155;
}
.flex-btn.secondary:hover {
  background-color: #e2e8f0;
}
.flex-btn.link {
  background-color: transparent;
  color: #06C755;
  text-decoration: underline;
  padding: 4px;
}
.flex-btn.link:hover {
  color: #05b04b;
}


/* 輸入框區 */
.input-area {
  height: 60px;
  background: #1e293b;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 8px;
}
.input-area input {
  flex: 1;
  height: 100%;
  border-radius: 20px;
  border: none;
  padding: 0 15px;
  font-size: 0.9rem;
  background: #334155;
  color: #fff;
  outline: none;
}
.input-area input::placeholder {
  color: #94a3b8;
}
.send-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}
.send-btn:hover {
  background: #05b04b;
}

/* Typing indicator dot animation */
.typing {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 25px;
}
.typing .dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  opacity: 0.4;
  animation: typing 1s infinite alternate;
}
.typing .dot:nth-child(2) {
  animation-delay: 0.2s;
}
.typing .dot:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes typing {
  0% { transform: translateY(0); opacity: 0.4; }
  100% { transform: translateY(-4px); opacity: 1; }
}

/* ==========================================
   Phase 2: 圖文選單 (Rich Menu) & LIFF WebView
   ========================================== */

/* 圖文選單切換條 */
.rich-menu-toggle {
  background: #1e293b;
  border-top: 1px solid #334155;
  color: var(--text-secondary);
  text-align: center;
  font-size: 11px;
  font-weight: bold;
  padding: 4px 0;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}
.rich-menu-toggle:hover {
  color: var(--text-primary);
  background: #334155;
}

/* 圖文選單網格 */
.rich-menu {
  background: #0f172a;
  border-top: 1px solid #1e293b;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.rich-menu.show {
  max-height: 180px; /* 圖文選單高度 */
}

.rich-menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  height: 170px;
  padding: 8px;
  gap: 8px;
}

.rich-menu-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.rich-menu-item:hover {
  background: rgba(6, 199, 85, 0.1);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.rich-icon {
  font-size: 20px;
}

.rich-label {
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
}

.rich-menu-item:hover .rich-label {
  color: var(--primary);
}

/* LIFF Webview 抽屜 */
.liff-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 88%;
  background: #020617;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.15);
  overflow: hidden;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.liff-sheet.show {
  transform: translateY(0);
}

.liff-sheet-header {
  height: 48px;
  background: #0f172a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  color: #f8fafc;
}

.liff-sheet-title {
  font-size: 13px;
  font-weight: bold;
  color: #94a3b8;
  letter-spacing: 0.5px;
}

.liff-sheet-close, .liff-sheet-refresh {
  cursor: pointer;
  font-size: 16px;
  color: #64748b;
  transition: color 0.2s ease;
  user-select: none;
  padding: 4px 8px;
}

.liff-sheet-close:hover {
  color: #ef4444;
}

.liff-sheet-refresh:hover {
  color: var(--primary);
}

.liff-sheet-body {
  flex: 1;
  width: 100%;
  height: calc(100% - 48px);
  background: #020617;
}

.liff-sheet-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
}

