/* mobile.css - Fully tested responsive layout */
@media only screen and (max-width: 768px) {
    /* Reset and base styles */
    * {
        box-sizing: border-box;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Main layout restructuring */
    .trading-content {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto auto !important;
        height: auto !important;
        padding: 0.5rem !important;
        gap: 1rem !important;
    }

    /* Left column container */
    .left-column {
        display: flex !important;
        flex-direction: row !important;
        width: 100% !important;
        gap: 0.5rem !important;
        margin-bottom: 0 !important;
        min-height: 320px;
    }

    /* Order book - left side (50% width) */
    .order-book-container {
        flex: 1 !important;
        min-width: 0 !important;
        height: 100% !important;
        margin-bottom: 0 !important;
        overflow: hidden;
    }

    /* Mobile forms - right side (50% width) */
    .order-forms-container-mobile {
        flex: 1 !important;
        min-width: 0 !important;
        display: block !important;
        margin: 0 !important;
        height: 100%;
    }

    /* Improved Order Tabs */
    .order-tabs {
        display: flex;
        border-bottom: 1px solid var(--border-light);
        margin-bottom: 1rem;
        position: relative;
    }

    .order-tab {
        flex: 1;
        padding: 1rem 0.5rem;
        text-align: center;
        background: none;
        border: none;
        border-bottom: 3px solid transparent;
        color: var(--text-muted);
        font-weight: 600;
        cursor: pointer;
        font-size: 1rem;
        transition: all 0.2s ease;
        position: relative;
        user-select: none;
        -webkit-user-select: none;
        touch-action: manipulation;
    }

    .order-tab::after {
        content: "";
        position: absolute;
        top: -10px;
        bottom: -10px;
        left: 0;
        right: 0;
    }

    .order-tab.active {
        color: var(--primary);
        border-bottom-color: var(--primary);
    }

    .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: var(--radius-lg);
        box-shadow: var(--shadow-sm);
        border: 1px solid var(--border-light);
    }

    .buy-order-form {
        border-top: 3px solid var(--success);
    }

    .sell-order-form {
        border-top: 3px solid var(--danger);
    }

    /* Form elements */
    .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;
    }

    /* Market info styling */
    .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;
        order: 1;
    }

    .market-price {
        font-size: 1.5rem;
        font-weight: 700;
        order: 2;
        color: var(--text-primary);
    }

    .market-change-container.desktop-only,
    .market-links.desktop-only,
    .stat-item.base-volume-item {
        display: none !important;
    }

    /* Chart container fixes */
    .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;
    }

    #price-chart {
        width: 100% !important;
        height: 100% !important;
        min-height: 300px;
    }

    /* Remove times under chart */
    .chartjs-tooltip {
        display: none !important;
    }

    .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;
    }

    .chart-actions {
        position: absolute;
        right: 0.5rem;
        top: 0.5rem;
        z-index: 10;
    }

    .market-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        width: 100%;
    }

    .stat-item {
        margin: 0;
    }

    /* Hide desktop elements */
    .order-forms-container {
        display: none !important;
    }

    .recent-trades.mobile-hide {
        display: none !important;
    }

    /* Chart area */
    .chart-area {
        width: 100% !important;
    }

    /* Market selector */
    .right-column {
        width: 100% !important;
    }

    /* Header adjustments */
    .dashboard-header {
        padding: 0.5rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    /* Order book rows */
    .order-book-row {
        padding: 0.5rem;
        font-size: 0.85rem;
    }

    /* Optimizations for 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;
        }

        .btn-buy, .btn-sell {
            padding: 1rem;
            font-size: 1rem;
        }

        .chart-wrapper {
            height: 280px !important;
            min-height: 280px !important;
        }

        .market-stats {
            grid-template-columns: 1fr;
        }
    }

    /* iPhone X specific adjustments */
    @media only screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) {
        .left-column {
            min-height: 280px;
        }
    }

    /* iPhone 12 Pro specific adjustments */
    @media only screen and (device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3) {
        .left-column {
            min-height: 300px;
        }
    }

    /* iPhone 12 Pro Max specific adjustments */
    @media only screen and (device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3) {
        .left-column {
            min-height: 320px;
        }
        
        .order-book-row {
            padding: 0.5rem;
            font-size: 0.9rem;
        }
    }

    /* Fix for landscape orientation */
    @media (orientation: landscape) {
        .chart-wrapper {
            height: 250px !important;
            min-height: 250px !important;
        }
    }
}

/* Original mobile styles preserved below */
@media only screen and (max-width: 768px) {
    .header-left, .header-right {
        width: 100%;
        justify-content: space-between;
    }

    .breadcrumb {
        font-size: 0.75rem;
        margin-top: 0.25rem;
    }

    .market-selector {
        max-height: 300px;
    }

    .market-item {
        padding: 0.5rem;
    }

    .chart-container {
        position: relative;
        width: 100%;
        min-height: 250px;
        margin: 0 auto;
    }

    canvas {
        width: 100% !important;
        height: auto !important;
        max-height: 200px;
    }

    .chart-header {
        padding: 0.75rem;
    }

    .chart-intervals {
        justify-content: center;
        gap: 0.25rem;
    }

    .interval-btn {
        padding: 0.25rem 0.4rem;
        font-size: 0.65rem;
    }

    .order-book-spread {
        padding: 0.25rem;
        font-size: 0.65rem;
    }

    .open-orders {
        margin-top: 1rem;
        max-height: 300px;
    }

    .orders-table th:nth-child(1),
    .orders-table td:nth-child(1),
    .orders-table th:nth-child(6),
    .orders-table td:nth-child(6) {
        display: none;
    }

    .modalO-content {
        width: 95% !important;
        max-width: none !important;
    }

    .confirm-row {
        font-size: 0.9rem;
    }

    .toast {
        bottom: 10px;
        right: 10px;
        left: 10px;
        width: auto;
    }

    .logo-icon {
        display: none;
    }

    .chart-actions {
        gap: 0.25rem;
    }

    .chart-action-btn {
        padding: 3px 5px;
        font-size: 0.7rem;
    }

    .input-currency {
        font-size: 0.75rem;
        right: 5px;
    }

    .market-pair {
        font-size: 1rem;
    }

    .btn-icon {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 0.8rem;
    }

    .btn-primary {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* Additional responsive adjustments */
@media only screen and (max-width: 480px) {
    .market-pair-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.1rem;
    }
    
    .market-price, .market-change {
        font-size: 0.9rem;
    }
    
    .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;
    }
}

/* 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) {
    .trading-content {
        grid-template-rows: auto auto !important;
    }
    
    .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;
    }
}

/* Hide chart time labels on mobile */
@media only screen and (max-width: 768px) {
    .chart-wrapper canvas {
        /* This will hide the x-axis time labels */
        margin-bottom: -20px;
    }
    
    .chartjs-tooltip {
        display: none !important;
    }
    
    /* Ensure the chart container doesn't show overflow */
    .chart-wrapper {
        overflow: hidden;
    }
    
    /* Hide x-axis labels completely */
    #price-chart ~ div canvas ~ div:last-child {
        display: none !important;
    }
}
/* 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;
    }
}