/* ============================================================
   Stage 3.1 — app shell: blue palette, header, bottom bar (phone) /
   top nav (desktop). Loaded only when UI_V3_SHELL is on (html.ui3).
   Every class is prefixed `s3-`.
   ============================================================ */

/* ---- Blue: the new default style (dark + light). Mint/Lime/Violet stay. ---- */
:root[data-accent="blue"] {
  --bg: #0D1117; --bg-elevated: #151A22; --card: #1A2029; --card-border: #283040;
  --text: #EDEFF3; --text-dim: #8E97A6; --accent: #6B9BF2; --accent-dim: #2F5BB7;
  --warn: #FF8A5B; --chip: #222A35; --btn-text: #0A1430; --bg-gradient-start: #141C2B;
  --header-bg: rgba(13,17,23,0.88); --accent-rgb: 107,155,242;
}
:root[data-theme="light"][data-accent="blue"] {
  --bg: #F2F4F8; --bg-elevated: #FFFFFF; --card: #FFFFFF; --card-border: #E6E9F0;
  --text: #0F172A; --text-dim: #5B6475; --accent: #2563EB; --accent-dim: #3B82F6;
  --warn: #EA580C; --chip: #EEF1F6; --btn-text: #FFFFFF; --bg-gradient-start: #E6ECF7;
  --header-bg: rgba(255,255,255,0.9); --modal-overlay: rgba(15,23,42,0.4); --close-bg: rgba(0,0,0,0.06);
  --accent-rgb: 37,99,235;
}

/* ---- header ---- */
html.ui3 body { font-family: 'Manrope', system-ui, sans-serif; }
html.ui3 header { background: var(--header-bg); }
.s3-head { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 14px; }
.s3-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-width: 0; background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; text-align: left; }
/* Brand (28.11.2026 logo): the store icon in an accent-coloured tile — the
   tile follows the user's accent colour; the icon is a white mask. */
.s3-mark { width: 38px; height: 38px; border-radius: 11px; background: var(--accent); flex: none; position: relative; }
.s3-mark::before { content: ''; position: absolute; inset: 6px 7px; background: #fff;
  -webkit-mask: url('../brand/probazar-mark.png') center / contain no-repeat; mask: url('../brand/probazar-mark.png') center / contain no-repeat; }
/* the "ProBazar" lettering from the logo (desktop), recoloured to the theme's text colour */
.s3-word { display: none; width: 118px; height: 21px; flex: none; background: var(--text);
  -webkit-mask: url('../brand/probazar-wordtext.png') left center / contain no-repeat; mask: url('../brand/probazar-wordtext.png') left center / contain no-repeat; }
.s3-brand-t { min-width: 0; }
.s3-brand b { display: block; font: 800 17px/21px 'Manrope', sans-serif; }
.s3-brand small { display: block; font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s3-topnav { display: none; gap: 4px; margin-left: auto; }
.s3-head-r { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.s3-topnav + .s3-head-r { margin-left: 8px; }
html.ui3 .theme-toggle { width: 40px; height: 40px; }
/* the panel button (staff bag / superadmin crown) moved into the header */
html.ui3 #shopPanelBtn.s3-icon { width: 40px; height: 40px; padding: 0; border-radius: 12px; border: 1px solid var(--card-border);
  background: var(--card); color: var(--text); align-items: center; justify-content: center; cursor: pointer; flex: none; }
html.ui3 #myProfileBtn { display: none !important; }   /* kept only for forum.js; the Profil tab triggers it */

/* Telegram mobile: its Back / chevron / "..." buttons sit in the top corners,
   so the row is centred between them (same rule as the old header). */
html.ui3.tg-mobile .s3-head { justify-content: center; padding: 0 56px; }
html.ui3.tg-mobile .s3-head-r { margin-left: 0; }
html.ui3.tg-mobile .s3-brand small { display: none; }

/* ---- tabs: bottom bar on phones, top nav on desktop ---- */
.s3-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none;
  color: var(--text-dim); font: 600 11px 'Manrope', sans-serif; cursor: pointer; position: relative; -webkit-tap-highlight-color: transparent; min-height: 44px; }
