/* mobile.css - Futures trading responsive layout */
@media only screen and (max-width: 768px) {
    * {
        box-sizing: border-box;
        -webkit-tap-highlight-color: transparent;
    }

    /* Main layout restructuring */
    .futures-content {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        padding: 0.5rem !important;
        gap: 1rem !important;
    }

    /* Left column: order book + mobile forms side by side */
    .left-column {
        display: flex !important;
        flex-direction: row !important;
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        gap: 0.5rem !important;
        min-height: 320px;
    }

    /* Order book - left side (50%) */
    .order-book-container {
        flex: 1 !important;
        min-width: 0 !important;
        height: 100% !important;
        overflow: hidden;
    }

    /* Mobile forms - right side (50%) */
    .order-forms-container-mobile {
        flex: 1 !important;
        min-width: 0 !important;
        display: block !important;
        margin: 0 !important;
        height: 100%;
    }

    /* Hide desktop forms */
    .order-forms-container {
        display: none !important;
    }

    /* Hide recent trades on mobile */
    .recent-trades.mobile-hide {
        display: none !important;
    }

    /* Order Tabs */
    .order-tabs {
        display: flex;
        border-bottom: 1px solid var(--border-color);
        margin-bottom: 1rem;
    }

    .order-tab {
        flex: 1;
        padding: 1rem 0.5rem;
        text-align: center;
        background: none;
        border: none;
        border-bottom: 3px solid transparent;
        color: var(--text-secondary);
        font-weight: 600;
        cursor: pointer;
        font-size: 1rem;
        transition: all 0.2s ease;
        user-select: none;
        -webkit-user-select: none;
        touch-action: manipulation;
    }

    .order-tab.active {
        color: var(--primary-color);
        border-bottom-color: var(--primary-color);
    }

    .order-tab:active {
        transform: scale(0.98);
    }

    .order-tab-content {
        display: none;
    }

    .order-tab-content.active {
        display: block;
    }

    /* Form styling */
    .buy-order-form, .sell-order-form {
        height: calc(100% - 3rem);
        padding: 1rem;
        border-radius: 8px;
        border: 1px solid var(--border-color);
    }

    .buy-order-form {
        border-top: 3px solid var(--buy-color);
    }

    .sell-order-form {
        border-top: 3px solid var(--sell-color);
    }

    .form-group input {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
        min-height: 3rem;
    }

    .form-actions {
        margin-top: 1.5rem;
    }

    .btn-buy, .btn-sell {
        padding: 1.25rem;
        font-size: 1.1rem;
        font-weight: 600;
        min-height: 3.5rem;
    }

    .form-percentages {
        margin-top: 0.75rem;
        gap: 0.5rem;
    }

    .percent-btn {
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
        min-height: 2.5rem;
    }

    /* Leverage slider */
    .leverage-slider {
        margin-top: 0.5rem;
    }

    .leverage-markers {
        font-size: 0.7rem;
    }

    /* Market info */
    .market-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .market-pair-container {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .market-pair {
        font-size: 1.5rem;
        font-weight: 700;
    }

    .market-price {
        font-size: 1.5rem;
        font-weight: 700;
    }

    .market-change-container.desktop-only,
    .market-links.desktop-only,
    .stat-item.base-volume-item {
        display: none !important;
    }

    /* Chart container */
    .chart-container {
        height: auto !important;
        min-height: 300px;
        max-height: none !important;
        padding: 0.5rem;
        margin: 0 -0.5rem;
    }

    .chart-wrapper {
        height: 300px !important;
        min-height: 300px !important;
        max-height: 300px !important;
        position: relative;
        overflow: hidden;
    }

    #price-chart {
        width: 100% !important;
        height: 100% !important;
        min-height: 300px;
    }

    .chart-header {
        padding: 0.75rem 0.5rem !important;
    }

    .chart-intervals {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .interval-btn {
        display: inline-block;
        margin: 0 0.15rem;
        flex-shrink: 0;
    }

    .chart-actions {
        position: absolute;
        right: 0.5rem;
        top: 0.5rem;
        z-index: 10;
        gap: 0.25rem;
    }

    .chart-action-btn {
        padding: 3px 5px;
        font-size: 0.7rem;
    }

    /* Market stats grid */
    .market-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        width: 100%;
    }

    .stat-item {
        margin: 0;
        justify-content: space-between;
    }

    /* Chart area full width */
    .chart-area {
        width: 100% !important;
    }

    /* Right column (market selector) full width */
    .right-column {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
    }

    .market-selector {
        max-height: 300px;
    }

    .market-item {
        padding: 0.5rem;
    }

    /* Header */
    .dashboard-header {
        padding: 0.5rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .header-left, .header-right {
        width: 100%;
        justify-content: space-between;
    }

    .breadcrumb {
        font-size: 0.75rem;
        margin-top: 0.25rem;
    }

    /* Order book rows */
    .order-book-row {
        padding: 0.5rem;
        font-size: 0.85rem;
    }

    .order-book-spread {
        padding: 0.25rem;
        font-size: 0.65rem;
    }

    /* Positions table */
    .positions-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .positions-table {
        font-size: 0.75rem;
        min-width: 700px;
    }

    .positions-table th,
    .positions-table td {
        padding: 0.5rem 0.4rem;
        white-space: nowrap;
    }

    /* Hide less critical position columns on mobile */
    .positions-table th:nth-child(6),
    .positions-table td:nth-child(6),
    .positions-table th:nth-child(10),
    .positions-table td:nth-child(10) {
        display: none;
    }

    /* Orders table */
    .orders-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .orders-table {
        font-size: 0.75rem;
        min-width: 600px;
    }

    .orders-table th,
    .orders-table td {
        padding: 0.5rem 0.4rem;
        white-space: nowrap;
    }

    /* Hide date and filled columns on mobile */
    .orders-table th:nth-child(1),
    .orders-table td:nth-child(1),
    .orders-table th:nth-child(7),
    .orders-table td:nth-child(7) {
        display: none;
    }

    .open-orders {
        margin-top: 1rem;
        max-height: 300px;
    }

    .open-positions {
        margin-top: 1rem;
    }

    /* Modals */
    .modalO-content {
        width: 95% !important;
        max-width: none !important;
    }

    .confirm-row {
        font-size: 0.9rem;
    }

    /* Toast */
    .toast {
        bottom: 10px;
        right: 10px;
        left: 10px;
        width: auto;
    }

    /* Input currency label */
    .input-currency {
        font-size: 0.75rem;
        right: 5px;
    }

    /* Buttons */
    .btn-icon {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 0.8rem;
    }

    .btn-primary {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .logo-icon {
        display: none;
    }

    /* Very small screens */
    @media only screen and (max-width: 480px) {
        .left-column {
            flex-direction: column !important;
        }

        .order-book-container,
        .order-forms-container-mobile {
            width: 100% !important;
        }

        .order-tab {
            padding: 1rem 0.25rem;
            font-size: 0.95rem;
        }

        .market-pair,
        .market-price {
            font-size: 1.3rem;
        }

        .market-pair-container {
            flex-direction: column;
            align-items: flex-start;
            gap: 0.1rem;
        }

        .btn-buy, .btn-sell {
            padding: 1rem;
            font-size: 1rem;
        }

        .chart-wrapper {
            height: 280px !important;
            min-height: 280px !important;
        }

        .market-stats {
            grid-template-columns: 1fr;
        }

        .orders-table th:nth-child(4),
        .orders-table td:nth-child(4) {
            display: none;
        }

        .percent-btn {
            padding: 0.15rem;
            font-size: 0.6rem;
        }

        .btn-buy, .btn-sell {
            padding: 0.5rem;
            font-size: 0.75rem;
        }

        .modalO-body {
            padding: 0.75rem;
        }

        .confirm-row {
            font-size: 0.8rem;
            margin-bottom: 0.5rem;
            padding-bottom: 0.5rem;
        }
    }

    /* Landscape */
    @media (orientation: landscape) {
        .chart-wrapper {
            height: 250px !important;
            min-height: 250px !important;
        }
    }
}

/* Portrait orientation */
@media only screen and (max-width: 768px) and (orientation: portrait) {
    .chart-container {
        height: 50vh;
    }

    .left-column {
        min-height: 280px;
    }
}

/* Landscape orientation */
@media only screen and (max-width: 768px) and (orientation: landscape) {
    .futures-content {
        flex-direction: column;
    }

    .left-column {
        min-height: 240px;
    }

    .form-group input {
        padding: 0.5rem;
    }
}

/* Small height devices */
@media only screen and (max-height: 600px) {
    .chart-container {
        height: 40vh;
    }

    .open-orders {
        max-height: 200px;
    }
}

/* Very small screens */
@media only screen and (max-width: 320px) {
    .interval-btn {
        padding: 0.15rem 0.25rem;
        font-size: 0.6rem;
    }

    .market-name {
        font-size: 0.75rem;
    }

    .market-change {
        font-size: 0.65rem;
        width: 3.5rem;
    }

    .btn-buy, .btn-sell {
        font-size: 0.7rem;
    }
}
