/* Futures Mobile Responsive Styles */
@media only screen and (max-width: 768px) {

    /* Reset */
    * {
        box-sizing: border-box;
        -webkit-tap-highlight-color: transparent;
    }

    body.futures-theme {
        overflow: auto;
    }

    /* Grid → Stacked layout */
    .futures-layout {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        min-height: 100vh;
    }

    /* ─── Ticker Bar ─── */
    .futures-ticker-bar {
        padding: 6px 10px;
        gap: 14px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        min-height: 48px;
    }

    .ticker-item.main-ticker {
        gap: 8px;
        padding-right: 14px;
    }

    .ticker-pair {
        font-size: 15px;
    }

    .ticker-price {
        font-size: 15px;
    }

    .ticker-stat {
        gap: 1px;
    }

    .stat-label {
        font-size: 9px;
    }

    .stat-value {
        font-size: 12px;
    }

    .desktop-only {
        display: none !important;
    }

    /* ─── Order Book ─── */
    .futures-book {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--ft-border);
        min-height: 300px;
    }

    /* ─── Chart ─── */
    .futures-chart {
        width: 100%;
        min-height: 350px;
    }

    .chart-canvas {
        height: 310px !important;
    }

    /* ─── Tabs ─── */
    .futures-tabs {
        width: 100%;
        min-height: 200px;
        overflow: visible;
    }

    .tab-content-container {
        height: auto;
        max-height: 250px;
        overflow-y: auto;
    }

    .positions-table th,
    .orders-table th {
        font-size: 11px;
        padding: 6px !important;
    }

    .positions-table td,
    .orders-table td {
        font-size: 11px;
        padding: 6px !important;
    }

    /* ─── Order Form ─── */
    .futures-form {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--ft-border);
        padding-bottom: 80px;
        /* Space for mobile nav */
    }

    .futures-form .trading-forms-wrapper {
        grid-template-columns: 1fr !important;
        gap: 4px !important;
        background-color: transparent !important;
    }

    .futures-form .trading-form-container {
        padding: 10px !important;
    }

    .futures-form .form-header {
        margin-bottom: 8px;
        padding-bottom: 6px;
    }

    .futures-form .form-title {
        font-size: 13px;
    }

    .futures-form .input-field {
        padding: 10px;
    }

    .futures-form .input-field input {
        font-size: 14px;
    }

    .futures-form .btn-execute {
        padding: 12px;
        font-size: 14px;
        min-height: 46px;
    }

    .futures-form .balance-display {
        padding: 8px 10px;
        font-size: 12px;
    }

    .futures-form .total-display {
        padding: 8px 10px;
        font-size: 13px;
    }

    /* Leverage Selector Fixes */
    .leverage-selector-container {
        padding: 4px 0 16px !important;
    }

    .leverage-markers {
        padding: 0 4px !important;
    }

    .leverage-marker span {
        font-size: 9px !important;
    }

    .leverage-value-input {
        width: 50px !important;
        font-size: 13px !important;
    }

    /* ─── Mobile Nav ─── */
    .mobile-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: var(--ft-bg-secondary);
        border-top: 1px solid var(--ft-border);
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.2);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        color: var(--ft-text-secondary);
        cursor: pointer;
        font-size: 10px;
        font-weight: 600;
        padding: 8px 14px;
        transition: all 0.2s ease;
        border-radius: 8px;
        position: relative;
        letter-spacing: 0.02em;
    }

    .mobile-nav-item i {
        font-size: 17px;
        transition: transform 0.2s ease;
    }

    .mobile-nav-item.active {
        color: var(--ft-accent);
    }

    .mobile-nav-item.active i {
        transform: translateY(-1px);
    }

    .mobile-nav-item:active {
        transform: scale(0.92);
        background: rgba(255, 255, 255, 0.04);
        transition: transform 0.1s ease;
    }

    /* Modal mobile */
    .modalO-content {
        width: 95% !important;
        max-width: none !important;
    }

    /* Toast above mobile nav */
    .toast {
        bottom: 70px;
        right: 10px;
        left: 10px;
    }

    /* ─── Mobile View Toggling ─── */
    .futures-book,
    .futures-tabs {
        display: none;
    }

    .futures-chart {
        display: flex;
        flex-direction: column;
    }

    .futures-form {
        display: none;
    }

    /* Mobile views via JS-added classes */
    body.mobile-view-chart .futures-chart {
        display: flex;
    }

    body.mobile-view-chart .futures-book,
    body.mobile-view-chart .futures-form,
    body.mobile-view-chart .futures-tabs {
        display: none;
    }

    body.mobile-view-book .futures-book {
        display: flex;
    }

    body.mobile-view-book .futures-chart,
    body.mobile-view-book .futures-form,
    body.mobile-view-book .futures-tabs {
        display: none;
    }

    body.mobile-view-form .futures-form {
        display: block;
        overflow-y: auto;
    }

    body.mobile-view-form .futures-chart,
    body.mobile-view-form .futures-book,
    body.mobile-view-form .futures-tabs {
        display: none;
    }

    body.mobile-view-tabs .futures-tabs {
        display: flex;
        flex-direction: column;
    }

    body.mobile-view-tabs .futures-chart,
    body.mobile-view-tabs .futures-book,
    body.mobile-view-tabs .futures-form {
        display: none;
    }
}

/* ─── Very Small Screens ─── */
@media only screen and (max-width: 480px) {
    .futures-form .btn-execute {
        padding: 10px;
        font-size: 13px;
    }

    .ticker-pair {
        font-size: 14px;
    }

    .ticker-price {
        font-size: 14px;
    }

    .positions-table th:nth-child(n+5),
    .positions-table td:nth-child(n+5),
    .orders-table th:nth-child(n+6),
    .orders-table td:nth-child(n+6) {
        display: none;
    }
}