.s3-tab.is-on { color: var(--accent); font-weight: 800; }
.s3-tab svg { width: 23px; height: 23px; }
.s3-dot { position: absolute; top: 6px; left: calc(50% + 7px); width: 9px; height: 9px; border-radius: 5px; background: #DC2626; border: 2px solid var(--bg-elevated); display: none; }
.s3-tab.has-dot .s3-dot { display: block; }
.s3-bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--bg-elevated); border-top: 1px solid var(--card-border);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0px) + var(--tg-safe-area-inset-bottom, 0px)); }
html.ui3 body { padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px) + var(--tg-safe-area-inset-bottom, 0px)); }
html.ui3 body.s3-typing .s3-bottom { display: none; }     /* keyboard open: never cover the input */
html.ui3 body.s3-typing { padding-bottom: 0; }
/* things that sat on the bottom edge move above the bar */
html.ui3 .forum-fab-wrap { bottom: calc(80px + env(safe-area-inset-bottom, 0px) + var(--tg-safe-area-inset-bottom, 0px)); }
html.ui3 body.s3-typing .forum-fab-wrap { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
html.ui3 #marketToast, html.ui3 .forum-toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important; }

@media (min-width: 900px) {
  .s3-bottom { display: none; }
  html.ui3 body { padding-bottom: 0; }
  html.ui3 .forum-fab-wrap { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  html.ui3 #marketToast, html.ui3 .forum-toast { bottom: 24px !important; }
  .s3-topnav { display: flex; }
  /* desktop: a 20% bigger tile + the logo lettering, then the shop counts after a thin divider */
  html.ui3 .s3-brand .s3-brand-t b { display: none; }
  html.ui3 .s3-brand .s3-mark { width: 46px; height: 46px; border-radius: 13px; }
  html.ui3 .s3-brand .s3-mark::before { inset: 7px 8.5px; }
  html.ui3 .s3-brand .s3-word { display: block; }
  html.ui3 .s3-brand { gap: 12px; }
  html.ui3 .s3-brand .s3-brand-t { margin-left: 4px; padding-left: 14px; border-left: 1px solid var(--card-border); }
  .s3-topnav .s3-tab { flex-direction: row; gap: 8px; height: 40px; min-height: 40px; padding: 0 14px; border-radius: 10px; font-size: 14px; font-weight: 700; color: var(--text); }
  .s3-topnav .s3-tab svg { width: 18px; height: 18px; }
  .s3-topnav .s3-tab:hover { background: var(--chip); }
  .s3-topnav .s3-tab.is-on { background: rgba(var(--accent-rgb), .12); color: var(--accent); }
  .s3-topnav .s3-dot { top: 6px; left: auto; right: 6px; }
}

/* the old top tab row is replaced by the bottom bar */
html.ui3 .view-switcher { display: none !important; }
html.ui3 .hero { display: none; }

/* The old header always reserved Telegram's 56px top band, even in a desktop
   browser or Telegram Desktop, where nothing is drawn over the page. Only the
   mobile Mini App (html.tg-mobile) needs the notch + Telegram button clearance. */
html.ui3:not(.tg-mobile) header { padding: 14px 20px; }

/* ---- 3.1 fix: Telegram fullscreen top band (reported on iPhone) ----
   The old header deliberately sat INSIDE Telegram's button row, centred
   between Close and the chevron/"..." cluster. With the theme toggle and the
   panel button that row no longer fits, and forum.js read Telegram's
   content inset before fullscreen was applied (it listened to
   viewportChanged, not contentSafeAreaChanged), so the value was a stale 0.
   Now: shell.js keeps --s3-safe-top / --s3-content-top live from the SDK and
   the header starts BELOW both the notch and Telegram's row. */
html.ui3.tg-mobile header {
  padding: calc(8px + max(env(safe-area-inset-top, 0px), var(--s3-safe-top, 0px)) + var(--s3-content-top, 46px)) 16px 10px;
}
html.ui3.tg-mobile .s3-head { justify-content: flex-start; padding: 0; }
html.ui3.tg-mobile .s3-head-r { margin-left: auto; }
html.ui3.tg-mobile .s3-brand small { display: block; }

/* ---- Profil opens as a full page, not a pop-up sheet ----
   Same #meOverlay / #meStack (all profile screens keep working); it fills the
   screen, the bottom bar stays on top of it with Profil active, and any tab
   closes it. On desktop it starts under the header and is centred. */
html.ui3 #meOverlay { z-index: 85; background: var(--bg); backdrop-filter: none; align-items: stretch; justify-content: center; padding: 0; }
html.ui3 #meOverlay > .modal { max-width: 760px; width: 100%; height: 100%; max-height: none; border-radius: 0; animation: none;
  background: var(--bg); box-shadow: none; }
html.ui3 #meCloseBtn { display: none; }
html.ui3 #meStack { padding-top: 16px; padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px) + var(--tg-safe-area-inset-bottom, 0px)); }
html.ui3.tg-mobile #meStack { padding-top: calc(14px + max(env(safe-area-inset-top, 0px), var(--s3-safe-top, 0px)) + var(--s3-content-top, 46px)); }
@media (min-width: 900px) {
  html.ui3 #meOverlay { top: var(--s3-head-h, 69px); }
  html.ui3 #meStack { padding: 24px 24px 32px; }
}
/* Kuzatuv: the catalogue's "no phones for this brand" line is not meant for
   an empty saved list (Stage 3.3 gives Kuzatuv its own screen). */
html.ui3 body.s3-watch #empty { display: none !important; }
/* big brand tile (login pop-up) */
.s3-mark.is-lg { display: block; width: 64px; height: 64px; border-radius: 19px; margin: 2px auto 12px; }
.s3-mark.is-lg::before { inset: 11px 12px; }
.forum-prompt-card.is-login h3 { text-align: center; }
