/* ═══════════════════════════════════════════════════════════════════════════
   iViRTH v5.0 — PWA Stylesheet
   Minimalist dark-first design with CSS variables for theming
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ──────────────────────────────────────────────── */
:root {
  /* Layout */
  --nav-h:         64px;
  --top-bar-h:     56px;
  --safe-top:      env(safe-area-inset-top, 0px);
  --safe-bottom:   env(safe-area-inset-bottom, 0px);
  --page-px:       1.25rem;

  /* Radii */
  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     14px;
  --radius-xl:     20px;

  /* Shadows */
  --shadow:        0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.5);

  /* Transitions */
  --transition:    0.15s ease;
}

/* ── Dark Theme (default) ───────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:       #000;
  --bg2:      #080808;
  --surface:  #111;
  --surface2: #1a1a1a;
  --border:   rgba(255,255,255,0.08);
  --border2:  rgba(255,255,255,0.15);
  --fg:       #fff;
  --fg2:      rgba(255,255,255,0.75);
  --muted:    rgba(255,255,255,0.45);
  --muted2:   rgba(255,255,255,0.25);
  --success:  #60d0a0;
  --error:    #ff4444;
  --accent:   #a0a0ff;
}

/* ── Light Theme ─────────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:       #f5f5f7;
  --bg2:      #fff;
  --surface:  #fff;
  --surface2: #f0f0f5;
  --border:   rgba(0,0,0,0.08);
  --border2:  rgba(0,0,0,0.15);
  --fg:       #111;
  --fg2:      rgba(0,0,0,0.75);
  --muted:    rgba(0,0,0,0.45);
  --muted2:   rgba(0,0,0,0.25);
  --success:  #1a8c5a;
  --error:    #cc2222;
  --accent:   #5050cc;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100dvh;
  overscroll-behavior: none;
}

/* ── App Shell ──────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.app-main {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 0.5rem);
  padding-top: calc(var(--top-bar-h) + var(--safe-top));
  -webkit-overflow-scrolling: touch;
}

/* ── Top Bar ────────────────────────────────────────────────────────────── */
.top-bar {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--top-bar-h);
  padding: calc(var(--safe-top) + 0.75rem) var(--page-px) 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
[data-theme="light"] .top-bar { background: rgba(245,245,247,0.9); }

.top-bar-logo {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #fff 0%, #a0a0ff 60%, #60d0a0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
[data-theme="light"] .top-bar-logo {
  background: linear-gradient(135deg, #111 0%, #5050cc 60%, #1a8c5a 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.top-bar-title {
  font-weight: 600;
  font-size: 1rem;
  flex: 1;
}

/* ── Bottom Nav ─────────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  align-items: flex-start;
  padding-top: 0.5rem;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-top: 1px solid var(--border);
  z-index: 100;
}
[data-theme="light"] .bottom-nav { background: rgba(245,245,247,0.92); }

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color var(--transition);
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item .avatar-sm { width: 22px; height: 22px; }
.nav-item .avatar-init { width: 22px; height: 22px; }
.nav-item.active { color: var(--fg); }
.nav-item.active svg { stroke: var(--fg); }

/* ── Page Padding ────────────────────────────────────────────────────────── */
.page-pad { padding: 1rem var(--page-px) 1.5rem; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  transition: border-color var(--transition);
}
.card-interactive {
  cursor: pointer;
}
.card-interactive:active { opacity: 0.8; transform: scale(0.99); }

.card-sm {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { opacity: 0.85; transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.btn-secondary {
  background: var(--surface2);
  color: var(--fg);
  border-color: var(--border2);
}
.btn-full { width: 100%; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.78rem; }

/* ── Inputs ─────────────────────────────────────────────────────────────── */
.input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--fg);
  outline: none;
  transition: border-color var(--transition);
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--muted2); }

.input-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.4rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Chips / Badges ──────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--fg2);
  white-space: nowrap;
}
.chip-success { background: rgba(96,208,160,0.12); color: var(--success); border-color: rgba(96,208,160,0.25); }
.chip-white   { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* ── Helix SSO Button ────────────────────────────────────────────────────── */
.helix-sso-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.8rem 1rem;
  background: linear-gradient(135deg, rgba(160,160,255,0.12), rgba(96,208,160,0.08));
  border: 1px solid rgba(160,160,255,0.25);
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  font-family: inherit;
}
.helix-sso-btn:hover { border-color: rgba(160,160,255,0.5); }

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.8rem 1rem;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}

/* ── Helix Badge ─────────────────────────────────────────────────────────── */
.helix-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  background: linear-gradient(135deg, rgba(160,160,255,0.15), rgba(96,208,160,0.1));
  border: 1px solid rgba(160,160,255,0.2);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
}

/* ── Avatars ─────────────────────────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.avatar-sm  { width: 28px; height: 28px; }
.avatar-md  { width: 40px; height: 40px; }
.avatar-xl  { width: 80px; height: 80px; }

.avatar-init {
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(160,160,255,0.3), rgba(96,208,160,0.2));
  border: 1px solid rgba(160,160,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

/* ── Stats Grid ──────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.5rem;
  text-align: center;
}
.stat-value { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.03em; }
.stat-label { font-size: 0.65rem; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.06em; }

/* ── Quick Launch Grid ───────────────────────────────────────────────────── */
.quick-launch {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.quick-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.85rem 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition);
}
.quick-item:active { opacity: 0.8; transform: scale(0.97); }
.quick-item-icon  { font-size: 1.4rem; }
.quick-item-label { font-size: 0.65rem; font-weight: 600; color: var(--muted); text-align: center; }

