/* ==========================================================================
   Leeorichi Apps — Stylesheet
   ========================================================================== */

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  /* Surfaces & Canvas */
  --bg-canvas: #0A0A0C;
  --bg-surface: #111114;
  --bg-surface-hover: #16161A;
  --bg-nav: #0A0A0C;

  /* Borders */
  --border-subtle: #202026;
  --border-default: #2A2A32;
  --border-highlight: #3F3F4A;
  --border-active: #E4E4E7;

  /* Typography Colors */
  --text-primary: #F4F4F5;
  --text-secondary: #A1A1AA;
  --text-tertiary: #71717A;
  --text-muted: #52525B;

  /* Accents */
  --accent-white: #FFFFFF;
  --accent-zinc: #E4E4E7;
  --accent-emerald: #10B981;

  /* Chips & Tags */
  --chip-bg: #18181C;
  --chip-border: #24242B;
  --chip-text: #D4D4D8;

  /* Sizing & Transitions */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 18px;
  --radius-full: 9999px;
  --transition-fast: 150ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  position: relative;
  overflow-x: hidden;
}

/* i18n Visibility */
html[lang="en"] .i18n-vi {
  display: none !important;
}

html[lang="vi"] .i18n-en {
  display: none !important;
}

/* ==========================================================================
   Navigation Bar
   ========================================================================== */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border-subtle);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* Brand */
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -0.2px;
  flex-shrink: 0;
}

.brand-logo {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: block;
  flex-shrink: 0;
}

.brand-divider {
  color: var(--border-default);
  font-weight: 400;
}

.brand-sub {
  color: var(--text-secondary);
  font-weight: 500;
}

/* Filter Tabs */
.nav-filters {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 4px;
  border-radius: var(--radius-full);
}

.filter-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: color var(--transition-fast), background-color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.filter-btn:hover {
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--bg-surface-hover);
  color: var(--accent-white);
  box-shadow: inset 0 0 0 1px var(--border-default);
}

.filter-count {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  opacity: 0.7;
}

/* Nav Actions (Search + Lang + GitHub) */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Search Box */
.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  width: 15px;
  height: 15px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 6px 12px 6px 32px;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--text-primary);
  width: 170px;
  transition: width var(--transition-fast), border-color var(--transition-fast), background-color var(--transition-fast);
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

.search-input:focus {
  outline: none;
  width: 220px;
  border-color: var(--border-highlight);
  background: var(--bg-surface-hover);
}

/* Language Switch */
.lang-switch {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 3px;
  border-radius: var(--radius-full);
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: color var(--transition-fast), background-color var(--transition-fast);
  line-height: 1;
}

.lang-btn:hover {
  color: var(--text-primary);
}

.lang-btn.active {
  background: var(--bg-surface-hover);
  color: var(--accent-white);
}

/* Nav Icon Links */
.nav-icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  text-decoration: none;
  transition: color var(--transition-fast), border-color var(--transition-fast), background-color var(--transition-fast);
}

.nav-icon-link:hover {
  color: var(--accent-white);
  border-color: var(--border-highlight);
  background: var(--bg-surface-hover);
}

.nav-icon-link svg {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   Main Container & Page Header
   ========================================================================== */
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  position: relative;
}

.page-header {
  padding-bottom: 28px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

.page-title {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.page-subtitle {
  font-size: 0.96rem;
  color: var(--text-secondary);
  line-height: 1.6;
  font-weight: 400;
}

/* ==========================================================================
   Apps Grid & Cards
   ========================================================================== */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 64px;
}

/* App Card */
.app-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 28px;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: border-color var(--transition-normal), background-color var(--transition-normal);
  scroll-margin-top: 80px;
}

.app-card:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-default);
}

.app-card:target {
  border-color: var(--border-active);
  box-shadow: 0 0 0 1px var(--border-active);
}

.app-card.is-hidden {
  display: none !important;
}

/* Card Header */
.card-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.app-icon-container {
  width: 60px;
  height: 60px;
  border-radius: 15px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border-default);
  background: var(--bg-canvas);
}

.app-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-title-group {
  flex: 1;
  min-width: 0;
}

.card-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.app-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.version-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--chip-bg);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  line-height: 1.4;
}

.app-meta-tags {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-tertiary);
  flex-wrap: wrap;
}

.platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  font-weight: 500;
}

.platform-badge svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.meta-separator {
  color: var(--border-default);
}

