/* Telegram Mini App: компактная оболочка поверх страниц сайта (body.tma-mode) */

body.tma-mode {
    background: var(--bg-light);
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

/* ---------- Верхняя панель ---------- */
.tma-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--nav);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--c-line);
}
.tma-topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    color: var(--c-ink);
    text-decoration: none;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 0.95rem;
    line-height: 1.1;
}
.tma-topbar-brand img {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--c-lav-soft);
    padding: 3px;
}
.tma-topbar-brand small {
    display: block;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--c-lav);
}
.tma-topbar-search {
    position: relative;
    flex: 1;
    min-width: 0;
}
.tma-topbar-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--c-ink-3);
    font-size: 0.85rem;
}
.tma-topbar-search input {
    width: 100%;
    height: 38px;
    padding: 0 12px 0 34px;
    border-radius: 999px;
    border: 1.5px solid var(--c-line-strong);
    background: var(--c-surface);
    color: var(--c-ink);
    font-size: 0.88rem;
}
.tma-topbar-search input::placeholder {
    color: var(--c-ink-3);
}
.tma-topbar-search input:focus {
    outline: none;
    border-color: var(--c-lav);
    box-shadow: var(--focus-ring);
}

/* ---------- Нижнее меню ---------- */
.tma-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1040;
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--nav);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--c-line);
}
.tma-nav-item {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 0;
    border: 0;
    background: none;
    color: var(--c-ink-3);
    text-decoration: none;
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 600;
}
.tma-nav-item i {
    font-size: 1.25rem;
}
.tma-nav-item i {
    transition: transform 0.25s var(--ease-spring);
}
.tma-nav-item.active,
.tma-nav-item:active {
    color: var(--c-lav-strong);
}
.tma-nav-item:active i {
    transform: scale(0.88);
}
.tma-nav-badge {
    position: absolute;
    top: 0;
    left: 50%;
    margin-left: 6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--c-peach);
    color: var(--c-peach-ink);
    font-size: 0.65rem;
    font-weight: 800;
    line-height: 18px;
    text-align: center;
}

/* ---------- Компактный подвал мобильной версии ---------- */
/* Место под фиксированное нижнее меню уже зарезервировано padding-bottom у body.tma-mode,
   поэтому подвал не перекрывается полосой навигации. */
.tma-footer {
    margin-top: 24px;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    background: var(--bg-deep);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}
.tma-footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 16px;
    margin-bottom: 8px;
}
.tma-footer-links a {
    color: #e2e8f0;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: underline;
}
.tma-footer-links a:active {
    color: var(--c-lav-mid);
}
.tma-footer-legal {
    color: #b9b4d0;
    font-size: 0.72rem;
}

/* ---------- Чат поддержки над нижним меню ---------- */
body.tma-mode .floating-assistant-pill {
    display: none !important;
}
body.tma-mode .floating-assistant-btn {
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: 14px;
    width: 46px;
    height: 46px;
}
body.tma-mode #liveSupportMessenger {
    bottom: calc(136px + env(safe-area-inset-bottom)) !important;
    max-height: calc(100vh - 210px) !important;
}

/* Страницы сайта внутри Mini App: без лишних внешних отступов */
body.tma-mode main > section:first-child,
body.tma-mode main > .container:first-child {
    padding-top: 16px;
}

/* ---------- Витрина /tma/ ---------- */
.tma-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px 12px 8px;
}
.tma-header-card {
    position: relative;
    overflow: hidden;
    padding: 22px 18px;
    border-radius: 24px;
    background: radial-gradient(ellipse at 85% 0%, rgba(124, 58, 237, 0.35) 0%, transparent 55%),
                linear-gradient(160deg, #1e1b4b 0%, var(--bg-deep) 70%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    box-shadow: 0 16px 36px -12px rgba(15, 23, 42, 0.45);
}
.tma-header-card h1 {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 1.55rem;
    line-height: 1.15;
    margin: 12px 0 8px;
}
.tma-header-card h1 .accent-gradient {
    background: linear-gradient(90deg, #5eead4 0%, #38bdf8 60%, #60a5fa 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.tma-header-card p {
    font-size: 0.82rem;
    color: #cbd5e1;
    margin-bottom: 16px;
}
.tma-location-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.7rem;
    font-weight: 600;
    color: #e2e8f0;
}
.tma-location-badge::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--brand-success);
}
.tma-greeting {
    position: absolute;
    top: 18px;
    right: 16px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #e2e8f0;
}
.tma-hero-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.tma-hero-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 44px;
    border-radius: 14px;
    font-size: 0.82rem;
    font-weight: 700;
    text-decoration: none;
    color: #ffffff;
}
.tma-hero-btn.is-primary {
    background: var(--brand-primary);
}
.tma-hero-btn.is-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.tma-section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 22px 0 12px;
}
.tma-section-title h2 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 800;
    margin: 0;
    color: var(--text-strong);
}
.tma-section-title a {
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
}

.tma-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    margin: 0 -12px;
    padding: 0 12px 4px;
    scrollbar-width: none;
}
.tma-chips::-webkit-scrollbar {
    display: none;
}
.tma-chip {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--surface-solid);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
.tma-chip i {
    color: var(--brand-primary);
}
.tma-chip small {
    color: var(--text-muted);
    font-weight: 500;
}

.tma-cart-card {
    margin-top: 16px;
    padding: 14px;
    border-radius: 18px;
    background: var(--surface-solid);
    border: 1px solid var(--border);
}

.tma-product-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border-radius: 18px;
    background: var(--surface-solid);
    border: 1px solid var(--border);
}
.tma-product-thumb {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 140px;
    background: var(--bg-light);
}
.tma-product-thumb img {
    max-width: 100%;
    max-height: 132px;
    object-fit: contain;
}
.tma-product-thumb .badge {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 0.62rem;
}
.tma-product-body {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding: 10px 12px 12px;
}
.tma-product-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.4em;
    margin-bottom: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-strong);
    text-decoration: none;
}
.tma-product-status {
    font-size: 0.68rem;
    font-weight: 600;
}
.tma-product-status.is-in-stock { color: var(--brand-success); }
.tma-product-status.is-made-to-order { color: var(--brand-accent-amber); }
.tma-product-status.is-out { color: var(--text-muted); }
.tma-product-price {
    font-size: 0.98rem;
    font-weight: 800;
    color: var(--text-strong);
}
.tma-product-opt {
    font-size: 0.68rem;
    color: var(--text-muted);
}
.tma-add-btn {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 0;
    background: var(--brand-primary);
    color: #ffffff;
    font-size: 1.1rem;
}
.tma-add-btn:disabled {
    background: var(--border);
    color: var(--text-muted);
}

.tma-full-site-link {
    display: block;
    margin: 24px 0 8px;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Каталог внутри Mini App: короткая шапка, без хлебных крошек (есть кнопка «Назад» Telegram) */
body.tma-mode .breadcrumb {
    display: none;
}
body.tma-mode .catalog-intro {
    padding: 16px !important;
    margin-bottom: 12px !important;
}
body.tma-mode .catalog-intro h1 {
    font-size: 1.35rem;
    margin-bottom: 0 !important;
}
body.tma-mode .catalog-intro p {
    display: none;
}

/* Первый экран на телефоне: одна главная кнопка (каталог есть в нижнем меню), товар виден сразу */
body.tma-mode .hero .btn-hero.is-ghost {
    display: none;
}
@media (max-width: 575.98px) {
    .hero .btn-hero.is-ghost { display: none; }
}
