/* =============================================================================
   AMATIC TABBAR — classic (casino/default) + trading layout
   ============================================================================= */

:root {
    --tabbar-height: 70px;
    --tabbar-hex-size: 100px;
    --tabbar-hex-rise: 40px;
    --tabbar-hex-bottom: 10px;
    --tabbar-bar-bg: #071827;
    --tabbar-trading-top: #33d6ff;
    --tabbar-trading-bottom: #0086d1;
    --tabbar-badge-teal: #009688;
    --tabbar-z: 2147483647;
    --tabbar-content-offset: 110px;
}

/* --- Bottom dock nav: permanently viewport-pinned (all browsers) --- */
.amatic-dock-nav,
.bottom-nav,
[data-tabbar-shell] {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    z-index: 2147483647 !important;
    margin: 0 !important;
    box-sizing: border-box;
    height: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px));
    overflow: visible;
    background-color: var(--tabbar-bar-bg);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.45);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: none !important;
    -webkit-transform: none !important;
    will-change: auto !important;
    pointer-events: auto;
}

html.has-tabbar {
    height: -webkit-fill-available;
}

html.has-tabbar,
body.has-tabbar {
    padding-bottom: 110px !important;
}

/* Escape flex/100vh scroll bugs that break position:fixed on mobile WebKit */
body.has-tabbar {
    display: block !important;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
}

/* --- Classic layout (original pre–Trading redesign) --- */
body.tabbar-layout-classic {
    --tabbar-height: 60px;
    --tabbar-z: 2147483647;
    --tabbar-center-size: clamp(52px, 13vw, 54px);
    --tabbar-center-icon-size: calc(var(--tabbar-center-size) * 0.65);
}

body.tabbar-layout-classic .tabbar-wrap {
    display: none !important;
}

body.tabbar-layout-classic .tabbar--classic {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    margin: 0;
    box-sizing: border-box;
    height: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px));
    background: #1a2c38;
    border-top: 1px solid #2f4553;
    display: none;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0 env(safe-area-inset-bottom, 0px);
    z-index: var(--tabbar-z);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    transform: none;
    -webkit-transform: none;
}

body.tabbar-layout-classic .tabbar--classic .tabbar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 6px;
    color: #b1bad3;
    text-decoration: none;
    border: none;
    background: transparent;
    cursor: pointer;
    position: relative;
    font-family: inherit;
    min-width: 0;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s;
}

body.tabbar-layout-classic .tabbar--classic .tabbar-item i {
    font-size: 20px;
    transition: transform 0.2s;
}

