/* Mobile Responsive Styles */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85% !important;
        max-width: 400px;
        height: 100vh;
        z-index: 1000;
        border-right: 1px solid var(--border-color);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        left: 0;
    }
    
    .resizer {
        display: none;
    }
    
    .sidebar-content {
        padding: 16px;
        gap: 16px;
    }
    
    .main-content {
        flex: 1;
        height: 100vh;
        width: 100vw;
    }

    .mobile-menu-btn {
        display: block;
        position: absolute;
        top: 16px;
        left: 16px;
        background: white;
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-md);
        border: 1px solid var(--border-color);
        z-index: 5;
    }

    #closeSidebarBtn {
        display: block !important;
    }

    .mobile-overlay.active {
        display: block;
    }
    
    /* Make buttons more touch-friendly */
    .btn {
        padding: 12px 20px;
        font-size: 1rem;
        min-height: 44px;
    }
    
    .btn.small {
        padding: 8px 16px;
        font-size: 0.875rem;
        min-height: 36px;
    }
    
    /* Larger checkboxes and toggle for easier tapping */
    .checkbox-label input[type="checkbox"],
    .form-group input[type="checkbox"] {
        width: 24px;
        height: 24px;
    }
    
    .toggle-slider {
        width: 56px;
        height: 28px;
    }
    
    .toggle-slider::before {
        width: 24px;
        height: 24px;
    }
    
    .toggle-switch input[type="checkbox"]:checked ~ .toggle-slider::before {
        transform: translateX(28px);
    }
    
    /* Adjust legend position */
    .legend-overlay {
        top: 16px;
        right: 16px;
        padding: 12px;
        max-width: calc(100vw - 80px); /* Leave space for menu btn */
    }
    
    /* Adjust zoom controls */
    .zoom-controls {
        bottom: 16px;
        right: 16px;
        padding: 6px;
    }
    
    .zoom-btn {
        width: 44px;
        height: 44px;
        font-size: 22px;
    }
    
    /* Table adjustments */
    table {
        font-size: 0.75rem;
    }
    
    th, td {
        padding: 8px 10px;
    }
    
    /* Settings grid - stack on mobile */
    .settings-grid {
        gap: 16px;
    }
    
    .setting-item label {
        font-size: 0.875rem;
    }
    
    /* Modal adjustments */
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 20px auto;
        max-height: 85vh;
    }
    
    .modal-body {
        padding: 16px;
    }
    
    /* Control group - stack vertically on very small screens */
    .control-group {
        flex-direction: column;
        gap: 12px;
    }
    
    .file-upload-btn {
        width: 100%;
    }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 480px) {
    .sidebar-header h1 {
        font-size: 1.125rem;
    }
    
    .panel h2 {
        font-size: 0.8125rem;
    }
    
    .legend-overlay {
        font-size: 0.75rem;
    }
    
    .legend-color {
        width: 20px;
        height: 20px;
    }
    
    .zoom-level {
        font-size: 0.7rem;
    }
    
    /* Make table scrollable horizontally */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        width: 60% !important;
    }
}

/* Touch-friendly improvements for all mobile devices */
@media (hover: none) and (pointer: coarse) {
    /* Increase tap targets */
    .delete-btn {
        padding: 10px;
        font-size: 1.4em;
    }
    
    .modal-close {
        width: 44px;
        height: 44px;
        font-size: 32px;
    }
    
    /* Prevent text selection on buttons */
    .btn,
    .zoom-btn,
    .checkbox-label,
    .toggle-switch {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
}
