/* ============================================================
   SmartPLAY — Landing Page + Chat Widget
   ============================================================ */

/* --- CSS Variables --- */
:root {
  --color-primary: #004486;
  --color-primary-light: #0a76bd;
  --color-primary-bg: #ecf5ff;
  --color-bg: #FFFFFF;
  --color-white: #FFFFFF;
  --color-text: #000000;
  --color-text-secondary: #606266;
  --color-border: #FD3D17;
  --color-bot-bubble: #f2f8fe;
  --color-user-bubble: #FFFFFF;
  --color-user-bubble-border: #FD3D17;
  --color-input-bg: #FFFFFF;
  --color-disclaimer: #909399;
  --color-hero-start: #1a4381;
  --color-hero-mid: #004486;
  --color-hero-end: #0a76bd;
  --color-accent: #2b7366;
  --color-footer: #117D35;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 6px 24px rgba(0,0,0,0.12);
  --shadow-xl: 0 12px 40px rgba(0,0,0,0.16);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --dialog-width: 420px;
  --landing-max: 1120px;
}

/* --- Reset --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans HK", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-white);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ============================================================
   LANDING PAGE
   ============================================================ */

/* --- Navbar --- */
.landing-nav {
  position: sticky;
  top: 0;
  z-index: 900;
  background: var(--color-white);
  color: var(--color-text);
  border-bottom: 3px solid #FB331F;
}

.landing-nav-inner {
  max-width: var(--landing-max);
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-text);
  text-decoration: none;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.nav-logo {
  border-radius: 6px;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: 24px;
}

.nav-links a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s;
}

.nav-links a:hover {
  color: var(--color-text);
}

/* --- Hero --- */
.hero {
  background: var(--color-white);
  color: var(--color-text);
  padding: 80px 24px 72px;
  text-align: center;
}

.hero-inner {
  max-width: 720px;
  margin: 0 auto;
}

.hero-title {
  font-size: 40px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

.hero-subtitle {
  font-size: 18px;
  line-height: 1.6;
  color: var(--color-text-secondary);
  margin-bottom: 20px;
  font-weight: 400;
}

.hero-desc {
  font-size: 15px;
  line-height: 1.7;
  color: var(--color-text-secondary);
  max-width: 580px;
  margin: 0 auto;
}

/* --- Sections --- */
.section {
  padding: 64px 24px;
}

.section-alt {
  background: var(--color-bg);
}

.section-inner {
  max-width: var(--landing-max);
  margin: 0 auto;
}

.section-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
  text-align: center;
}

.section-subtitle {
  font-size: 15px;
  color: var(--color-text-secondary);
  text-align: center;
  margin-bottom: 40px;
  line-height: 1.6;
}

/* --- Cards --- */
.cards-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.card-icon {
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
}

.card h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 8px;
}

.card p {
  font-size: 14px;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

/* --- AI Promo Section --- */
.ai-promo {
  display: flex;
  gap: 48px;
  align-items: center;
}

.ai-promo-text {
  flex: 1;
}

.ai-promo-text .section-title,
.ai-promo-text .section-subtitle {
  text-align: left;
}

.ai-promo-text .section-subtitle {
  margin-bottom: 24px;
}

.btn-open-chat {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  background: var(--color-primary);
  color: var(--color-white);
  border: none;
  border-radius: 28px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
}

.btn-open-chat:hover {
  background: var(--color-primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.ai-promo-sample {
  flex: 1;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.sample-label {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
  font-weight: 500;
}

.sample-questions {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sample-questions li {
  position: relative;
  padding-left: 20px;
  font-size: 14px;
  color: var(--color-text);
  line-height: 1.5;
}

.sample-questions li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-accent);
}

/* --- Steps --- */
.steps-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

.step {
  text-align: center;
  padding: 0 12px;
}

.step-num {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-white);
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.step h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

.step p {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

/* --- News --- */
.news-list {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.news-item {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.news-date {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-primary-bg);
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.news-text {
  font-size: 14px;
  color: var(--color-text);
  line-height: 1.5;
}

/* --- Footer --- */
.landing-footer {
  background: var(--color-footer);
  color: rgba(255,255,255,0.8);
  padding: 40px 24px;
  text-align: center;
}

.footer-inner {
  max-width: var(--landing-max);
  margin: 0 auto;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 20px;
}

.footer-links a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--color-white);
}

.footer-disclaimer {
  font-size: 12px;
  line-height: 1.6;
  opacity: 0.7;
  margin-bottom: 12px;
}

.footer-copy {
  font-size: 12px;
  opacity: 0.5;
}

/* ============================================================
   CHAT WIDGET
   ============================================================ */

/* --- Floating Action Button --- */
.chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-white);
  border: none;
  cursor: pointer;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  animation: fabPulse 3s ease-in-out infinite;
}

.chat-fab:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-xl);
  background: var(--color-primary-light);
  animation: none;
}