/* Description */
.app-desc {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

.app-desc strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Feature Tags List */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.tag-item {
  display: inline-flex;
  align-items: center;
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 0.76rem;
  color: var(--chip-text);
  font-weight: 500;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.tag-item:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-default);
  color: var(--accent-white);
}

/* Compact Spec Grid */
.spec-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.spec-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.spec-label {
  color: var(--text-tertiary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.4px;
  line-height: 1.2;
}

.spec-value {
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spec-divider {
  display: none;
}

/* Actions Bar */
.actions-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
}

.actions-primary-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Button System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  font-family: inherit;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Primary Button */
.btn-solid-primary {
  background: var(--accent-white);
  color: #0A0A0C;
  border-color: var(--accent-white);
  flex: 1;
}

.btn-solid-primary:hover {
  background: var(--accent-zinc);
  border-color: var(--accent-zinc);
}

/* Secondary Button */
.btn-outline {
  background: var(--chip-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}

.btn-outline:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-highlight);
  color: var(--accent-white);
}

.btn-icon-only {
  padding: 10px;
  width: 40px;
  height: 40px;
}

/* Copied State Feedback */
.btn-copy.copied {
  background: rgba(16, 185, 129, 0.14) !important;
  border-color: rgba(16, 185, 129, 0.45) !important;
  color: #34D399 !important;
}

/* Secondary Actions Bar */
.actions-secondary-row {
  display: flex;
  gap: 8px;
}

.btn-secondary-action {
  flex: 1;
  font-size: 0.82rem;
  padding: 8px 14px;
}

/* ==========================================================================
   Changelog Details / Accordion (Timeline Style)
   ========================================================================== */
.changelog-box {
  margin-top: 14px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
}

.changelog-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-tertiary);
  transition: color var(--transition-fast);
}

.changelog-toggle::-webkit-details-marker {
  display: none;
}

.changelog-toggle:hover {
  color: var(--text-secondary);
}

.changelog-toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.changelog-toggle-label svg {
  width: 14px;
  height: 14px;
}

.toggle-arrow {
  width: 15px;
  height: 15px;
  transition: transform var(--transition-fast);
}

details[open] .toggle-arrow {
  transform: rotate(180deg);
}

.changelog-drawer {
  margin-top: 16px;
  padding-left: 12px;
  border-left: 2px solid var(--border-subtle);
  font-size: 0.82rem;
}

.timeline-entry {
  position: relative;
  margin-bottom: 18px;
  padding-left: 14px;
}

.timeline-entry:last-child {
  margin-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -18px;
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-zinc);
  border: 2px solid var(--bg-canvas);
}

.timeline-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.timeline-version {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-primary);
}

.timeline-date {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.timeline-list {
  list-style: none;
  color: var(--text-secondary);
  line-height: 1.55;
}

.timeline-list li {
  position: relative;
  margin-bottom: 5px;
  padding-left: 12px;
}

.timeline-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--text-tertiary);
}

/* ==========================================================================
   QR Code Modal
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 28px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65);
  transform: scale(0.97);
  transition: transform var(--transition-normal);
}

.modal-backdrop.is-open .modal-card {
  transform: scale(1);
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.modal-close-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--accent-white);
}

.modal-close-btn svg {
  width: 18px;
  height: 18px;
}

.modal-header-app {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.modal-app-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--border-default);
}

.modal-app-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.modal-app-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-qr-frame {
  background: #FFFFFF;
  padding: 14px;
  border-radius: var(--radius-lg);
  display: inline-block;
  margin-bottom: 20px;
}

.modal-qr-img {
  width: 200px;
  height: 200px;
  display: block;
}

.modal-instructions {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

.modal-url-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
}

.modal-url-text {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  text-align: left;
}

.modal-copy-url-btn {
  background: var(--chip-bg);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  font-family: inherit;
}

.modal-copy-url-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--accent-white);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-canvas);
  padding: 36px 24px;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.footer-left {
  font-size: 0.82rem;
  color: var(--text-tertiary);
}

.footer-left strong {
  color: var(--text-secondary);
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.82rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

.footer-dot {
  color: var(--border-default);
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 960px) {
  .apps-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .nav-container {
    flex-wrap: wrap;
    padding: 10px 16px;
  }
  .nav-filters {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .search-wrapper {
    display: none;
  }
  .page-title {
    font-size: 1.5rem;
  }
  .page-subtitle {
    font-size: 0.9rem;
  }
  .main-container {
    padding: 28px 16px 60px;
  }
  .app-card {
    padding: 22px 18px;
    border-radius: var(--radius-lg);
  }
  .footer-container {
    flex-direction: column;
    text-align: center;
  }
}
