/* Platform shell layout — единственный источник правды для chrome по KickPlatform */

/* ——— Shared: app fills viewport ——— */
body.shell-telegram .app-container,
body.shell-web-mobile .app-container,
body.shell-web-desktop .app-container {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

/* ========== TELEGRAM MINI APP ========== */
body.shell-telegram #bottom-nav-component,
body.shell-telegram #bottom-nav-component .bottom-nav {
    display: flex !important;
}

body.shell-telegram .header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: auto;
    min-height: 56px;
    box-sizing: border-box;
    padding-top: var(--tg-miniapp-header-offset, 80px);
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    padding-bottom: 8px;
    z-index: var(--z-header, 100);
    overflow: visible;
}

body.shell-telegram .header .header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 64px;
}

body.shell-telegram .header .logo {
    flex: 0 0 auto;
    margin: 0;
    max-width: min(52vw, 220px);
    height: 64px;
    display: flex;
    align-items: center;
}

body.shell-telegram .header .logo-img {
    height: 64px !important;
    width: auto !important;
    max-width: min(52vw, 220px) !important;
    min-width: 0 !important;
    object-fit: contain;
    object-position: left center;
}

body.shell-telegram .header .header-center {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    justify-content: center;
}

body.shell-telegram .header .header-balance-row {
    max-width: 100%;
}

body.shell-telegram .header .balance-amount-line {
    font-size: clamp(0.75rem, 3.2vw, 0.95rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 28vw;
}

body.shell-telegram .header-deposit-btn {
    display: inline-flex !important;
    padding: 6px 10px;
    font-size: 11px;
    flex-shrink: 0;
}

body.shell-telegram .header .header-nav {
    display: none !important;
}

body.shell-telegram .main-content {
    padding-top: calc(72px + var(--tg-miniapp-header-offset, 80px) + 8px) !important;
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 10px)) !important;
    padding-left: max(0px, env(safe-area-inset-left, 0px));
    padding-right: max(0px, env(safe-area-inset-right, 0px));
    flex: 1;
    min-height: 0;
}

/* Telegram Desktop client: lift bottom-nav above Telegram chrome */
body.shell-telegram.tg-desktop .bottom-nav {
    bottom: 48px !important;
}

body.shell-telegram.tg-desktop .main-content {
    padding-bottom: calc(88px + 48px + env(safe-area-inset-bottom, 0px)) !important;
}

@media (max-width: 390px) {
    body.shell-telegram .header .logo,
    body.shell-telegram .header .logo-img {
        height: 56px !important;
        max-width: min(50vw, 190px) !important;
    }
    body.shell-telegram .header-deposit-btn {
        padding: 5px 8px;
        font-size: 10px;
    }
    body.shell-telegram .header .balance-amount-line {
        max-width: 22vw;
    }
}

/* ========== WEB MOBILE ========== */
body.shell-web-mobile #bottom-nav-component,
body.shell-web-mobile #bottom-nav-component .bottom-nav {
    display: flex !important;
}

body.shell-web-mobile .main-content {
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important;
}

body.shell-web-mobile #app-inner {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

body.shell-web-mobile #header-component {
    display: block;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: var(--z-header, 100);
}

body.shell-web-mobile .web-topbar {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 10px;
    padding: 8px 12px;
    min-height: 64px;
    padding-top: max(8px, env(safe-area-inset-top));
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    box-sizing: border-box;
}

body.shell-web-mobile .web-topbar .logo--web-topbar {
    position: relative !important;
    width: auto !important;
    min-width: 0;
    max-width: min(48vw, 200px);
    height: 48px !important;
    overflow: visible;
}

body.shell-web-mobile .web-topbar .logo--web-topbar .logo-img {
    position: static !important;
    transform: none !important;
    top: auto !important;
    left: auto !important;
    height: 48px !important;
    min-height: 40px;
    min-width: 0;
    max-width: min(48vw, 200px) !important;
    width: auto !important;
    object-fit: contain;
    object-position: left center;
}

body.shell-web-mobile .web-topbar-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

body.shell-web-mobile .web-topbar-end {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
    gap: 8px;
    min-width: 0;
}

body.shell-web-mobile .web-topbar-end .header-center--web-topbar-end {
    margin: 0;
    padding: 0;
    justify-content: flex-end;
    flex: 0 1 auto;
    min-width: 0;
}

body.shell-web-mobile .header-deposit-btn {
    display: inline-flex !important;
    padding: 6px 10px;
    font-size: 11px;
}

body.shell-web-mobile .header-web-auth {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
}

body.shell-web-mobile .header-auth-btn {
    padding: 7px 10px;
    font-size: 12px;
    white-space: nowrap;
}

body.shell-web-mobile #main-content.main-content {
    padding-top: 0 !important;
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
}

@media (max-width: 380px) {
    body.shell-web-mobile .web-topbar .logo--web-topbar,
    body.shell-web-mobile .web-topbar .logo--web-topbar .logo-img {
        max-width: min(36vw, 120px) !important;
        height: 40px !important;
    }
    body.shell-web-mobile .header-auth-btn {
        padding: 6px 8px;
        font-size: 11px;
    }
}

/* ========== WEB DESKTOP ========== */
body.shell-web-desktop #bottom-nav-component,
body.shell-web-desktop #bottom-nav-component .bottom-nav {
    display: none !important;
}

body.shell-web-desktop #main-content.main-content {
    padding-bottom: 48px !important;
    overflow-x: hidden;
}

/* Page content: avoid horizontal overflow on all shells */
body.shell-telegram .main-content,
body.shell-web-mobile .main-content,
body.shell-web-desktop .main-content {
    max-width: 100%;
}

body.shell-telegram .slots-page,
body.shell-web-mobile .slots-page,
body.shell-telegram .profile-page,
body.shell-web-mobile .profile-page {
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    box-sizing: border-box;
}

/* Connection warning under TG header */
body.shell-telegram .connection-warning {
    top: calc(var(--tg-miniapp-header-offset, 80px) + 56px + 8px);
}

/* Preload / auth-gate: всегда по центру; form не занимает место рядом с loading */
body.shell-telegram .auth-gate,
body.shell-web-mobile .auth-gate,
body.shell-web-desktop .auth-gate,
body.tg-miniapp .auth-gate,
body.web-browser .auth-gate {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
body.shell-telegram .auth-gate.auth-gate--active,
body.shell-web-mobile .auth-gate.auth-gate--active,
body.shell-web-desktop .auth-gate.auth-gate--active,
body.tg-miniapp .auth-gate.auth-gate--active,
body.web-browser .auth-gate.auth-gate--active {
    display: flex !important;
}
body.shell-telegram .auth-gate-form[aria-hidden="true"],
body.shell-web-mobile .auth-gate-form[aria-hidden="true"],
body.shell-web-desktop .auth-gate-form[aria-hidden="true"],
body.tg-miniapp .auth-gate-form[aria-hidden="true"],
body.web-browser .auth-gate-form[aria-hidden="true"] {
    display: none !important;
}
body.shell-telegram .auth-gate-loading,
body.shell-web-mobile .auth-gate-loading,
body.shell-web-desktop .auth-gate-loading {
    margin-left: auto;
    margin-right: auto;
    align-items: center;
    text-align: center;
}
body.shell-telegram .auth-gate-loading__brand,
body.shell-web-mobile .auth-gate-loading__brand,
body.shell-web-desktop .auth-gate-loading__brand {
    width: 100%;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}
