/* ========================================================================= */
/* COMPREHENSIVE iPHONE & MOBILE RESPONSIVE STYLES                           */
/* ========================================================================= */

@media (max-width: 850px) {
    /* Container Override */
    .app-container {
        display: flex;
        flex-direction: column !important;
        width: 100vw;
        height: 100vh;
        overflow-x: hidden;
    }

    /* Force mobile only buttons to show */
    .mobile-only {
        display: inline-flex !important;
    }

    /* Sidebar - Transform into a full-height drawer overlay */
    .sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        width: 280px !important;
        height: 100vh !important;
        z-index: 99999 !important;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 15px rgba(0,0,0,0.8);
        background: var(--nectar-dark-gray) !important;
    }

    .sidebar.open {
        transform: translateX(0) !important;
    }

    /* Main Content */
    .main-content {
        width: 100vw !important;
        flex: 1;
        overflow-x: hidden; /* Prevent horizontal scroll */
        overflow-y: auto;
    }

    /* Top Bar Header */
    .top-bar {
        width: 100%;
        padding: 10px 15px !important;
        flex-wrap: wrap;
        gap: 10px;
        position: sticky !important;
        top: 0 !important;
        z-index: 1000 !important;
    }
    
    .top-bar h2 {
        font-size: 1.2rem;
    }

    /* Stats Grid (Top Cards) */
    .dashboard-grid, .grid-list, .plans-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        padding: 0 15px;
    }

    /* Other Grids (Charts, Settings, User Form) */
    .finance-content, .settings-container, .charts-grid, .form-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    /* Global Padding adjustment for Views */
    .view-container {
        padding: 15px !important;
        width: 100vw !important;
        overflow-x: hidden !important;
        box-sizing: border-box;
    }

    /* Tables - iPhone specific horizontal scrolling */
    .table-container, .table-responsive, .table-card {
        width: 100%;
        max-width: 100vw;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important; /* Smooth scroll on iOS */
        border-radius: 8px;
        box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
        padding-bottom: 5px; /* Give room for scrollbar */
    }

    table, .data-table {
        min-width: 600px !important; /* Force table to maintain shape, user will scroll */
        width: 100%;
    }

    th, td {
        padding: 16px 20px !important;
        font-size: 0.95rem !important;
        white-space: nowrap !important; /* Extremely important: forces columns to stay wide so user can scroll! */
    }

    /* Charts Container */
    .chart-box {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .chart-wrapper {
        min-width: 400px;
        height: 250px !important;
    }

    /* Modals - Fix width for iPhones */
    .modal-container {
        width: 95% !important;
        max-width: 400px !important;
        margin: 10px auto;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Login Screen Fixes */
    .login-card {
        width: 90% !important;
        padding: 20px !important;
    }
    
    /* Inputs Fix for iOS Zooming */
    input, select, textarea {
        font-size: 16px !important; /* iOS zooms on inputs if less than 16px */
    }

    /* Hide Desktop Elements */
    .desktop-only {
        display: none !important;
    }
}