.chat-fab:active {
  transform: scale(0.95);
}

.chat-fab.hidden {
  display: none;
}

@keyframes fabPulse {
  0%, 100% { box-shadow: var(--shadow-lg), 0 0 0 0 rgba(0, 68, 134, 0.4); }
  50% { box-shadow: var(--shadow-lg), 0 0 0 12px rgba(0, 68, 134, 0); }
}

/* --- Backdrop Overlay --- */
.chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1098;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.chat-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* --- Chat Dialog --- */
.chat-dialog {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--dialog-width);
  height: 100vh;
  height: 100dvh;
  z-index: 1099;
  background: var(--color-white);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  transform: translateX(110%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 1px solid var(--color-border);
}

.chat-dialog.open {
  transform: translateX(0);
}

/* --- Dialog Header --- */
.chat-dialog-header {
  flex-shrink: 0;
  height: 60px;
  background: var(--color-primary);
  color: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.chat-dialog-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
}

.chat-dialog-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-dialog-new,
.btn-dialog-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: var(--color-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-dialog-new:hover,
.btn-dialog-close:hover {
  background: rgba(255,255,255,0.3);
}

/* --- Dialog Body --- */
.chat-dialog-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  background: var(--color-bg);
  scroll-behavior: smooth;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100%;
}

/* --- Chat Welcome Screen (inside dialog) --- */
.chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 12px;
  animation: fadeIn 0.4s ease;
}

.chat-welcome.hidden {
  display: none;
}

.chat-welcome-avatar {
  margin-bottom: 16px;
}

.chat-welcome-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 8px;
}

.chat-welcome-desc {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 20px;
}

/* --- Quick Reply Chips --- */
.chat-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.quick-reply-btn {
  padding: 8px 14px;
  background: var(--color-white);
  color: var(--color-primary);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.quick-reply-btn:hover {
  background: var(--color-primary-bg);
  border-color: var(--color-primary-light);
  color: var(--color-primary-light);
}

/* --- Messages --- */
.message {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: fadeInUp 0.3s ease;
}

.message-bot {
  align-self: flex-start;
}

.message-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin-top: 2px;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.msg-bot-bubble {
  background: var(--color-bot-bubble);
  border-bottom-left-radius: 4px;
}

.msg-user-bubble {
  background: var(--color-user-bubble);
  border: 1px solid var(--color-user-bubble-border);
  border-bottom-right-radius: 4px;
  box-shadow: var(--shadow-sm);
}

/* --- Bot Message Markdown --- */
.msg-bot-bubble h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 10px 0 4px;
  color: var(--color-primary);
}

.msg-bot-bubble h2:first-child { margin-top: 0; }

.msg-bot-bubble h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 8px 0 4px;
}

.msg-bot-bubble p { margin: 4px 0; }

.msg-bot-bubble ul, .msg-bot-bubble ol {
  margin: 4px 0;
  padding-left: 18px;
}

.msg-bot-bubble li { margin: 2px 0; }

