/* ==========================================================================
   Túi AI — Website Stylesheet (Static, Lightweight, System Font)
   Palette inspired by lib/ui/theme.dart (Warm Cream + Soft Blue)
   WCAG AA/AAA Accessible, Fully Responsive (320px+), Light & Dark
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Light Theme (Warm cream + soft blue) */
  --bg: #FAF8F5;
  --surface: #FFFFFF;
  --surface-subtle: #F4EFEA;
  --surface-bubble: #EFEBE4;
  --text: #1E2124;
  --text-muted: #545B64;
  --border: #E4DED4;
  --border-subtle: #ECE7DE;

  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-surface: #EFF6FF;
  --accent-border: #BFDBFE;

  --green: #15803D;
  --green-surface: #F0FDF4;
  --green-border: #BBF7D0;

  --amber: #B45309;
  --amber-surface: #FFFBEB;
  --amber-border: #FDE68A;

  --red: #B91C1C;
  --red-surface: #FEF2F2;
  --red-border: #FECACA;

  --shadow-sm: 0 1px 3px rgba(30, 33, 36, 0.05);
  --shadow-md: 0 4px 16px -2px rgba(30, 33, 36, 0.08), 0 2px 6px -1px rgba(30, 33, 36, 0.04);
  --shadow-lg: 0 16px 36px -6px rgba(30, 33, 36, 0.12);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 9999px;

  --container-max: 1100px;
  --content-max: 760px;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark Theme (Warm dark grey + clear blue) */
    --bg: #141619;
    --surface: #1C1F24;
    --surface-subtle: #23272E;
    --surface-bubble: #2B2F38;
    --text: #F3F4F6;
    --text-muted: #9CA3AF;
    --border: #2E333C;
    --border-subtle: #252932;

    --accent: #3B82F6;
    --accent-hover: #60A5FA;
    --accent-surface: #1E293B;
    --accent-border: #1E3A8A;

    --green: #34D399;
    --green-surface: #064E3B;
    --green-border: #065F46;

    --amber: #FBBF24;
    --amber-surface: #451A03;
    --amber-border: #78350F;

    --red: #F87171;
    --red-surface: #450A0A;
    --red-border: #7F1D1D;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px -2px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 36px -6px rgba(0, 0, 0, 0.6);
  }
}

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

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  color: var(--text);
}

/* Skip link for Accessibility */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--accent);
  color: #FFFFFF;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  z-index: 9999;
  text-decoration: none;
  box-shadow: var(--shadow-md);
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 1rem;
  outline: 3px solid #FFFFFF;
  outline-offset: 2px;
}

/* Draft Banner */
.draft-banner {
  background-color: var(--amber-surface);
  color: var(--amber);
  border-bottom: 1px solid var(--amber-border);
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  position: relative;
  z-index: 100;
  width: 100%;
  max-width: 100%;
  word-break: break-word;
}

/* Focus outline */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Typography */
h1, h2, h3, h4 {
  color: var(--text);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
  word-break: break-word;
}

h1 { font-size: clamp(1.75rem, 5vw + 0.5rem, 3rem); }
h2 { font-size: clamp(1.4rem, 3vw + 0.3rem, 2.125rem); }
h3 { font-size: clamp(1.15rem, 2vw + 0.2rem, 1.5rem); }
h4 { font-size: 1.125rem; }

p {
  margin-bottom: 1rem;
  color: var(--text);
  overflow-wrap: break-word;
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
  word-break: break-word;
}

a:hover {
  color: var(--accent-hover);
}

/* Layout Utilities */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  box-sizing: border-box;
}

.content-narrow {
  max-width: var(--content-max);
  margin-left: auto;
  margin-right: auto;
}

.break-desktop {
  display: inline;
}

@media (max-width: 768px) {
  .break-desktop {
    display: none;
  }
}

/* Header & Navigation */
.site-header {
  background-color: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 4.25rem;
  gap: 1rem;
  width: 100%;
  max-width: 100%;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: block;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  list-style: none;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background-color 0.15s ease;
  white-space: nowrap;
}

.nav-link:hover, .nav-link.active {
  color: var(--text);
  background-color: var(--surface-subtle);
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  background-color: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.2rem 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  flex-shrink: 0;
}

.lang-switch a {
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-pill);
  text-decoration: none;
  color: var(--text-muted);
}

.lang-switch a.active {
  background-color: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Hero Section */
.hero {
  padding: 3.5rem 0 3rem;
  text-align: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background-color: var(--green-surface);
  color: var(--green);
  border: 1px solid var(--green-border);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-pill);
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  max-width: 100%;
  white-space: normal;
  text-align: center;
  line-height: 1.4;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--green);
  flex-shrink: 0;
}

.hero-title {
  margin-bottom: 1.25rem;
}

.hero-subtitle {
  font-size: clamp(1.0625rem, 1.2vw + 0.8rem, 1.25rem);
  color: var(--text-muted);
  max-width: 680px;
  margin: 0 auto 2rem;
  line-height: 1.55;
}

.hero-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}

/* Button & Status Pill */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-pill);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn-primary {
  background-color: var(--accent);
  color: #FFFFFF;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  color: #FFFFFF;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-pill);
  font-size: 0.9375rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.status-note {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Showcase & Screenshots Gallery */
.showcase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.device-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-md);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.device-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.device-img {
  width: 100%;
  max-width: 280px;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--surface-subtle);
  display: block;
  margin-bottom: 0.75rem;
}

