/* Libermall ID Mini App — Tier-1 styles, theme-aware */
:root {
  --bg: var(--tg-theme-bg-color, #EEF3FB);
  --section-bg: var(--tg-theme-secondary-bg-color, #FFFFFF);
  --text: var(--tg-theme-text-color, #17212B);
  --hint: var(--tg-theme-hint-color, #64748B);
  --link: var(--tg-theme-link-color, #2A7BFF);
  --button: var(--tg-theme-button-color, #2A7BFF);
  --button-text: var(--tg-theme-button-text-color, #FFFFFF);
  --destructive: var(--tg-theme-destructive-text-color, #EF4444);
  --primary: #2A7BFF;
  --green: #2ECC71;
  --orange: #FFB02E;
  --red: #EF4444;
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; -webkit-font-smoothing: antialiased; }
body { padding: 0 0 calc(var(--safe-bottom) + 24px); min-height: 100vh; overflow-x: hidden; }
a { color: var(--link); text-decoration: none; }

.loader { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.loader svg { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.92); opacity: 0.7; } }

/* ── screen layout ── */
.screen { padding: 20px 16px 16px; }
.screen header { margin-bottom: 24px; }
.screen h1 { font-size: 24px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 6px; }
.screen .lead { color: var(--hint); font-size: 14px; line-height: 1.5; margin: 0; }

/* ── profile hero ── */
.profile-hero { background: var(--section-bg); border-radius: 16px; padding: 24px 20px; margin-bottom: 16px; }
.profile-hero .row { display: flex; align-items: center; gap: 14px; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 22px; flex-shrink: 0; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-weight: 600; font-size: 17px; margin: 0; }
.profile-id { color: var(--hint); font-size: 13px; margin-top: 2px; }
.profile-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 8px; background: rgba(46,204,113,0.12); color: var(--green); font-size: 11px; font-weight: 600; margin-left: 6px; }

/* ── section ── */
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--hint); margin: 24px 16px 8px; padding: 0; }
.list { background: var(--section-bg); border-radius: 14px; overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; cursor: pointer; transition: background .12s; min-height: 56px; border-bottom: 1px solid rgba(120,120,128,0.12); }
.list-item:last-child { border-bottom: 0; }
.list-item:active { background: rgba(120,120,128,0.10); }
.list-item-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; font-size: 16px; font-weight: 700; }
.list-item-body { flex: 1; min-width: 0; }
.list-item-title { font-size: 15px; font-weight: 500; margin: 0; }
.list-item-subtitle { color: var(--hint); font-size: 13px; margin-top: 2px; }
.list-item-arrow { color: var(--hint); font-size: 18px; opacity: 0.5; }

/* ── chips ── */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 4px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { padding: 6px 14px; border-radius: 999px; background: var(--section-bg); color: var(--text); font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer; transition: all .12s; }
.chip.active { background: var(--primary); color: #fff; }
.chip:active { transform: scale(0.96); }

/* ── buttons ── */
.btn { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; padding: 14px 20px; border-radius: 12px; font-size: 15px; font-weight: 600; text-decoration: none; border: 0; cursor: pointer; transition: all .12s; }
.btn-primary { background: var(--button); color: var(--button-text); }
.btn-primary:active { transform: scale(0.98); opacity: 0.9; }
.btn-secondary { background: var(--section-bg); color: var(--text); }
.btn-destructive { background: rgba(239,68,68,0.08); color: var(--destructive); }

/* ── grid 2x3 ── */
.grid-products { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.product-card { background: var(--section-bg); border-radius: 14px; padding: 16px; text-align: center; cursor: pointer; transition: transform .15s; }
.product-card:active { transform: scale(0.96); }
.product-card .icon { width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 18px; }
.product-card .name { font-size: 14px; font-weight: 600; }
.product-card .desc { color: var(--hint); font-size: 12px; margin-top: 2px; line-height: 1.3; }

/* ── empty ── */
.empty { text-align: center; padding: 32px 24px; }
.empty .emoji { font-size: 48px; margin-bottom: 12px; }
.empty .title { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.empty .desc { color: var(--hint); font-size: 14px; line-height: 1.5; }

/* ── note/info ── */
.note { background: rgba(42,123,255,0.08); border-radius: 12px; padding: 14px 16px; font-size: 13px; line-height: 1.5; color: var(--text); margin: 12px 0; }
.note strong { color: var(--primary); }

/* ── footer hint ── */
.screen-foot { text-align: center; color: var(--hint); font-size: 12px; padding: 32px 16px 16px; }
.screen-foot a { color: var(--hint); margin: 0 8px; }

/* ── screen transitions ── */
.screen { animation: slideIn .22s ease-out; }
@keyframes slideIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── safe area top ── */
.screen { padding-top: calc(20px + var(--safe-top)); }