/* ── iON Connect Card ────────────────────────────────────────────────────── */
.ion-connect-card {
  background: linear-gradient(135deg, rgba(160,160,255,0.08), rgba(96,208,160,0.05));
  border: 1px solid rgba(160,160,255,0.18);
  border-radius: var(--radius-xl);
  padding: 1.5rem 1.25rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.ion-connect-card::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 150px; height: 150px;
  background: radial-gradient(circle, rgba(160,160,255,0.1) 0%, transparent 70%);
  pointer-events: none;
}

/* ── Marketplace Hero ────────────────────────────────────────────────────── */
.marketplace-hero {
  background: linear-gradient(160deg, #0a0a1a 0%, #000 60%);
  padding: 1.5rem var(--page-px) 1rem;
  position: relative;
  overflow: hidden;
}
.marketplace-hero::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(160,160,255,0.12) 0%, transparent 70%);
  pointer-events: none;
}

/* ── Category Pills ──────────────────────────────────────────────────────── */
.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition);
}
.category-pill.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* ── Store Cards ─────────────────────────────────────────────────────────── */
.store-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}

.store-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.store-card:active { transform: scale(0.98); opacity: 0.85; }
.store-card-icon   { font-size: 1.6rem; margin-bottom: 0.15rem; }
.store-card-name   { font-size: 0.85rem; font-weight: 700; line-height: 1.2; }
.store-card-house  { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.store-card-desc   { font-size: 0.72rem; color: var(--muted); line-height: 1.4; flex: 1; }
.store-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 0.35rem; }
.store-rating      { font-size: 0.72rem; color: var(--muted); display: flex; align-items: center; gap: 0.2rem; }
.star              { color: #ffaa00; }

/* Store badges */
.store-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid;
}
.store-badge-free { background: rgba(96,208,160,0.12); color: #60d0a0; border-color: rgba(96,208,160,0.3); }
.store-badge-pro  { background: rgba(160,160,255,0.12); color: #a0a0ff; border-color: rgba(160,160,255,0.3); }

/* House sections */
.house-section {
  margin-bottom: 1.75rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}
.house-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}
.house-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Asset / List Items ──────────────────────────────────────────────────── */
.asset-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background var(--transition);
}

.list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:active { opacity: 0.7; }

.install-btn {
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  font-family: inherit;
  white-space: nowrap;
  transition: all var(--transition);
}
.install-btn-primary   { background: var(--fg); color: var(--bg); }
.install-btn-installed { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }

/* ── Minion Cards ────────────────────────────────────────────────────────── */
.minion-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.65rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition);
}
.minion-icon { font-size: 1.6rem; margin-bottom: 0.35rem; }
.minion-name { font-size: 0.72rem; font-weight: 600; line-height: 1.2; }
.minion-type { font-size: 0.62rem; color: var(--muted); margin-top: 2px; }

/* ── TRIVENI Streams ─────────────────────────────────────────────────────── */
.triveni-stream {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}
.stream-label {
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: 0.03em;
}

/* ── Profile Hero ────────────────────────────────────────────────────────── */
.profile-hero {
  text-align: center;
  padding: 1.5rem 0;
  margin-bottom: 1.5rem;
}

/* ── Bottom Sheet ────────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  backdrop-filter: blur(4px);
}
.sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  max-height: 85dvh;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  border: 1px solid var(--border);
  z-index: 201;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--safe-bottom) + 1rem);
  animation: slideUp 0.25s ease;
}
.sheet-handle {
  width: 36px; height: 4px;
  background: var(--border2);
  border-radius: 999px;
  margin: 0.85rem auto 0;
}
.detail-sheet-content { padding: 1.25rem; }

/* ── Reviews ─────────────────────────────────────────────────────────────── */
.review-item {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}
.review-item:last-child { border-bottom: none; }
.review-stars { color: #ffaa00; font-size: 0.75rem; letter-spacing: 0.05em; }

/* ── Plan Features ───────────────────────────────────────────────────────── */
.plan-features { display: flex; flex-direction: column; gap: 0.35rem; }
.plan-feature {
  font-size: 0.8rem;
  color: var(--fg2);
  padding-left: 1rem;
  position: relative;
  line-height: 1.4;
}
.plan-feature::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--success);
  font-size: 0.72rem;
}

/* ── Install Banner ──────────────────────────────────────────────────────── */
.install-banner {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 2rem);
  max-width: 440px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 99;
  animation: slideUp 0.3s ease;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 1rem);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 2rem);
  max-width: 440px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs-scroll {
  overflow-x: auto;
  scrollbar-width: none;
  display: flex;
  gap: 0.45rem;
  margin: 0 -1.25rem;
  padding: 0 1.25rem 0.5rem;
}
.tabs-scroll::-webkit-scrollbar { display: none; }

/* ── Section Titles ──────────────────────────────────────────────────────── */
.section-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

/* ── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 0.5rem; opacity: 0.5; }

/* ── Utilities ───────────────────────────────────────────────────────────── */
.hidden        { display: none !important; }
.truncate      { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.font-semibold { font-weight: 600; }
.font-medium   { font-weight: 500; }
.text-sm       { font-size: 0.875rem; }
.text-xs       { font-size: 0.75rem; }
.text-muted    { color: var(--muted); }
.text-muted2   { color: var(--muted2); }
.mt-2          { margin-top: 0.5rem; }

/* ── Animations ──────────────────────────────────────────────────────────── */
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Scrollbars ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 999px; }

/* ── Links ───────────────────────────────────────────────────────────────── */
a { color: inherit; }

/* ── Desktop centering ───────────────────────────────────────────────────── */
@media (min-width: 520px) {
  .top-bar, .bottom-nav, .sheet, .install-banner, .toast-container {
    left: 50%;
    transform: translateX(-50%);
  }
  .overlay { display: flex; align-items: flex-end; justify-content: center; }
}