.device-caption {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.device-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Features Grid */
.features {
  padding: 4rem 0 3rem;
}

.section-head {
  text-align: center;
  margin-bottom: 2.75rem;
}

.section-title {
  margin-bottom: 0.75rem;
}

.section-sub {
  color: var(--text-muted);
  font-size: 1.0625rem;
  max-width: 600px;
  margin: 0 auto;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.feature-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background-color: var(--accent-surface);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  margin-bottom: 0.25rem;
}

.feature-card h3 {
  font-size: 1.1875rem;
}

.feature-card p {
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.55;
}

/* Limitations Section */
.limitations {
  padding: 3rem 0;
}

.limitations-card {
  background: var(--surface);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
}

.limitations-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.limitations-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--amber-surface);
  color: var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.125rem;
}

.limitations-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.limitations-item {
  background: var(--surface-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  border: 1px solid var(--border-subtle);
}

.limitations-item h4 {
  margin-bottom: 0.4rem;
  font-size: 1rem;
}

.limitations-item p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Prose (Content pages: Privacy, Terms, Support, Delete-Data) */
.prose-page {
  padding: 3rem 0 4rem;
}

.prose {
  line-height: 1.7;
}

.prose h1 {
  margin-bottom: 0.75rem;
}

.prose-meta {
  color: var(--text-muted);
  font-size: 0.9375rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.prose h2 {
  margin-top: 2.25rem;
  margin-bottom: 0.85rem;
  padding-top: 0.5rem;
}

.prose h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.6rem;
}

.prose p {
  margin-bottom: 1.15rem;
}

.prose ul, .prose ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.prose li {
  margin-bottom: 0.5rem;
  color: var(--text);
}

.prose strong {
  color: var(--text);
}

.prose-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-sm);
}

.prose-card.highlight {
  border-left: 4px solid var(--accent);
  background-color: var(--accent-surface);
}

.prose-card.warning {
  border-left: 4px solid var(--amber);
  background-color: var(--amber-surface);
}

/* FAQ Component */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.faq-item h3 {
  font-size: 1.0625rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.faq-item p {
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.55;
}

/* Footer */
.site-footer {
  margin-top: auto;
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  padding: 3rem 0 2rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2.5rem;
  margin-bottom: 2.5rem;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.footer-brand p {
  color: var(--text-muted);
  font-size: 0.875rem;
  max-width: 340px;
}

.footer-col h4 {
  font-size: 0.9375rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text);
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.15s ease;
}

.footer-links a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.footer-bottom {
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* 404 Page */
.error-page {
  padding: 5rem 0;
  text-align: center;
}

.error-code {
  font-size: clamp(3.5rem, 8vw, 6rem);
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 1rem;
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .brand {
    order: 1;
  }

  .lang-switch {
    order: 2;
  }

  .site-header nav {
    order: 3;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    margin-top: 0.35rem;
  }

  .nav-links {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.35rem;
    padding-top: 0.25rem;
    gap: 0.35rem;
    scrollbar-width: none;
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-links li {
    flex-shrink: 0;
  }

  .nav-link {
    font-size: 0.8125rem;
    padding: 0.25rem 0.5rem;
    white-space: nowrap;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .showcase-grid {
    grid-template-columns: 1fr;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  html, body {
    width: 100%;
    max-width: 390px;
    margin: 0;
  }

  .container {
    width: 100%;
    max-width: 390px;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    margin-left: 0;
    margin-right: 0;
  }

  .hero {
    padding: 2rem 0 1.5rem;
  }

  .hero-title {
    font-size: 1.625rem;
    line-height: 1.3;
  }

  .hero-subtitle {
    font-size: 0.9375rem;
    margin-bottom: 1.25rem;
  }

  .badge {
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
  }

  .prose-page {
    padding: 1.5rem 0 2rem;
  }
}

/* Print Styles */
@media print {
  .site-header, .site-footer, .draft-banner, .skip-link {
    display: none !important;
  }
  body, .prose-page {
    background: #FFFFFF !important;
    color: #000000 !important;
  }
  a {
    color: #000000 !important;
    text-decoration: underline !important;
  }
}

/* ==========================================================================
   Utility classes (thay thế thuộc tính style inline — CSP style-src 'self' cấm inline)
   !important để giữ đúng độ ưu tiên như style inline trước đây.
   ========================================================================== */
.u-card-title { margin-top: 0 !important; font-size: 1.25rem !important; }
.u-card-title-sm { margin-top: 0 !important; font-size: 1.125rem !important; }
.u-list-tight { margin-top: 0.5rem !important; margin-bottom: 0.5rem !important; }
.u-mt-lg { margin-top: 2.5rem !important; }
.u-mb-0 { margin-bottom: 0 !important; }
.u-text-lg { font-size: 1.125rem !important; }
.u-text-xs { font-size: 0.8125rem !important; }
.u-note { font-size: 0.875rem !important; color: var(--text-muted) !important; margin-bottom: 0 !important; }
.u-lead { margin-bottom: 2rem !important; font-size: 1.125rem !important; }
.u-lead-muted { color: var(--text-muted) !important; font-size: 1.125rem !important; margin-bottom: 2rem !important; }
.u-intro { margin-bottom: 1.5rem !important; color: var(--text-muted) !important; }
.u-rounded { border-radius: 6px !important; }
.u-brand-row { display: flex !important; align-items: center !important; gap: 0.5rem !important; }
.u-plain-bottom { border-top: none !important; padding-top: 0 !important; }
.badge-dot-amber { background-color: var(--amber) !important; }
