/*
  Kafil — mini app stillari. Suno Market uslubidagi dizayn tokenlariga
  asoslangan (rang, radius, soya), lekin Telegram --tg-theme-* o'zgaruvchilari
  orqali foydalanuvchi tanlagan light/dark mavzuga moslashadi.
*/

:root {
  --bg: var(--tg-theme-secondary-bg-color, #eef1f6);
  --card: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #0f1b2d);
  --hint: var(--tg-theme-hint-color, #8a929e);
  --line: rgba(138, 146, 158, .14);
  --blue: var(--tg-theme-button-color, #2f8fff);
  --blue-text: var(--tg-theme-button-text-color, #ffffff);
  --blue-soft: rgba(47, 143, 255, .1);
  --blue-grad-a: #4a90ff;
  --blue-grad-b: #6aa8ff;
  --violet: #8b6aff;
  --green: #34c759;
  --green-soft: rgba(52, 199, 89, .12);
  --amber: #ff9f0a;
  --amber-soft: rgba(255, 159, 10, .14);
  --red: #ff3b30;
  --red-soft: rgba(255, 59, 48, .12);

  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 2px 12px rgba(20, 40, 80, .05);
  --shadow-lift: 0 6px 20px rgba(20, 40, 80, .08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--tg-theme-secondary-bg-color, #10131a);
    --card: var(--tg-theme-bg-color, #1b1f29);
    --text: var(--tg-theme-text-color, #f1f3f7);
    --hint: var(--tg-theme-hint-color, #8b93a3);
    --line: rgba(255, 255, 255, .08);
    --blue-soft: rgba(47, 143, 255, .18);
    --green-soft: rgba(52, 199, 89, .16);
    --amber-soft: rgba(255, 159, 10, .18);
    --red-soft: rgba(255, 59, 48, .18);
    --shadow: 0 2px 10px rgba(0, 0, 0, .35);
    --shadow-lift: 0 8px 24px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: "Inter", -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .price, .val, .detail-price { letter-spacing: -.3px; }

.hidden { display: none !important; }

/* ── Splash ── */
.splash {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  background: var(--bg); z-index: 100; transition: opacity .3s;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash-logo { font-size: 60px; animation: pop .5s cubic-bezier(.34,1.56,.64,1); }
.splash-name { font-size: 30px; font-weight: 800; letter-spacing: -.5px; }
.splash-tag { color: var(--hint); font-size: 14px; text-align: center; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── Layout ── */
.app { min-height: 100vh; padding-bottom: 108px; }
.view { padding: 14px 16px 0; animation: fade .28s cubic-bezier(.2,.8,.2,1); }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.head { margin-bottom: 16px; }
.head h1 { font-size: 20px; font-weight: 800; }
.head .sub { color: var(--hint); font-size: 13.5px; margin-top: 3px; }

/* ── Suzuvchi tab bar (Suno hap-shakl) ── */
.tabbar {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  width: calc(100% - 32px); max-width: 388px;
  background: var(--card); border-radius: 26px; box-shadow: var(--shadow-lift);
  display: flex; align-items: center; padding: 8px; gap: 4px;
  z-index: 50;
}
.tab {
  flex: 1; background: none; border: none; cursor: pointer; padding: 10px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--hint); font-size: 11px; font-weight: 600; border-radius: 18px;
  transition: all .15s; font-family: inherit;
}
.tab .tab-ic { font-size: 20px; }
.tab.active { color: var(--blue); background: var(--blue-soft); }
.tab-profile {
  flex: 0 0 auto; width: 48px; height: 48px; border-radius: 50%; padding: 0;
  background: linear-gradient(135deg, #6a8dff, var(--violet)); margin-left: 4px;
  display: flex; align-items: center; justify-content: center;
  border: 2.5px solid transparent; transition: border-color .15s;
}
.tab-profile.active { border-color: var(--blue); background: linear-gradient(135deg, #6a8dff, var(--violet)); }
.tab-profile-av { color: #fff; font-weight: 700; font-size: 17px; }

/* ── Qidiruv ── */
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: var(--radius-sm); color: var(--hint);
  padding: 13px 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.search-box input {
  border: none; outline: none; width: 100%;
  color: var(--text); font-size: 15.5px; font-family: inherit; background: none;
}
.search-box input::placeholder { color: var(--hint); }

/* ── Chips (filtr) ── */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 9px 16px; border-radius: 22px; border: none;
  background: var(--card); color: var(--text); font-size: 13.5px; font-weight: 600;
  cursor: pointer; box-shadow: var(--shadow); transition: all .15s;
}
.chip.active { background: var(--blue); color: var(--blue-text); box-shadow: 0 3px 10px rgba(47,143,255,.3); }

/* ── Kartalar (e'lonlar) ── */
.list { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  cursor: pointer; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s;
}
.card:active { transform: scale(.985); }
.card.sold { opacity: .62; }
.card-top { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.card-title { font-size: 17.5px; font-weight: 700; margin-bottom: 4px; }
.card-desc { font-size: 13.5px; color: var(--hint); line-height: 1.45; margin-bottom: 12px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; }
.price { font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.price .cur { font-size: 13px; font-weight: 600; color: var(--hint); margin-left: 3px; }
.price.sm { font-size: 16px; }
.price.sm .cur { font-size: 11.5px; }
.seller { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--hint); }
.seller-dot {
  width: 22px; height: 22px; border-radius: 50%; font-size: 11px;
  background: linear-gradient(135deg, #6a8dff, var(--violet)); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}

/* ── Badge ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; border-radius: 9px; font-size: 11.5px; font-weight: 700;
}
.badge.type { background: var(--bg); color: var(--text); }
.badge.escrow { background: var(--green-soft); color: var(--green); }
.badge.sold-badge { background: var(--red-soft); color: var(--red); }
.st-green { background: var(--green-soft); color: var(--green); }
.st-amber { background: var(--amber-soft); color: var(--amber); }
.st-blue { background: var(--blue-soft); color: var(--blue); }
.st-red { background: var(--red-soft); color: var(--red); }
.st-gray { background: var(--bg); color: var(--hint); }

/* ── Empty / loading ── */
.empty, .loading { text-align: center; padding: 50px 20px; color: var(--hint); }
.empty-ic { font-size: 52px; margin-bottom: 14px; }
.empty p { font-size: 15px; line-height: 1.5; }

/* ── Detail ── */
.detail { animation: fade .25s; }
.detail-badges { display: flex; gap: 7px; margin: 4px 0 14px; flex-wrap: wrap; }
.detail-title { font-size: 26px; font-weight: 800; letter-spacing: -.5px; margin-bottom: 8px; word-break: break-word; }
.detail-price { font-size: 34px; font-weight: 800; color: var(--blue); letter-spacing: -1px; margin-bottom: 16px; }
.detail-price .cur { font-size: 16px; color: var(--hint); font-weight: 600; margin-left: 4px; }
.detail-desc { font-size: 15.5px; line-height: 1.55; color: var(--text); opacity: .82; margin-bottom: 18px; }

.seller-box {
  display: flex; align-items: center; gap: 13px; background: var(--card);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.seller-av {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #6a8dff, var(--violet)); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 19px;
}
.seller-nm { font-weight: 700; font-size: 15.5px; }
.seller-rt { font-size: 13px; color: var(--hint); margin-top: 1px; }

/* ── Tugmalar ── */
.btn {
  width: 100%; padding: 17px; border: none; border-radius: 16px;
  font-size: 16.5px; font-weight: 700; font-family: inherit; cursor: pointer;
  transition: transform .12s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--blue); color: var(--blue-text); box-shadow: 0 6px 16px rgba(47,143,255,.35); }
.btn.ghost { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.btn.big { margin: 6px 0 20px; }
.buy-actions { display: flex; flex-direction: column; gap: 10px; }
.hint { color: var(--hint); font-size: 13px; line-height: 1.5; text-align: center; margin-top: 12px; }
.note {
  background: var(--bg); border-radius: var(--radius-sm);
  padding: 14px 16px; color: var(--hint); font-size: 13px; line-height: 1.55;
}

/* ── Forma ── */
.form { display: flex; flex-direction: column; gap: 6px; }
.form label { font-size: 13.5px; font-weight: 700; color: var(--hint); margin: 16px 2px 8px; }
.form input, .form textarea {
  width: 100%; background: var(--card); border: 2px solid transparent; border-radius: var(--radius-sm);
  padding: 15px 16px; font-size: 16px; font-family: inherit; color: var(--text);
  box-shadow: var(--shadow); outline: none; resize: none;
}
.form input:focus, .form textarea:focus { border-color: var(--blue); }
.type-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.type-btn {
  background: var(--card); border: 2px solid transparent; border-radius: var(--radius-sm);
  padding: 14px 6px; text-align: center; cursor: pointer; box-shadow: var(--shadow);
  transition: all .15s; color: var(--text); font-size: 24px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.type-btn span { font-size: 11.5px; font-weight: 600; }
.type-btn.active { border-color: var(--blue); background: var(--blue-soft); }
.switch { display: flex; align-items: center; gap: 10px; margin-top: 18px !important; cursor: pointer; }
.switch input { width: auto; box-shadow: none; padding: 0; }
.switch span { font-size: 14px; font-weight: 600; color: var(--text); }

/* ── Bitim ── */
.deal {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  cursor: pointer; box-shadow: var(--shadow); transition: transform .12s;
  display: flex; flex-direction: column; gap: 8px;
}
.deal:active { transform: scale(.985); }
.deal-row { display: flex; justify-content: space-between; align-items: center; }
.deal-id { font-weight: 700; font-size: 15px; }
.deal-path { color: var(--hint); font-size: 13px; }

/* ── Stepper (escrow progress) ── */
.stepper { display: flex; align-items: flex-start; margin: 22px 0; }
.step { display: flex; flex-direction: column; align-items: center; gap: 7px; width: 64px; flex-shrink: 0; }
.step-dot {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; background: var(--bg); color: var(--hint); transition: all .3s;
}
.step.done .step-dot { background: var(--green); color: #fff; }
.step.cur .step-dot { background: var(--blue); color: #fff; box-shadow: 0 0 0 5px var(--blue-soft); }
.step-lbl { font-size: 10px; text-align: center; color: var(--hint); line-height: 1.25; }
.step.done .step-lbl, .step.cur .step-lbl { color: var(--text); font-weight: 600; }
.step-line { flex: 1; height: 3px; border-radius: 3px; background: var(--bg); margin-top: 14.5px; }
.step.done + .step-line { background: var(--green); }

/* ── Profil karta (Suno bosh karta) ── */
.profile-card {
  background: var(--card); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #6a8dff, var(--violet));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 24px; font-weight: 700; flex-shrink: 0;
}
.profile-name { font-size: 22px; font-weight: 700; }

.balance-inner {
  background: var(--bg); border-radius: var(--radius-sm);
  padding: 16px 18px; display: flex; align-items: center; justify-content: space-between;
}
.balance-inner .lbl { font-size: 14px; color: var(--hint); margin-bottom: 4px; }
.balance-inner .val { font-size: 30px; font-weight: 800; letter-spacing: -.5px; }
.balance-inner .val .cur { font-size: 15px; font-weight: 600; color: var(--hint); }
.balance-add {
  width: 52px; height: 52px; border-radius: var(--radius-sm); flex-shrink: 0;
  background: var(--blue); border: none; color: var(--blue-text); font-size: 28px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 4px 12px rgba(47, 143, 255, .35); transition: transform .12s;
}
.balance-add:active { transform: scale(.94); }

/* ── Statistika grid ── */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat {
  background: var(--card); border-radius: var(--radius);
  padding: 16px 8px; text-align: center; box-shadow: var(--shadow);
}
.stat .num { font-size: 24px; font-weight: 800; }
.stat .cap { font-size: 12.5px; color: var(--hint); margin-top: 2px; }

/* ── Profil menyu ── */
.menu { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.menu-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 16px; border: none; background: none; color: var(--text);
  font-size: 15.5px; font-weight: 600; cursor: pointer; font-family: inherit; text-align: left;
  border-bottom: 1px solid var(--line); width: 100%;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: var(--bg); }
.menu-badge { background: var(--green-soft); color: var(--green); padding: 4px 10px; border-radius: 9px; font-size: 12.5px; font-weight: 700; }

/* ── To'ldirish karta ── */
.topup-card {
  background: linear-gradient(135deg, var(--blue-grad-a), var(--blue-grad-b)); border-radius: var(--radius);
  padding: 22px; color: #fff; margin-bottom: 14px; box-shadow: 0 8px 24px rgba(74,144,255,.3);
}
.topup-card .lbl { font-size: 14px; opacity: .9; }
.topup-card .card-num { font-size: 24px; font-weight: 800; letter-spacing: 1.5px; margin: 8px 0; font-variant-numeric: tabular-nums; word-break: break-all; }
.topup-card .copy {
  background: rgba(255,255,255,.2); border: none; color: #fff; padding: 10px 18px;
  border-radius: 11px; font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: 110px; left: 50%; transform: translateX(-50%);
  background: rgba(15,27,45,.92); color: #fff; padding: 13px 22px; border-radius: 14px;
  font-size: 14px; font-weight: 500; z-index: 200; animation: toastin .3s cubic-bezier(.2,.8,.2,1);
  max-width: 88%; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
