/* ── Body baseline ─────────────────────────────────────────────────── */
html {
  background: var(--tg-theme-bg-color, #0f0f10);
  min-height: 100vh;
}

/* ── no-tg adjustments ─────────────────────────────────────────────── */
body.no-tg .app-navbar {
  padding: 12px 0;
}

body.no-tg .bottom-nav {
  padding-bottom: 0;
  height: 64px;
}

body.no-tg .bottom-nav .nav-inner {
  height: 64px;
  align-items: center;
}

/* ── Layout utility ────────────────────────────────────────────────── */
.page-wrap-narrow {
  max-width: 680px;
  margin: 0 auto;
}

/* ── Auth overlay ──────────────────────────────────────────────────── */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

@media (min-width: 480px) {
  .auth-overlay { align-items: center; }
}

.auth-overlay.is-open {
  opacity: 1;
  pointer-events: all;
}

.auth-sheet {
  background: var(--tg-theme-secondary-bg-color, #16171a);
  border-radius: 1.25rem 1.25rem 0 0;
  width: 100%;
  max-width: 400px;
  padding: 1rem 1.5rem 2rem;
  transform: scale(.95) translateY(12px);
  transition: transform .2s ease;
}

@media (min-width: 480px) {
  .auth-sheet {
    border-radius: 1.25rem;
    transform: scale(.95) translateY(12px);
  }
}

.auth-overlay.is-open .auth-sheet {
  transform: scale(1) translateY(0);
}

.auth-sheet-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: .5rem;
}

.auth-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 .25rem;
  color: var(--tg-theme-text-color, #eaeaea);
}

/* ── Auth states ───────────────────────────────────────────────────── */
.auth-state {
  display: flex;
  flex-direction: column;
}

.auth-state--hidden {
  display: none !important;
}

/* ── Method picker ─────────────────────────────────────────────────── */
.auth-methods {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1rem;
}

.auth-method-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  background: var(--tg-theme-bg-color, #0f0f10);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: .75rem;
  padding: .9rem 1.2rem;
  color: var(--tg-theme-text-color, #eaeaea);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  min-width: 90px;
}

.auth-method-btn:hover {
  border-color: #fcc000;
  background: rgba(252,192,0,.07);
}

.auth-method-icon {
  font-size: 1.6rem;
}

.auth-method-label {
  font-size: .8rem;
}

/* ── Input ─────────────────────────────────────────────────────────── */
.auth-input {
  width: 100%;
  background: var(--tg-theme-bg-color, #0f0f10);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: .6rem;
  color: var(--tg-theme-text-color, #eaeaea);
  padding: .7rem 1rem;
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
  margin-top: .75rem;
}

.auth-input:focus {
  border-color: #fcc000;
}

.auth-hint {
  color: var(--tg-theme-hint-color, #a0a0a0);
  font-size: .88rem;
  margin-bottom: .25rem;
}

.auth-error {
  color: #f55;
  font-size: .82rem;
  min-height: 1.1rem;
  margin-top: .3rem;
}

/* ── Shared buttons ────────────────────────────────────────────────── */
.btn-primary-big {
  display: block;
  width: 100%;
  background: #fcc000;
  color: #000;
  border: none;
  border-radius: 2rem;
  padding: .75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: opacity .15s;
}

.btn-primary-big:hover { opacity: .9; }
.btn-primary-big:disabled { opacity: .5; cursor: not-allowed; }

.close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.1);
  color: var(--tg-theme-text-color, #eaeaea);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
  font-size: .9rem;
}

.close-btn:hover { background: rgba(255,255,255,.18); }

/* ── Web main button bar (replaces Telegram MainButton for non-TG users) ── */
.web-btn-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: .8rem 1rem;
  background: var(--tg-bg, #0f0f10);
  border-top: 1px solid rgba(255,255,255,.08);
  z-index: 200;
  box-shadow: 0 -4px 16px rgba(0,0,0,.25);
}

body.no-tg .web-btn-bar {
  display: flex;
  justify-content: center;
}

/* size the button — centered, reasonable on both mobile and desktop */
.web-btn-bar .btn {
  max-width: 520px;
  width: 100%;
  font-size: 1rem;
  font-weight: 600;
  border-radius: .75rem;
}

/* avoid content hiding behind the fixed bar */
body.no-tg:has(.web-btn-bar) {
  padding-bottom: 72px;
}

/* ── Light mode CSS variable overrides for web users ── */
@media (prefers-color-scheme: light) {
  body.no-tg {
    --tg-bg: #f5f5f5;
    --tg-text: #111111;
    --tg-hint: #777777;
    --tg-link: #0055cc;
    --tg-btn: #0066ff;
    --tg-btn-txt: #ffffff;
    --card-bg: #ffffff;
    --border-softer: rgba(0,0,0,.09);
    --border-soft: rgba(0,0,0,.15);
    --shadow-soft: 0 4px 16px rgba(0,0,0,.10);
    background-color: #f5f5f5;
    color: #111111;
  }

  body.no-tg .auth-sheet {
    background: #ffffff;
    border: 1px solid rgba(0,0,0,.12);
  }

  body.no-tg .auth-method-btn {
    background: #f0f0f0;
    border-color: rgba(0,0,0,.15);
    color: #111;
  }

  body.no-tg .auth-input {
    background: #ffffff;
    border-color: rgba(0,0,0,.2);
    color: #111;
  }

  body.no-tg .web-btn-bar {
    border-top-color: rgba(0,0,0,.10);
    box-shadow: 0 -4px 16px rgba(0,0,0,.08);
  }
}

/* ── Bootstrap 5.3 dark-mode fix: btn-outline-light actually appears light ────────────
   Bootstrap redefines --bs-light as a dark grey (~#3f4346) in dark mode, making
   btn-outline-light render with a dark border — invisible on a dark background.
   Override the button-level CSS vars so the outline is visibly light at all times.    */
[data-bs-theme="dark"] .btn-outline-light {
  --bs-btn-color:              #eaeaea;
  --bs-btn-border-color:       rgba(234,234,234,.6);
  --bs-btn-hover-color:        #111;
  --bs-btn-hover-bg:           #eaeaea;
  --bs-btn-hover-border-color: #eaeaea;
  --bs-btn-active-color:       #111;
  --bs-btn-active-bg:          #fff;
  --bs-btn-active-border-color:#eaeaea;
  --bs-btn-disabled-color:     rgba(234,234,234,.35);
  --bs-btn-disabled-border-color: rgba(234,234,234,.35);
  --bs-btn-focus-shadow-rgb:   234,234,234;
}

/* ── Web users: toolbar is always dark (--tg-theme-bg-color is never set for web) ── */
body.no-tg .toolbar {
  background: #16171a;
  border-bottom-color: rgba(255,255,255,.08);
}

body.no-tg #searchInput {
  background-color: #2a2d31 !important;
  border-color: rgba(255,255,255,.15) !important;
  color: #eaeaea !important;
}

body.no-tg #searchInput::placeholder {
  color: #a0a0a0;
  opacity: .9;
}

body.no-tg #cartBtn {
  border-color: rgba(255,255,255,.22) !important;
  color: #eaeaea !important;
}