.msg-bot-bubble strong { font-weight: 600; }

.msg-bot-bubble a {
  color: var(--color-primary-light);
  text-decoration: underline;
  word-break: break-all;
}

.msg-bot-bubble code {
  background: rgba(0,0,0,0.06);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 12px;
  font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
}

.msg-bot-bubble pre {
  background: rgba(0,0,0,0.06);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 6px 0;
  font-size: 12px;
}

.msg-bot-bubble pre code {
  background: none;
  padding: 0;
}

/* --- Loading Dots --- */
.loading-dots {
  display: flex;
  gap: 3px;
  padding: 3px 0;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-secondary);
  animation: bounce 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0s; }

/* --- Dialog Input Area --- */
.chat-dialog-input {
  flex-shrink: 0;
  padding: 10px 14px 12px;
  background: var(--color-white);
  border-top: 1px solid var(--color-border);
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 6px 6px 6px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-row:focus-within {
  border-color: var(--color-primary-light);
  box-shadow: 0 0 0 3px rgba(253, 61, 23, 0.15);
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  max-height: 100px;
  padding: 4px 0;
  color: var(--color-text);
  background: transparent;
}

.chat-input::placeholder {
  color: var(--color-disclaimer);
}

.btn-send {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  color: var(--color-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
}

.btn-send:hover:not(:disabled) {
  background: var(--color-primary-light);
  transform: scale(1.08);
}

.btn-send:disabled {
  background: #c0c4cc;
  cursor: not-allowed;
}

.chat-input-hint {
  font-size: 10px;
  color: var(--color-disclaimer);
  text-align: center;
  margin-top: 6px;
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet & Mobile: full-screen chat dialog */
@media (max-width: 767px) {
  .chat-dialog {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    top: 0;
    right: 0;
    transform: translateY(110%);
    border-left: none;
    border-radius: 0;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .chat-dialog.open {
    transform: translateY(0);
  }

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

  .chat-fab {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
  }

  .chat-backdrop {
    display: none;
  }
}

/* Medium screens: landing page layout adjustments */
@media (max-width: 900px) {
  .hero-title {
    font-size: 28px;
  }

  .hero-subtitle {
    font-size: 16px;
  }

  .section-title {
    font-size: 22px;
  }

  .cards-row {
    grid-template-columns: 1fr;
    max-width: 400px;
    margin: 0 auto;
  }

  .ai-promo {
    flex-direction: column;
    gap: 24px;
  }

  .ai-promo-text .section-title,
  .ai-promo-text .section-subtitle {
    text-align: center;
  }

  .ai-promo-text {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .steps-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .nav-links {
    gap: 16px;
  }

  .nav-links a {
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .hero {
    padding: 48px 16px 40px;
  }

  .hero-title {
    font-size: 22px;
  }

  .hero-subtitle {
    font-size: 14px;
  }

  .hero-desc {
    font-size: 13px;
  }

  .section {
    padding: 40px 16px;
  }

  .section-title {
    font-size: 20px;
  }

  .steps-row {
    grid-template-columns: 1fr 1fr;
  }

  .step {
    padding: 0 4px;
  }

  .step-num {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .landing-nav-inner {
    padding: 0 12px;
    height: 52px;
  }

  .nav-brand {
    font-size: 14px;
    gap: 6px;
  }

  .nav-brand svg {
    width: 26px;
    height: 26px;
  }

  .nav-links {
    gap: 12px;
  }

  .nav-links a {
    font-size: 12px;
  }

  .footer-links {
    gap: 16px;
  }

  .footer-links a {
    font-size: 12px;
  }

  .news-item {
    flex-direction: column;
    gap: 8px;
  }
}

/* Very small screens */
@media (max-width: 380px) {
  .chat-dialog {
    width: 100vw;
  }

  .message {
    max-width: 92%;
  }

  .msg-bubble {
    padding: 8px 10px;
    font-size: 12px;
  }
}
