/* Mobile Chart Overrides - iOS Safari Bottom Bar Fix */

/* iOS Safari bottom safe area fix */
@media (max-width: 767px) {

    /* Add padding to body for iOS home indicator and Safari toolbar */
    html {
        height: 100%;
        height: -webkit-fill-available;
    }

    body {
        min-height: 100%;
        min-height: -webkit-fill-available;
        /* Critical: Add bottom padding for Safari navigation bar */
        padding-bottom: env(safe-area-inset-bottom, 20px) !important;
    }

    /* Main app container - leave space for Safari toolbar */
    #app_root {
        height: calc(100dvh - env(safe-area-inset-bottom, 0px)) !important;
        min-height: -webkit-fill-available;
        /* Prevent content from going under Safari toolbar */
        padding-bottom: 0 !important;
    }

    /* TradingView chart widget container */
    .TVChartContainer,
    [class*="TVChartContainer"],
    .chart-page,
    [class*="chart-page"],
    #tv_chart_container {
        /* Reduce height to account for Safari toolbar */
        height: calc(100dvh - 50px) !important;
        max-height: calc(100dvh - 50px) !important;
    }

    /* Bottom widget bar - ensure it's visible above Safari toolbar */
    .layout__area--bottom,
    [class*="bottomWidgetBar"],
    [class*="bottom-widget"],
    .chart-controls-bar {
        /* Push above Safari's bottom bar */
        margin-bottom: env(safe-area-inset-bottom, 20px) !important;
        padding-bottom: 10px !important;
        position: relative !important;
        z-index: 100 !important;
    }
}

/* iOS Safari specific - stronger fix */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 767px) {

        /* iOS-only styles */
        body {
            /* Use -webkit-fill-available for iOS */
            height: -webkit-fill-available;
        }

        #app_root {
            /* Subtract estimated Safari toolbar height */
            height: calc(100vh - 80px) !important;
        }

        .TVChartContainer,
        #tv_chart_container {
            height: calc(100vh - 80px) !important;
        }
    }
}

/* iPhone with notch (X and later) - extra bottom spacing */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 767px) {
        #app_root {
            padding-bottom: env(safe-area-inset-bottom) !important;
        }
    }
}