body.tabbar-layout-classic .tabbar--classic .tabbar-item span {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

body.tabbar-layout-classic .tabbar--classic .tabbar-item:hover,
body.tabbar-layout-classic .tabbar--classic .tabbar-item.active {
    color: var(--tabbar-item-active, var(--accent-green, #fc8c03));
}

body.tabbar-layout-classic .tabbar--classic .tabbar-item.active i {
    transform: scale(1.1);
}

body.tabbar-layout-classic .tabbar-trading-icon {
    display: block;
    width: 20px;
    height: 20px;
    opacity: 0.85;
    transition: transform 0.2s, opacity 0.2s;
}

body.tabbar-layout-classic .tabbar--classic .tabbar-item.active .tabbar-trading-icon {
    transform: scale(1.1);
    opacity: 1;
}

body.tabbar-layout-classic .tabbar--classic .chat-badge {
    position: absolute;
    top: 4px;
    right: 50%;
    transform: translateX(12px);
    background: #ff4454;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

/* --- Unified dock nav — fixed on all viewports --- */
body.tabbar-unified-nav {
    --tabbar-height: 70px;
    --tabbar-hex-size: 100px;
    --tabbar-hex-rise: 40px;
    --tabbar-hex-bottom: 10px;
    --tabbar-bar-bg: #071827;
    --tabbar-trading-top: #33d6ff;
    --tabbar-trading-bottom: #0086d1;
    --tabbar-badge-teal: #009688;
    --tabbar-z: 2147483647;
    --tabbar-content-offset: calc(
        var(--tabbar-height) + var(--tabbar-hex-rise) + env(safe-area-inset-bottom, 0px)
    );
}

body.tabbar-unified-nav .amatic-dock-nav__bar,
.amatic-dock-nav__bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: env(safe-area-inset-bottom, 0px);
    height: var(--tabbar-height);
    pointer-events: none;
    z-index: 0;
}

body.tabbar-unified-nav .amatic-dock-nav__shape,
.amatic-dock-nav__shape {
    display: block;
    width: 100%;
    height: 100%;
}

body.tabbar-unified-nav .amatic-dock-nav__items,
.amatic-dock-nav__items {
    position: absolute;
    left: 0;
    right: 0;
    bottom: env(safe-area-inset-bottom, 0px);
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: end;
    width: 100%;
    height: var(--tabbar-height);
    padding: 0 4px 10px;
    margin: 0;
    pointer-events: auto;
    box-sizing: border-box;
}

body.tabbar-unified-nav .amatic-dock-nav__link,
.amatic-dock-nav__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    min-width: 0;
    height: 100%;
    padding: 0 2px;
    color: #8fa3b8;
    text-decoration: none;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s ease, transform 0.18s ease;
}

body.tabbar-unified-nav .amatic-dock-nav__link.is-disabled {
    opacity: 0.35;
    pointer-events: none;
}

body.tabbar-unified-nav .amatic-dock-nav__icon {
    font-size: 20px;
    line-height: 1;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

body.tabbar-unified-nav .amatic-dock-nav__text {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.35px;
    line-height: 1;
    white-space: nowrap;
    flex-shrink: 0;
}

body.tabbar-unified-nav .amatic-dock-nav__link.is-active {
    color: var(--tabbar-item-active, var(--accent-green, #fc8c03));
}

body.tabbar-unified-nav .amatic-dock-nav__link.is-active .amatic-dock-nav__icon {
    transform: scale(1.05);
}

body.tabbar-unified-nav .amatic-dock-nav__link.is-pressed {
    transform: scale(0.94);
}

body.tabbar-unified-nav .amatic-dock-nav__link--trading {
    position: relative;
    overflow: visible;
    justify-content: flex-end;
    gap: 4px;
    z-index: 2;
}

body.tabbar-unified-nav .amatic-dock-nav__trading-fab {
    position: static;
    display: block;
    width: 100%;
    height: 24px;
    flex-shrink: 0;
    pointer-events: none;
}

body.tabbar-unified-nav .amatic-dock-nav__trading-fab--empty {
    visibility: hidden;
}

body.tabbar-unified-nav .amatic-dock-nav__badge {
    position: absolute;
    left: 50%;
    bottom: var(--tabbar-hex-bottom);
    width: var(--tabbar-hex-size);
    height: var(--tabbar-hex-size);
    transform: translateX(-50%);
    display: block;
    object-fit: contain;
    pointer-events: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
    z-index: 3;
}

body.tabbar-unified-nav .amatic-dock-nav__text--trading {
    color: var(--tabbar-trading-top);
    margin-top: 0;
    position: relative;
    z-index: 4;
    flex-shrink: 0;
}

body.tabbar-unified-nav .amatic-dock-nav__link--trading.is-active .amatic-dock-nav__text--trading {
    color: var(--tabbar-trading-top);
}

body.tabbar-unified-nav .amatic-dock-nav__link--trading.is-pressed,
body.tabbar-unified-nav .amatic-dock-nav__link--trading:active {
    transform: none;
}

body.tabbar-unified-nav .amatic-dock-nav__link--trading.is-pressed .amatic-dock-nav__badge,
body.tabbar-unified-nav .amatic-dock-nav__link--trading:active .amatic-dock-nav__badge {
    transform: translateX(-50%) scale(0.97);
    opacity: 0.92;
}

html.has-tabbar .site-footer,
body.has-tabbar .site-footer,
body:has(.amatic-dock-nav) .site-footer {
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
}

body.tabbar-unified-nav .sb-betslip-mobile-bar {
    bottom: calc(var(--tabbar-height) + var(--tabbar-hex-rise) + 10px + env(safe-area-inset-bottom, 0px)) !important;
    z-index: calc(var(--tabbar-z) - 1) !important;
}

@media (max-width: 768px) {
    body.tabbar-layout-classic .tabbar--classic {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        justify-items: center;
        align-items: center;
        overflow: visible;
    }

    body.tabbar-layout-classic .tabbar--classic.tabbar-items-3 {
        grid-template-columns: repeat(3, 1fr);
    }

    body.tabbar-layout-classic .tabbar--classic .tabbar-item {
        flex: unset;
        width: 100%;
        max-width: 100%;
    }

    body.tabbar-layout-classic.has-tabbar:not(.tabbar-unified-nav) {
        padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px)) !important;
    }

    body.tabbar-layout-classic .tabbar-center-trading {
        grid-column: 3;
        grid-row: 1;
        position: relative;
        justify-self: center;
        align-self: end;
        width: var(--tabbar-center-size);
        height: var(--tabbar-center-size);
        margin: 0 0 6px;
        transform: translateY(-13px);
        padding: 0;
        text-decoration: none;
        background: transparent;
        border: none;
        cursor: pointer;
        z-index: calc(var(--tabbar-z) + 2);
        display: flex;
        align-items: center;
        justify-content: center;
        -webkit-tap-highlight-color: transparent;
    }

    body.tabbar-layout-classic .tabbar-center-trading__hex {
        position: relative;
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        clip-path: polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%);
        background: var(--tabbar-item-active, var(--accent-green, #fc8c03));
        border: 1.5px solid rgba(255, 255, 255, 0.14);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
        transition: filter 0.2s ease, transform 0.15s ease;
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }

    body.tabbar-layout-classic .tabbar-center-trading .tabbar-icon--beepay-center,
    body.tabbar-layout-classic .tabbar-center-trading .tabbar-icon--bitcoin-center {
        position: relative;
        z-index: 1;
        width: var(--tabbar-center-icon-size);
        height: var(--tabbar-center-icon-size);
        display: block;
        flex-shrink: 0;
        color: #fff;
        shape-rendering: geometricPrecision;
    }

    body.tabbar-layout-classic .tabbar-center-trading:hover .tabbar-center-trading__hex {
        filter: brightness(1.08);
    }

    body.tabbar-layout-classic .tabbar-center-trading:active .tabbar-center-trading__hex {
        transform: scale(0.97);
    }

    body.tabbar-layout-classic .tabbar-center-trading.active .tabbar-center-trading__hex {
        filter: brightness(1.05);
    }
}

@media (max-width: 412px) {
    body.tabbar-unified-nav .amatic-dock-nav__text {
        font-size: 9px;
    }
}

@media (max-width: 360px) {
    body.tabbar-unified-nav .amatic-dock-nav__icon {
        font-size: 18px;
    }
    body.tabbar-unified-nav {
        --tabbar-hex-size: 94px;
        --tabbar-hex-rise: 36px;
        --tabbar-hex-bottom: 8px;
    }
}

@media (max-width: 320px) {
    body.tabbar-unified-nav .amatic-dock-nav__items {
        padding: 0 2px 10px;
    }
    body.tabbar-unified-nav .amatic-dock-nav__text {
        font-size: 8px;
    }
}

@media (max-width: 400px) {
    body.tabbar-layout-classic:not(.tabbar-unified-nav) .tabbar--classic .tabbar-item i {
        font-size: 17px;
    }
    body.tabbar-layout-classic:not(.tabbar-unified-nav) .tabbar--classic .tabbar-item span {
        font-size: 9px;
    }
    body.tabbar-layout-classic:not(.tabbar-unified-nav) {
        --tabbar-height: 56px;
    }
}

@media (min-width: 769px) {
    /* Desktop: hide mobile dock — use top header + section nav instead */
    body.tabbar-unified-nav .amatic-dock-nav,
    body.tabbar-unified-nav .bottom-nav,
    body.tabbar-unified-nav [data-tabbar-shell] {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
        opacity: 0 !important;
    }

    html.has-tabbar,
    body.has-tabbar,
    body.tabbar-unified-nav.has-tabbar {
        padding-bottom: 0 !important;
    }

    body.tabbar-unified-nav .sb-betslip-mobile-bar {
        bottom: 16px !important;
    }

    body.tabbar-layout-classic .tabbar--classic {
        display: none !important;
    }

    body.tabbar-layout-classic.has-tabbar:not(.tabbar-unified-nav) {
        padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* Casino page: modal above nav (padding handled by unified-nav rules) */
body.tabbar-casino-page.has-tabbar:not(.tabbar-unified-nav) {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
}

body.tabbar-casino-page .game-modal.active {
    z-index: 100010 !important;
    align-items: stretch !important;
    justify-content: stretch !important;
}

body.tabbar-casino-page .game-modal.active .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
}

body.tabbar-casino-page .game-modal.active .game-iframe {
    height: calc(100% - 60px) !important;
    height: calc(100dvh - 60px) !important;
}

body.tabbar-casino-page .error-modal.active {
    z-index: 100011 !important;
}

body.tabbar-casino-page.game-modal-open .tabbar--classic,
body.tabbar-casino-page.game-modal-open .amatic-dock-nav,
body.tabbar-casino-page.game-modal-open .tabbar-wrap {
    display: none !important;
    pointer-events: none !important;
}

/* --- Trading layout (floating bar with featured center) --- */
body.tabbar-layout-trading {
    --tabbar-height: 76px;
    --tabbar-featured-size: 56px;
    --tabbar-featured-total: 92px;
    --tabbar-radius: 24px;
    --tabbar-offset-bottom: 12px;
    --tabbar-offset-x: 12px;
    --tabbar-z: 2147483647;
    --tabbar-bg: rgba(26, 44, 56, 0.88);
    --tabbar-border: rgba(47, 69, 83, 0.55);
    --tabbar-item-active: var(--accent-green, #fc8c03);
    --tabbar-item-inactive: #b1bad3;
    --tabbar-glow: rgba(var(--accent-rgb, 252, 140, 3), 0.35);
    --tabbar-content-pad: calc(
        var(--tabbar-offset-bottom) + var(--tabbar-height) + 24px + env(safe-area-inset-bottom, 0px)
    );
    --tabbar-float-offset: calc(
        var(--tabbar-offset-bottom) + var(--tabbar-height) + 16px + env(safe-area-inset-bottom, 0px)
    );
}

body.tabbar-layout-trading .tabbar--classic {
    display: none !important;
}

body.tabbar-layout-trading .tabbar-wrap {
    position: fixed;
    bottom: var(--tabbar-offset-bottom);
    left: var(--tabbar-offset-x);
    right: var(--tabbar-offset-x);
    z-index: var(--tabbar-z);
    pointer-events: none;
    display: none;
    box-sizing: border-box;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: none;
    -webkit-transform: none;
}

body.tabbar-layout-trading .tabbar {
    position: relative;
    pointer-events: auto;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    height: var(--tabbar-height);
    background: var(--tabbar-bg);
    border: 1px solid var(--tabbar-border);
    border-radius: var(--tabbar-radius);
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.55),
        0 4px 16px rgba(0, 0, 0, 0.35),
        0 0 32px var(--tabbar-glow),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    overflow: visible;
}

body.tabbar-layout-trading .tabbar-group {
    display: flex;
    align-items: flex-end;
    justify-content: space-evenly;
    flex: 1;
    min-width: 0;
}

body.tabbar-layout-trading .tabbar-group--center {
    flex: 0 0 auto;
    position: relative;
    z-index: 2;
    padding: 0 2px;
}

body.tabbar-layout-trading .tabbar-indicator {
    position: absolute;
    bottom: 10px;
    height: 3px;
    border-radius: 999px;
    background: var(--tabbar-item-active);
    box-shadow: 0 0 10px var(--tabbar-glow), 0 0 4px var(--tabbar-item-active);
    width: 28px;
    left: 0;
    opacity: 0;
    transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1), width 0.28s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
    pointer-events: none;
    z-index: 3;
}

body.tabbar-layout-trading .tabbar-indicator.is-visible {
    opacity: 1;
}

body.tabbar-layout-trading .tabbar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    padding: 10px 4px 12px;
    color: var(--tabbar-item-inactive);
    text-decoration: none;
    border: none;
    background: transparent;
    cursor: pointer;
    min-width: 0;
    opacity: 0.55;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.25s ease, opacity 0.25s ease, transform 0.25s ease;
    position: relative;
}

body.tabbar-layout-trading .tabbar-item:hover {
    color: #fff;
    opacity: 0.85;
}

body.tabbar-layout-trading .tabbar-item.active {
    color: var(--tabbar-item-active);
    opacity: 1;
}

body.tabbar-layout-trading .tabbar-icon {
    width: 22px;
    height: 22px;
    display: block;
    transition: transform 0.25s ease, filter 0.25s ease;
}

body.tabbar-layout-trading .tabbar-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

body.tabbar-layout-trading .tabbar-item--featured {
    flex: 0 0 auto;
    opacity: 1;
    padding: 0 6px 8px;
    margin-top: -20px;
    min-width: 72px;
    min-height: var(--tabbar-featured-total);
    justify-content: flex-end;
}

body.tabbar-layout-trading .tabbar-featured-shell {
    position: relative;
    width: var(--tabbar-featured-size);
    height: var(--tabbar-featured-size);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, rgba(var(--accent-rgb, 252, 140, 3), 0.28), rgba(15, 33, 46, 0.95));
    clip-path: polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%);
    box-shadow: 0 0 24px var(--tabbar-glow), 0 6px 20px rgba(0, 0, 0, 0.4);
}

body.tabbar-layout-trading .tabbar-featured-glow {
    position: absolute;
    inset: -6px;
    clip-path: polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%);
    background: radial-gradient(circle at 50% 40%, rgba(var(--accent-rgb, 252, 140, 3), 0.5), transparent 70%);
    opacity: 0.85;
    pointer-events: none;
}

body.tabbar-layout-trading .tabbar-item--featured .tabbar-icon {
    width: 26px;
    height: 26px;
    color: #fff;
    position: relative;
    z-index: 1;
}

body.tabbar-layout-trading .chat-badge {
    position: absolute;
    top: 4px;
    right: 50%;
    transform: translateX(14px);
    background: #ff4454;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
    z-index: 4;
}

body.tabbar-layout-trading .tabbar-wrap {
    display: block;
}

body.tabbar-layout-trading.has-tabbar {
    padding-bottom: var(--tabbar-content-pad) !important;
}

body.tabbar-layout-trading.has-tabbar .trading-watchlist-fab {
    bottom: var(--tabbar-float-offset) !important;
}

body.tabbar-layout-trading.has-tabbar .trading-toast {
    bottom: calc(var(--tabbar-float-offset) + 8px) !important;
}

body.tabbar-layout-trading.has-tabbar .toast-notification.show {
    bottom: var(--tabbar-float-offset) !important;
}
